中国做网站知名的公司/免费数据统计网站
转自:http://www.cnblogs.com/pengdonglin137/p/5143516.html
作者信息
作者: 彭东林
邮箱:pengdonglin137@163.com
QQ:405728433
平台简介
开发板:tiny4412ADK + S700 + 4GB Flash
要移植的内核版本:Linux-4.4.0 (支持device tree)
u-boot版本:友善之臂自带的 U-Boot 2010.12 (为支持uImage启动,做了少许改动)
busybox版本:busybox 1.25
交叉编译工具链: arm-none-linux-gnueabi-gcc
(gcc version 4.8.3 20140320 (prerelease) (Sourcery CodeBench Lite 2014.05-29))
步骤
继续上文。
由于Linux-4.4.0对tiny4412已经有了很好的支持,所以留给我们的工作就很少了。
一、修改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 {
这里关键的一点是在chosen中增加了bootargs的设置,上面设置bootargs表示的意思是:根文件系统是ramdisk,可读写,文件系统类型是ext4格式,串口终端使用ttySAC0,波特率是115200,earlyprintk用于打印内核启动早期的一些log,它会把printk的信息打印到一个叫做bootconsole的终端上,在真正的console注册后,bootconsole会被disable掉,要想使用earlyprintk,需要在内核中做相关的配置,这个下面再说。bootargs的设置很灵活,既可以在内核的设备树中设置,也可以在u-boot中设置,需要注意的是:如果在u-boot中设置了bootargs的话,在bootm的时候u-boot会用自己的bootargs来覆盖设备树里的bootargs( do_bootm_linux -> bootm_linux_fdt -> fdt_chosen)。还有一点是把SD卡控制器2给禁掉了,目前SD控制器的初始化还有些问题,会导致内核挂掉,这个以后再解决,因为我们将来先用ramdisk做根文件系统,跟eMMC和SD卡都没有关系。
二、制作ramdisk根文件系统
1、制作ramdisk,首先需要下载busybox的代码,可以从https://busybox.net/downloads/下载,然后编译出根文件系统,具体过程我这里就不写了,网上有很多这方面的资料。我已经制作好了一个可用了文件系统,可以从下面的地址处下载:
http://files.cnblogs.com/files/pengdonglin137/rootfs.tar.gz
下载完成后,解压缩,开始制作ramdisk,制作的过程我写了一个脚本 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
最后生成的ramdisk.img就是我们需要的,在上面的脚本中生成的ramdisk镜像也可以作为ramdisk使用,用法下面再说。
下面的链接是一个已经制作好的ramdisk镜像,解压后即可使用:
http://files.cnblogs.com/files/pengdonglin137/ramdisk.zip
2、配置内核,支持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) (修改为8M)
General setup --->;
[*] Initial RAM filesystem and RAM disk (initramfs/initrd) support
这个exynos的默认配置就已经支持了。
3、配置内核,使其支持tmpfs
$ make menuconfig
File systems --->;
Pseudo filesystems --->
[*] Virtual memory file system support (former shm fs)
[*] Tmpfs POSIX Access Control Lists
这个exynos的默认配置也已经支持了。
三、编译内核
1、首先要设置使用的交叉编译工具链
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、编译
make exynos_defconfig
make uImage LOADADDR=0x40008000 -j2
生成的uImage在arch/arm/boot下。
四、编译设备树
make dtbs
然后在 arch/arm/boot/dts/会生成tiny4412上用的设备树镜像文件exynos4412-tiny4412.dtb。
五、测试
由于tiny4412的u-boot目前还不支持usb网卡,只能使用dnw来下载,并且tiny4412的u-boot中已经自带了dnw命令了。开发机上运行的dnw的代码可以到下面的链接下载:
http://files.cnblogs.com/files/pengdonglin137/dnw.tar.gz
下载完成后解压,在压缩包里已经有一个编译好的dnw可执行程序。也可执行make,会自动编译生成一个dnw可执行程序,要编译的话,机器上要安装usb相关的库,安装命令如下:
sudo apt-get install libusb-dev
有了dnw,下面开始测试。
- 启动开发板,进入u-boot命令模式;
- 下载uImage
在u-boot里执行下载uImage的命令: dnw 0x40600000 (这个地址不唯一)
在开发机中执行:dnw arch/arm/boot/uImage
- 下载ramdisk
在u-boot里执行下载uImage的命令: dnw 0x41000000 (这个地址不唯一)
在开发机中执行:dnw ramdisk.img
- 下载设备树镜像
在u-boot里执行下载uImage的命令: dnw 0x42000000 (这个地址不唯一)
在开发机中执行:dnw arch/arm/boot/dts/exynos4412-tiny4412.dtb
- 启动内核
使用bootm启动内核:bootm 0x40600000 0x41000000 0x42000000
下面是完整的启动log:
U-Boot 2010.12-00000-gb391276-dirty (Jan 17 2016 - 06:03:22) for TINY4412CPU: S5PC220 [Samsung SOC on SMP Platform Base on ARM CortexA9]APLL = 1400MHz, MPLL = 800MHzBoard: TINY4412 DRAM: 1023 MiBvdd_arm: 1.2 vdd_int: 1.0 vdd_mif: 1.1BL1 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 environmentNet: 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-dirtyImage Type: ARM Linux Kernel Image (uncompressed)Data Size: 4437392 Bytes = 4333 KiBLoad Address: 40008000Entry Point: 40008000Verifying Checksum ... OK ## Loading init Ramdisk from Legacy Image at 41000000 ...Image Name: ramdiskImage Type: ARM Linux RAMDisk Image (gzip compressed)Data Size: 2585838 Bytes = 2525 KiBLoad Address: 00000000Entry Point: 00000000Verifying Checksum ... OK ## Flattened Device Tree blob at 42000000Booting using the fdt blob at 0x42000000Loading Kernel Image ... OK OK ## Loading init Ramdisk from Legacy Image at 41000000 ...Image Name: ramdiskImage Type: ARM Linux RAMDisk Image (gzip compressed)Data Size: 2585838 Bytes = 2525 KiBLoad Address: 00000000Entry Point: 00000000Verifying Checksum ... OKLoading Ramdisk to 43a84000, end 43cfb4ee ... OKLoading Device Tree to 413f2000, end 413ff539 ... OKStarting 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 [ 0.000000] PID hash table entries: 4096 (order: 2, 16384 bytes) [ 0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes) [ 0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes) [ 0.000000] Memory: 960832K/1047552K available (5863K kernel code, 292K rwdata, 2284K rodata, 440K init, 315K bss, 21184K reserved, 65536K cma-reserved, 195584K highmem) [ 0.000000] Virtual kernel memory layout: [ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB) [ 0.000000] fixmap : 0xffc00000 - 0xfff00000 (3072 kB) [ 0.000000] vmalloc : 0xf0800000 - 0xff800000 ( 240 MB) [ 0.000000] lowmem : 0xc0000000 - 0xf0000000 ( 768 MB) [ 0.000000] pkmap : 0xbfe00000 - 0xc0000000 ( 2 MB) [ 0.000000] modules : 0xbf000000 - 0xbfe00000 ( 14 MB) [ 0.000000] .text : 0xc0008000 - 0xc07fd188 (8149 kB) [ 0.000000] .init : 0xc07fe000 - 0xc086c000 ( 440 kB) [ 0.000000] .data : 0xc086c000 - 0xc08b52f0 ( 293 kB) [ 0.000000] .bss : 0xc08b8000 - 0xc0906d28 ( 316 kB) [ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1 [ 0.000000] Preemptible hierarchical RCU implementation. [ 0.000000] Build-time adjustment of leaf fanout to 32. [ 0.000000] RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=4. [ 0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=32, nr_cpu_ids=4 [ 0.000000] NR_IRQS:16 nr_irqs:16 16 [ 0.000000] GIC physical location is 0x10490000 [ 0.000000] L2C: platform modifies aux control register: 0x02070000 ->; 0x3e470001 [ 0.000000] L2C: platform provided aux values permit register corruption. [ 0.000000] L2C: DT/platform modifies aux control register: 0x02070000 ->; 0x3e470001 [ 0.000000] L2C-310 enabling early BRESP for Cortex-A9 [ 0.000000] L2C-310: enabling full line of zeros but not enabled in Cortex-A9 [ 0.000000] L2C-310 dynamic clock gating enabled, standby mode enabled [ 0.000000] L2C-310 cache controller enabled, 16 ways, 1024 kB [ 0.000000] L2C-310: CACHE_ID 0x4100c4c8, AUX_CTRL 0x4e470001 [ 0.000000] Exynos4x12 clocks: sclk_apll = 466666667, sclk_mpll = 800000000 [ 0.000000] sclk_epll = 96000000, sclk_vpll = 108000000, arm_clk = 1400000000 [ 0.000000] Switching to timer-based delay loop, resolution 41ns [ 0.000000] clocksource: mct-frc: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns [ 0.000003] sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 89478484971ns [ 0.008035] Console: colour dummy device 80x30 [ 0.012425] Calibrating delay loop (skipped), value calculated using timer frequency.. 48.00 BogoMIPS (lpj=120000) [ 0.022827] pid_max: default: 32768 minimum: 301 [ 0.027579] Mount-cache hash table entries: 2048 (order: 1, 8192 bytes) [ 0.034206] Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes) [ 0.041686] CPU: Testing write buffer coherency: ok [ 0.046640] CPU0: thread -1, cpu 0, socket 10, mpidr 80000a00 [ 0.052536] Setting up static identity map for 0x400082c0 - 0x40008318 [ 0.099784] CPU1: thread -1, cpu 1, socket 10, mpidr 80000a01 [ 0.114774] CPU2: thread -1, cpu 2, socket 10, mpidr 80000a02 [ 0.129775] CPU3: thread -1, cpu 3, socket 10, mpidr 80000a03 [ 0.129815] Brought up 4 CPUs [ 0.150143] SMP: Total of 4 processors activated (192.00 BogoMIPS). [ 0.156477] CPU: All CPU(s) started in SVC mode. [ 0.161676] devtmpfs: initialized [ 0.173957] VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4 [ 0.181783] lcd0-power-domain@10023C80 has as child subdomain: tv-power-domain@10023C20. [ 0.190155] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 9556302231375000 ns [ 0.201755] pinctrl core: initialized pinctrl subsystem [ 0.207668] NET: Registered protocol family 16 [ 0.213539] DMA: preallocated 256 KiB pool for atomic coherent allocations [ 0.234740] cpuidle: using governor ladder [ 0.249735] cpuidle: using governor menu [ 0.254286] exynos-audss-clk 3810000.clock-controller: setup completed [ 0.306823] SCSI subsystem initialized [ 0.310855] usbcore: registered new interface driver usbfs [ 0.316329] usbcore: registered new interface driver hub [ 0.321714] usbcore: registered new device driver usb [ 0.327898] Advanced Linux Sound Architecture Driver Initialized. [ 0.335087] clocksource: Switched to clocksource mct-frc [ 0.349988] missing cooling_device property [ 0.354099] failed to build thermal zone cpu-thermal: -2 [ 0.359566] NET: Registered protocol family 2 [ 0.364266] TCP established hash table entries: 8192 (order: 3, 32768 bytes) [ 0.371286] TCP bind hash table entries: 8192 (order: 5, 163840 bytes) [ 0.377936] TCP: Hash tables configured (established 8192 bind 8192) [ 0.384305] UDP hash table entries: 512 (order: 2, 24576 bytes) [ 0.390258] UDP-Lite hash table entries: 512 (order: 2, 24576 bytes) [ 0.396795] NET: Registered protocol family 1 [ 0.401289] RPC: Registered named UNIX socket transport module. [ 0.407131] RPC: Registered udp transport module. [ 0.411902] RPC: Registered tcp transport module. [ 0.416674] RPC: Registered tcp NFSv4.1 backchannel transport module. [ 0.423325] Trying to unpack rootfs image as initramfs... [ 0.429054] rootfs image is not initramfs (no cpio magic); looks like an initrd [ 0.442728] Freeing initrd memory: 2528K (c3a84000 - c3cfc000) [ 0.449900] futex hash table entries: 1024 (order: 4, 65536 bytes) [ 0.465272] romfs: ROMFS MTD (C) 2007 Red Hat, Inc. [ 0.470817] bounce: pool size: 64 pages [ 0.474564] io scheduler noop registered [ 0.478570] io scheduler deadline registered [ 0.483072] io scheduler cfq registered (default) [ 0.492532] dma-pl330 12680000.pdma: Loaded driver for PL330 DMAC-141330 [ 0.499160] dma-pl330 12680000.pdma: DBUFF-32x4bytes Num_Chans-8 Num_Peri-32 Num_Events-32 [ 0.510651] dma-pl330 12690000.pdma: Loaded driver for PL330 DMAC-141330 [ 0.517272] dma-pl330 12690000.pdma: DBUFF-32x4bytes Num_Chans-8 Num_Peri-32 Num_Events-32 [ 0.526575] dma-pl330 12850000.mdma: Loaded driver for PL330 DMAC-141330 [ 0.533201] dma-pl330 12850000.mdma: DBUFF-64x8bytes Num_Chans-8 Num_Peri-1 Num_Events-32 [ 0.601269] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled [ 0.608816] 13800000.serial: ttySAC0 at MMIO 0x13800000 (irq = 44, base_baud = 0) is a S3C6400/10 [ 0.617669] console [ttySAC0] enabled [ 0.617669] console [ttySAC0] enabled [ 0.624994] bootconsole [earlycon0] disabled [ 0.624994] bootconsole [earlycon0] disabled [ 0.633916] 13810000.serial: ttySAC1 at MMIO 0x13810000 (irq = 45, base_baud = 0) is a S3C6400/10 [ 0.634277] 13820000.serial: ttySAC2 at MMIO 0x13820000 (irq = 46, base_baud = 0) is a S3C6400/10 [ 0.634631] 13830000.serial: ttySAC3 at MMIO 0x13830000 (irq = 47, base_baud = 0) is a S3C6400/10 [ 0.639182] [drm] Initialized drm 1.1.0 20060810 [ 0.652946] brd: module loaded [ 0.657821] loop: module loaded [ 0.658627] usbcore: registered new interface driver r8152 [ 0.658763] usbcore: registered new interface driver asix [ 0.659855] usbcore: registered new interface driver ax88179_178a [ 0.665958] usbcore: registered new interface driver cdc_ether [ 0.671772] usbcore: registered new interface driver smsc75xx [ 0.677506] usbcore: registered new interface driver smsc95xx [ 0.683217] usbcore: registered new interface driver net1080 [ 0.688858] usbcore: registered new interface driver cdc_subset [ 0.694760] usbcore: registered new interface driver zaurus [ 0.700345] usbcore: registered new interface driver cdc_ncm [ 0.706295] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver [ 0.712416] ehci-exynos: EHCI EXYNOS driver [ 0.716700] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver [ 0.722742] ohci-exynos: OHCI EXYNOS driver [ 0.727264] usbcore: registered new interface driver usb-storage [ 0.733431] mousedev: PS/2 mouse device common for all mice [ 0.739205] s3c-rtc 10070000.rtc: failed to find rtc source clock [ 0.744539] s3c-rtc: probe of 10070000.rtc failed with error -2 [ 0.750636] i2c /dev entries driver [ 0.755967] device-mapper: ioctl: 4.34.0-ioctl (2015-10-28) initialised: dm-devel@redhat.com [ 0.763141] sdhci: Secure Digital Host Controller Interface driver [ 0.768478] sdhci: Copyright(c) Pierre Ossman [ 0.772952] Synopsys Designware Multimedia Card Interface Driver [ 0.780793] usbcore: registered new interface driver usbhid [ 0.784347] usbhid: USB HID core driver [ 0.791116] NET: Registered protocol family 10 [ 0.793128] sit: IPv6 over IPv4 tunneling driver [ 0.797746] NET: Registered protocol family 17 [ 0.801655] NET: Registered protocol family 15 [ 0.806225] Registering SWP/SWPB emulation handler [ 0.812058] hctosys: unable to open rtc device (rtc0) [ 0.827998] ALSA device list: [ 0.828035] No soundcards found. [ 0.828678] RAMDISK: gzip image found at block 0 [ 0.970206] EXT4-fs (ram0): mounted filesystem wirdered data mode. Opts: (null) [ 0.970301] VFS: Mounted root (ext4 filesystem) on device 1:0. [ 0.970419] devtmpfs: mounted [ 0.970694] Freeing unused kernel memory: 440K (c07fe000 - c086c000)Please press Enter to activate this console. [root@tiny4412 ]#