objcopy 得到的镜像是可以被 u-boot 加载执行的
arch/arm/boot/Image
arch/arm/boot/zImage
arch/arm/boot/uImage
在 https://blog.csdn.net/u011011827/article/details/115380889 中 说明了
u-boot 镜像可以怎么用
linux 和 u-boot 是一样的 ,请参考 链接中 的 "文件数据的解析"
bin-linux 的 00000000 位置 的 32bit 数据 是 b reset 的 二进制码
但是 elf-linux 的 00000 位置 是 elf 格式的格式相关码
当然 如果 u-boot 有加载 并执行 elf 文件的能力的话,应该也可以加载 elf-linux
当然 如果 spl 有加载 elf/xxx 格式 的可执行文件, 应该也可以加载 elf-u-boot xxx-u-boot
linux-5.11 镜像 的生成过程
vmlinux -objcopy-> arch/arm/boot/Image
arch/arm/boot/Image -gzip & add arch/arm/boot/compressed/head.S-> arch/arm/boot/compressed/vmlinux
arch/arm/boot/compressed/vmlinux -objcopy-> arch/arm/boot/zImage
arch/arm/boot/zImage -mkuboot-> arch/arm/boot/uImage
7.4M vmlinux
8.6M arch/arm/boot/Image
2.9M arch/arm/boot/compressed/vmlinux
2.8M arch/arm/boot/zImage
2.8M arch/arm/boot/uImage
镜像uImage的执行
arch/arm/boot/uImage 是 make uImage 过程中 自动生成的
bash ./scripts/mkuboot.sh -A arm -O linux -C none -T kernel -a 0x50008000 -e 0x50008000 -n 'Linux-5.11.0-00004-g2b88cbadf5c-dirty' -d arch/arm/boot/zImage arch/arm/boot/uImage
bootcmd=tftp 0x50008000 uImage;bootm 0x50008000
=> tftp 0x50008000 uImage
dm9000 i/o: 0x18000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: e2:7c:ef:97:da:b4
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 10.10.11.59; our IP address is 10.10.11.120
Filename 'uImage'.
Load address: 0x50008000
Loading: #################################################################
#################################################################
#################################################################
####
1 MiB/s
done
Bytes transferred = 2913360 (2c7450 hex)
=> bootm 0x50008000
## Booting kernel from Legacy Image at 50008000 ...
Image Name: Linux-5.11.0-00004-g2b88cbadf5c-
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2913296 Bytes = 2.8 MiB
Load Address: 50008000
Entry Point: 50008000
Verifying Checksum ... OK
Loading Kernel Image
Starting kernel ...
Booting Linux on physical CPU 0x0
Linux version 5.11.0-00004-g2b88cbadf5c-dirty (suws@ubuntu) (arm-linux-gnueabi-gcc (Linaro GCC 7.4-2019.02) 7.4.1 20181213 [linaro-7.4-2019.02 revision 56ec6f6b99cc167ff0c2f8e1a2eed33b1edc85d4], GNU ld (Linaro_Binutils-2019.02) 2.28.2.20170706) #44 Fri Apr 16 14:06:43 CST 2021
CPU: ARMv6-compatible processor [410fb766] revision 6 (ARMv7), cr=00c5387d
镜像Image的执行
将 arch/arm/boot/Image 直接 加个 uImage头,生成 arch/arm/boot/uImage2
bash ./scripts/mkuboot.sh -A arm -O linux -C none -T kernel -a 0x50008000 -e 0x50008000 -n 'Linux-5.11.0-00004-g2b88cbadf5c-dirty' -d arch/arm/boot/Image arch/arm/boot/uImage2
=> bootm 0x50008000
## Booting kernel from Legacy Image at 50008000 ...
Image Name: Linux-5.11.0-00004-g2b88cbadf5c-
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 8938664 Bytes = 8.5 MiB
Load Address: 50008000
Entry Point: 50008000
Verifying Checksum ... OK
Loading Kernel Image
Image too large: increase CONFIG_SYS_BOOTM_LEN
Must RESET board to recover
resetting ...
reset...
diff --git a/include/configs/ok6410a.h b/include/configs/ok6410a.h
index 2808281..66d1c41 100755
--- a/include/configs/ok6410a.h
+++ b/include/configs/ok6410a.h
@@ -213,5 +213,6 @@
#undef CONFIG_DEBUG_UART_CLOCK
#define CONFIG_DEBUG_UART_CLOCK get_uart_clk(0)
+#define CONFIG_SYS_BOOTM_LEN SZ_64M
#endif
=> tftp 0x50008000 uImage2
dm9000 i/o: 0x18000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: e2:7c:ef:97:da:b4
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 10.10.11.59; our IP address is 10.10.11.120
Filename 'uImage2'.
Load address: 0x50008000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
########################
1.2 MiB/s
done
Bytes transferred = 8938728 (8864e8 hex)
=> bootm 0x50008000
## Booting kernel from Legacy Image at 50008000 ...
Image Name: Linux-5.11.0-00004-g2b88cbadf5c-
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 8938664 Bytes = 8.5 MiB
Load Address: 50008000
Entry Point: 50008000
Verifying Checksum ... OK
Loading Kernel Image
Starting kernel ...
Booting Linux on physical CPU 0x0
Linux version 5.11.0-00004-g2b88cbadf5c-dirty (suws@ubuntu) (arm-linux-gnueabi-gcc (Linaro GCC 7.4-2019.02) 7.4.1 20181213 [linaro-7.4-2019.02 revision 56ec6f6b99cc167ff0c2f8e1a2eed33b1edc85d4], GNU ld (Linaro_Binutils-2019.02) 2.28.2.20170706) #44 Fri Apr 16 14:06:43 CST 2021
CPU: ARMv6-compatible processor [410fb766] revision 6 (ARMv7), cr=00c5387d
不能直接执行的镜像
镜像arch/arm/boot/compressed/vmlinux的执行
bash ./scripts/mkuboot.sh -A arm -O linux -C none -T kernel -a 0x50008000 -e 0x50008000 -n 'Linux-5.11.0-00004-g2b88cbadf5c-dirty' -d arch/arm/boot/compressed/vmlinux arch/arm/boot/uImage3
=> tftp 0x50008000 uImage3
dm9000 i/o: 0x18000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: e2:7c:ef:97:da:b4
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 10.10.11.59; our IP address is 10.10.11.120
Filename 'uImage3'.
Load address: 0x50008000
Loading: #################################################################
#################################################################
#################################################################
#########
1.2 MiB/s
done
Bytes transferred = 2985716 (2d8ef4 hex)
=> bootm 0x50008000
## Booting kernel from Legacy Image at 50008000 ...
Image Name: Linux-5.11.0-00004-g2b88cbadf5c-
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2985652 Bytes = 2.8 MiB
Load Address: 50008000
Entry Point: 50008000
Verifying Checksum ... OK
Loading Kernel Image
Starting kernel ...
data abort
pc : [<50008024>] lr : [<5ff30e5c>]
reloc pc : [<4fbd8024>] lr : [<5fb00e5c>]
sp : 5fe2eca0 ip : 00000024 fp : 00000001
r10: 00000001 r9 : 5fe2fee0 r8 : 5fe2eca0
r7 : 00000000 r6 : 50008000 r5 : 5ff6a4e4 r4 : 00000000
r3 : 5fe2ffb0 r2 : 50000100 r1 : 0000065a r0 : 00000000
Flags: nZCv IRQs off FIQs off Mode SVC_32
Code: 00000001 00000000 00000034 002d8c5c (05000200)
Resetting CPU ...
resetting ...
reset...
镜像vmlinux的执行
bash ./scripts/mkuboot.sh -A arm -O linux -C none -T kernel -a 0x50008000 -e 0x50008000 -n 'Linux-5.11.0-00004-g2b88cbadf5c-dirty' -d vmlinux arch/arm/boot/uImage4
=> tftp 0x50008000 uImage4
dm9000 i/o: 0x18000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: e2:7c:ef:97:da:b4
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 10.10.11.59; our IP address is 10.10.11.120
Filename 'uImage4'.
Load address: 0x50008000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
########
1.2 MiB/s
done
Bytes transferred = 7743116 (76268c hex)
=> bootm 0x50008000
## Booting kernel from Legacy Image at 50008000 ...
Image Name: Linux-5.11.0-00004-g2b88cbadf5c-
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 7743052 Bytes = 7.4 MiB
Load Address: 50008000
Entry Point: 50008000
Verifying Checksum ... OK
Loading Kernel Image
Starting kernel ...
undefined instruction
pc : [<5000809c>] lr : [<5ff30e5c>]
reloc pc : [<4fbd809c>] lr : [<5fb00e5c>]
sp : 5fe2eca0 ip : 00000024 fp : 00000001
r10: 00000001 r9 : 5fe2fee0 r8 : 00000400
r7 : 00000000 r6 : 50008000 r5 : 5ff6a4e4 r4 : 00000000
r3 : 5fe2ffb0 r2 : afff8000 r1 : 0000065a r0 : 00000000
Flags: Nzcv IRQs off FIQs off Mode SVC_32
Code: 00000006 00010000 00000001 00530000 (ffff0000)
Resetting CPU ...
resetting ...
reset...