没有人生活在过去,也没有人生活在未来,现在是生命确实占有的唯一形态。 —— 叔本华
本文介绍如何给Exynos 4412 SoC移植Linux内核,所有过程亲自实践,真实有效。
项目名称 | 版本说明 |
---|---|
内核 | Linux Kernel 4.1.36 |
硬件 | iTop4412 SCP 精英板 |
uboot | 2015.04 |
busybox | 1.26.1 |
第一部分:代码的使用过程介绍
1.1 使用uboot
参考 uboot调试, 下载源代码后,编译生成uboot镜像并烧写到sd卡中。
host > ./build.sh
host > sudo ./mkuboot /dev/sdc #modify the dev name yourself
1.2 使用Linux kernel
编译内核镜像并烧写到sd卡中
1.3 启动命令
host # mmc read 40007000 1000 3000
host # mmc read 41000000 800 a0
host # bootm 40007000 - 41000000
1.4 系统启动日志展示
见附录一
第二部分:uboot/kernel/rootfs的配置
2.1 uboot配置
下面给出部分uboot配置, 具体过程参见uboot调试一文。 因为提供了源代码,所以就不详细介绍了。最重要的是bootargs参数。
表2-1 bootargs配置
参数名字 | 内容 |
---|---|
bootargs | bootargs=console=ttySAC2,115200n8 earlyprintk |
2.2 kernel配置
内核的defconfig文件为landrover_defconfig,根据exynos_defconfig修改而来; dts文件根据exynos4412-tiny4412.dts修改,调整了compatible参数,只保留了一个okay的uart。其他的基本都是默认的。直接编译即可,因为内核太庞大,不方便提供源码,有需要的可以联系我。联系方式见博客”about”栏目。
2.3 根文件系统配置
参考我的博文关于initrd和initramfs。 按照上面的步骤来就可以。
busybox的配置网上博客一大堆,百度一搜就能搜到,这里就不讲了。
第三部分 总结
总的来说,由于内核已经对exynos 4412这款SoC有比较好的支持,所以移植过程很简单,时间跨度为两天。其中昨天还是在陪女朋友加班,一直到凌晨4点。卡了一会的地方是设备树的问题,因为我烧写dtb文件的时候大小错了,只烧了64KB(实际有67KB,现在烧写0xa0个block,也就是80KB),结果自然是不能工作了。
第四部分 附录
附录一
启动日志
LANDROVER # bootm 40007000 - 41000000
## Current stack ends at 0x7ae65698 do_bootm_states:591 started.
* kernel: cmdline image address = 0x40007000
## Booting kernel from Legacy Image at 40007000 ...
Image Name: Linux-4.1.36-gacf8321-dirty
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 5709176 Bytes = 5.4 MiB
Load Address: 40007000
Entry Point: 40007000
Verifying Checksum ... OK
kernel data at 0x40007040, len = 0x00571d78 (5709176)
do_bootm_states:595 searching os[done].
## Skipping init Ramdisk
## No init Ramdisk
ramdisk start = 0x00000000, ramdisk end = 0x00000000
## Flattened Device Tree blob at 41000000
Booting using the fdt blob at 0x41000000
do_bootm_states find other.
Loading Kernel Image ... OK
kernel loaded at 0x40007000, end = 0x40578d78
images.os.start = 0x40007000, images.os.end = 0x40578db8
images.os.load = 0x40007000, load_end = 0x40578d78
do_bootm_states: load OS done.
do_bootm_states: reserve fdt done.
using: FDT
## initrd_high = 0xffffffff, copy_to_ram = 1
ramdisk load start = 0x00000000, ramdisk load end = 0x00000000
Loading Device Tree to 4fff4000, end 4ffffe1c ... OK
do_bootm_states: run the OS.
## Transferring control to Linux (at address 40007000)...
Starting kernel ...
Uncompressing Linux... done, booting the kernel.
[ 0.000000] Booting Linux on physical CPU 0xa00
[ 0.000000] Linux version 4.1.36-gacf8321-dirty (camus@camus) (gcc version 4.8.3 20140320 (prerelease) (So7
[ 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: Landrover Switch board based on Exynos4412
[ 0.000000] bootconsole [earlycon0] enabled
[ 0.000000] cma: Reserved 64 MiB at 0x7c000000
[ 0.000000] Memory policy: Data cache writealloc
[ 0.000000] Samsung CPU ID: 0xe4412011
[ 0.000000] PERCPU: Embedded 10 pages/cpu @eefa6000 s11776 r8192 d20992 u40960
[ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 260624
[ 0.000000] Kernel command line: console=ttySAC2,115200n8 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: 965432K/1048576K available (3156K kernel code, 110K rwdata, 1156K rodata, 3548K init, )
[ 0.000000] Virtual kernel memory layout:
[ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB)
[ 0.000000] fixmap : 0xffc00000 - 0xfff00000 (3072 kB)
[ 0.000000] vmalloc : 0xf0000000 - 0xff000000 ( 240 MB)
[ 0.000000] lowmem : 0xc0000000 - 0xef800000 ( 760 MB)
[ 0.000000] pkmap : 0xbfe00000 - 0xc0000000 ( 2 MB)
[ 0.000000] modules : 0xbf000000 - 0xbfe00000 ( 14 MB)
[ 0.000000] .text : 0xc0008000 - 0xc043e578 (4314 kB)
[ 0.000000] .init : 0xc043f000 - 0xc07b6000 (3548 kB)
[ 0.000000] .data : 0xc07b6000 - 0xc07d1aa0 ( 111 kB)
[ 0.000000] .bss : 0xc07d4000 - 0xc0810414 ( 242 kB)
[ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
[ 0.000000] Preemptible hierarchical RCU implementation.
[ 0.000000] Additional per-CPU info printed with stalls.
[ 0.000000] RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=4.
[ 0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=16, 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 ID prefetch enabled, offset 8 lines
[ 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 0x7e470001
[ 0.000000] Exynos4x12 clocks: sclk_apll = 500000000, sclk_mpll = 800000000
[ 0.000000] sclk_epll = 96000000, sclk_vpll = 108000000, arm_clk = 1000000000
[ 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.000005] sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 89478484971ns
[ 0.008036] Console: colour dummy device 80x30
register s3c24xx serial console.
s3c24xx_serial_console_setup: co=c07c85a8 (2), 115200n8
port iobase = 0x0.
s3c24xx_serial_console_setup: port mapbase is NULL.
[ 0.026652] Calibrating delay loop (skipped), value calculated using timer frequency.. 48.00 BogoMIPS (lpj)
[ 0.037069] pid_max: default: 32768 minimum: 301
[ 0.041840] Mount-cache hash table entries: 2048 (order: 1, 8192 bytes)
[ 0.048443] Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes)
[ 0.056076] CPU: Testing write buffer coherency: ok
[ 0.061070] CPU0: thread -1, cpu 0, socket 10, mpidr 80000a00
[ 0.067030] Setting up static identity map for 0x400082c0 - 0x40008318
[ 0.110025] CPU1: thread -1, cpu 1, socket 10, mpidr 80000a01
[ 0.120023] CPU2: thread -1, cpu 2, socket 10, mpidr 80000a02
[ 0.130021] CPU3: thread -1, cpu 3, socket 10, mpidr 80000a03
[ 0.130078] Brought up 4 CPUs
[ 0.150413] SMP: Total of 4 processors activated (192.00 BogoMIPS).
[ 0.156749] CPU: All CPU(s) started in SVC mode.
[ 0.161864] devtmpfs: initialized
[ 0.176717] VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4
[ 0.184693] clocksource jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 9556302231375000 ns
[ 0.196159] pinctrl core: initialized pinctrl subsystem
[ 0.203220] DMA: preallocated 256 KiB pool for atomic coherent allocations
[ 0.224812] cpuidle: using governor ladder
[ 0.239808] cpuidle: using governor menu
[ 0.244564] exynos-audss-clk 3810000.clock-controller: setup completed
[ 0.260253] 10023c80.lcd0-power-domain has as child subdomain: 10023c20.tv-power-domain.
[ 0.287155] Switched to clocksource mct-frc
[ 0.498179] futex hash table entries: 1024 (order: 4, 65536 bytes)
[ 0.514943] romfs: ROMFS MTD (C) 2007 Red Hat, Inc.
[ 0.520410] bounce: pool size: 64 pages
[ 0.524268] io scheduler noop registered
[ 0.528174] io scheduler deadline registered
[ 0.532926] io scheduler cfq registered (default)
[ 0.596474] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
s3c24xx_serial_probe(ee99b800) 2
s3c24xx_serial_probe: initialising port c07c8878...
s3c24xx_serial_init_port: port=c07c88a8, platdev=ee99b800
resource [mem 0x13820000-0x138200ff])
port: map=0x13820000, mem=f7020000, irq=45 (45,46), clock=1
s3c24xx_serial_probe: adding port
[ 0.628294] 13820000.serial: ttySAC2 at MMIO 0x13820000 (irq = 45, base_baud = 0) is a S3C6400/10
s3c24xx_serial_console_setup: co=c07c85a8 (2), 115200n8
port iobase = 0x0.
s3c24xx_serial_console_setup: port=c07c88a8 (2)
s3c24xx_serial_console_setup: baud 115200
fracval = 0004
config: 8bits/char
setting ulcon to 00000003, brddiv to 53, udivslot 00000004
uart: ulcon = 0x00000003, ucon = 0x000003c5, ufcon = 0x00000111
[ 0.665916] console [tt[SAC2] enabled
0.665916] console [ttySAC2] enabled
[ 0.673203] bootconsole [early[on0] disabled
0.673203] bootconsole [earlycon0] disabled
[ 0.682616] [drm] Initialized drm 1.1.0 20060810
[ 0.694951] brd: module loaded
[ 0.701632] loop: module loaded
[ 0.703693] mousedev: PS/2 mouse device common for all mice
[ 0.709272] i2c /dev entries driver
[ 0.713863] Registering SWP/SWPB emulation handler
[ 0.718434] hctosys: unable to open rtc device (rtc0)
[ 0.737978] Warning: unable to open an initial console.
[ 0.744425] Freeing unused kernel memory: 3548K (c043f000 - c07b6000)
s3c64xx_serial_startup: port=c07c88a8 (13820000,f7020000)
s3c64xx_serial_startup ok
fracval = 0004
config: 8bits/char
setting ulcon to 00000003, brddiv to 53, udivslot 00000004
uart: ulcon = 0x00000003, ucon = 0x0000f3c5, ufcon = 0x00000131
fracval = 0004
config: 8bits/char
setting ulcon to 00000003, brddiv to 53, udivslot 00000004
uart: ulcon = 0x00000003, ucon = 0x0000f3c5, ufcon = 0x00000131
Please press Enter to activate this console.
[root@osee ]#
[root@osee ]#
[root@osee ]#
[root@osee ]#