U-Boot 加载并启动 Linux 系统程序
零、介绍
最近在玩一些嵌入式的开发板,在引导操作系统时需要用到U-Boot,故此研究一下。
U-Boot(Universal Bootloader)是一款开源的通用引导加载程序,专为嵌入式系统设计,支持 ARM、x86、RISC-V 等主流架构及超过 1200 种硬件平台,具备跨平台兼容性与高度灵活性。它通过集成丰富的命令行交互、脚本自动化、文件系统支持(FAT/EXT4)及网络协议(TFTP/NFS),实现从硬件初始化到操作系统加载的全流程管理,可启动 Linux、Android、ChromeOS 等多类系统。开发者能够通过模块化设计自定义命令、驱动及功能模块,并通过配置文件灵活剪裁引导流程,满足消费电子、工业控制、物联网等场景的定制需求。依托活跃的开源社区生态,U-Boot 以轻量高效、稳定可靠的特性,成为嵌入式领域适配广泛且易于扩展的核心引导解决方案。
壹、资源准备
针对某款开发板,我们需要准备一些接下来要用到的软件。后面我使用我准备的资源来做示例。
1. 针对于开发板制作的:
- U-Boot 引导程序
- Linux 系统程序
- DTB 设备树文件
- RootFS 根文件系统
我准备的:
其中:
- U-Boot 引导程序为uboot.bin;
- Linux 系统程序为linux;
- DTB 设备树文件为dt.dtb;
- RootFS 根文件系统为ramdisk.img。
下文中会用对应的文件名表示资源。
2. 辅助软件:
- Linux 系统
- NFS 服务器程序
- TFTP 服务器程序
- DiskGenius 磁盘管理程序专业版 或者 Win32 Disk Imager
- 7z解压缩软件
我准备的:
其中:
- Linux 系统为ubuntu-22.04.5-desktop-amd64.iso;
- NFS 服务器程序为nfs1268.zip 和 nfs-languages.zip;
- TFTP 服务器程序为tftpd64.464.zip;
- Win32 Disk Imager为Win32DiskImager-1.0.0-binary.zip;
- 7z解压缩软件为7z2201-x64.exe。
到网上基本上都能找到以上资源。
贰、U-Boot启动盘制作
我们需要把 U-Boot 引导程序写入到SD卡中,然后让开发板上CPU自带的BL程序从SD卡启动,这样就能在开发板上启动 U-Boot 引导程序了。
1. 创建SD卡格式镜像
SD卡的存储空间以扇区为单位,每个扇区的大小为512字节,其中第一个扇区存储分区表,后续的扇区可自行分区和格式化。若选择SD卡启动,开发板上的处理器上电后会从第二个扇区开始将其中的内容搬移到内存,所以我们把 U-Boot 引导程序放到从第二个扇区及之后的空间。之后的空间就可以根据个人需求进行划分和存储了。
因此,我们需要制作一个SD卡镜像,其组成格式为512字节的第一个扇区空白部分和 U-Boot 引导程序。
1. 1 创建512字节的空白文件
在Linux中,使用如下命令生成一个空白的512字节大小的文件:- sudo dd if=/dev/zero of=blank.bin count=1
复制代码 其中,dd是一个文件复制工具,if表示输入文件,/dev/zero是Linux系统中的特殊设备文件,会无限输出 0 字节,of表示输出文件,count=1表示复制一个块,默认情况下,dd 的块大小为 512 字节,因此最终生成的文件大小为 1 × 512 = 512 字节。
运行结果:- yu@Yubuntu:~/mkimg$ ls -l
- 总计 516
- -rw-rw-r-- 1 yu yu 527104 3月 29 21:53 uboot.bin
- yu@Yubuntu:~/mkimg$ sudo dd if=/dev/zero of=blank.bin count=1
- [sudo] yu 的密码:
- 记录了1+0 的读入
- 记录了1+0 的写出
- 512字节已复制,0.000127706 s,4.0 MB/s
- yu@Yubuntu:~/mkimg$ ls -l
- 总计 520
- -rw-r--r-- 1 root root 512 3月 29 21:54 blank.bin
- -rw-rw-r-- 1 yu yu 527104 3月 29 21:53 uboot.bin
- yu@Yubuntu:~/mkimg$
复制代码 1. 2 合成SD卡镜像
接着是把512字节的空白文件和 U-Boot 引导程序合并,使用如下命令将两个文件进行合并:- cat blank.bin uboot.bin > uboot_sd.bin
复制代码 其中:
- cat 命令的主要功能是连接文件并将内容输出,这里使用 cat 连接blank.bin 和 uboot.bin,cat 命令会按照指定的顺序依次读取这些文件的内容并输出;
- > 是一个重定向操作符,它的作用是把 cat 命令的输出内容重定向到 uboot_sd.bin 里。
运行结果:- yu@Yubuntu:~/mkimg$ cat blank.bin uboot.bin > uboot_sd.bin
- yu@Yubuntu:~/mkimg$ ls -l
- 总计 1036
- -rw-r--r-- 1 root root 512 3月 29 21:54 blank.bin
- -rw-rw-r-- 1 yu yu 527104 3月 29 21:53 uboot.bin
- -rw-rw-r-- 1 yu yu 527616 3月 29 22:01 uboot_sd.bin
- yu@Yubuntu:~/mkimg$
复制代码 这样,我们得到了一个SD卡镜像文件:uboot_sd.bin。
1. 3 生成空白SD卡镜像
这一步前面没有提及,为啥突然出现这一步,我们可以稍加思考。假设我们SD卡中已经存有大量数据,我们直接把 uboot_sd.bin 写入前面的扇区,后面的扇区没有管,那后面的扇区却是还有之前残留的数据的,这样开发板上的CPU无法分辨哪些是有用的,故需要我们手动把后面的扇区清理一下。清理的方法也很简单,我们只需要写入空白文件即可,故此步骤为生成足够大小的空白文件。
使用如下命令生成对应的空白文件:- sudo dd if=/dev/zero of=clear.bin count=2048
复制代码 运行结果:- yu@Yubuntu:~/mkimg$ sudo dd if=/dev/zero of=clear.bin count=2048
- 记录了2048+0 的读入
- 记录了2048+0 的写出
- 1048576字节(1.0 MB,1.0 MiB)已复制,0.020858 s,50.3 MB/s
- yu@Yubuntu:~/mkimg$ ls -l
- 总计 2060
- -rw-r--r-- 1 root root 512 3月 29 21:54 blank.bin
- -rw-r--r-- 1 root root 1048576 3月 29 22:07 clear.bin
- -rw-rw-r-- 1 yu yu 527104 3月 29 21:53 uboot.bin
- -rw-rw-r-- 1 yu yu 527616 3月 29 22:01 uboot_sd.bin
- yu@Yubuntu:~/mkimg$
复制代码 这样我们得到了一个1兆字节大小的文件:clear.bin。
2. 刷写SD卡
找一张闲置的SD卡,或提前备份好SD卡上的重要文件,把SD卡通过读卡器连接到电脑。把上一步生成的 clear.bin 和 uboot_sd.bin 文件放到Windows系统上,运行 DiskGenius 磁盘管理程序专业版 或者 Win32 Disk Imager 程序。
2.1 清理SD卡
选择“clear.bin”作为映像文件,选择“U盘”作为设备,点击“写入”即可把SD卡前面的空间空出来,此时因为没有文件系统信息,Windows 无法识别 SD 卡,这是正常的。
2.2 把 SD 卡镜像文件写入 SD 卡
跟刚刚的步骤一致,选择 uboot_sd.bin 作为映像文件,选择 U盘 作为设备,点击“写入”即可把SD卡镜像文件写入 SD 卡。
这样我们的 SD 卡 U-Boot 启动盘就做好了~
2.3 通过 DiskGenius 磁盘管理程序专业版写入
DiskGenius 磁盘管理程序专业版是收费的,故此只简单介绍下步骤,步骤如下:
首先选择你要刷写的 SD 卡,然后点“扇区编辑”选项卡,点击“扇区复制”图标打开扇区复制窗口,选择来源,源自我们刚刚合成的文件,再选择目标磁盘,目标磁盘为 SD 卡,参数设置这边的来源磁盘和目标磁盘的起始扇区都设置为0,下面“遇到坏扇区区域时”选择“逐扇区复制”,最后点击“复制”按钮即可。
叁、从SD卡启动
把 SD 卡插入到开发板上,设置开发板从 SD 卡启动,打开电源开关,可以在串口上看到 U-Boot 引导程序的输出信息:- U-Boot 2013.01 (Mar 29 2025 - 15:17:15) for ex4412
- CPU: Exynos4412@1000MHz
- Board: ORIGEN
- DRAM: 1 GiB
- WARNING: Caches not enabled
- PMIC: S5M8767(VER5.0)
- MMC: MMC0: 14910 MB
- In: serial
- Out: serial
- Err: serial
- MMC read: dev # 0, block # 48, count 16 ...16 blocks read: OK
- eMMC CLOSE Success.!!
- Checking Boot Mode ... EMMC4.41
- Net: dm9000
- Hit any key to stop autoboot: 0
- ex4412 #
复制代码 在自动启动倒计时开始后,按下任意键可以中断自动启动,让 U-Boot 引导程序在当前停留。
接下来就是加载和运行 Linux 系统程序了。
肆、网络设置
把开发板的以太网口与电脑的以太网口通过网线相连接。
1. 电脑网络设置
在电脑的设置中设置以太网口的IP、网关和DNS等。
IP地址自拟,合理即可。
2. 开发板网络设置
在开发板上,通过 setenv 命令和 saveenv 命令来设置IP和保存设置。
其中,setenv 命令格式:- setenv <环境变量名> <变量值,若有空格,需用双引号引起>
复制代码 示例:- ex4412 # setenv gatewayip 192.168.100.1
- ex4412 # setenv ipaddr 192.168.100.110
- ex4412 # setenv netmask 255.255.255.0
- ex4412 # setenv serverip 192.168.100.100
- ex4412 # saveenv
- Saving Environment to MMC...
- Writing to MMC(0)... .done
- ex4412 #
复制代码 IP地址自拟,与电脑的在同一网段且不冲突即可。
肆、通过TFTP方式加载并启动 Linux 系统程序
启动 TFTP 服务器程序,设置好共享目录,把 U-Boot 引导程序、Linux 系统程序、DTB 设备树文件 和 RootFS 根文件系统都放入到共享目录中去。
目录内容如下:- D:\board>tree /f
- 卷 井中月 的文件夹 PATH 列表
- 卷序列号为 FE8F-1AB3
- D:.
- dt.dtb
- linux
- ramdisk.img
- uboot.bin
- 没有子文件夹
- D:\board>
复制代码 1. 手动从 TFTP 服务器加载并启动
使用 TFTP 加载文件到内存的命令(tftp)格式为:1.1 加载 Linux 系统程序
使用 TFTP 加载 Linux 系统程序到内存的0x41000000位置:- ex4412 # tftp 41000000 linux
- dm9000 i/o: 0x5000000, id: 0x90000a46
- DM9000: running in 16 bit mode
- MAC: 00:1a:2b:33:44:55
- operating at 100M full duplex mode
- Using dm9000 device
- TFTP from server 192.168.100.100; our IP address is 192.168.100.110
- Filename 'linux'.
- Load address: 0x41000000
- Loading: T #################################################################
- #################################################################
- #################################################################
- ###########
- 387.7 KiB/s
- done
- Bytes transferred = 3019120 (2e1170 hex)
- ex4412 #
复制代码 1.2 加载 DTB 设备树文件
加载 DTB 设备树文件到内存的0x42000000位置:- ex4412 # tftp 42000000 dt.dtb
- dm9000 i/o: 0x5000000, id: 0x90000a46
- DM9000: running in 16 bit mode
- MAC: 00:1a:2b:33:44:55
- operating at 100M full duplex mode
- Using dm9000 device
- TFTP from server 192.168.100.100; our IP address is 192.168.100.110
- Filename 'dt.dtb'.
- Load address: 0x42000000
- Loading: ###
- 986.3 KiB/s
- done
- Bytes transferred = 34358 (8636 hex)
- ex4412 #
复制代码 1.3 加载 RootFS 根文件系统
加载 RootFS 根文件系统到内存的0x43000000位置:- ex4412 # tftp 43000000 ramdisk.img
- dm9000 i/o: 0x5000000, id: 0x90000a46
- DM9000: running in 16 bit mode
- MAC: 00:1a:2b:33:44:55
- operating at 100M full duplex mode
- Using dm9000 device
- TFTP from server 192.168.100.100; our IP address is 192.168.100.110
- Filename 'ramdisk.img'.
- Load address: 0x43000000
- Loading: #################################################################
- #################################################################
- ############################################
- 1.1 MiB/s
- done
- Bytes transferred = 2544147 (26d213 hex)
- ex4412 #
复制代码 1.4 启动 Linux 系统程序
启动 Linux 系统程序的命令格式为:- bootm <Linux 系统程序在内存中的位置> <RootFS 根文件系统在内存中的位置> <DTB 设备树文件在内存中的位置>
复制代码 示例:- ex4412 # bootm 41000000 43000000 42000000
- ## Booting kernel from Legacy Image at 41000000 ...
- Image Name: Linux-3.14.0
- Image Type: ARM Linux Kernel Image (uncompressed)
- Data Size: 3019056 Bytes = 2.9 MiB
- Load Address: 40008000
- Entry Point: 40008000
- Verifying Checksum ... OK
- ## Loading init Ramdisk from Legacy Image at 43000000 ...
- Image Name: ramdisk
- Image Type: ARM Linux RAMDisk Image (gzip compressed)
- Data Size: 2544083 Bytes = 2.4 MiB
- 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 Ramdisk to 4fd92000, end 4ffff1d3 ... OK
- Loading Device Tree to 4fd86000, end 4fd91635 ... OK
- Starting kernel ...
- [ 0.000000] Booting Linux on physical CPU 0xa00
- [ 0.000000] Linux version 3.14.0 (linux@linux) (gcc version 4.6.4 (crosstool-NG hg+default-2685dfa9de14 - tc0002) ) #5 SMP PREEMPT Thu Apr 17 22:17:51 EDT 2024
- [ 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: Insignal Origen evaluation board based on Exynos4412
- [ 0.000000] Memory policy: Data cache writealloc
- [ 0.000000] CPU EXYNOS4412 (id 0xe4412011)
- [ 0.000000] Running under secure firmware.
- [ 0.000000] PERCPU: Embedded 7 pages/cpu @eefb6000 s7424 r8192 d13056 u32768
- [ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 256528
- [ 0.000000] Kernel command line: console=ttySAC2,115200
- [ 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: 1014372K/1032192K available (3948K kernel code, 236K rwdata, 1316K rodata, 231K init, 276K bss, 17820K reserved, 270336K highmem)
- [ 0.000000] Virtual kernel memory layout:
- [ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB)
- [ 0.000000] fixmap : 0xfff00000 - 0xfffe0000 ( 896 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 - 0xc052c258 (5265 kB)
- [ 0.000000] .init : 0xc052d000 - 0xc0566d00 ( 232 kB)
- [ 0.000000] .data : 0xc0568000 - 0xc05a3340 ( 237 kB)
- [ 0.000000] .bss : 0xc05a334c - 0xc05e8384 ( 277 kB)
- [ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
- [ 0.000000] Preemptible hierarchical RCU implementation.
- [ 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] Exynos4x12 clocks: sclk_apll = 500000000, sclk_mpll = 800000000
- [ 0.000000] sclk_epll = 96000000, sclk_vpll = 350000000, arm_clk = 1000000000
- [ 0.000000] sched_clock: 32 bits at 200 Hz, resolution 5000000ns, wraps every 10737418240000000ns
- [ 0.000000] Console: colour dummy device 80x30
- [ 0.045000] Calibrating delay loop... 1992.29 BogoMIPS (lpj=4980736)
- [ 0.045000] pid_max: default: 32768 minimum: 301
- [ 0.045000] Mount-cache hash table entries: 2048 (order: 1, 8192 bytes)
- [ 0.045000] Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes)
- [ 0.050000] CPU: Testing write buffer coherency: ok
- [ 0.050000] missing device node for CPU 0
- [ 0.050000] missing device node for CPU 1
- [ 0.050000] missing device node for CPU 2
- [ 0.050000] missing device node for CPU 3
- [ 0.050000] CPU0: thread -1, cpu 0, socket 10, mpidr 80000a00
- [ 0.050000] Setting up static identity map for 0x403be650 - 0x403be6a8
- [ 0.070000] CPU1: Booted secondary processor
- [ 0.090000] CPU1: thread -1, cpu 1, socket 10, mpidr 80000a01
- [ 0.100000] CPU2: Booted secondary processor
- [ 0.120000] CPU2: thread -1, cpu 2, socket 10, mpidr 80000a02
- [ 0.130000] CPU3: Booted secondary processor
- [ 0.150000] CPU3: thread -1, cpu 3, socket 10, mpidr 80000a03
- [ 0.150000] Brought up 4 CPUs
- [ 0.150000] SMP: Total of 4 processors activated.
- [ 0.150000] CPU: All CPU(s) started in SVC mode.
- [ 0.150000] devtmpfs: initialized
- [ 0.150000] VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4
- [ 0.155000] pinctrl core: initialized pinctrl subsystem
- [ 0.155000] regulator-dummy: no parameters
- [ 0.155000] NET: Registered protocol family 16
- [ 0.155000] DMA: preallocated 256 KiB pool for atomic coherent allocations
- [ 0.175000] S3C Power Management, Copyright 2004 Simtec Electronics
- [ 0.175000] EXYNOS4x12 PMU Initialize
- [ 0.175000] EXYNOS: Initializing architecture
- [ 0.210000] bio: create slab <bio-0> at 0
- [ 0.210000] VMEM_VDD_2.8V: 2800 mV
- [ 0.215000] SCSI subsystem initialized
- [ 0.215000] usbcore: registered new interface driver usbfs
- [ 0.215000] usbcore: registered new interface driver hub
- [ 0.215000] usbcore: registered new device driver usb
- [ 0.215000] s3c-i2c 13860000.i2c: slave address 0x00
- [ 0.215000] s3c-i2c 13860000.i2c: bus frequency set to 19 KHz
- [ 0.220000] sec_pmic 0-0066: No interrupt specified, no interrupts
- [ 0.245000] VDD_ALIVE: failed to apply 1100000uV constraint
- [ 0.245000] s5m8767-pmic s5m8767-pmic: regulator init failed for 0
- [ 0.245000] s3c-i2c 13860000.i2c: i2c-0: S3C I2C adapter
- [ 0.245000] Switched to clocksource mct-frc
- [ 0.275000] NET: Registered protocol family 2
- [ 0.275000] TCP established hash table entries: 8192 (order: 3, 32768 bytes)
- [ 0.275000] TCP bind hash table entries: 8192 (order: 5, 163840 bytes)
- [ 0.275000] TCP: Hash tables configured (established 8192 bind 8192)
- [ 0.275000] TCP: reno registered
- [ 0.275000] UDP hash table entries: 512 (order: 2, 24576 bytes)
- [ 0.275000] UDP-Lite hash table entries: 512 (order: 2, 24576 bytes)
- [ 0.275000] NET: Registered protocol family 1
- [ 0.275000] RPC: Registered named UNIX socket transport module.
- [ 0.275000] RPC: Registered udp transport module.
- [ 0.275000] RPC: Registered tcp transport module.
- [ 0.275000] RPC: Registered tcp NFSv4.1 backchannel transport module.
- [ 0.280000] Trying to unpack rootfs image as initramfs...
- [ 0.280000] rootfs image is not initramfs (no cpio magic); looks like an initrd
- [ 0.290000] Freeing initrd memory: 2484K (cfd92000 - cffff000)
- [ 0.295000] futex hash table entries: 1024 (order: 4, 65536 bytes)
- [ 0.295000] bounce pool size: 64 pages
- [ 0.320000] ROMFS MTD (C) 2007 Red Hat, Inc.
- [ 0.320000] msgmni has been set to 1458
- [ 0.320000] io scheduler noop registered
- [ 0.320000] io scheduler deadline registered
- [ 0.320000] io scheduler cfq registered (default)
- [ 0.335000] dma-pl330 12680000.pdma: Loaded driver for PL330 DMAC-1315632
- [ 0.335000] dma-pl330 12680000.pdma: DBUFF-32x4bytes Num_Chans-8 Num_Peri-32 Num_Events-32
- [ 0.345000] dma-pl330 12690000.pdma: Loaded driver for PL330 DMAC-1315632
- [ 0.345000] dma-pl330 12690000.pdma: DBUFF-32x4bytes Num_Chans-8 Num_Peri-32 Num_Events-32
- [ 0.350000] dma-pl330 12850000.mdma: Loaded driver for PL330 DMAC-1315632
- [ 0.350000] dma-pl330 12850000.mdma: DBUFF-64x8bytes Num_Chans-8 Num_Peri-1 Num_Events-32
- [ 0.540000] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
- [ 0.540000] 13800000.serial: ttySAC0 at MMIO 0x13800000 (irq = 84, base_baud = 0) is a S3C6400/10
- [ 0.545000] 13810000.serial: ttySAC1 at MMIO 0x13810000 (irq = 85, base_baud = 0) is a S3C6400/10
- [ 0.545000] 13820000.serial: ttySAC2 at MMIO 0x13820000 (irq = 86, base_baud = 0) is a S3C6400/10
- [ 1.170000] console [ttySAC2] enabled
- [ 1.175000] 13830000.serial: ttySAC3 at MMIO 0x13830000 (irq = 87, base_baud = 0) is a S3C6400/10
- [ 1.200000] brd: module loaded
- [ 1.210000] loop: module loaded
- [ 1.215000] dm9000 5000000.ethernet: read wrong id 0x01010101
- [ 1.220000] eth0: dm9000a at f0076000,f0078004 IRQ 167 MAC: 00:0a:2d:a6:55:a2 (platform data)
- [ 1.225000] usbcore: registered new interface driver asix
- [ 1.230000] usbcore: registered new interface driver ax88179_178a
- [ 1.240000] usbcore: registered new interface driver cdc_ether
- [ 1.245000] usbcore: registered new interface driver smsc75xx
- [ 1.250000] usbcore: registered new interface driver smsc95xx
- [ 1.255000] usbcore: registered new interface driver net1080
- [ 1.260000] usbcore: registered new interface driver cdc_subset
- [ 1.265000] usbcore: registered new interface driver zaurus
- [ 1.270000] usbcore: registered new interface driver cdc_ncm
- [ 1.280000] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
- [ 1.285000] ehci-exynos: EHCI EXYNOS driver
- [ 1.290000] exynos-ehci 12580000.ehci: no platform data or transceiver defined
- [ 1.295000] platform 12580000.ehci: Driver exynos-ehci requests probe deferral
- [ 1.305000] usbcore: registered new interface driver usb-storage
- [ 1.320000] usb3503 8.usb3503: switched to HUB mode
- [ 1.325000] usb3503 8.usb3503: usb3503_probe: probed in hub mode
- [ 1.330000] mousedev: PS/2 mouse device common for all mice
- [ 1.335000] input: 100a0000.keypad as /devices/100a0000.keypad/input/input0
- [ 1.345000] device-mapper: ioctl: 4.27.0-ioctl (2013-10-30) initialised: dm-devel@redhat.com
- [ 1.350000] sdhci: Secure Digital Host Controller Interface driver
- [ 1.360000] sdhci: Copyright(c) Pierre Ossman
- [ 1.365000] s3c-sdhci 12530000.sdhci: clock source 2: mmc_busclk.2 (5000000 Hz)
- [ 1.370000] mmc0: no vqmmc regulator found
- [ 1.375000] mmc0: no vmmc regulator found
- [ 1.410000] mmc0: SDHCI controller on samsung-hsmmc [12530000.sdhci] using ADMA
- [ 1.415000] Synopsys Designware Multimedia Card Interface Driver
- [ 1.420000] dwmmc_exynos 12550000.mmc: no vmmc regulator found: -19
- [ 1.425000] dwmmc_exynos 12550000.mmc: Using internal DMA controller.
- [ 1.430000] dwmmc_exynos 12550000.mmc: Version ID is 240a
- [ 1.440000] dwmmc_exynos 12550000.mmc: DW MMC controller at irq 109, 32 bit host data width, 128 deep fifo
- [ 1.475000] dwmmc_exynos 12550000.mmc: 1 slots initialized
- [ 1.480000] usbcore: registered new interface driver usbhid
- [ 1.485000] usbhid: USB HID core driver
- [ 1.490000] TCP: cubic registered
- [ 1.495000] NET: Registered protocol family 17
- [ 1.495000] NET: Registered protocol family 15
- [ 1.500000] Registering SWP/SWPB emulation handler
- [ 1.510000] VMEM_VDD_2.8V: disabling
- [ 1.510000] regulator-dummy: disabling
- [ 1.515000] exynos-ehci 12580000.ehci: EHCI Host Controller
- [ 1.515000] mmc1: BKOPS_EN bit is not set
- [ 1.515000] mmc_host mmc1: Bus speed (slot 0) = 50000000Hz (slot req 52000000Hz, actual 50000000HZ div = 0)
- [ 1.520000] mmc_host mmc1: Bus speed (slot 0) = 100000000Hz (slot req 52000000Hz, actual 50000000HZ div = 1)
- [ 1.520000] mmc1: new high speed DDR MMC card at address 0001
- [ 1.520000] mmcblk0: mmc1:0001 AJTD4R 14.5 GiB
- [ 1.520000] mmcblk0boot0: mmc1:0001 AJTD4R partition 1 4.00 MiB
- [ 1.520000] mmcblk0boot1: mmc1:0001 AJTD4R partition 2 4.00 MiB
- [ 1.520000] mmcblk0rpmb: mmc1:0001 AJTD4R partition 3 4.00 MiB
- [ 1.520000] mmcblk0: p1 p2 p3 p4
- [ 1.525000] mmcblk0boot1: unknown partition table
- [ 1.525000] mmcblk0boot0: unknown partition table
- [ 1.585000] exynos-ehci 12580000.ehci: new USB bus registered, assigned bus number 1
- [ 1.590000] exynos-ehci 12580000.ehci: irq 102, io mem 0x12580000
- [ 1.605000] exynos-ehci 12580000.ehci: USB 2.0 started, EHCI 1.00
- [ 1.610000] hub 1-0:1.0: USB hub found
- [ 1.610000] hub 1-0:1.0: 3 ports detected
- [ 1.615000] drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
- [ 1.620000] clk: Not disabling unused clocks
- [ 1.625000] RAMDISK: gzip image found at block 0
- [ 1.675000] mmc0: new high speed SDHC card at address 59b4
- [ 1.680000] mmcblk1: mmc0:59b4 SDU1 7.50 GiB
- [ 1.685000] mmcblk1: unknown partition table
- [ 1.905000] VFS: Mounted root (ext2 filesystem) on device 1:0.
- [ 1.925000] usb 1-3: new high-speed USB device number 2 using exynos-ehci
- [ 2.060000] hub 1-3:1.0: USB hub found
- [ 2.060000] hub 1-3:1.0: 3 ports detected
- [root@yieq4412 ]#
复制代码 Linux 系统程序启动成功!
2. 开机自动从 TFTP 服务器加载并启动
重启开发板,进入到 U-Boot 引导程序,我们要设置 U-Boot 引导程序开机自动加载并启动 Linux 系统程序需要通过设置 bootcmd 环境变量来实现,bootcmd 环境变量的值可以是多条 U-Boot 命令,每条命令只需要用“;”隔开即可。
变量格式:- bootcmd=<U-Boot 命令1>;<U-Boot 命令2>;......
复制代码 2.1 配置
把上面的4条命令写入到 bootcmd 环境变量:- setenv bootcmd "tftp 41000000 linux;tftp 42000000 dt.dtb;tftp 43000000 ramdisk.img;bootm 41000000 43000000 42000000"
复制代码 设置完记得使用 saveenv 命令保存。
示例:- ex4412 # setenv bootcmd "tftp 41000000 linux;tftp 42000000 dt.dtb;tftp 43000000 ramdisk.img;bootm 41000000 43000000 42000000"
- ex4412 # saveenv
- Saving Environment to MMC...
- Writing to MMC(0)... .done
- ex4412 #
复制代码 我们把刚刚的4条命令设置成了 bootcmd 环境变量的值,下次开机时,U-Boot 引导程序会自动执行我们这4条命令而无需人工干预,实现了自动启动~
2.2 试验
重启开发板以试验:- U-Boot 2013.01 (Mar 29 2025 - 15:17:15) for ex4412
- CPU: Exynos4412@1000MHz
- Board: ORIGEN
- DRAM: 1 GiB
- WARNING: Caches not enabled
- PMIC: S5M8767(VER5.0)
- MMC: MMC0: 14910 MB
- In: serial
- Out: serial
- Err: serial
- MMC read: dev # 0, block # 48, count 16 ...16 blocks read: OK
- eMMC CLOSE Success.!!
- Checking Boot Mode ... EMMC4.41
- Net: dm9000
- Hit any key to stop autoboot: 0
- dm9000 i/o: 0x5000000, id: 0x90000a46
- DM9000: running in 16 bit mode
- MAC: 00:1a:2b:33:44:55
- operating at 100M full duplex mode
- Using dm9000 device
- TFTP from server 192.168.100.100; our IP address is 192.168.100.110
- Filename 'linux'.
- Load address: 0x41000000
- Loading: #################################################################
- #################################################################
- #################################################################
- ###########
- 1.1 MiB/s
- done
- Bytes transferred = 3019120 (2e1170 hex)
- dm9000 i/o: 0x5000000, id: 0x90000a46
- DM9000: running in 16 bit mode
- MAC: 00:1a:2b:33:44:55
- operating at 100M full duplex mode
- Using dm9000 device
- TFTP from server 192.168.100.100; our IP address is 192.168.100.110
- Filename 'dt.dtb'.
- Load address: 0x42000000
- Loading: ###
- 1.1 MiB/s
- done
- Bytes transferred = 34358 (8636 hex)
- dm9000 i/o: 0x5000000, id: 0x90000a46
- DM9000: running in 16 bit mode
- MAC: 00:1a:2b:33:44:55
- operating at 100M full duplex mode
- Using dm9000 device
- TFTP from server 192.168.100.100; our IP address is 192.168.100.110
- Filename 'ramdisk.img'.
- Load address: 0x43000000
- Loading: #################################################################
- #################################################################
- ############################################
- 1.1 MiB/s
- done
- Bytes transferred = 2544147 (26d213 hex)
- ## Booting kernel from Legacy Image at 41000000 ...
- Image Name: Linux-3.14.0
- Image Type: ARM Linux Kernel Image (uncompressed)
- Data Size: 3019056 Bytes = 2.9 MiB
- Load Address: 40008000
- Entry Point: 40008000
- Verifying Checksum ... OK
- ## Loading init Ramdisk from Legacy Image at 43000000 ...
- Image Name: ramdisk
- Image Type: ARM Linux RAMDisk Image (gzip compressed)
- Data Size: 2544083 Bytes = 2.4 MiB
- 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 Ramdisk to 4fd92000, end 4ffff1d3 ... OK
- Loading Device Tree to 4fd86000, end 4fd91635 ... OK
- Starting kernel ...
- [ 0.000000] Booting Linux on physical CPU 0xa00
- [ 0.000000] Linux version 3.14.0 (linux@linux) (gcc version 4.6.4 (crosstool-NG hg+default-2685dfa9de14 - tc0002) ) #5 SMP PREEMPT Thu Apr 17 22:17:51 EDT 2024
- [ 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: Insignal Origen evaluation board based on Exynos4412
- [ 0.000000] Memory policy: Data cache writealloc
- [ 0.000000] CPU EXYNOS4412 (id 0xe4412011)
- [ 0.000000] Running under secure firmware.
- [ 0.000000] PERCPU: Embedded 7 pages/cpu @eefb6000 s7424 r8192 d13056 u32768
- [ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 256528
- [ 0.000000] Kernel command line: console=ttySAC2,115200
- [ 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: 1014372K/1032192K available (3948K kernel code, 236K rwdata, 1316K rodata, 231K init, 276K bss, 17820K reserved, 270336K highmem)
- [ 0.000000] Virtual kernel memory layout:
- [ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB)
- [ 0.000000] fixmap : 0xfff00000 - 0xfffe0000 ( 896 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 - 0xc052c258 (5265 kB)
- [ 0.000000] .init : 0xc052d000 - 0xc0566d00 ( 232 kB)
- [ 0.000000] .data : 0xc0568000 - 0xc05a3340 ( 237 kB)
- [ 0.000000] .bss : 0xc05a334c - 0xc05e8384 ( 277 kB)
- [ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
- [ 0.000000] Preemptible hierarchical RCU implementation.
- [ 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] Exynos4x12 clocks: sclk_apll = 500000000, sclk_mpll = 800000000
- [ 0.000000] sclk_epll = 96000000, sclk_vpll = 350000000, arm_clk = 1000000000
- [ 0.000000] sched_clock: 32 bits at 200 Hz, resolution 5000000ns, wraps every 10737418240000000ns
- [ 0.000000] Console: colour dummy device 80x30
- [ 0.045000] Calibrating delay loop... 1992.29 BogoMIPS (lpj=4980736)
- [ 0.045000] pid_max: default: 32768 minimum: 301
- [ 0.045000] Mount-cache hash table entries: 2048 (order: 1, 8192 bytes)
- [ 0.045000] Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes)
- [ 0.050000] CPU: Testing write buffer coherency: ok
- [ 0.050000] missing device node for CPU 0
- [ 0.050000] missing device node for CPU 1
- [ 0.050000] missing device node for CPU 2
- [ 0.050000] missing device node for CPU 3
- [ 0.050000] CPU0: thread -1, cpu 0, socket 10, mpidr 80000a00
- [ 0.050000] Setting up static identity map for 0x403be650 - 0x403be6a8
- [ 0.070000] CPU1: Booted secondary processor
- [ 0.090000] CPU1: thread -1, cpu 1, socket 10, mpidr 80000a01
- [ 0.100000] CPU2: Booted secondary processor
- [ 0.120000] CPU2: thread -1, cpu 2, socket 10, mpidr 80000a02
- [ 0.130000] CPU3: Booted secondary processor
- [ 0.150000] CPU3: thread -1, cpu 3, socket 10, mpidr 80000a03
- [ 0.150000] Brought up 4 CPUs
- [ 0.150000] SMP: Total of 4 processors activated.
- [ 0.150000] CPU: All CPU(s) started in SVC mode.
- [ 0.150000] devtmpfs: initialized
- [ 0.150000] VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4
- [ 0.155000] pinctrl core: initialized pinctrl subsystem
- [ 0.155000] regulator-dummy: no parameters
- [ 0.155000] NET: Registered protocol family 16
- [ 0.155000] DMA: preallocated 256 KiB pool for atomic coherent allocations
- [ 0.175000] S3C Power Management, Copyright 2004 Simtec Electronics
- [ 0.175000] EXYNOS4x12 PMU Initialize
- [ 0.175000] EXYNOS: Initializing architecture
- [ 0.210000] bio: create slab <bio-0> at 0
- [ 0.210000] VMEM_VDD_2.8V: 2800 mV
- [ 0.215000] SCSI subsystem initialized
- [ 0.215000] usbcore: registered new interface driver usbfs
- [ 0.215000] usbcore: registered new interface driver hub
- [ 0.215000] usbcore: registered new device driver usb
- [ 0.220000] s3c-i2c 13860000.i2c: slave address 0x00
- [ 0.220000] s3c-i2c 13860000.i2c: bus frequency set to 19 KHz
- [ 0.220000] sec_pmic 0-0066: No interrupt specified, no interrupts
- [ 0.245000] VDD_ALIVE: failed to apply 1100000uV constraint
- [ 0.245000] s5m8767-pmic s5m8767-pmic: regulator init failed for 0
- [ 0.245000] s3c-i2c 13860000.i2c: i2c-0: S3C I2C adapter
- [ 0.245000] Switched to clocksource mct-frc
- [ 0.275000] NET: Registered protocol family 2
- [ 0.275000] TCP established hash table entries: 8192 (order: 3, 32768 bytes)
- [ 0.275000] TCP bind hash table entries: 8192 (order: 5, 163840 bytes)
- [ 0.275000] TCP: Hash tables configured (established 8192 bind 8192)
- [ 0.275000] TCP: reno registered
- [ 0.275000] UDP hash table entries: 512 (order: 2, 24576 bytes)
- [ 0.275000] UDP-Lite hash table entries: 512 (order: 2, 24576 bytes)
- [ 0.275000] NET: Registered protocol family 1
- [ 0.275000] RPC: Registered named UNIX socket transport module.
- [ 0.275000] RPC: Registered udp transport module.
- [ 0.275000] RPC: Registered tcp transport module.
- [ 0.275000] RPC: Registered tcp NFSv4.1 backchannel transport module.
- [ 0.275000] Trying to unpack rootfs image as initramfs...
- [ 0.280000] rootfs image is not initramfs (no cpio magic); looks like an initrd
- [ 0.290000] Freeing initrd memory: 2484K (cfd92000 - cffff000)
- [ 0.295000] futex hash table entries: 1024 (order: 4, 65536 bytes)
- [ 0.295000] bounce pool size: 64 pages
- [ 0.320000] ROMFS MTD (C) 2007 Red Hat, Inc.
- [ 0.320000] msgmni has been set to 1458
- [ 0.320000] io scheduler noop registered
- [ 0.320000] io scheduler deadline registered
- [ 0.320000] io scheduler cfq registered (default)
- [ 0.335000] dma-pl330 12680000.pdma: Loaded driver for PL330 DMAC-1315632
- [ 0.335000] dma-pl330 12680000.pdma: DBUFF-32x4bytes Num_Chans-8 Num_Peri-32 Num_Events-32
- [ 0.345000] dma-pl330 12690000.pdma: Loaded driver for PL330 DMAC-1315632
- [ 0.345000] dma-pl330 12690000.pdma: DBUFF-32x4bytes Num_Chans-8 Num_Peri-32 Num_Events-32
- [ 0.350000] dma-pl330 12850000.mdma: Loaded driver for PL330 DMAC-1315632
- [ 0.350000] dma-pl330 12850000.mdma: DBUFF-64x8bytes Num_Chans-8 Num_Peri-1 Num_Events-32
- [ 0.565000] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
- [ 0.565000] 13800000.serial: ttySAC0 at MMIO 0x13800000 (irq = 84, base_baud = 0) is a S3C6400/10
- [ 0.565000] 13810000.serial: ttySAC1 at MMIO 0x13810000 (irq = 85, base_baud = 0) is a S3C6400/10
- [ 0.565000] 13820000.serial: ttySAC2 at MMIO 0x13820000 (irq = 86, base_baud = 0) is a S3C6400/10
- [ 1.195000] console [ttySAC2] enabled
- [ 1.195000] 13830000.serial: ttySAC3 at MMIO 0x13830000 (irq = 87, base_baud = 0) is a S3C6400/10
- [ 1.220000] brd: module loaded
- [ 1.230000] loop: module loaded
- [ 1.235000] dm9000 5000000.ethernet: read wrong id 0x01010101
- [ 1.240000] eth0: dm9000a at f0076000,f0078004 IRQ 167 MAC: 00:0a:2d:a6:55:a2 (platform data)
- [ 1.250000] usbcore: registered new interface driver asix
- [ 1.255000] usbcore: registered new interface driver ax88179_178a
- [ 1.260000] usbcore: registered new interface driver cdc_ether
- [ 1.265000] usbcore: registered new interface driver smsc75xx
- [ 1.270000] usbcore: registered new interface driver smsc95xx
- [ 1.275000] usbcore: registered new interface driver net1080
- [ 1.280000] usbcore: registered new interface driver cdc_subset
- [ 1.290000] usbcore: registered new interface driver zaurus
- [ 1.295000] usbcore: registered new interface driver cdc_ncm
- [ 1.300000] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
- [ 1.305000] ehci-exynos: EHCI EXYNOS driver
- [ 1.310000] exynos-ehci 12580000.ehci: no platform data or transceiver defined
- [ 1.315000] platform 12580000.ehci: Driver exynos-ehci requests probe deferral
- [ 1.325000] usbcore: registered new interface driver usb-storage
- [ 1.340000] usb3503 8.usb3503: switched to HUB mode
- [ 1.345000] usb3503 8.usb3503: usb3503_probe: probed in hub mode
- [ 1.350000] mousedev: PS/2 mouse device common for all mice
- [ 1.360000] input: 100a0000.keypad as /devices/100a0000.keypad/input/input0
- [ 1.365000] device-mapper: ioctl: 4.27.0-ioctl (2013-10-30) initialised: dm-devel@redhat.com
- [ 1.375000] sdhci: Secure Digital Host Controller Interface driver
- [ 1.380000] sdhci: Copyright(c) Pierre Ossman
- [ 1.385000] s3c-sdhci 12530000.sdhci: clock source 2: mmc_busclk.2 (5000000 Hz)
- [ 1.390000] mmc0: no vqmmc regulator found
- [ 1.395000] mmc0: no vmmc regulator found
- [ 1.430000] mmc0: SDHCI controller on samsung-hsmmc [12530000.sdhci] using ADMA
- [ 1.435000] Synopsys Designware Multimedia Card Interface Driver
- [ 1.440000] dwmmc_exynos 12550000.mmc: no vmmc regulator found: -19
- [ 1.445000] dwmmc_exynos 12550000.mmc: Using internal DMA controller.
- [ 1.450000] dwmmc_exynos 12550000.mmc: Version ID is 240a
- [ 1.460000] dwmmc_exynos 12550000.mmc: DW MMC controller at irq 109, 32 bit host data width, 128 deep fifo
- [ 1.500000] dwmmc_exynos 12550000.mmc: 1 slots initialized
- [ 1.505000] usbcore: registered new interface driver usbhid
- [ 1.510000] usbhid: USB HID core driver
- [ 1.515000] TCP: cubic registered
- [ 1.515000] NET: Registered protocol family 17
- [ 1.520000] NET: Registered protocol family 15
- [ 1.525000] Registering SWP/SWPB emulation handler
- [ 1.530000] VMEM_VDD_2.8V: disabling
- [ 1.535000] regulator-dummy: disabling
- [ 1.540000] exynos-ehci 12580000.ehci: EHCI Host Controller
- [ 1.545000] exynos-ehci 12580000.ehci: new USB bus registered, assigned bus number 1
- [ 1.545000] mmc1: BKOPS_EN bit is not set
- [ 1.545000] mmc_host mmc1: Bus speed (slot 0) = 50000000Hz (slot req 52000000Hz, actual 50000000HZ div = 0)
- [ 1.550000] mmc_host mmc1: Bus speed (slot 0) = 100000000Hz (slot req 52000000Hz, actual 50000000HZ div = 1)
- [ 1.550000] mmc1: new high speed DDR MMC card at address 0001
- [ 1.580000] exynos-ehci 12580000.ehci: irq 102, io mem 0x12580000
- [ 1.585000] mmcblk0: mmc1:0001 AJTD4R 14.5 GiB
- [ 1.590000] mmcblk0boot0: mmc1:0001 AJTD4R partition 1 4.00 MiB
- [ 1.595000] exynos-ehci 12580000.ehci: USB 2.0 started, EHCI 1.00
- [ 1.605000] mmcblk0boot1: mmc1:0001 AJTD4R partition 2 4.00 MiB
- [ 1.605000] hub 1-0:1.0: USB hub found
- [ 1.605000] hub 1-0:1.0: 3 ports detected
- [ 1.615000] mmcblk0rpmb: mmc1:0001 AJTD4R partition 3 4.00 MiB
- [ 1.615000] drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
- [ 1.615000] clk: Not disabling unused clocks
- [ 1.635000] mmcblk0: p1 p2 p3 p4
- [ 1.640000] mmcblk0boot1: unknown partition table
- [ 1.645000] mmcblk0boot0: unknown partition table
- [ 1.650000] RAMDISK: gzip image found at block 0
- [ 1.710000] mmc0: new high speed SDHC card at address 59b4
- [ 1.715000] mmcblk1: mmc0:59b4 SDU1 7.50 GiB
- [ 1.720000] mmcblk1: unknown partition table
- [ 1.915000] usb 1-3: new high-speed USB device number 2 using exynos-ehci
- [ 1.915000] VFS: Mounted root (ext2 filesystem) on device 1:0.
- [ 2.055000] hub 1-3:1.0: USB hub found
- [ 2.055000] hub 1-3:1.0: 3 ports detected
- [root@yieq4412 ]# ls
- bin etc linuxrc mnt root sys usr
- dev lib lost+found proc sbin tmp var
- [root@yieq4412 ]#
复制代码 成功~
伍、从eMMC启动 Linux 系统程序
U-Boot 引导程序的MMC(Multi Media Card)读写命令格式:- mmc <读写> <设备号> <内存地址> <从哪个扇区开始读写> <读写的长度>
复制代码 其中,可以是写(write)/读(read)。
我们要想从EMMC启动 Linux 系统程序,就得先把 Linux 系统程序写入到eMMC中,这跟我们前面制作SD卡启动盘一样的。
1. 把程序加载到内存中
程序不在SD卡上,也不在开发板上,在我们之前启动的 TFTP 服务器上,故第一步,我们需要把程序从 TFTP 服务器上加载到内存中,方便我们下一步操作。
命令:- tftp 41000000 linux
- tftp 42000000 dt.dtb
- tftp 43000000 ramdisk.img
复制代码 执行结果:- ex4412 # tftp 41000000 linuxdm9000 i/o: 0x5000000, id: 0x90000a46 DM9000: running in 16 bit modeMAC: 00:1a:2b:33:44:55operating at 100M full duplex modeUsing dm9000 deviceTFTP from server 192.168.100.100; our IP address is 192.168.100.110Filename 'linux'.Load address: 0x41000000Loading: ################################################################# ################################################################# ################################################################# ########### 1.1 MiB/sdoneBytes transferred = 3019120 (2e1170 hex)ex4412 # tftp 42000000 dt.dtbdm9000 i/o: 0x5000000, id: 0x90000a46 DM9000: running in 16 bit modeMAC: 00:1a:2b:33:44:55operating at 100M full duplex modeUsing dm9000 deviceTFTP from server 192.168.100.100; our IP address is 192.168.100.110Filename 'dt.dtb'.Load address: 0x42000000Loading: ### 1.1 MiB/sdoneBytes transferred = 34358 (8636 hex)ex4412 # tftp 43000000 ramdisk.img
- dm9000 i/o: 0x5000000, id: 0x90000a46
- DM9000: running in 16 bit mode
- MAC: 00:1a:2b:33:44:55
- operating at 100M full duplex mode
- Using dm9000 device
- TFTP from server 192.168.100.100; our IP address is 192.168.100.110
- Filename 'ramdisk.img'.
- Load address: 0x43000000
- Loading: #################################################################
- #################################################################
- ############################################
- 1.1 MiB/s
- done
- Bytes transferred = 2544147 (26d213 hex)
- ex4412 #
复制代码 这样我们成功把 Linux 系统程序、DTB 设备树文件和 RootFS 根文件系统分别存到了内存中的 0x41000000、0x42000000 和 0x43000000 位置上。
2. 把程序写入eMMC中
接着,我们需要使用 mmc 命令把内存中的程序数据写入到 eMMc 中,这里我们要根据我们程序文件的大小简单地做个计算,确保它们在 eMMC 中不会被覆盖掉。
在准备相关程序的时候我们就能看到:dt.dtb为34KB、linux为2949KB、ramdisk.img为2485KB,换算到块大小为512字节的块中,那么 dt.dtb 占用 68(0x44) 个块,linux 占用 5898(0x170A) 个块,ramdisk.img 占用 4970(0x136A) 个块,为了方便指令的编写和冗余,我们可以这么设计 eMMC 的空间布局:
命令:- mmc write 0 0x42000000 0x500 0x100
- mmc write 0 0x41000000 0x600 0x2000
- mmc write 0 0x43000000 0x2600 0x2000
复制代码 执行结果:- ex4412 # mmc write 0 0x42000000 0x500 0x100
- MMC write: dev # 0, block # 1280, count 256. 256 blocks write finish
- 256 blocks verify1: OK
- ex4412 # mmc write 0 0x41000000 0x600 0x2000
- MMC write: dev # 0, block # 1536, count 8192. 8192 blocks write finish
- 8192 blocks written: OK
- ex4412 # mmc write 0 0x43000000 0x2600 0x2000
- MMC write: dev # 0, block # 9728, count 8192. 8192 blocks write finish
- 8192 blocks written: OK
- ex4412 #
复制代码 3. 设置开机自动从 eMMC 读取程序并启动
现在,程序已经写入到 eMMC 了,那么开机后应该是从 eMMC 读取程序,而不是通过 TFTP 服务器读取程序了。
从 eMMC 读取数据到内存的命令很简单,就我们上一步写入的命令,把“write”改为“read”就好了。
命令:- mmc read 0 0x42000000 0x500 0x100
- mmc read 0 0x41000000 0x600 0x2000
- mmc read 0 0x43000000 0x2600 0x2000
复制代码 这三条命令执行完后,内存中的空间布局跟我们使用 TFTP 服务器加载程序到内存中的空间布局是一样的,因此启动 Linux 系统程序的命令仍然是:- bootm 41000000 43000000 42000000
复制代码 我们希望开机自动完成上面的事情,故设置 bootcmd 环境变量,设置的命令为:- setenv bootcmd "mmc read 0 0x42000000 0x500 0x100;mmc read 0 0x41000000 0x600 0x2000;mmc read 0 0x43000000 0x2600 0x2000;bootm 41000000 43000000 42000000"
复制代码 设置完别忘记使用 saveenv 命令保存。
运行结果:- ex4412 # setenv bootcmd "mmc read 0 0x42000000 0x500 0x100;mmc read 0 0x41000000 0x600 0x2000;mmc read 0 0x43000000 0x2600 0x2000;bootm 41000000 43000000 42000000"
- ex4412 # saveenv
- Saving Environment to MMC...
- Writing to MMC(0)... .done
- ex4412 #
复制代码 4. 试验
重启开发板以试验:- U-Boot 2013.01 (Mar 29 2025 - 15:17:15) for ex4412
- CPU: Exynos4412@1000MHz
- Board: ORIGEN
- DRAM: 1 GiB
- WARNING: Caches not enabled
- PMIC: S5M8767(VER5.0)
- MMC: MMC0: 14910 MB
- In: serial
- Out: serial
- Err: serial
- MMC read: dev # 0, block # 48, count 16 ...16 blocks read: OK
- eMMC CLOSE Success.!!
- Checking Boot Mode ... EMMC4.41
- Net: dm9000
- Hit any key to stop autoboot: 0
- MMC read: dev # 0, block # 1280, count 256 ...256 blocks read: OK
- MMC read: dev # 0, block # 1536, count 8192 ...8192 blocks read: OK
- MMC read: dev # 0, block # 9728, count 8192 ...8192 blocks read: OK
- ## Booting kernel from Legacy Image at 41000000 ...
- Image Name: Linux-3.14.0
- Image Type: ARM Linux Kernel Image (uncompressed)
- Data Size: 3019056 Bytes = 2.9 MiB
- Load Address: 40008000
- Entry Point: 40008000
- Verifying Checksum ... OK
- ## Loading init Ramdisk from Legacy Image at 43000000 ...
- Image Name: ramdisk
- Image Type: ARM Linux RAMDisk Image (gzip compressed)
- Data Size: 2544083 Bytes = 2.4 MiB
- 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 Ramdisk to 4fd92000, end 4ffff1d3 ... OK
- Loading Device Tree to 4fd86000, end 4fd91635 ... OK
- Starting kernel ...
- [ 0.000000] Booting Linux on physical CPU 0xa00
- [ 0.000000] Linux version 3.14.0 (linux@linux) (gcc version 4.6.4 (crosstool-NG hg+default-2685dfa9de14 - tc0002) ) #5 SMP PREEMPT Thu Apr 17 22:17:51 EDT 2024
- [ 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: Insignal Origen evaluation board based on Exynos4412
- [ 0.000000] Memory policy: Data cache writealloc
- [ 0.000000] CPU EXYNOS4412 (id 0xe4412011)
- [ 0.000000] Running under secure firmware.
- [ 0.000000] PERCPU: Embedded 7 pages/cpu @eefb6000 s7424 r8192 d13056 u32768
- [ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 256528
- [ 0.000000] Kernel command line: console=ttySAC2,115200
- [ 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: 1014372K/1032192K available (3948K kernel code, 236K rwdata, 1316K rodata, 231K init, 276K bss, 17820K reserved, 270336K highmem)
- [ 0.000000] Virtual kernel memory layout:
- [ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB)
- [ 0.000000] fixmap : 0xfff00000 - 0xfffe0000 ( 896 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 - 0xc052c258 (5265 kB)
- [ 0.000000] .init : 0xc052d000 - 0xc0566d00 ( 232 kB)
- [ 0.000000] .data : 0xc0568000 - 0xc05a3340 ( 237 kB)
- [ 0.000000] .bss : 0xc05a334c - 0xc05e8384 ( 277 kB)
- [ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
- [ 0.000000] Preemptible hierarchical RCU implementation.
- [ 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] Exynos4x12 clocks: sclk_apll = 500000000, sclk_mpll = 800000000
- [ 0.000000] sclk_epll = 96000000, sclk_vpll = 350000000, arm_clk = 1000000000
- [ 0.000000] sched_clock: 32 bits at 200 Hz, resolution 5000000ns, wraps every 10737418240000000ns
- [ 0.000000] Console: colour dummy device 80x30
- [ 0.045000] Calibrating delay loop... 1992.29 BogoMIPS (lpj=4980736)
- [ 0.045000] pid_max: default: 32768 minimum: 301
- [ 0.045000] Mount-cache hash table entries: 2048 (order: 1, 8192 bytes)
- [ 0.045000] Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes)
- [ 0.050000] CPU: Testing write buffer coherency: ok
- [ 0.050000] missing device node for CPU 0
- [ 0.050000] missing device node for CPU 1
- [ 0.050000] missing device node for CPU 2
- [ 0.050000] missing device node for CPU 3
- [ 0.050000] CPU0: thread -1, cpu 0, socket 10, mpidr 80000a00
- [ 0.050000] Setting up static identity map for 0x403be650 - 0x403be6a8
- [ 0.070000] CPU1: Booted secondary processor
- [ 0.090000] CPU1: thread -1, cpu 1, socket 10, mpidr 80000a01
- [ 0.100000] CPU2: Booted secondary processor
- [ 0.120000] CPU2: thread -1, cpu 2, socket 10, mpidr 80000a02
- [ 0.130000] CPU3: Booted secondary processor
- [ 0.150000] CPU3: thread -1, cpu 3, socket 10, mpidr 80000a03
- [ 0.150000] Brought up 4 CPUs
- [ 0.150000] SMP: Total of 4 processors activated.
- [ 0.150000] CPU: All CPU(s) started in SVC mode.
- [ 0.150000] devtmpfs: initialized
- [ 0.150000] VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4
- [ 0.155000] pinctrl core: initialized pinctrl subsystem
- [ 0.155000] regulator-dummy: no parameters
- [ 0.155000] NET: Registered protocol family 16
- [ 0.155000] DMA: preallocated 256 KiB pool for atomic coherent allocations
- [ 0.175000] S3C Power Management, Copyright 2004 Simtec Electronics
- [ 0.175000] EXYNOS4x12 PMU Initialize
- [ 0.175000] EXYNOS: Initializing architecture
- [ 0.210000] bio: create slab <bio-0> at 0
- [ 0.210000] VMEM_VDD_2.8V: 2800 mV
- [ 0.215000] SCSI subsystem initialized
- [ 0.215000] usbcore: registered new interface driver usbfs
- [ 0.215000] usbcore: registered new interface driver hub
- [ 0.215000] usbcore: registered new device driver usb
- [ 0.215000] s3c-i2c 13860000.i2c: slave address 0x00
- [ 0.215000] s3c-i2c 13860000.i2c: bus frequency set to 19 KHz
- [ 0.215000] sec_pmic 0-0066: No interrupt specified, no interrupts
- [ 0.245000] VDD_ALIVE: failed to apply 1100000uV constraint
- [ 0.245000] s5m8767-pmic s5m8767-pmic: regulator init failed for 0
- [ 0.245000] s3c-i2c 13860000.i2c: i2c-0: S3C I2C adapter
- [ 0.245000] Switched to clocksource mct-frc
- [ 0.275000] NET: Registered protocol family 2
- [ 0.275000] TCP established hash table entries: 8192 (order: 3, 32768 bytes)
- [ 0.275000] TCP bind hash table entries: 8192 (order: 5, 163840 bytes)
- [ 0.280000] TCP: Hash tables configured (established 8192 bind 8192)
- [ 0.280000] TCP: reno registered
- [ 0.280000] UDP hash table entries: 512 (order: 2, 24576 bytes)
- [ 0.280000] UDP-Lite hash table entries: 512 (order: 2, 24576 bytes)
- [ 0.280000] NET: Registered protocol family 1
- [ 0.280000] RPC: Registered named UNIX socket transport module.
- [ 0.280000] RPC: Registered udp transport module.
- [ 0.280000] RPC: Registered tcp transport module.
- [ 0.280000] RPC: Registered tcp NFSv4.1 backchannel transport module.
- [ 0.280000] Trying to unpack rootfs image as initramfs...
- [ 0.280000] rootfs image is not initramfs (no cpio magic); looks like an initrd
- [ 0.290000] Freeing initrd memory: 2484K (cfd92000 - cffff000)
- [ 0.295000] futex hash table entries: 1024 (order: 4, 65536 bytes)
- [ 0.295000] bounce pool size: 64 pages
- [ 0.320000] ROMFS MTD (C) 2007 Red Hat, Inc.
- [ 0.320000] msgmni has been set to 1458
- [ 0.320000] io scheduler noop registered
- [ 0.320000] io scheduler deadline registered
- [ 0.325000] io scheduler cfq registered (default)
- [ 0.340000] dma-pl330 12680000.pdma: Loaded driver for PL330 DMAC-1315632
- [ 0.340000] dma-pl330 12680000.pdma: DBUFF-32x4bytes Num_Chans-8 Num_Peri-32 Num_Events-32
- [ 0.350000] dma-pl330 12690000.pdma: Loaded driver for PL330 DMAC-1315632
- [ 0.350000] dma-pl330 12690000.pdma: DBUFF-32x4bytes Num_Chans-8 Num_Peri-32 Num_Events-32
- [ 0.350000] dma-pl330 12850000.mdma: Loaded driver for PL330 DMAC-1315632
- [ 0.350000] dma-pl330 12850000.mdma: DBUFF-64x8bytes Num_Chans-8 Num_Peri-1 Num_Events-32
- [ 0.555000] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
- [ 0.560000] 13800000.serial: ttySAC0 at MMIO 0x13800000 (irq = 84, base_baud = 0) is a S3C6400/10
- [ 0.560000] 13810000.serial: ttySAC1 at MMIO 0x13810000 (irq = 85, base_baud = 0) is a S3C6400/10
- [ 0.560000] 13820000.serial: ttySAC2 at MMIO 0x13820000 (irq = 86, base_baud = 0) is a S3C6400/10
- [ 1.185000] console [ttySAC2] enabled
- [ 1.190000] 13830000.serial: ttySAC3 at MMIO 0x13830000 (irq = 87, base_baud = 0) is a S3C6400/10
- [ 1.215000] brd: module loaded
- [ 1.225000] loop: module loaded
- [ 1.230000] dm9000 5000000.ethernet: read wrong id 0x01010101
- [ 1.235000] eth0: dm9000a at f0076000,f0078004 IRQ 167 MAC: 00:0a:2d:a6:55:a2 (platform data)
- [ 1.240000] usbcore: registered new interface driver asix
- [ 1.245000] usbcore: registered new interface driver ax88179_178a
- [ 1.255000] usbcore: registered new interface driver cdc_ether
- [ 1.260000] usbcore: registered new interface driver smsc75xx
- [ 1.265000] usbcore: registered new interface driver smsc95xx
- [ 1.270000] usbcore: registered new interface driver net1080
- [ 1.275000] usbcore: registered new interface driver cdc_subset
- [ 1.280000] usbcore: registered new interface driver zaurus
- [ 1.285000] usbcore: registered new interface driver cdc_ncm
- [ 1.295000] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
- [ 1.300000] ehci-exynos: EHCI EXYNOS driver
- [ 1.305000] exynos-ehci 12580000.ehci: no platform data or transceiver defined
- [ 1.310000] platform 12580000.ehci: Driver exynos-ehci requests probe deferral
- [ 1.320000] usbcore: registered new interface driver usb-storage
- [ 1.335000] usb3503 8.usb3503: switched to HUB mode
- [ 1.340000] usb3503 8.usb3503: usb3503_probe: probed in hub mode
- [ 1.345000] mousedev: PS/2 mouse device common for all mice
- [ 1.350000] input: 100a0000.keypad as /devices/100a0000.keypad/input/input0
- [ 1.360000] device-mapper: ioctl: 4.27.0-ioctl (2013-10-30) initialised: dm-devel@redhat.com
- [ 1.365000] sdhci: Secure Digital Host Controller Interface driver
- [ 1.375000] sdhci: Copyright(c) Pierre Ossman
- [ 1.375000] s3c-sdhci 12530000.sdhci: clock source 2: mmc_busclk.2 (5000000 Hz)
- [ 1.385000] mmc0: no vqmmc regulator found
- [ 1.390000] mmc0: no vmmc regulator found
- [ 1.425000] mmc0: SDHCI controller on samsung-hsmmc [12530000.sdhci] using ADMA
- [ 1.430000] Synopsys Designware Multimedia Card Interface Driver
- [ 1.435000] dwmmc_exynos 12550000.mmc: no vmmc regulator found: -19
- [ 1.440000] dwmmc_exynos 12550000.mmc: Using internal DMA controller.
- [ 1.445000] dwmmc_exynos 12550000.mmc: Version ID is 240a
- [ 1.455000] dwmmc_exynos 12550000.mmc: DW MMC controller at irq 109, 32 bit host data width, 128 deep fifo
- [ 1.495000] dwmmc_exynos 12550000.mmc: 1 slots initialized
- [ 1.500000] usbcore: registered new interface driver usbhid
- [ 1.505000] usbhid: USB HID core driver
- [ 1.510000] TCP: cubic registered
- [ 1.510000] NET: Registered protocol family 17
- [ 1.515000] NET: Registered protocol family 15
- [ 1.520000] Registering SWP/SWPB emulation handler
- [ 1.525000] VMEM_VDD_2.8V: disabling
- [ 1.530000] regulator-dummy: disabling
- [ 1.535000] exynos-ehci 12580000.ehci: EHCI Host Controller
- [ 1.540000] exynos-ehci 12580000.ehci: new USB bus registered, assigned bus number 1
- [ 1.545000] exynos-ehci 12580000.ehci: irq 102, io mem 0x12580000
- [ 1.560000] mmc1: BKOPS_EN bit is not set
- [ 1.565000] exynos-ehci 12580000.ehci: USB 2.0 started, EHCI 1.00
- [ 1.570000] hub 1-0:1.0: USB hub found
- [ 1.570000] mmc_host mmc1: Bus speed (slot 0) = 50000000Hz (slot req 52000000Hz, actual 50000000HZ div = 0)
- [ 1.570000] mmc_host mmc1: Bus speed (slot 0) = 100000000Hz (slot req 52000000Hz, actual 50000000HZ div = 1)
- [ 1.570000] mmc1: new high speed DDR MMC card at address 0001
- [ 1.600000] hub 1-0:1.0: 3 ports detected
- [ 1.600000] mmcblk0: mmc1:0001 AJTD4R 14.5 GiB
- [ 1.600000] mmcblk0boot0: mmc1:0001 AJTD4R partition 1 4.00 MiB
- [ 1.600000] mmcblk0boot1: mmc1:0001 AJTD4R partition 2 4.00 MiB
- [ 1.600000] mmcblk0rpmb: mmc1:0001 AJTD4R partition 3 4.00 MiB
- [ 1.625000] mmcblk0: p1 p2 p3 p4
- [ 1.630000] drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
- [ 1.635000] clk: Not disabling unused clocks
- [ 1.635000] mmcblk0boot1: unknown partition table
- [ 1.635000] mmcblk0boot0: unknown partition table
- [ 1.650000] RAMDISK: gzip image found at block 0
- [ 1.700000] mmc0: new high speed SDHC card at address 59b4
- [ 1.705000] mmcblk1: mmc0:59b4 SDU1 7.50 GiB
- [ 1.710000] mmcblk1: unknown partition table
- [ 1.915000] VFS: Mounted root (ext2 filesystem) on device 1:0.
- [ 1.935000] usb 1-3: new high-speed USB device number 2 using exynos-ehci
- [ 2.070000] hub 1-3:1.0: USB hub found
- [ 2.070000] hub 1-3:1.0: 3 ports detected
- [root@yieq4412 ]# ls
- bin etc linuxrc mnt root sys usr
- dev lib lost+found proc sbin tmp var
- [root@yieq4412 ]#
复制代码 成功~
陆、使用 TFTP 加载 Linux 系统程序 但 使用 NFS 挂载 RootFS 根文件系统
这是什么奇怪的需求?!但是仔细一想,很有道理,Linux 系统程序和DTB 设备树文件在系统启动后不方便变动,而 RootFS 根文件系统是需要变动的而且最好还能像我们电脑上的 Linux 一样,能在里面存东西,而不是每次上电后都是会被还原的,因此若是能够直接把电脑上的某个 NFS 共享目录作为 RootFS 根文件系统岂不妙哉!同时,也省去了传输文件的这一步。
1. 准备
1.1 解压 ramdisk.img
1.1.1 权限准备
若你使用的是 Windows 系统(需要专业版或企业版),我们在解压之前需要授予当前用户创建符号链接的权限,因为 RootFS 根文件系统中为了方便集成和节省空间,很多命令都是以符号链接的形式存在的。另外为了方便后续对 RootFS 根文件系统中内容的修改,我们也需要这个权限。如若你登录的是“Administrator”账号,可以略去这一步,“Administrator”账号默认是有这个权限的。
按“Windows + R”键,在弹出的运行窗口中输入 secpol.msc 后回车以打开“本地安全策略”,在“本地安全策略”窗口中依次找到“安全设置”->“本地策略”->“用户权限分配”->“创建符号链接”,双击“创建符号链接”条目,会打开一个“创建符号链接 属性”窗口,在窗口中选择“添加用户或组”,在弹出的“选择用户或组”的窗口中点击“高级”按钮,在弹出的“选择用户或组(高级)”窗口中,点击“立即查找”按钮,在下方“搜索结果”列表中找到当前用户,选择后依次点“确定”按钮来保存设置。
设置完成后需要重启电脑(或注销重新登录当前用户)后才能生效。
1.1.2 解压 ramdisk.img 文件
RootFS 根文件系统 ramdisk.img 本质是一个压缩包,我们把 RootFS 根文件系统 ramdisk.img 使用7z解压出来,得到这样的一个目录:
1.2 配置 NFS 服务器
把这个目录设置为共享目录,下面是 NFS 服务器 haneWIN 的配置条目(haneWIN 首选项保持默认):- "D:\board\ramdisk\ramdisk~" -name:rootnfs -exec -mapall:0:0 -umask:0000
复制代码 其中:
- "D:\board\ramdisk\ramdisk~" 为共享目录,这里我设置的是解压 ramdisk.img 文件得到的目录,目录要是有空格需要用半角双引号引起;
- -name:rootnfs 是设置共享名称为“rootnfs”;
- -exec 是强制为所有文件设置可执行权限位;
- -mapall:0:0 是将所有 Unix 用户 ID 和组 ID 映射到 0 和 0;
- -umask:0000 是设置文件系统上组和其他用户权限的 umask,这里设置为 0000 即创建的文件默认是 666 权限。
后面的三个参数主要是方便开发板和电脑交互,避免在交互时遇到权限问题。
在 Linux 系统上显示共享目录:- yu@Yubuntu:~$ showmount -e 192.168.146.1
- Export list for 192.168.146.1:
- /rootnfs -public
- yu@Yubuntu:~$
复制代码 2. 配置 U-Boot 引导程序
我们要能正常启动 Linux 系统程序,一共需要加载三个程序/数据包,分别是 Linux 系统程序、DTB 设备树文件 和 RootFS 根文件系统,在本节中,Linux 系统程序和 DTB 设备树文件还是跟以前一样,是通过 TFTP 加载的,而 RootFS 根文件系统在本节中需要通过 NFS 服务器加载。
稍加思考,我们发现,Linux 系统程序和 DTB 设备树文件是在 U-Boot 引导程序中由 U-Boot 引导程序从 TFTP 服务器上加载到内存中的,但是 NFS 服务器算是一种文件系统,那么文件系统应该由使用它的操作系统来管理,故 U-Boot 引导程序无法提前挂载好 NFS 服务器,NFS 服务器应该是由 Linux 系统程序来挂载的。
确实,我们在 U-Boot 引导程序中把 Linux 系统程序和 DTB 设备树文件加载到内存里并启动 Linux 系统程序,而 NFS 服务器相关的信息是由 U-Boot 引导程序通过参数的方式传递给 Linux 系统程序的,这样 Linux 系统程序在启动时就可以根据接受到的参数直接挂载 NFS 服务器,以达到启动完成就可用。
2.1 配置 TFTP 加载项
跟前面的一样,从 TFTP 服务器加载 Linux 系统程序和 DTB 设备树文件的命令如下:- tftp 41000000 linux
- tftp 42000000 dt.dtb
复制代码 没有 RootFS 根文件系统的启动命令如下:- bootm 41000000 - 42000000
复制代码 注意,bootm 命令的格式要求按顺序提供 Linux 系统程序在内存中的位置、RootFS 根文件系统在内存中的位置和 DTB 设备树文件在内存中的位置,但是我们这次没有 RootFS 根文件系统在内存中的位置,根据命令格式要求,没有的不能跳过,必须使用-作为占位符。
我们希望开发板开机后自动加载并启动,因此需要设置 bootcmd 环境变量:- setenv bootcmd "tftp 41000000 linux;tftp 42000000 dt.dtb;bootm 41000000 - 42000000"
复制代码 设置后注意使用 saveenv 命令保存设置。
运行结果:- ex4412 # setenv bootcmd "tftp 41000000 linux;tftp 42000000 dt.dtb;bootm 41000000 - 42000000"
- ex4412 # saveenv
- Saving Environment to MMC...
- Writing to MMC(0)... .done
- ex4412 #
复制代码 若是在没有 RootFS 根文件系统的情况下启动 Linux 系统程序,会卡在启动阶段,无法进入系统,下面是无 RootFS 根文件系统的启动过程:- U-Boot 2013.01 (Mar 29 2025 - 15:17:15) for ex4412
- CPU: Exynos4412@1000MHz
- Board: ORIGEN
- DRAM: 1 GiB
- WARNING: Caches not enabled
- PMIC: S5M8767(VER5.0)
- MMC: MMC0: 14910 MB
- In: serial
- Out: serial
- Err: serial
- MMC read: dev # 0, block # 48, count 16 ...16 blocks read: OK
- eMMC CLOSE Success.!!
- Checking Boot Mode ... EMMC4.41
- Net: dm9000
- Hit any key to stop autoboot: 0
- dm9000 i/o: 0x5000000, id: 0x90000a46
- DM9000: running in 16 bit mode
- MAC: 00:1a:2b:33:44:55
- operating at 100M full duplex mode
- Using dm9000 device
- TFTP from server 192.168.100.100; our IP address is 192.168.100.110
- Filename 'linux'.
- Load address: 0x41000000
- Loading: #################################################################
- #################################################################
- #################################################################
- ###########
- 1.1 MiB/s
- done
- Bytes transferred = 3019120 (2e1170 hex)
- dm9000 i/o: 0x5000000, id: 0x90000a46
- DM9000: running in 16 bit mode
- MAC: 00:1a:2b:33:44:55
- operating at 100M full duplex mode
- Using dm9000 device
- TFTP from server 192.168.100.100; our IP address is 192.168.100.110
- Filename 'dt.dtb'.
- Load address: 0x42000000
- Loading: ###
- 1016.6 KiB/s
- done
- Bytes transferred = 34358 (8636 hex)
- ## Booting kernel from Legacy Image at 41000000 ...
- Image Name: Linux-3.14.0
- Image Type: ARM Linux Kernel Image (uncompressed)
- Data Size: 3019056 Bytes = 2.9 MiB
- Load Address: 40008000
- Entry Point: 40008000
- Verifying Checksum ... OK
- ## Flattened Device Tree blob at 42000000
- Booting using the fdt blob at 0x42000000
- Loading Kernel Image ... OK
- OK
- Loading Device Tree to 4fff4000, end 4ffff635 ... OK
- Starting kernel ...
- [ 0.000000] Booting Linux on physical CPU 0xa00
- [ 0.000000] Linux version 3.14.0 (linux@linux) (gcc version 4.6.4 (crosstool-NG hg+default-2685dfa9de14 - tc0002) ) #5 SMP PREEMPT Thu Apr 17 22:17:51 EDT 2024
- [ 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: Insignal Origen evaluation board based on Exynos4412
- [ 0.000000] Memory policy: Data cache writealloc
- [ 0.000000] CPU EXYNOS4412 (id 0xe4412011)
- [ 0.000000] Running under secure firmware.
- [ 0.000000] PERCPU: Embedded 7 pages/cpu @eefb6000 s7424 r8192 d13056 u32768
- [ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 256528
- [ 0.000000] Kernel command line: console=ttySAC2,115200
- [ 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: 1016860K/1032192K available (3948K kernel code, 236K rwdata, 1316K rodata, 231K init, 276K bss, 15332K reserved, 270336K highmem)
- [ 0.000000] Virtual kernel memory layout:
- [ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB)
- [ 0.000000] fixmap : 0xfff00000 - 0xfffe0000 ( 896 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 - 0xc052c258 (5265 kB)
- [ 0.000000] .init : 0xc052d000 - 0xc0566d00 ( 232 kB)
- [ 0.000000] .data : 0xc0568000 - 0xc05a3340 ( 237 kB)
- [ 0.000000] .bss : 0xc05a334c - 0xc05e8384 ( 277 kB)
- [ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
- [ 0.000000] Preemptible hierarchical RCU implementation.
- [ 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] Exynos4x12 clocks: sclk_apll = 500000000, sclk_mpll = 800000000
- [ 0.000000] sclk_epll = 96000000, sclk_vpll = 350000000, arm_clk = 1000000000
- [ 0.000000] sched_clock: 32 bits at 200 Hz, resolution 5000000ns, wraps every 10737418240000000ns
- [ 0.000000] Console: colour dummy device 80x30
- [ 0.045000] Calibrating delay loop... 1992.29 BogoMIPS (lpj=4980736)
- [ 0.045000] pid_max: default: 32768 minimum: 301
- [ 0.045000] Mount-cache hash table entries: 2048 (order: 1, 8192 bytes)
- [ 0.045000] Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes)
- [ 0.050000] CPU: Testing write buffer coherency: ok
- [ 0.050000] missing device node for CPU 0
- [ 0.050000] missing device node for CPU 1
- [ 0.050000] missing device node for CPU 2
- [ 0.050000] missing device node for CPU 3
- [ 0.050000] CPU0: thread -1, cpu 0, socket 10, mpidr 80000a00
- [ 0.050000] Setting up static identity map for 0x403be650 - 0x403be6a8
- [ 0.070000] CPU1: Booted secondary processor
- [ 0.090000] CPU1: thread -1, cpu 1, socket 10, mpidr 80000a01
- [ 0.100000] CPU2: Booted secondary processor
- [ 0.120000] CPU2: thread -1, cpu 2, socket 10, mpidr 80000a02
- [ 0.130000] CPU3: Booted secondary processor
- [ 0.150000] CPU3: thread -1, cpu 3, socket 10, mpidr 80000a03
- [ 0.150000] Brought up 4 CPUs
- [ 0.150000] SMP: Total of 4 processors activated.
- [ 0.150000] CPU: All CPU(s) started in SVC mode.
- [ 0.150000] devtmpfs: initialized
- [ 0.150000] VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4
- [ 0.155000] pinctrl core: initialized pinctrl subsystem
- [ 0.155000] regulator-dummy: no parameters
- [ 0.155000] NET: Registered protocol family 16
- [ 0.155000] DMA: preallocated 256 KiB pool for atomic coherent allocations
- [ 0.175000] S3C Power Management, Copyright 2004 Simtec Electronics
- [ 0.175000] EXYNOS4x12 PMU Initialize
- [ 0.175000] EXYNOS: Initializing architecture
- [ 0.205000] bio: create slab <bio-0> at 0
- [ 0.210000] VMEM_VDD_2.8V: 2800 mV
- [ 0.215000] SCSI subsystem initialized
- [ 0.215000] usbcore: registered new interface driver usbfs
- [ 0.215000] usbcore: registered new interface driver hub
- [ 0.215000] usbcore: registered new device driver usb
- [ 0.215000] s3c-i2c 13860000.i2c: slave address 0x00
- [ 0.215000] s3c-i2c 13860000.i2c: bus frequency set to 19 KHz
- [ 0.215000] sec_pmic 0-0066: No interrupt specified, no interrupts
- [ 0.245000] VDD_ALIVE: failed to apply 1100000uV constraint
- [ 0.245000] s5m8767-pmic s5m8767-pmic: regulator init failed for 0
- [ 0.245000] s3c-i2c 13860000.i2c: i2c-0: S3C I2C adapter
- [ 0.245000] Switched to clocksource mct-frc
- [ 0.275000] NET: Registered protocol family 2
- [ 0.275000] TCP established hash table entries: 8192 (order: 3, 32768 bytes)
- [ 0.275000] TCP bind hash table entries: 8192 (order: 5, 163840 bytes)
- [ 0.275000] TCP: Hash tables configured (established 8192 bind 8192)
- [ 0.275000] TCP: reno registered
- [ 0.275000] UDP hash table entries: 512 (order: 2, 24576 bytes)
- [ 0.275000] UDP-Lite hash table entries: 512 (order: 2, 24576 bytes)
- [ 0.275000] NET: Registered protocol family 1
- [ 0.275000] RPC: Registered named UNIX socket transport module.
- [ 0.275000] RPC: Registered udp transport module.
- [ 0.275000] RPC: Registered tcp transport module.
- [ 0.275000] RPC: Registered tcp NFSv4.1 backchannel transport module.
- [ 0.280000] futex hash table entries: 1024 (order: 4, 65536 bytes)
- [ 0.280000] bounce pool size: 64 pages
- [ 0.305000] ROMFS MTD (C) 2007 Red Hat, Inc.
- [ 0.305000] msgmni has been set to 1458
- [ 0.305000] io scheduler noop registered
- [ 0.305000] io scheduler deadline registered
- [ 0.305000] io scheduler cfq registered (default)
- [ 0.320000] dma-pl330 12680000.pdma: Loaded driver for PL330 DMAC-1315632
- [ 0.320000] dma-pl330 12680000.pdma: DBUFF-32x4bytes Num_Chans-8 Num_Peri-32 Num_Events-32
- [ 0.330000] dma-pl330 12690000.pdma: Loaded driver for PL330 DMAC-1315632
- [ 0.330000] dma-pl330 12690000.pdma: DBUFF-32x4bytes Num_Chans-8 Num_Peri-32 Num_Events-32
- [ 0.335000] dma-pl330 12850000.mdma: Loaded driver for PL330 DMAC-1315632
- [ 0.335000] dma-pl330 12850000.mdma: DBUFF-64x8bytes Num_Chans-8 Num_Peri-1 Num_Events-32
- [ 0.520000] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
- [ 0.525000] 13800000.serial: ttySAC0 at MMIO 0x13800000 (irq = 84, base_baud = 0) is a S3C6400/10
- [ 0.525000] 13810000.serial: ttySAC1 at MMIO 0x13810000 (irq = 85, base_baud = 0) is a S3C6400/10
- [ 0.525000] 13820000.serial: ttySAC2 at MMIO 0x13820000 (irq = 86, base_baud = 0) is a S3C6400/10
- [ 1.135000] console [ttySAC2] enabled
- [ 1.140000] 13830000.serial: ttySAC3 at MMIO 0x13830000 (irq = 87, base_baud = 0) is a S3C6400/10
- [ 1.165000] brd: module loaded
- [ 1.175000] loop: module loaded
- [ 1.175000] dm9000 5000000.ethernet: read wrong id 0x01010101
- [ 1.185000] eth0: dm9000a at f0076000,f0078004 IRQ 167 MAC: 00:0a:2d:a6:55:a2 (platform data)
- [ 1.190000] usbcore: registered new interface driver asix
- [ 1.195000] usbcore: registered new interface driver ax88179_178a
- [ 1.200000] usbcore: registered new interface driver cdc_ether
- [ 1.210000] usbcore: registered new interface driver smsc75xx
- [ 1.215000] usbcore: registered new interface driver smsc95xx
- [ 1.220000] usbcore: registered new interface driver net1080
- [ 1.225000] usbcore: registered new interface driver cdc_subset
- [ 1.230000] usbcore: registered new interface driver zaurus
- [ 1.235000] usbcore: registered new interface driver cdc_ncm
- [ 1.245000] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
- [ 1.250000] ehci-exynos: EHCI EXYNOS driver
- [ 1.250000] exynos-ehci 12580000.ehci: no platform data or transceiver defined
- [ 1.260000] platform 12580000.ehci: Driver exynos-ehci requests probe deferral
- [ 1.265000] usbcore: registered new interface driver usb-storage
- [ 1.285000] usb3503 8.usb3503: switched to HUB mode
- [ 1.285000] usb3503 8.usb3503: usb3503_probe: probed in hub mode
- [ 1.295000] mousedev: PS/2 mouse device common for all mice
- [ 1.300000] input: 100a0000.keypad as /devices/100a0000.keypad/input/input0
- [ 1.310000] device-mapper: ioctl: 4.27.0-ioctl (2013-10-30) initialised: dm-devel@redhat.com
- [ 1.315000] sdhci: Secure Digital Host Controller Interface driver
- [ 1.320000] sdhci: Copyright(c) Pierre Ossman
- [ 1.325000] s3c-sdhci 12530000.sdhci: clock source 2: mmc_busclk.2 (5000000 Hz)
- [ 1.335000] mmc0: no vqmmc regulator found
- [ 1.340000] mmc0: no vmmc regulator found
- [ 1.370000] mmc0: SDHCI controller on samsung-hsmmc [12530000.sdhci] using ADMA
- [ 1.375000] Synopsys Designware Multimedia Card Interface Driver
- [ 1.380000] dwmmc_exynos 12550000.mmc: no vmmc regulator found: -19
- [ 1.385000] dwmmc_exynos 12550000.mmc: Using internal DMA controller.
- [ 1.390000] dwmmc_exynos 12550000.mmc: Version ID is 240a
- [ 1.400000] dwmmc_exynos 12550000.mmc: DW MMC controller at irq 109, 32 bit host data width, 128 deep fifo
- [ 1.440000] dwmmc_exynos 12550000.mmc: 1 slots initialized
- [ 1.450000] usbcore: registered new interface driver usbhid
- [ 1.455000] usbhid: USB HID core driver
- [ 1.455000] TCP: cubic registered
- [ 1.460000] NET: Registered protocol family 17
- [ 1.465000] NET: Registered protocol family 15
- [ 1.470000] Registering SWP/SWPB emulation handler
- [ 1.475000] VMEM_VDD_2.8V: disabling
- [ 1.480000] regulator-dummy: disabling
- [ 1.480000] exynos-ehci 12580000.ehci: EHCI Host Controller
- [ 1.490000] exynos-ehci 12580000.ehci: new USB bus registered, assigned bus number 1
- [ 1.495000] exynos-ehci 12580000.ehci: irq 102, io mem 0x12580000
- [ 1.510000] exynos-ehci 12580000.ehci: USB 2.0 started, EHCI 1.00
- [ 1.515000] hub 1-0:1.0: USB hub found
- [ 1.515000] mmc1: BKOPS_EN bit is not set
- [ 1.520000] hub 1-0:1.0: 3 ports detected
- [ 1.525000] drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
- [ 1.525000] mmc_host mmc1: Bus speed (slot 0) = 50000000Hz (slot req 52000000Hz, actual 50000000HZ div = 0)
- [ 1.525000] mmc_host mmc1: Bus speed (slot 0) = 100000000Hz (slot req 52000000Hz, actual 50000000HZ div = 1)
- [ 1.525000] mmc1: new high speed DDR MMC card at address 0001
- [ 1.525000] mmcblk0: mmc1:0001 AJTD4R 14.5 GiB
- [ 1.525000] mmcblk0boot0: mmc1:0001 AJTD4R partition 1 4.00 MiB
- [ 1.525000] mmcblk0boot1: mmc1:0001 AJTD4R partition 2 4.00 MiB
- [ 1.530000] mmcblk0rpmb: mmc1:0001 AJTD4R partition 3 4.00 MiB
- [ 1.580000] clk: Not disabling unused clocks
- [ 1.580000] mmcblk0: p1 p2 p3 p4
- [ 1.590000] mmcblk0boot1: unknown partition table
- [ 1.595000] mmcblk0boot0: unknown partition table
- [ 1.600000] VFS: Cannot open root device "(null)" or unknown-block(0,0): error -6
- [ 1.605000] Please append a correct "root=" boot option; here are the available partitions:
- [ 1.615000] b300 15267840 mmcblk0 driver: mmcblk
- [ 1.620000] b301 13578240 mmcblk0p1 00000000-01
- [ 1.625000] b302 307200 mmcblk0p2 00000000-02
- [ 1.630000] b303 1048576 mmcblk0p3 00000000-03
- [ 1.635000] b304 307200 mmcblk0p4 00000000-04
- [ 1.640000] b318 4096 mmcblk0rpmb (driver?)
- [ 1.645000] b310 4096 mmcblk0boot1 (driver?)
- [ 1.650000] b308 4096 mmcblk0boot0 (driver?)
- [ 1.655000] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
- [ 1.660000] mmc0: new high speed SDHC card at address 59b4
- [ 1.665000] mmcblk1: mmc0:59b4 SDU1 7.50 GiB
- [ 1.665000] mmcblk1: unknown partition table
- [ 1.665000] CPU: 2 PID: 1 Comm: swapper/0 Not tainted 3.14.0 #5
- [ 1.665000] [<c0013e10>] (unwind_backtrace) from [<c0011240>] (show_stack+0x10/0x14)
- [ 1.665000] [<c0011240>] (show_stack) from [<c03b9368>] (dump_stack+0x64/0xb4)
- [ 1.665000] [<c03b9368>] (dump_stack) from [<c03b67a8>] (panic+0x8c/0x1dc)
- [ 1.665000] [<c03b67a8>] (panic) from [<c052e034>] (mount_block_root+0x188/0x234)
- [ 1.665000] [<c052e034>] (mount_block_root) from [<c052e2b4>] (mount_root+0xe8/0x108)
- [ 1.665000] [<c052e2b4>] (mount_root) from [<c052e434>] (prepare_namespace+0x160/0x1c4)
- [ 1.665000] [<c052e434>] (prepare_namespace) from [<c052dcd0>] (kernel_init_freeable+0x180/0x1c8)
- [ 1.665000] [<c052dcd0>] (kernel_init_freeable) from [<c03b5a98>] (kernel_init+0x8/0xe4)
- [ 1.665000] [<c03b5a98>] (kernel_init) from [<c000e4b8>] (ret_from_fork+0x14/0x3c)
- [ 1.755000] CPU0: stopping
- [ 1.755000] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 3.14.0 #5
- [ 1.755000] [<c0013e10>] (unwind_backtrace) from [<c0011240>] (show_stack+0x10/0x14)
- [ 1.755000] [<c0011240>] (show_stack) from [<c03b9368>] (dump_stack+0x64/0xb4)
- [ 1.755000] [<c03b9368>] (dump_stack) from [<c00131bc>] (handle_IPI+0x154/0x180)
- [ 1.755000] [<c00131bc>] (handle_IPI) from [<c0008568>] (gic_handle_irq+0x60/0x68)
- [ 1.755000] [<c0008568>] (gic_handle_irq) from [<c0011d40>] (__irq_svc+0x40/0x70)
- [ 1.755000] Exception stack(0xc0569f68 to 0xc0569fb0)
- [ 1.755000] 9f60: 00000000 00000000 00002260 00000000 c0568000 c0570494
- [ 1.755000] 9f80: c03c1b24 c05a3219 c05a3219 413fc090 00000001 00000000 c0577140 c0569fb0
- [ 1.755000] 9fa0: c000eff4 c000eff8 60000153 ffffffff
- [ 1.755000] [<c0011d40>] (__irq_svc) from [<c000eff8>] (arch_cpu_idle+0x28/0x30)
- [ 1.755000] [<c000eff8>] (arch_cpu_idle) from [<c00589b0>] (cpu_startup_entry+0x9c/0x138)
- [ 1.755000] [<c00589b0>] (cpu_startup_entry) from [<c052daf4>] (start_kernel+0x368/0x3c4)
- [ 1.755000] [<c052daf4>] (start_kernel) from [<40008074>] (0x40008074)
- [ 1.755000] CPU3: stopping
- [ 1.755000] CPU: 3 PID: 0 Comm: swapper/3 Not tainted 3.14.0 #5
- [ 1.755000] [<c0013e10>] (unwind_backtrace) from [<c0011240>] (show_stack+0x10/0x14)
- [ 1.755000] [<c0011240>] (show_stack) from [<c03b9368>] (dump_stack+0x64/0xb4)
- [ 1.755000] [<c03b9368>] (dump_stack) from [<c00131bc>] (handle_IPI+0x154/0x180)
- [ 1.755000] [<c00131bc>] (handle_IPI) from [<c0008568>] (gic_handle_irq+0x60/0x68)
- [ 1.755000] [<c0008568>] (gic_handle_irq) from [<c0011d40>] (__irq_svc+0x40/0x70)
- [ 1.755000] Exception stack(0xee8cffa0 to 0xee8cffe8)
- [ 1.755000] ffa0: 00000003 00000000 00001b2c 00000000 ee8ce000 c0570494 c03c1b24 c05a3219
- [ 1.755000] ffc0: c05a3219 413fc090 00000001 00000000 f8500620 ee8cffe8 c000eff4 c000eff8
- [ 1.755000] ffe0: 60000153 ffffffff
- [ 1.755000] [<c0011d40>] (__irq_svc) from [<c000eff8>] (arch_cpu_idle+0x28/0x30)
- [ 1.755000] [<c000eff8>] (arch_cpu_idle) from [<c00589b0>] (cpu_startup_entry+0x9c/0x138)
- [ 1.755000] [<c00589b0>] (cpu_startup_entry) from [<40008604>] (0x40008604)
- [ 1.755000] CPU1: stopping
- [ 1.755000] CPU: 1 PID: 0 Comm: swapper/1 Not tainted 3.14.0 #5
- [ 1.755000] [<c0013e10>] (unwind_backtrace) from [<c0011240>] (show_stack+0x10/0x14)
- [ 1.755000] [<c0011240>] (show_stack) from [<c03b9368>] (dump_stack+0x64/0xb4)
- [ 1.755000] [<c03b9368>] (dump_stack) from [<c00131bc>] (handle_IPI+0x154/0x180)
- [ 1.755000] [<c00131bc>] (handle_IPI) from [<c0008568>] (gic_handle_irq+0x60/0x68)
- [ 1.755000] [<c0008568>] (gic_handle_irq) from [<c0011d40>] (__irq_svc+0x40/0x70)
- [ 1.755000] Exception stack(0xee8cbfa0 to 0xee8cbfe8)
- [ 1.755000] bfa0: 00000001 00000000 00001590 00000000 ee8ca000 c0570494 c03c1b24 c05a3219
- [ 1.755000] bfc0: c05a3219 413fc090 00000001 00000000 c0577140 ee8cbfe8 c000eff4 c000eff8
- [ 1.755000] bfe0: 60000153 ffffffff
- [ 1.755000] [<c0011d40>] (__irq_svc) from [<c000eff8>] (arch_cpu_idle+0x28/0x30)
- [ 1.755000] [<c000eff8>] (arch_cpu_idle) from [<c00589b0>] (cpu_startup_entry+0x9c/0x138)
- [ 1.755000] [<c00589b0>] (cpu_startup_entry) from [<40008604>] (0x40008604)
复制代码 2.2 配置 NFS 参数
接下来是使用 U-Boot 引导程序传递 NFS 服务器相关的配置参数给 Linux 系统,我们需要设置 bootargs 环境变量。
在 U-Boot 引导程序中,bootargs 是一个非常重要的环境变量。它主要用于在启动 Linux 内核时传递参数,这些参数会影响内核的启动行为和系统的初始化过程。简单来说,bootargs 就像是一个配置清单,告诉内核应该如何挂载根文件系统、使用哪个串口进行控制台输出、设置网络参数等。
设置 bootargs 环境变量的命令如下:- setenv bootargs 'root=/dev/nfs nfsroot=192.168.100.100:/rootnfs,proto=tcp,nfsvers=3 rw clk_ignore_unused console=ttySAC2,115200 init=/linuxrc ip=192.168.100.110'
复制代码 其中:
- root=/dev/nfs 指定根文件系统的设备类型为 NFS;
- nfsroot=192.168.100.100:/rootnfs,proto=tcp,nfsvers=3中的 nfsroot 用于指定 NFS 服务器的地址和共享目录,192.168.100.100 是 NFS 服务器的 IP 地址,/rootnfs 是服务器上共享的目录的共享名称(Linux上共享名称为其路径),proto=tcp 表示使用 TCP 协议进行 NFS 通信,nfsvers=3 表示使用 NFS 版本 3;
- rw 表示以读写模式挂载根文件系统;
- clk_ignore_unused 这个参数告诉内核忽略未使用的时钟,有助于减少系统的功耗和资源占用;
- console=ttySAC2,115200 是用来指定内核使用的控制台设备和波特率的,ttySAC2 是串口设备名,115200 是串口通信的波特率,这意味着内核的输出信息将通过 ttySAC2 串口以 115200bps 的速率进行传输;
- init=/linuxrc 用来指定内核启动后第一个执行的程序,这里指定为 /linuxrc,这是一个初始化脚本,用于完成系统的初始化工作,如挂载文件系统、启动服务等;
- ip=192.168.100.110 这个参数为系统指定了一个静态 IP 地址 192.168.100.110,用于网络通信。
设置完后记得用 saveenv 保存设置。
运行结果:- ex4412 # setenv bootargs 'root=/dev/nfs nfsroot=192.168.100.100:/rootnfs,proto=tcp,nfsvers=3 rw clk_ignore_unused console=ttySAC2,115200 init=/linuxrc ip=192.168.100.110'
- ex4412 # saveenv
- Saving Environment to MMC...
- Writing to MMC(0)... .done
- ex4412 #
复制代码 2.3 试验
2.3.1 启动
重启开发板,试试看能不能正常启动和共享~- U-Boot 2013.01 (Mar 29 2025 - 15:17:15) for ex4412
- CPU: Exynos4412@1000MHz
- Board: ORIGEN
- DRAM: 1 GiB
- WARNING: Caches not enabled
- PMIC: S5M8767(VER5.0)
- MMC: MMC0: 14910 MB
- In: serial
- Out: serial
- Err: serial
- MMC read: dev # 0, block # 48, count 16 ...16 blocks read: OK
- eMMC CLOSE Success.!!
- Checking Boot Mode ... EMMC4.41
- Net: dm9000
- Hit any key to stop autoboot: 0
- dm9000 i/o: 0x5000000, id: 0x90000a46
- DM9000: running in 16 bit mode
- MAC: 00:1a:2b:33:44:55
- operating at 100M full duplex mode
- Using dm9000 device
- TFTP from server 192.168.100.100; our IP address is 192.168.100.110
- Filename 'linux'.
- Load address: 0x41000000
- Loading: #################################################################
- #################################################################
- #################################################################
- ###########
- 1.1 MiB/s
- done
- Bytes transferred = 3019120 (2e1170 hex)
- dm9000 i/o: 0x5000000, id: 0x90000a46
- DM9000: running in 16 bit mode
- MAC: 00:1a:2b:33:44:55
- operating at 100M full duplex mode
- Using dm9000 device
- TFTP from server 192.168.100.100; our IP address is 192.168.100.110
- Filename 'dt.dtb'.
- Load address: 0x42000000
- Loading: ###
- 1.1 MiB/s
- done
- Bytes transferred = 34358 (8636 hex)
- ## Booting kernel from Legacy Image at 41000000 ...
- Image Name: Linux-3.14.0
- Image Type: ARM Linux Kernel Image (uncompressed)
- Data Size: 3019056 Bytes = 2.9 MiB
- Load Address: 40008000
- Entry Point: 40008000
- Verifying Checksum ... OK
- ## Flattened Device Tree blob at 42000000
- Booting using the fdt blob at 0x42000000
- Loading Kernel Image ... OK
- OK
- Loading Device Tree to 4fff4000, end 4ffff635 ... OK
- Starting kernel ...
- [ 0.000000] Booting Linux on physical CPU 0xa00
- [ 0.000000] Linux version 3.14.0 (linux@linux) (gcc version 4.6.4 (crosstool-NG hg+default-2685dfa9de14 - tc0002) ) #5 SMP PREEMPT Thu Apr 17 22:17:51 EDT 2024
- [ 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: Insignal Origen evaluation board based on Exynos4412
- [ 0.000000] Memory policy: Data cache writealloc
- [ 0.000000] CPU EXYNOS4412 (id 0xe4412011)
- [ 0.000000] Running under secure firmware.
- [ 0.000000] PERCPU: Embedded 7 pages/cpu @eefb6000 s7424 r8192 d13056 u32768
- [ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 256528
- [ 0.000000] Kernel command line: root=/dev/nfs nfsroot=192.168.100.100:/rootnfs rw console=ttySAC2,115200 init=/linuxrc ip=192.168.100.110
- [ 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: 1016860K/1032192K available (3948K kernel code, 236K rwdata, 1316K rodata, 231K init, 276K bss, 15332K reserved, 270336K highmem)
- [ 0.000000] Virtual kernel memory layout:
- [ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB)
- [ 0.000000] fixmap : 0xfff00000 - 0xfffe0000 ( 896 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 - 0xc052c258 (5265 kB)
- [ 0.000000] .init : 0xc052d000 - 0xc0566d00 ( 232 kB)
- [ 0.000000] .data : 0xc0568000 - 0xc05a3340 ( 237 kB)
- [ 0.000000] .bss : 0xc05a334c - 0xc05e8384 ( 277 kB)
- [ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
- [ 0.000000] Preemptible hierarchical RCU implementation.
- [ 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] Exynos4x12 clocks: sclk_apll = 500000000, sclk_mpll = 800000000
- [ 0.000000] sclk_epll = 96000000, sclk_vpll = 350000000, arm_clk = 1000000000
- [ 0.000000] sched_clock: 32 bits at 200 Hz, resolution 5000000ns, wraps every 10737418240000000ns
- [ 0.000000] Console: colour dummy device 80x30
- [ 0.045000] Calibrating delay loop... 1992.29 BogoMIPS (lpj=4980736)
- [ 0.045000] pid_max: default: 32768 minimum: 301
- [ 0.045000] Mount-cache hash table entries: 2048 (order: 1, 8192 bytes)
- [ 0.045000] Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes)
- [ 0.050000] CPU: Testing write buffer coherency: ok
- [ 0.050000] missing device node for CPU 0
- [ 0.050000] missing device node for CPU 1
- [ 0.050000] missing device node for CPU 2
- [ 0.050000] missing device node for CPU 3
- [ 0.050000] CPU0: thread -1, cpu 0, socket 10, mpidr 80000a00
- [ 0.050000] Setting up static identity map for 0x403be650 - 0x403be6a8
- [ 0.070000] CPU1: Booted secondary processor
- [ 0.090000] CPU1: thread -1, cpu 1, socket 10, mpidr 80000a01
- [ 0.100000] CPU2: Booted secondary processor
- [ 0.120000] CPU2: thread -1, cpu 2, socket 10, mpidr 80000a02
- [ 0.130000] CPU3: Booted secondary processor
- [ 0.150000] CPU3: thread -1, cpu 3, socket 10, mpidr 80000a03
- [ 0.150000] Brought up 4 CPUs
- [ 0.150000] SMP: Total of 4 processors activated.
- [ 0.150000] CPU: All CPU(s) started in SVC mode.
- [ 0.150000] devtmpfs: initialized
- [ 0.150000] VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4
- [ 0.155000] pinctrl core: initialized pinctrl subsystem
- [ 0.155000] regulator-dummy: no parameters
- [ 0.155000] NET: Registered protocol family 16
- [ 0.155000] DMA: preallocated 256 KiB pool for atomic coherent allocations
- [ 0.175000] S3C Power Management, Copyright 2004 Simtec Electronics
- [ 0.175000] EXYNOS4x12 PMU Initialize
- [ 0.175000] EXYNOS: Initializing architecture
- [ 0.210000] bio: create slab <bio-0> at 0
- [ 0.210000] VMEM_VDD_2.8V: 2800 mV
- [ 0.215000] SCSI subsystem initialized
- [ 0.215000] usbcore: registered new interface driver usbfs
- [ 0.215000] usbcore: registered new interface driver hub
- [ 0.215000] usbcore: registered new device driver usb
- [ 0.215000] s3c-i2c 13860000.i2c: slave address 0x00
- [ 0.215000] s3c-i2c 13860000.i2c: bus frequency set to 19 KHz
- [ 0.220000] sec_pmic 0-0066: No interrupt specified, no interrupts
- [ 0.245000] VDD_ALIVE: failed to apply 1100000uV constraint
- [ 0.245000] s5m8767-pmic s5m8767-pmic: regulator init failed for 0
- [ 0.245000] s3c-i2c 13860000.i2c: i2c-0: S3C I2C adapter
- [ 0.245000] Switched to clocksource mct-frc
- [ 0.275000] NET: Registered protocol family 2
- [ 0.275000] TCP established hash table entries: 8192 (order: 3, 32768 bytes)
- [ 0.275000] TCP bind hash table entries: 8192 (order: 5, 163840 bytes)
- [ 0.275000] TCP: Hash tables configured (established 8192 bind 8192)
- [ 0.275000] TCP: reno registered
- [ 0.275000] UDP hash table entries: 512 (order: 2, 24576 bytes)
- [ 0.275000] UDP-Lite hash table entries: 512 (order: 2, 24576 bytes)
- [ 0.275000] NET: Registered protocol family 1
- [ 0.275000] RPC: Registered named UNIX socket transport module.
- [ 0.275000] RPC: Registered udp transport module.
- [ 0.275000] RPC: Registered tcp transport module.
- [ 0.275000] RPC: Registered tcp NFSv4.1 backchannel transport module.
- [ 0.280000] futex hash table entries: 1024 (order: 4, 65536 bytes)
- [ 0.280000] bounce pool size: 64 pages
- [ 0.305000] ROMFS MTD (C) 2007 Red Hat, Inc.
- [ 0.305000] msgmni has been set to 1458
- [ 0.310000] io scheduler noop registered
- [ 0.310000] io scheduler deadline registered
- [ 0.310000] io scheduler cfq registered (default)
- [ 0.325000] dma-pl330 12680000.pdma: Loaded driver for PL330 DMAC-1315632
- [ 0.325000] dma-pl330 12680000.pdma: DBUFF-32x4bytes Num_Chans-8 Num_Peri-32 Num_Events-32
- [ 0.335000] dma-pl330 12690000.pdma: Loaded driver for PL330 DMAC-1315632
- [ 0.335000] dma-pl330 12690000.pdma: DBUFF-32x4bytes Num_Chans-8 Num_Peri-32 Num_Events-32
- [ 0.335000] dma-pl330 12850000.mdma: Loaded driver for PL330 DMAC-1315632
- [ 0.335000] dma-pl330 12850000.mdma: DBUFF-64x8bytes Num_Chans-8 Num_Peri-1 Num_Events-32
- [ 0.530000] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
- [ 0.530000] 13800000.serial: ttySAC0 at MMIO 0x13800000 (irq = 84, base_baud = 0) is a S3C6400/10
- [ 0.530000] 13810000.serial: ttySAC1 at MMIO 0x13810000 (irq = 85, base_baud = 0) is a S3C6400/10
- [ 0.530000] 13820000.serial: ttySAC2 at MMIO 0x13820000 (irq = 86, base_baud = 0) is a S3C6400/10
- [ 1.145000] console [ttySAC2] enabled
- [ 1.150000] 13830000.serial: ttySAC3 at MMIO 0x13830000 (irq = 87, base_baud = 0) is a S3C6400/10
- [ 1.175000] brd: module loaded
- [ 1.185000] loop: module loaded
- [ 1.190000] dm9000 5000000.ethernet: read wrong id 0x01010101
- [ 1.195000] eth0: dm9000a at f0076000,f0078004 IRQ 167 MAC: 00:0a:2d:a6:55:a2 (platform data)
- [ 1.205000] usbcore: registered new interface driver asix
- [ 1.210000] usbcore: registered new interface driver ax88179_178a
- [ 1.215000] usbcore: registered new interface driver cdc_ether
- [ 1.220000] usbcore: registered new interface driver smsc75xx
- [ 1.225000] usbcore: registered new interface driver smsc95xx
- [ 1.230000] usbcore: registered new interface driver net1080
- [ 1.235000] usbcore: registered new interface driver cdc_subset
- [ 1.245000] usbcore: registered new interface driver zaurus
- [ 1.250000] usbcore: registered new interface driver cdc_ncm
- [ 1.255000] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
- [ 1.260000] ehci-exynos: EHCI EXYNOS driver
- [ 1.265000] exynos-ehci 12580000.ehci: no platform data or transceiver defined
- [ 1.270000] platform 12580000.ehci: Driver exynos-ehci requests probe deferral
- [ 1.280000] usbcore: registered new interface driver usb-storage
- [ 1.295000] usb3503 8.usb3503: switched to HUB mode
- [ 1.300000] usb3503 8.usb3503: usb3503_probe: probed in hub mode
- [ 1.305000] mousedev: PS/2 mouse device common for all mice
- [ 1.315000] input: 100a0000.keypad as /devices/100a0000.keypad/input/input0
- [ 1.320000] device-mapper: ioctl: 4.27.0-ioctl (2013-10-30) initialised: dm-devel@redhat.com
- [ 1.330000] sdhci: Secure Digital Host Controller Interface driver
- [ 1.335000] sdhci: Copyright(c) Pierre Ossman
- [ 1.340000] s3c-sdhci 12530000.sdhci: clock source 2: mmc_busclk.2 (5000000 Hz)
- [ 1.345000] mmc0: no vqmmc regulator found
- [ 1.350000] mmc0: no vmmc regulator found
- [ 1.385000] mmc0: SDHCI controller on samsung-hsmmc [12530000.sdhci] using ADMA
- [ 1.390000] Synopsys Designware Multimedia Card Interface Driver
- [ 1.395000] dwmmc_exynos 12550000.mmc: no vmmc regulator found: -19
- [ 1.400000] dwmmc_exynos 12550000.mmc: Using internal DMA controller.
- [ 1.405000] dwmmc_exynos 12550000.mmc: Version ID is 240a
- [ 1.415000] dwmmc_exynos 12550000.mmc: DW MMC controller at irq 109, 32 bit host data width, 128 deep fifo
- [ 1.455000] dwmmc_exynos 12550000.mmc: 1 slots initialized
- [ 1.460000] usbcore: registered new interface driver usbhid
- [ 1.465000] usbhid: USB HID core driver
- [ 1.470000] TCP: cubic registered
- [ 1.470000] NET: Registered protocol family 17
- [ 1.475000] NET: Registered protocol family 15
- [ 1.480000] Registering SWP/SWPB emulation handler
- [ 1.485000] VMEM_VDD_2.8V: disabling
- [ 1.490000] regulator-dummy: disabling
- [ 1.495000] exynos-ehci 12580000.ehci: EHCI Host Controller
- [ 1.500000] exynos-ehci 12580000.ehci: new USB bus registered, assigned bus number 1
- [ 1.505000] exynos-ehci 12580000.ehci: irq 102, io mem 0x12580000
- [ 1.520000] exynos-ehci 12580000.ehci: USB 2.0 started, EHCI 1.00
- [ 1.525000] hub 1-0:1.0: USB hub found
- [ 1.525000] hub 1-0:1.0: 3 ports detected
- [ 1.530000] mmc1: BKOPS_EN bit is not set
- [ 1.535000] drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
- [ 1.535000] mmc_host mmc1: Bus speed (slot 0) = 50000000Hz (slot req 52000000Hz, actual 50000000HZ div = 0)
- [ 1.535000] mmc_host mmc1: Bus speed (slot 0) = 100000000Hz (slot req 52000000Hz, actual 50000000HZ div = 1)
- [ 1.535000] mmc1: new high speed DDR MMC card at address 0001
- [ 1.565000] mmcblk0: mmc1:0001 AJTD4R 14.5 GiB
- [ 1.570000] mmcblk0boot0: mmc1:0001 AJTD4R partition 1 4.00 MiB
- [ 1.575000] mmcblk0boot1: mmc1:0001 AJTD4R partition 2 4.00 MiB
- [ 1.580000] mmcblk0rpmb: mmc1:0001 AJTD4R partition 3 4.00 MiB
- [ 1.590000] dm9000 5000000.ethernet eth0: link down
- [ 1.595000] mmcblk0: p1 p2 p3 p4
- [ 1.600000] mmcblk0boot1: unknown partition table
- [ 1.605000] mmcblk0boot0: unknown partition table
- [ 1.670000] mmc0: new high speed SDHC card at address 59b4
- [ 1.675000] mmcblk1: mmc0:59b4 SDU1 7.50 GiB
- [ 1.680000] mmcblk1: unknown partition table
- [ 1.815000] dm9000 5000000.ethernet eth0: link up, 100Mbps, full-duplex, lpa 0xCDE1
- [ 1.815000] IP-Config: Guessing netmask 255.255.255.0
- [ 1.815000] IP-Config: Complete:
- [ 1.815000] device=eth0, hwaddr=00:0a:2d:a6:55:a2, ipaddr=192.168.100.110, mask=255.255.255.0, gw=255.255.255.255
- [ 1.815000] host=192.168.100.110, domain=, nis-domain=(none)
- [ 1.815000] bootserver=255.255.255.255, rootserver=192.168.100.100, rootpath=
- [ 1.815000] clk: Not disabling unused clocks
- [ 1.855000] usb 1-3: new high-speed USB device number 2 using exynos-ehci
- [ 1.920000] VFS: Mounted root (nfs filesystem) on device 0:10.
- [ 1.930000] devtmpfs: mounted
- [ 1.930000] Freeing unused kernel memory: 228K (c052d000 - c0566000)
- [ 2.025000] hub 1-3:1.0: USB hub found
- [ 2.030000] hub 1-3:1.0: 3 ports detected
- [root@yieq4412 ]# ls
- bin etc linuxrc mnt root sys usr
- dev lib lost+found proc sbin tmp var
- [root@yieq4412 ]#
复制代码 成功~
2.3.1 共享
电脑到开发板
我们通过 Linux 电脑在 RootFS 根文件系统中写入一个文件:- yu@Yubuntu:~$ sudo mount -t nfs -o nolock 192.168.146.1:/rootnfs /mnt
- [sudo] yu 的密码:
- yu@Yubuntu:~$ cd /mnt
- yu@Yubuntu:/mnt$ ls
- bin dev etc lib linuxrc lost+found mnt proc root sbin sys tmp usr var
- yu@Yubuntu:/mnt$ cd root
- yu@Yubuntu:/mnt/root$ ls
- yu@Yubuntu:/mnt/root$ vi hello.c
- yu@Yubuntu:/mnt/root$ cat hello.c
- #include<stdio.h>
- int main()
- {
- printf("Hello NFS!\n");
- return 0;
- }
- yu@Yubuntu:/mnt/root$
复制代码 好~
再到开发板上看看:- [root@yieq4412 ]# ls
- bin etc linuxrc mnt root sys usr
- dev lib lost+found proc sbin tmp var
- [root@yieq4412 ]# cd root/
- [root@yieq4412 root]# ls
- hello.c
- [root@yieq4412 root]# cat hello.c
- #include<stdio.h>
- int main()
- {
- printf("Hello NFS!\n");
- return 0;
- }
- [root@yieq4412 root]#
复制代码 很不错,开发板可以直接看到刚刚在 Linux 电脑上创建的文件。
开发板到电脑
在开发板上创建一个文件:- [root@yieq4412 root]#ls
- hello.c
- [root@yieq4412 root]#vi hi.c
- [root@yieq4412 root]#cat hi.c
- #include<stdio.h>
- int main()
- {
- printf("Hi NFS!\n");
- return 0;
- }
- [root@yieq4412 root]#
复制代码 在电脑上查看:- yu@Yubuntu:/mnt/root$ ls
- hello.c hi.c
- yu@Yubuntu:/mnt/root$ cat hi.c
- #include<stdio.h>
- int main()
- {
- printf("Hi NFS!\n");
- return 0;
- }
- yu@Yubuntu:/mnt/root$
复制代码 能正常查看,成功~
柒、从 eMMC 中加载 U-Boot 引导程序
有时候我们使用 SD 卡并不是很方便,我们希望能直接从 eMMC 中启动,此时,需要从 eMMC 中加载 U-Boot 引导程序。
1. 把 U-Boot 引导程序加载到内存
使用 tftp 命令从 TFTP 服务器加载“uboot.bin”:执行结果:- ex4412 # tftp 41000000 uboot.bin
- dm9000 i/o: 0x5000000, id: 0x90000a46
- DM9000: running in 16 bit mode
- MAC: 00:1a:2b:33:44:55
- operating at 100M full duplex mode
- Using dm9000 device
- TFTP from server 192.168.100.100; our IP address is 192.168.100.110
- Filename 'uboot.bin'.
- Load address: 0x41000000
- Loading: ####################################
- 1.1 MiB/s
- done
- Bytes transferred = 527104 (80b00 hex)
- ex4412 #
复制代码 2. 备份环境变量
因为待会儿备份环境可能会被覆盖掉,所以在写入之前,我们需要把有用的环境变量备份一下,包括但不限于网络设置,启动设置等,使用 printenv 命令打印所有环境变量,我们复制下来保存一下,执行结果如下:- ex4412 # printenv
- baudrate=115200
- bootargs=root=/dev/nfs nfsroot=192.168.100.100:/rootnfs rw console=ttySAC2,115200 init=/linuxrc ip=192.168.100.110
- bootcmd=tftp 41000000 linux;tftp 42000000 dt.dtb;bootm 41000000 - 42000000
- bootdelay=3
- ethact=dm9000
- ethaddr=00:1a:2b:33:44:55
- fileaddr=41000000
- filesize=80B00
- gatewayip=192.168.100.1
- ipaddr=192.168.100.110
- netmask=255.255.255.0
- serverip=192.168.100.100
- stderr=serial
- stdin=serial
- stdout=serial
- Environment size: 457/16380 bytes
- ex4412 #
复制代码 3. 把 U-Boot 引导程序写入到 eMMC 的启动分区
因为 eMMC 中的启动分区比较重要,所以 U-Boot 引导程序会给 eMMC 中的启动分区加一把锁以防止随意修改导致启动不了等意外情况的发生。我们需要先解锁,然后再把 U-Boot 引导程序写入到 eMMC 的启动分区,最后上锁。
使用如下命令给 eMMC 中的启动分区加锁、解锁:- emmc <open/close> <eMMc编号>
复制代码 其中,open/close 分别表示解锁和上锁。
根据我们“伍、从eMMC启动 Linux 系统程序”部分的 eMMC 的空间布局设计,操作的命令如下:- emmc open 0
- mmc write 0 0x41000000 0x0 0x500
- emmc close 0
复制代码 运行结果:- ex4412 # emmc open 0
- ex4412 # mmc write 0 0x41000000 0x0 0x500
- MMC write: dev # 0, block # 0, count 1280. 1280 blocks write finish
- 1280 blocks verify1: OK
- ex4412 # emmc close 0
- eMMC CLOSE Success.!!
- ex4412 #
复制代码 成功~
4. 设置开发板从 eMMC 的启动分区启动
拔出 SD 卡,使用拨码开关或者其他方式,设置开发板从 eMMC 启动:- U-Boot 2013.01 (Mar 29 2025 - 15:17:15) for ex4412
- CPU: Exynos4412@1000MHz
- Board: ORIGEN
- DRAM: 1 GiB
- WARNING: Caches not enabled
- PMIC: S5M8767(VER5.0)
- MMC: MMC0: 14910 MB
- In: serial
- Out: serial
- Err: serial
- MMC read: dev # 0, block # 48, count 16 ...16 blocks read: OK
- eMMC CLOSE Success.!!
- Checking Boot Mode ... EMMC4.41
- Net: dm9000
- Hit any key to stop autoboot: 0
- ex4412 #
复制代码 成功~
5. 恢复环境变量
使用 printenv 检查环境变量是否还存在,若不存在,需要我们把之前备份的环境变量恢复一下:- setenv baudrate 115200
- setenv bootargs "root=/dev/nfs nfsroot=192.168.100.100:/rootnfs rw console=ttySAC2,115200 init=/linuxrc ip=192.168.100.110"
- setenv bootcmd "tftp 41000000 linux;tftp 42000000 dt.dtb;bootm 41000000 - 42000000"
- setenv bootdelay 3
- setenv ethact dm9000
- setenv ethaddr 00:1a:2b:33:44:55
- setenv fileaddr 41000000
- setenv filesize 80B00
- setenv gatewayip 192.168.100.1
- setenv ipaddr 192.168.100.110
- setenv netmask 255.255.255.0
- setenv serverip 192.168.100.100
- setenv stderr serial
- setenv stdin serial
- setenv stdout serial
复制代码 设置完记得用 saveenv 保存一下。
运行结果:
6. 试验
在不插入 SD 卡的情况下,打开电源,开发板输出如下信息:- U-Boot 2013.01 (Mar 29 2025 - 15:17:15) for ex4412
- CPU: Exynos4412@1000MHz
- Board: ORIGEN
- DRAM: 1 GiB
- WARNING: Caches not enabled
- PMIC: S5M8767(VER5.0)
- MMC: MMC0: 14910 MB
- In: serial
- Out: serial
- Err: serial
- MMC read: dev # 0, block # 48, count 16 ...16 blocks read: OK
- eMMC CLOSE Success.!!
- Checking Boot Mode ... EMMC4.41
- Net: dm9000
- Hit any key to stop autoboot: 0
- dm9000 i/o: 0x5000000, id: 0x90000a46
- DM9000: running in 16 bit mode
- MAC: 00:1a:2b:33:44:55
- operating at 100M full duplex mode
- Using dm9000 device
- TFTP from server 192.168.100.100; our IP address is 192.168.100.110
- Filename 'linux'.
- Load address: 0x41000000
- Loading: #################################################################
- #################################################################
- #################################################################
- ###########
- 1.1 MiB/s
- done
- Bytes transferred = 3019120 (2e1170 hex)
- dm9000 i/o: 0x5000000, id: 0x90000a46
- DM9000: running in 16 bit mode
- MAC: 00:1a:2b:33:44:55
- operating at 100M full duplex mode
- Using dm9000 device
- TFTP from server 192.168.100.100; our IP address is 192.168.100.110
- Filename 'dt.dtb'.
- Load address: 0x42000000
- Loading: ###
- 1.1 MiB/s
- done
- Bytes transferred = 34358 (8636 hex)
- ## Booting kernel from Legacy Image at 41000000 ...
- Image Name: Linux-3.14.0
- Image Type: ARM Linux Kernel Image (uncompressed)
- Data Size: 3019056 Bytes = 2.9 MiB
- Load Address: 40008000
- Entry Point: 40008000
- Verifying Checksum ... OK
- ## Flattened Device Tree blob at 42000000
- Booting using the fdt blob at 0x42000000
- Loading Kernel Image ... OK
- OK
- Loading Device Tree to 4fff4000, end 4ffff635 ... OK
- Starting kernel ...
- [ 0.000000] Booting Linux on physical CPU 0xa00
- [ 0.000000] Linux version 3.14.0 (linux@linux) (gcc version 4.6.4 (crosstool-NG hg+default-2685dfa9de14 - tc0002) ) #5 SMP PREEMPT Thu Apr 17 22:17:51 EDT 2024
- [ 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: Insignal Origen evaluation board based on Exynos4412
- [ 0.000000] Memory policy: Data cache writealloc
- [ 0.000000] CPU EXYNOS4412 (id 0xe4412011)
- [ 0.000000] Running under secure firmware.
- [ 0.000000] PERCPU: Embedded 7 pages/cpu @eefb6000 s7424 r8192 d13056 u32768
- [ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 256528
- [ 0.000000] Kernel command line: root=/dev/nfs nfsroot=192.168.100.100:/rootnfs rw console=ttySAC2,115200 init=/linuxrc ip=192.168.100.110
- [ 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: 1016860K/1032192K available (3948K kernel code, 236K rwdata, 1316K rodata, 231K init, 276K bss, 15332K reserved, 270336K highmem)
- [ 0.000000] Virtual kernel memory layout:
- [ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB)
- [ 0.000000] fixmap : 0xfff00000 - 0xfffe0000 ( 896 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 - 0xc052c258 (5265 kB)
- [ 0.000000] .init : 0xc052d000 - 0xc0566d00 ( 232 kB)
- [ 0.000000] .data : 0xc0568000 - 0xc05a3340 ( 237 kB)
- [ 0.000000] .bss : 0xc05a334c - 0xc05e8384 ( 277 kB)
- [ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
- [ 0.000000] Preemptible hierarchical RCU implementation.
- [ 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] Exynos4x12 clocks: sclk_apll = 500000000, sclk_mpll = 800000000
- [ 0.000000] sclk_epll = 96000000, sclk_vpll = 350000000, arm_clk = 1000000000
- [ 0.000000] sched_clock: 32 bits at 200 Hz, resolution 5000000ns, wraps every 10737418240000000ns
- [ 0.000000] Console: colour dummy device 80x30
- [ 0.045000] Calibrating delay loop... 1992.29 BogoMIPS (lpj=4980736)
- [ 0.045000] pid_max: default: 32768 minimum: 301
- [ 0.045000] Mount-cache hash table entries: 2048 (order: 1, 8192 bytes)
- [ 0.045000] Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes)
- [ 0.050000] CPU: Testing write buffer coherency: ok
- [ 0.050000] missing device node for CPU 0
- [ 0.050000] missing device node for CPU 1
- [ 0.050000] missing device node for CPU 2
- [ 0.050000] missing device node for CPU 3
- [ 0.050000] CPU0: thread -1, cpu 0, socket 10, mpidr 80000a00
- [ 0.050000] Setting up static identity map for 0x403be650 - 0x403be6a8
- [ 0.070000] CPU1: Booted secondary processor
- [ 0.090000] CPU1: thread -1, cpu 1, socket 10, mpidr 80000a01
- [ 0.100000] CPU2: Booted secondary processor
- [ 0.120000] CPU2: thread -1, cpu 2, socket 10, mpidr 80000a02
- [ 0.130000] CPU3: Booted secondary processor
- [ 0.150000] CPU3: thread -1, cpu 3, socket 10, mpidr 80000a03
- [ 0.150000] Brought up 4 CPUs
- [ 0.150000] SMP: Total of 4 processors activated.
- [ 0.150000] CPU: All CPU(s) started in SVC mode.
- [ 0.150000] devtmpfs: initialized
- [ 0.150000] VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4
- [ 0.155000] pinctrl core: initialized pinctrl subsystem
- [ 0.155000] regulator-dummy: no parameters
- [ 0.155000] NET: Registered protocol family 16
- [ 0.155000] DMA: preallocated 256 KiB pool for atomic coherent allocations
- [ 0.175000] S3C Power Management, Copyright 2004 Simtec Electronics
- [ 0.175000] EXYNOS4x12 PMU Initialize
- [ 0.175000] EXYNOS: Initializing architecture
- [ 0.210000] bio: create slab <bio-0> at 0
- [ 0.210000] VMEM_VDD_2.8V: 2800 mV
- [ 0.215000] SCSI subsystem initialized
- [ 0.215000] usbcore: registered new interface driver usbfs
- [ 0.215000] usbcore: registered new interface driver hub
- [ 0.215000] usbcore: registered new device driver usb
- [ 0.220000] s3c-i2c 13860000.i2c: slave address 0x00
- [ 0.220000] s3c-i2c 13860000.i2c: bus frequency set to 19 KHz
- [ 0.220000] sec_pmic 0-0066: No interrupt specified, no interrupts
- [ 0.245000] VDD_ALIVE: failed to apply 1100000uV constraint
- [ 0.245000] s5m8767-pmic s5m8767-pmic: regulator init failed for 0
- [ 0.245000] s3c-i2c 13860000.i2c: i2c-0: S3C I2C adapter
- [ 0.245000] Switched to clocksource mct-frc
- [ 0.275000] NET: Registered protocol family 2
- [ 0.275000] TCP established hash table entries: 8192 (order: 3, 32768 bytes)
- [ 0.275000] TCP bind hash table entries: 8192 (order: 5, 163840 bytes)
- [ 0.275000] TCP: Hash tables configured (established 8192 bind 8192)
- [ 0.275000] TCP: reno registered
- [ 0.275000] UDP hash table entries: 512 (order: 2, 24576 bytes)
- [ 0.275000] UDP-Lite hash table entries: 512 (order: 2, 24576 bytes)
- [ 0.275000] NET: Registered protocol family 1
- [ 0.275000] RPC: Registered named UNIX socket transport module.
- [ 0.275000] RPC: Registered udp transport module.
- [ 0.275000] RPC: Registered tcp transport module.
- [ 0.275000] RPC: Registered tcp NFSv4.1 backchannel transport module.
- [ 0.280000] futex hash table entries: 1024 (order: 4, 65536 bytes)
- [ 0.280000] bounce pool size: 64 pages
- [ 0.305000] ROMFS MTD (C) 2007 Red Hat, Inc.
- [ 0.305000] msgmni has been set to 1458
- [ 0.310000] io scheduler noop registered
- [ 0.310000] io scheduler deadline registered
- [ 0.310000] io scheduler cfq registered (default)
- [ 0.325000] dma-pl330 12680000.pdma: Loaded driver for PL330 DMAC-1315632
- [ 0.325000] dma-pl330 12680000.pdma: DBUFF-32x4bytes Num_Chans-8 Num_Peri-32 Num_Events-32
- [ 0.335000] dma-pl330 12690000.pdma: Loaded driver for PL330 DMAC-1315632
- [ 0.335000] dma-pl330 12690000.pdma: DBUFF-32x4bytes Num_Chans-8 Num_Peri-32 Num_Events-32
- [ 0.335000] dma-pl330 12850000.mdma: Loaded driver for PL330 DMAC-1315632
- [ 0.335000] dma-pl330 12850000.mdma: DBUFF-64x8bytes Num_Chans-8 Num_Peri-1 Num_Events-32
- [ 0.555000] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
- [ 0.555000] 13800000.serial: ttySAC0 at MMIO 0x13800000 (irq = 84, base_baud = 0) is a S3C6400/10
- [ 0.555000] 13810000.serial: ttySAC1 at MMIO 0x13810000 (irq = 85, base_baud = 0) is a S3C6400/10
- [ 0.555000] 13820000.serial: ttySAC2 at MMIO 0x13820000 (irq = 86, base_baud = 0) is a S3C6400/10
- [ 1.170000] console [ttySAC2] enabled
- [ 1.175000] 13830000.serial: ttySAC3 at MMIO 0x13830000 (irq = 87, base_baud = 0) is a S3C6400/10
- [ 1.200000] brd: module loaded
- [ 1.210000] loop: module loaded
- [ 1.215000] dm9000 5000000.ethernet: read wrong id 0x01010101
- [ 1.220000] eth0: dm9000a at f0076000,f0078004 IRQ 167 MAC: 00:0a:2d:a6:55:a2 (platform data)
- [ 1.230000] usbcore: registered new interface driver asix
- [ 1.235000] usbcore: registered new interface driver ax88179_178a
- [ 1.240000] usbcore: registered new interface driver cdc_ether
- [ 1.245000] usbcore: registered new interface driver smsc75xx
- [ 1.250000] usbcore: registered new interface driver smsc95xx
- [ 1.255000] usbcore: registered new interface driver net1080
- [ 1.260000] usbcore: registered new interface driver cdc_subset
- [ 1.270000] usbcore: registered new interface driver zaurus
- [ 1.275000] usbcore: registered new interface driver cdc_ncm
- [ 1.280000] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
- [ 1.285000] ehci-exynos: EHCI EXYNOS driver
- [ 1.290000] exynos-ehci 12580000.ehci: no platform data or transceiver defined
- [ 1.295000] platform 12580000.ehci: Driver exynos-ehci requests probe deferral
- [ 1.305000] usbcore: registered new interface driver usb-storage
- [ 1.320000] usb3503 8.usb3503: switched to HUB mode
- [ 1.325000] usb3503 8.usb3503: usb3503_probe: probed in hub mode
- [ 1.330000] mousedev: PS/2 mouse device common for all mice
- [ 1.340000] input: 100a0000.keypad as /devices/100a0000.keypad/input/input0
- [ 1.345000] device-mapper: ioctl: 4.27.0-ioctl (2013-10-30) initialised: dm-devel@redhat.com
- [ 1.355000] sdhci: Secure Digital Host Controller Interface driver
- [ 1.360000] sdhci: Copyright(c) Pierre Ossman
- [ 1.365000] s3c-sdhci 12530000.sdhci: clock source 2: mmc_busclk.2 (40000000 Hz)
- [ 1.370000] mmc0: no vqmmc regulator found
- [ 1.375000] mmc0: no vmmc regulator found
- [ 1.410000] mmc0: SDHCI controller on samsung-hsmmc [12530000.sdhci] using ADMA
- [ 1.415000] Synopsys Designware Multimedia Card Interface Driver
- [ 1.420000] dwmmc_exynos 12550000.mmc: no vmmc regulator found: -19
- [ 1.425000] dwmmc_exynos 12550000.mmc: Using internal DMA controller.
- [ 1.430000] dwmmc_exynos 12550000.mmc: Version ID is 240a
- [ 1.440000] dwmmc_exynos 12550000.mmc: DW MMC controller at irq 109, 32 bit host data width, 128 deep fifo
- [ 1.480000] dwmmc_exynos 12550000.mmc: 1 slots initialized
- [ 1.490000] usbcore: registered new interface driver usbhid
- [ 1.495000] usbhid: USB HID core driver
- [ 1.495000] TCP: cubic registered
- [ 1.500000] NET: Registered protocol family 17
- [ 1.505000] NET: Registered protocol family 15
- [ 1.510000] Registering SWP/SWPB emulation handler
- [ 1.515000] VMEM_VDD_2.8V: disabling
- [ 1.520000] regulator-dummy: disabling
- [ 1.520000] exynos-ehci 12580000.ehci: EHCI Host Controller
- [ 1.525000] exynos-ehci 12580000.ehci: new USB bus registered, assigned bus number 1
- [ 1.535000] exynos-ehci 12580000.ehci: irq 102, io mem 0x12580000
- [ 1.545000] mmc1: BKOPS_EN bit is not set
- [ 1.550000] exynos-ehci 12580000.ehci: USB 2.0 started, EHCI 1.00
- [ 1.550000] hub 1-0:1.0: USB hub found
- [ 1.550000] hub 1-0:1.0: 3 ports detected
- [ 1.550000] drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
- [ 1.570000] mmc_host mmc1: Bus speed (slot 0) = 50000000Hz (slot req 52000000Hz, actual 50000000HZ div = 0)
- [ 1.580000] mmc_host mmc1: Bus speed (slot 0) = 100000000Hz (slot req 52000000Hz, actual 50000000HZ div = 1)
- [ 1.580000] dm9000 5000000.ethernet eth0: link down
- [ 1.595000] mmc1: new high speed DDR MMC card at address 0001
- [ 1.600000] mmcblk0: mmc1:0001 AJTD4R 14.5 GiB
- [ 1.605000] mmcblk0boot0: mmc1:0001 AJTD4R partition 1 4.00 MiB
- [ 1.610000] mmcblk0boot1: mmc1:0001 AJTD4R partition 2 4.00 MiB
- [ 1.615000] mmcblk0rpmb: mmc1:0001 AJTD4R partition 3 4.00 MiB
- [ 1.620000] mmcblk0: p1 p2 p3 p4
- [ 1.630000] mmcblk0boot1: unknown partition table
- [ 1.635000] mmcblk0boot0: unknown partition table
- [ 1.785000] dm9000 5000000.ethernet eth0: link up, 100Mbps, full-duplex, lpa 0xCDE1
- [ 1.790000] IP-Config: Guessing netmask 255.255.255.0
- [ 1.790000] IP-Config: Complete:
- [ 1.790000] device=eth0, hwaddr=00:0a:2d:a6:55:a2, ipaddr=192.168.100.110, mask=255.255.255.0, gw=255.255.255.255
- [ 1.790000] host=192.168.100.110, domain=, nis-domain=(none)
- [ 1.790000] bootserver=255.255.255.255, rootserver=192.168.100.100, rootpath=
- [ 1.790000] clk: Not disabling unused clocks
- [ 1.850000] VFS: Mounted root (nfs filesystem) on device 0:10.
- [ 1.855000] devtmpfs: mounted
- [ 1.860000] Freeing unused kernel memory: 228K (c052d000 - c0566000)
- [ 1.885000] usb 1-3: new high-speed USB device number 2 using exynos-ehci
- [ 2.030000] hub 1-3:1.0: USB hub found
- [ 2.035000] hub 1-3:1.0: 3 ports detected
- [root@yieq4412 ]# ls
- bin etc linuxrc mnt root sys usr
- dev lib lost+found proc sbin tmp var
- [root@yieq4412 ]#
复制代码 成功启动到 Linux 系统程序中去了!
捌、总结
本文介绍了如何使用 U-Boot 引导程序加载并启动 Linux 系统程序的几种方式,每种方式各有特点。开发时用得比较多的是 TFTP 加载 Linux 系统程序和 DTB 设备树文件,NFS 加载 RootFS 根文件系统;生产环境用得比较多的是从 eMMC 启动 U-Boot 引导程序并从 eMMC 加载 Linux 系统程序、DTB 设备树文件和 RootFS 根文件系统并启动 Linux 系统程序。
以上就是本文的全部内容,有什么疑问的可以在评论区讨论一下~
玖、参考资料
- U-Boot:https://www.u-boot.org/
- Win32 Disk Imager:https://sourceforge.net/projects/win32diskimager/
来源:程序园用户自行投稿发布,如果侵权,请联系站长删除
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作! |