做者: 彭東林node
郵箱:pengdonglin137@163.comlinux
QQ:405728433android
開發板:tiny4412ADK + S700 + 4GB Flashgit
要移植的內核版本:Linux-4.4.0 (支持device tree)shell
u-boot版本:友善之臂自帶的 U-Boot 2010.12 (爲支持uImage啓動,作了少量改動)ubuntu
busybox版本:busybox 1.25bash
交叉編譯工具鏈: arm-none-linux-gnueabi-gcc app
(gcc version 4.8.3 20140320 (prerelease) (Sourcery CodeBench Lite 2014.05-29))dom
繼續上文。socket
因爲Linux-4.4.0對tiny4412已經有了很好的支持,因此留給咱們的工做就不多了。
1、修改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卡都沒有關係。
2、製做ramdisk根文件系統
一、製做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
二、配置內核,支持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的默認配置就已經支持了。
三、配置內核,使其支持tmpfs
$ make menuconfig
File systems --->;
Pseudo filesystems --->
[*] Virtual memory file system support (former shm fs)
[*] Tmpfs POSIX Access Control Lists
這個exynos的默認配置也已經支持了。
3、編譯內核
一、首先要設置使用的交叉編譯工具鏈
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-
二、編譯
make exynos_defconfig
make uImage LOADADDR=0x40008000 -j2
生成的uImage在arch/arm/boot下。
4、編譯設備樹
make dtbs
而後在 arch/arm/boot/dts/會生成tiny4412上用的設備樹鏡像文件exynos4412-tiny4412.dtb。
5、測試
因爲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的命令: dnw 0x40600000 (這個地址不惟一)
在開發機中執行:dnw arch/arm/boot/uImage
在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 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 [ 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 ]#