根据我的理解,uImage 是通过在 Image 上运行 mkimage 获得的
您的理解仅部分正确。
A uImage可以包含任何类型的文件,并且不限于LinuxImage文件。事实上它不太可能是(未压缩的)Image文件(因为这不是传统的make选项)。
另一方面,zImage 是压缩图像,它不包含加载地址和入口点(我的想法,如果我[原文如此]错了,请纠正我)
你错了,是zImage确实包含内核的加载地址和入口点。需要加载地址才能将内核映像解压到正确的 RAM 地址。解压后需要内核的入口点来执行它。
为 ARM 构建 Image 和 zImage 时,Makefile 使用
ZRELADDR == virt_to_phys(PAGE_OFFSET + TEXT_OFFSET)
这应该转换为物理内存的开头 + 0x8000。
zImage 本身(即自解压程序)是 PIC,位置无关代码。 zImage可以加载到RAM中的任何位置,并在其首地址执行,即它的入口点是它的加载地址。
在这种情况下,为什么使用 uImage 而不是 zImage?
对于旧版本的 U-Boot,没有选择,因为bootz命令可能不适用于 Linux 内核。
如今,这可能是一种主观选择。
请注意,Linux 内核社区对内核中对 U-Boot 的支持存在一些不满。 IOW,如果有些人按他们的方式行事,我的印象是你将无法建立一个uImage来自主线源。
我[原文如此]很想了解 zImage 和 uImage 的格式是什么,您能否建议一些参考资料?
zImage 的布局本质上是由其链接器规范给出的。
对于 ARM,请参阅arch/arm/boot/compressed/vmlinux.lds.S.
注意_magic_start包含无意义的加载地址。 Vincent Sanders 的第 5 节也提到了这一点引导 ARM Linux
The zImage has a magic number and some useful information near its beginning.
Table 2. Useful fields in zImage head code
Offset into zImage Value Description
0x24 0x016F2818 Magic number used to identify this is an ARM Linux zImage
0x28 start address The address the zImage starts at
0x2C end address The address the zImage ends at
The start and end offsets can be used to determine the length of the compressed image (size = end - start).
...
The start address is usually 0 as the zImage code is position independent.
但请注意,ARM 启动要求已被 Russel King 的启动要求取代文档/手臂/启动
uImage 的布局只是 U-Boot 标头加上图像文件(无论是什么)。
(希望我所写的内容与汤姆·里尼所写的内容没有矛盾。)