Linux kernel transplantation based on tiny4412 (supports device tree) (2)

Publisher:数据梦想Latest update time:2023-06-20 Source: elecfansKeywords:tiny4412  Linux Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Platform introduction

Development board: tiny4412ADK + S700 + 4GB Flash

Kernel version to be transplanted: Linux-4.4.0 (supports device tree)

u-boot version: U-Boot 2010.12 that comes with Friendly Arm (some changes have been made to support uImage startup)

busybox version: busybox 1.25

Cross-compilation tool chain: arm-none-linux-gnueabi-gcc

      (gcc version 4.8.3 20140320 (prerelease) (Sourcery CodeBench Lite 2014.05-29))


step

Continue above.

Since Linux-4.4.0 already has good support for tiny4412, there is very little work left for us.

1. Modify arch/arm/boot/dts/exynos4412-tiny4412.dts

diff --git a/arch/arm/boot/dts/exynos4412-tiny4412.dts b/arch/arm/boot/dts/exynos4412-tiny4412.dts

index 4840bbd..aeca42a 100644

--- a/arch/arm/boot/dts/exynos4412-tiny4412.dts

+++ b/arch/arm/boot/dts/exynos4412-tiny4412.dts

@@ -21,6 +21,7 @@

 

        chosen {

                stdout-path = &;serial_0;

+               bootargs = "root=/dev/ram0 rw rootfstype=ext4 console=ttySAC0,115200 init=/linuxrc earlyprintk";

        };

 

        memory {

@@ -78,7 +79,7 @@

        bus-width = <;4>;

        pinctrl-0 = <;&sd2_clk &sd2_cmd &sd2_cd &sd2_bus4>;

        pinctrl-names = "default";

-       status = "okay";

+       status = "disabled";

 };

 

 &;serial_0 {

The key point here is to add the bootargs setting in chosen. The above setting of bootargs means: the root file system is ramdisk, readable and writable, the file system type is ext4 format, the serial terminal uses ttySAC0, and the baud rate is 115200. earlyprintk is used to print some logs in the early stages of kernel startup. It will print the printk information to a terminal called bootconsole. After the real console is registered, the bootconsole will be disabled. If you want to use earlyprintk, you need to make relevant changes in the kernel. configuration, which will be discussed below. The setting of bootargs is very flexible. It can be set in the kernel device tree or in u-boot. It should be noted that if bootargs is set in u-boot, u-boot will use it during bootm. Use your own bootargs to overwrite the bootargs in the device tree (do_bootm_linux -> bootm_linux_fdt -> fdt_chosen). Another point is to disable the SD card controller 2. There are still some problems with the initialization of the SD controller, which will cause the kernel to hang. This will be solved later, because we will first use ramdisk as the root file system in the future, and use eMMC and SD card doesn't matter.


2. Create ramdisk root file system


1. To make a ramdisk, you first need to download the busybox code, which can be downloaded from https://busybox.net/downloads/, and then compile the root file system. I will not write about the specific process here. There is a lot of information on this on the Internet. I have made a working file system, which can be downloaded from the following address:


https://files.cnblogs.com/files/pengdonglin137/rootfs.tar.gz


After the download is completed, decompress it and start making ramdisk. During the production process, I wrote a script mk_ramdisk.sh


#!/bin/bash

 

rm -rf ramdisk*

 

sudo dd if=/dev/zero of=ramdisk bs=1k count=8192

 

sudo mkfs.ext4 -F ramdisk

 

sudo mkdir -p ./initrd

sudo mount -t ext4 ramdisk ./initrd

 

sudo cp rootfs/* ./initrd -raf

 

sudo mknod initrd/dev/console c 5 1

sudo mknod initrd/dev/null c 1 3

 

sudo umount ./initrd

 

sudo gzip --best -c ramdisk >; ramdisk.gz

 

sudo mkimage -n "ramdisk" -A arm -O linux -T ramdisk -C gzip -d ramdisk.gz ramdisk.img

 

The finally generated ramdisk.img is what we need. The ramdisk image generated in the above script can also be used as a ramdisk. The usage will be discussed below.


The link below is a ramdisk image that has been made and can be used after decompression:


https://files.cnblogs.com/files/pengdonglin137/ramdisk.zip


2. Configure the kernel to support ramdisk


make menuconfig

File systems --->;

    <*> Second extended fs support

Device Drivers

    SCSI device support --->;

        <*> SCSI disk support

    Block devices --->;

        <*>RAM block device support

        (16)Default number of RAM disks

        (8192) Default RAM disk size (kbytes) (modified to 8M)

General setup --->;

    [*] Initial RAM filesystem and RAM disk (initramfs/initrd) support

The default configuration of exynos already supports this.


3. Configure the kernel to support tmpfs


$ make menuconfig

File systems --->;

    Pseudo filesystems --->

        [*] Virtual memory file system support (former shm fs)

        [*] Tmpfs POSIX Access Control Lists

The default configuration of exynos is also supported.


3. Compile the kernel


1. First, set up the cross-compilation tool chain used.


diff --git a/Makefile b/Makefile

index 70dea02..5d96411 100644

--- a/Makefile

+++ b/Makefile

@@ -248,8 +248,8 @@ SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/

 # "make" in the configured kernel build directory always uses that.

 # Default value for CROSS_COMPILE is not to prefix executables

 # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile

-ARCH           ?= $(SUBARCH)

-CROSS_COMPILE  ?= $(CONFIG_CROSS_COMPILE:"%"=%)

+ARCH           ?= arm

+CROSS_COMPILE  ?= /root/tiny4412_android5/SysPort/cross_compile/arm-2014.05/bin/arm-none-linux-gnueabi-

2. Compile


make exynos_defconfig

make uImage LOADADDR=0x40008000 -j2

The generated uImage is under arch/arm/boot. 


4. Compile device tree


make dtbs

Then the device tree image file exynos4412-tiny4412.dtb used on tiny4412 will be generated in arch/arm/boot/dts/.


5. Test


Since tiny4412's u-boot currently does not support USB network cards, it can only be downloaded using dnw, and tiny4412's u-boot already comes with the dnw command. The code of dnw running on the development machine can be downloaded from the link below:


https://files.cnblogs.com/files/pengdonglin137/dnw.tar.gz


After downloading, unzip it. There is already a compiled dnw executable program in the compressed package. You can also execute make, which will automatically compile and generate a dnw executable program. To compile, USB-related libraries must be installed on the machine. The installation command is as follows:


sudo  apt-get install libusb-dev


With dnw, let’s start testing.


Start the development board and enter u-boot command mode;

DownloaduImage

Execute the command to download uImage in u-boot: dnw 0x40600000 (this address is not unique)


Execute in the development machine: dnw arch/arm/boot/uImage


Download ramdisk

Execute the command to download uImage in u-boot: dnw 0x41000000 (this address is not unique)


Execute in the development machine: dnw ramdisk.img


Download device tree image

Execute the command to download uImage in u-boot: dnw 0x42000000 (this address is not unique)


Execute in the development machine: dnw arch/arm/boot/dts/exynos4412-tiny4412.dtb


Start kernel

Use bootm to start the kernel: bootm 0x40600000 0x41000000 0x42000000


The following is the complete startup log:


U-Boot 2010.12-00000-gb391276-dirty (Jan 17 2016 - 06:03:22) for TINY4412



CPU:    S5PC220 [Samsung SOC on SMP Platform Base on ARM CortexA9]

        APLL = 1400MHz, MPLL = 800MHz


Board:  TINY4412

DRAM:   1023 MiB


vdd_arm: 1.2

vdd_int: 1.0

vdd_mif: 1.1


BL1 version:  N/A (TrustZone Enabled BSP)



Checking Boot Mode ... SDMMC

REVISION: 1.1

MMC Device 0: 3803 MB

MMC Device 1: 3728 MB

MMC Device 2: N/A

*** Warning - using default environment


Net:    No ethernet found.

Hit any key to stop autoboot:  0 

TINY4412 # dnw 0x41000000

OTG cable Connected!

Now, Waiting for DNW to transmit data

Download Done!! Download Address: 0x41000000, Download Filesize:0x27752e

Checksum is being calculated...

Checksum O.K.

TINY4412 # dnw 0x42000000

OTG cable Connected!

Now, Waiting for DNW to transmit data

Download Done!! Download Address: 0x42000000, Download Filesize:0xa53a

Checksum is being calculated.

Checksum O.K.

TINY4412 # dnw 0x40600000

OTG cable Connected!

Now, Waiting for DNW to transmit data

Download Done!! Download Address: 0x40600000, Download Filesize:0x43b5d0

Checksum is being calculated.....

Checksum O.K.

TINY4412 # bootm 0x40600000 0x41000000 0x42000000

## Booting kernel from Legacy Image at 40600000 ...

   Image Name:   Linux-4.4.0-gbd49c0f-dirty

   Image Type:   ARM Linux Kernel Image (uncompressed)

   Data Size:    4437392 Bytes = 4333 KiB

   Load Address: 40008000

   Entry Point:  40008000

   Verifying Checksum ... OK

## Loading init Ramdisk from Legacy Image at 41000000 ...

   Image Name:   ramdisk

   Image Type:   ARM Linux RAMDisk Image (gzip compressed)

   Data Size:    2585838 Bytes = 2525 KiB

   Load Address: 00000000

   Entry Point:  00000000

   Verifying Checksum ... OK

## Flattened Device Tree blob at 42000000

   Booting using the fdt blob at 0x42000000

   Loading Kernel Image ... OK

OK

## Loading init Ramdisk from Legacy Image at 41000000 ...

   Image Name:   ramdisk

   Image Type:   ARM Linux RAMDisk Image (gzip compressed)

   Data Size:    2585838 Bytes = 2525 KiB

   Load Address: 00000000

   Entry Point:  00000000

   Verifying Checksum ... OK

   Loading Ramdisk to 43a84000, end 43cfb4ee ... OK

   Loading Device Tree to 413f2000, end 413ff539 ... OK


Starting kernel ...


Uncompressing Linux... done, booting the kernel.

[    0.000000] Booting Linux on physical CPU 0xa00

[    0.000000] Linux version 4.4.0-gbd49c0f-dirty (root@ubuntu) (gcc version 4.8.3 20140320 (prerelease) (Sourcery CodeBench Lite 2014.05-29) ) #24 SMP PREEMPT Tue Jan 19 05:39:48 PST 2016

[    0.000000] CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=10c5387d

[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache

[    0.000000] Machine model: FriendlyARM TINY4412 board based on Exynos4412

[    0.000000] bootconsole [earlycon0] enabled

[    0.000000] cma: Reserved 64 MiB at 0x7bc00000

[    0.000000] Memory policy: Data cache writealloc

[    0.000000] Samsung CPU ID: 0xe4412011

[    0.000000] PERCPU: Embedded 12 pages/cpu @ef79b000 s18816 r8192 d22144 u49152

[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 260352

[    0.000000] Kernel command line: root=/dev/ram0 rw rootfstype=ext4 console=ttySAC0,115200 init=/linuxrc earlyprintk

[1] [2]
Keywords:tiny4412  Linux Reference address:Linux kernel transplantation based on tiny4412 (supports device tree) (2)

Previous article:Linux kernel transplantation based on tiny4412 (supports device tree) (1)
Next article:Linux kernel transplantation based on tiny4412 (supports device tree) (3)

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号