使用 LOADADDR 构建内核 uImage

Building kernel uImage using LOADADDR

在构建内核时,我将 LOADADDR 设置为“0x80008000”:

make uImage LOADADDR=0x80008000

你能帮忙理解一下这个有什么用吗?我可以更改LOADADDR吗,LOADADDR的长度有什么限制吗?

(我假设您根据 U-Boot 的提及和 LOADADDR 的值使用 ARM。)

Can you please help to understand what is the use of this?

LOADADDR 指定内核映像将由链接器定位的地址。(这适用于一些体系结构(例如 Blackfin),但不适用于 ARM。

LOADADDR 由 U-Boot 指定内核映像所在的地址,并由 mkimage 存储在 U-Boot header 中效用。通常加载地址(用于放置在内存中)也是起始地址(用于执行)。请注意,uImage 文件通常只是带有 U-Boot 包装器的(self-extracting,压缩的)zImage 文件。

Can I change the LOADADDR,

是的,但根据(Vincent Sanders)Booting ARM Linux这将违反 ARM 惯例:

  • 尽管能够将 zImage 放置在内存中的任何位置, 惯例是它被加载到物理 RAM 的底部加上 0x8000 (32K) 的偏移量。这为参数块留下 space 通常放置在偏移量 0x100、零页异常向量和页 表。这种约定很常见。

(您问题中提到的 uImage 可能只是带有 U-Boot 包装器的 zImage,因此引文适用。)

is there any restriction on the length of the LOADADDR?

长度”?如果您使用的是 32 位处理器,则此地址的长度将为 32 位。


附录

arch/arm/boot/Makefile 仅使用 LOADADDR 从 zImage 构建 uImage。

来自 (Russel King's) Booting ARM Linux 此 LOADADDR 的约束是:

The kernel should be placed in the first 128MiB of RAM. It is recommended that it is loaded above 32MiB in order to avoid the need to relocate prior to decompression, which will make the boot process slightly faster.

When booting a raw (non-zImage) kernel the constraints are tighter. In this case the kernel must be loaded at an offset into system equal to TEXT_OFFSET - PAGE_OFFSET.

设备树或 ATAG 或 initramfs 的预期位置可以在此 LOADADDR 上添加更多约束。