tiny4412学习(二)之移植linux-4.x支持设备树

  • 硬件平台:tiny4412
  • 系统:linux-4.4
  • 文件系统:busybox-1.25
  • 编译器: arm-none-linux-gnueabi-gcc (gcc version 4.8.3 20140320
  • uboot:友善自带uboot,见上节
实验参考摩斯电码的博客:
http://www.cnblogs.com/pengdonglin137/p/5137941.html
http://www.cnblogs.com/pengdonglin137/p/5143516.html

一、u-boot修改

1、更新交叉工具链

到:http://www.veryarm.com/arm-none-linux-gnueabi-gcc
下载:arm-2014.05-29-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
tar –xjf arm-2014.05-29-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
修改环境变量:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/work/gcc/arm-2014.05/bin"
arm-none-linux-gnueabi-gcc -v:
gcc version 4.8.3 20140320 (prerelease) (Sourcery CodeBench Lite 2014.05-29)

2、关闭uboot开启的MMU

(1)修改include/configs/tiny4412.h

#define CONFIG_ENABLE_MMU

修改为

#undef CONFIG_ENABLE_MMU

(2) 只关闭MMU还不够,还需要修改u-boot的链接地址

修改文件board/samsung/tiny4412/config.mk

CONFIG_SYS_TEXT_BASE = 0xc3e00000

修改为

CONFIG_SYS_TEXT_BASE = 0x43e00000

因为板子是1G内存,从4000 0000 开始

4000 0000 - 5000 0000 256M

......

7000 0000 - 8000 0000 1G

3、使uboot可以引导uImage

修改uboot源码下:common/cmd_bootm.c

(1)

int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
        ulong           iflag;
        ulong           load_end = 0;
        int             ret;
        boot_os_fn      *boot_fn;
        int             iszImage = 0;

(2)

images.legacy_hdr_valid = 1;            

iszImage = 1;               

goto after_header_check;.

(3)

images.os.os = hdr->;ih_os;     

images.ep = image_get_ep (&;images.legacy_hdr_os_copy);

改为

if (iszImage) {              

images.os.os = hdr->ih_os;              

images.ep = image_get_ep (&images.legacy_hdr_os_copy);      

}

4、修改uboot支持设备树

修改include/configs/tiny4412.h

增加如下两个宏

#define CONFIG_OF_LIBFDT
#define CONFIG_SYS_BOOTMAPSZ (20 << 20)

5、编译uboot

(1)修改makefile,增加:

ifeq ($(ARCH),arm)

CROSS_COMPILE ?=/work/gcc/arm-2014.05/bin/arm-none-linux-gnueabi-

endif

(2)make distclean

(3)make tiny4412_config

(4)make

(5)烧写到SD卡

cd sd_fuse/tiny4412

./sd_fusing.sh /dev/sdc (fdisk -l查看)

(6)启动uboot

U-Boot 2010.12 (Jul 02 2017 - 11:26:09) 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
fwbl1: 0
iram block: 16
u-boot: 48
TrustZone S/W: 704
env: 1024
knl: 1057
rfs: 13345
bl2: 16
MMC Device 0: 14756 MB
lizuobin read idff
lizuobin read idff
lizuobin read idff
lizuobin read idff
fwbl1: 0
iram block: 16
u-boot: 48
TrustZone S/W: 704
env: 1024
knl: 1057
rfs: 13345
bl2: 16
MMC Device 1: 3728 MB
MMC Device 2: N/A
Net:    No ethernet found.
Hit any key to stop autoboot:  0 

二、内核及文件系统系统制作

1、内核移植(支持设备树)

(1)下载源码:https://www.kernel.org/pub/linux/kernel/v4.x/  下载  linux-4.4.tar.gz  

(2)解压:tar –xzf  linux-4.4.tar.gz 

(3)cd linux-4.4

(4)修改makefile,增加

+ARCH           ?= arm
+CROSS_COMPILE  ?= /work/gcc/arm-2014.05/bin/arm-none-linux-gnueabi-

(5)配置:linux-4.4 已经很好的支持了tiny4412,所以移植的工作并不多。

make exynos_defconfig
(6) 修改arch/arm/boot/dts/exynos4412-tiny4412.dts
      chosen {                
stdout-path = &;serial_0;                
bootargs = "root=/dev/ram0 rw rootfstype=ext4 console=ttySAC0,115200 init=/linuxrc earlyprintk";     };

        pinctrl-names = "default";
        #status = "okay";       
status = "disabled"; 
}&serial_0 
(7)配置内核,支持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
(8) 配置内核,使其支持tmpfs
$ make menuconfig
File systems --->;
    Pseudo filesystems --->
        [*] Virtual memory file system support (former shm fs)
        [*] Tmpfs POSIX Access Control Lists
exynos的默认配置也已经支持了。
(9)编译产生uImage
make uImage LOADADDR=0x40008000 -j2
生成的uImage在arch/arm/boot下。 
(10)编译设备树
make dtbs
arch/arm/boot/dts/会生成tiny4412上用的设备树镜像文件exynos4412-tiny4412.dtb。
(11)文件系统制作
下载busybox的代码,制作ramdisk镜像。

三、下载测试

下载内核、文件系统、设备树文件
#u-boot:dnw 0x40600000
dnw arch/arm/boot/uImage
#u-boot:dnw 0x41000000 
dnw ramdisk.img
#u-boot:dnw 0x42000000
dnw arch/arm/boot/dts/exynos4412-tiny4412.dtb
启动内核 使用bootm启动内核:

bootm 0x40600000 0x41000000 0x42000000

启动日志:
TINY4412 # bootm 0x40600000 0x41000000 0x42000000
## Booting kernel from Legacy Image at 40600000 ...
   Image Name:   Linux-4.4.0
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    4193128 Bytes = 4094 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 413ff555 ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0xa00
[    0.000000] Linux version 4.4.0 (root@book-virtual-machine) (gcc version 4.8.3 20140320 (prerelease) (Sourcery CodeBench Lite 2014.05-29) ) #1 SMP PREEMPT Sun Jul 2 11:55:00 CST 2017
[    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] 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 @ef79c000 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/mmcblk0p1 rootfstype=ext4 console=ttySAC0,115200 init=/linuxrc ctp=2 skipcali=y loglevel=7
[    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: 961316K/1047552K available (5715K kernel code, 239K rwdata, 2020K rodata, 432K init, 315K bss, 20700K 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 - 0xc0795eac   (7736 kB)
[    0.000000]       .init : 0xc0796000 - 0xc0802000   ( 432 kB)
[    0.000000]       .data : 0xc0802000 - 0xc083de00   ( 240 kB)
[    0.000000]        .bss : 0xc0840000 - 0xc088ec28   ( 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.000125] Console: colour dummy device 80x30
[    0.000138] Calibrating delay loop (skipped), value calculated using timer frequency.. 48.00 BogoMIPS (lpj=120000)
[    0.000148] pid_max: default: 32768 minimum: 301
[    0.000215] Mount-cache hash table entries: 2048 (order: 1, 8192 bytes)
[    0.000222] Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes)
[    0.000596] CPU: Testing write buffer coherency: ok
[    0.000793] CPU0: thread -1, cpu 0, socket 10, mpidr 80000a00
[    0.001024] Setting up static identity map for 0x40008280 - 0x400082d8
[    0.045045] CPU1: thread -1, cpu 1, socket 10, mpidr 80000a01
[    0.060040] CPU2: thread -1, cpu 2, socket 10, mpidr 80000a02
[    0.075041] CPU3: thread -1, cpu 3, socket 10, mpidr 80000a03
[    0.075081] Brought up 4 CPUs
[    0.075093] SMP: Total of 4 processors activated (192.00 BogoMIPS).
[    0.075098] CPU: All CPU(s) started in SVC mode.
[    0.075616] devtmpfs: initialized
[    0.084885] VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4
[    0.085179] lcd0-power-domain@10023C80 has as child subdomain: tv-power-domain@10023C20.
[    0.085542] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 9556302231375000 ns
[    0.087530] pinctrl core: initialized pinctrl subsystem
[    0.088329] NET: Registered protocol family 16
[    0.089749] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.105005] cpuidle: using governor ladder
[    0.120000] cpuidle: using governor menu
[    0.120758] exynos-audss-clk 3810000.clock-controller: setup completed
[    0.157186] SCSI subsystem initialized
[    0.157551] usbcore: registered new interface driver usbfs
[    0.157627] usbcore: registered new interface driver hub
[    0.157707] usbcore: registered new device driver usb
[    0.158855] Advanced Linux Sound Architecture Driver Initialized.
[    0.159956] clocksource: Switched to clocksource mct-frc
[    0.169326] missing cooling_device property
[    0.169336] failed to build thermal zone cpu-thermal: -2
[    0.169438] NET: Registered protocol family 2
[    0.169823] TCP established hash table entries: 8192 (order: 3, 32768 bytes)
[    0.169883] TCP bind hash table entries: 8192 (order: 5, 163840 bytes)
[    0.170058] TCP: Hash tables configured (established 8192 bind 8192)
[    0.170135] UDP hash table entries: 512 (order: 2, 24576 bytes)
[    0.170163] UDP-Lite hash table entries: 512 (order: 2, 24576 bytes)
[    0.170308] NET: Registered protocol family 1
[    0.170515] RPC: Registered named UNIX socket transport module.
[    0.170522] RPC: Registered udp transport module.
[    0.170526] RPC: Registered tcp transport module.
[    0.170531] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.170682] Trying to unpack rootfs image as initramfs...
[    0.171066] rootfs image is not initramfs (no cpio magic); looks like an initrd
[    0.178611] Freeing initrd memory: 2528K (c3a84000 - c3cfc000)
[    0.180220] futex hash table entries: 1024 (order: 4, 65536 bytes)
[    0.189910] romfs: ROMFS MTD (C) 2007 Red Hat, Inc.
[    0.190627] bounce: pool size: 64 pages
[    0.190639] io scheduler noop registered
[    0.190648] io scheduler deadline registered
[    0.190827] io scheduler cfq registered (default)
[    0.195804] dma-pl330 12680000.pdma: Loaded driver for PL330 DMAC-141330
[    0.195815] dma-pl330 12680000.pdma:         DBUFF-32x4bytes Num_Chans-8 Num_Peri-32 Num_Events-32
[    0.198955] dma-pl330 12690000.pdma: Loaded driver for PL330 DMAC-141330
[    0.198966] dma-pl330 12690000.pdma:         DBUFF-32x4bytes Num_Chans-8 Num_Peri-32 Num_Events-32
[    0.199872] dma-pl330 12850000.mdma: Loaded driver for PL330 DMAC-141330
[    0.199882] dma-pl330 12850000.mdma:         DBUFF-64x8bytes Num_Chans-8 Num_Peri-1 Num_Events-32
[    0.258208] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
[    0.259497] 13800000.serial: ttySAC0 at MMIO 0x13800000 (irq = 44, base_baud = 0) is a S3C6400/10
[    0.893042] console [ttySAC0] enabled
[    0.897038] 13810000.serial: ttySAC1 at MMIO 0x13810000 (irq = 45, base_baud = 0) is a S3C6400/10
[    0.905817] 13820000.serial: ttySAC2 at MMIO 0x13820000 (irq = 46, base_baud = 0) is a S3C6400/10
[    0.914662] 13830000.serial: ttySAC3 at MMIO 0x13830000 (irq = 47, base_baud = 0) is a S3C6400/10
[    0.924239] [drm] Initialized drm 1.1.0 20060810
[    0.938118] brd: module loaded
[    0.943226] loop: module loaded
[    0.944056] usbcore: registered new interface driver r8152
[    0.944186] usbcore: registered new interface driver asix
[    0.944901] usbcore: registered new interface driver ax88179_178a
[    0.950999] usbcore: registered new interface driver cdc_ether
[    0.956814] usbcore: registered new interface driver smsc75xx
[    0.962551] usbcore: registered new interface driver smsc95xx
[    0.968259] usbcore: registered new interface driver net1080
[    0.973900] usbcore: registered new interface driver cdc_subset
[    0.979802] usbcore: registered new interface driver zaurus
[    0.985391] usbcore: registered new interface driver cdc_ncm
[    0.991341] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    0.997448] ehci-exynos: EHCI EXYNOS driver
[    1.001740] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    1.007792] ohci-exynos: OHCI EXYNOS driver
[    1.012303] usbcore: registered new interface driver usb-storage
[    1.018477] mousedev: PS/2 mouse device common for all mice
[    1.024259] s3c-rtc 10070000.rtc: failed to find rtc source clock
[    1.029582] s3c-rtc: probe of 10070000.rtc failed with error -2
[    1.035678] i2c /dev entries driver
[    1.041008] device-mapper: ioctl: 4.34.0-ioctl (2015-10-28) initialised: [email protected]
[    1.048188] sdhci: Secure Digital Host Controller Interface driver
[    1.053518] sdhci: Copyright(c) Pierre Ossman
[    1.057990] Synopsys Designware Multimedia Card Interface Driver
[    1.065815] usbcore: registered new interface driver usbhid
[    1.069388] usbhid: USB HID core driver
[    1.076210] NET: Registered protocol family 10
[    1.078177] sit: IPv6 over IPv4 tunneling driver
[    1.082805] NET: Registered protocol family 17
[    1.086696] NET: Registered protocol family 15
[    1.091276] Registering SWP/SWPB emulation handler
[    1.097130] hctosys: unable to open rtc device (rtc0)
[    1.112737] ALSA device list:
[    1.112775]   No soundcards found.
[    1.113484] RAMDISK: gzip image found at block 0
[    1.257012] EXT4-fs (ram0): mounted filesystem with o鋎ered data mode. Opts: (null)
[    1.257106] VFS: Mounted root (ext4 filesystem) on device 1:0.

Please press Enter to activate this console. 
[root@tiny4412 ]# 
[root@tiny4412 ]# 
[root@tiny4412 ]# ls
bin         etc         linuxrc     mnt         root        sys         usr
dev         lib         lost+found  proc        sbin        tmp         var



内核、uboot、文件系统文件下载:

http://download.csdn.net/detail/fengyuwuzu0519/9886548






你可能感兴趣的:(tiny4412学习(二)之移植linux-4.x支持设备树)