我使用 FIT 多映像(映像 + initrd + DTB)在arm64上启动Linux。如果我增加 initrd 大小(从 16 MB -> 20MB),主板将挂在“启动内核”处。但是,如果我更改 bootm 的加载地址(从 0x2000000 到 0x1000000),它会成功启动。关于为什么在较低负载地址启动的任何指示? bootm多镜像加载地址与Image、initrd、FDT最终跳转地址有什么关系?
看来当 FIT bin 在 0x2000000 处加载时,它会覆盖内核或 DTB。如果我连接 JTAG,我可以看到内核正在跳转到 head.S,但进入未定义状态。
- 主板配置:2 GB RAM (0x00000000 - 0x8000000)
- Init high 已启用(因此 initrd 被重新定位到 high mem)
- FDT_high=0xffffffffffffffff所以就地使用了DTB。
- FDT加载地址为(0x9000000)
控制台输出:
## Current stack ends at 0x7f6cc6c0 * kernel: cmdline image address = 0x02000000
## Loading kernel from FIT Image at 02000000 ...
Using 'config@1' configuration
Verifying Hash Integrity ... OK
Trying 'kernel@0' kernel subimage
Description: linux-mvl-4.4
Type: Kernel Image
Compression: uncompressed
Data Start: 0x020000bc
Data Size: 12473856 Bytes = 11.9 MiB
Architecture: AArch64
OS: Linux
Load Address: 0x00080000
Entry Point: 0x00080000
Verifying Hash Integrity ... OK
kernel data at 0x020000bc, len = 0x00be5600 (12473856)
* ramdisk: using config 'config@1' from image at 0x02000000
## Loading ramdisk from FIT Image at 02000000 ...
Using 'config@1' configuration
Trying 'ramdisk@0' ramdisk subimage
Description: initramfs
Type: RAMDisk Image
Compression: lzma compressed
Data Start: 0x02be5764
Data Size: 22356891 Bytes = 21.3 MiB
Architecture: AArch64
OS: Linux
Can't get 'load' property from FIT 0x02000000, node: offset 12474104,
name ramdisk@0 (FDT_ERR_NOTFOUND)
Load Address: unavailable
Can't get 'entry' property from FIT 0x02000000, node: offset 12474104, name ramdisk@0 (FDT_ERR_NOTFOUND)
Entry Point: unavailable
Verifying Hash Integrity ... OK
Can't get 'load' property from FIT 0x02000000, node: offset 12474104, name
ramdisk@0 (FDT_ERR_NOTFOUND)
ramdisk start = 0x02be5764, ramdisk end = 0x04137aff
* fdt: using config 'config@1' from image at 0x02000000
## Checking for 'FDT'/'FDT Image' at 02000000
## Loading fdt from FIT Image at 02000000 ...
Using 'config@1' configuration
Trying 'fdt@1' fdt subimage
Description: P1 fdt
Type: Flat Device Tree
Compression: uncompressed
Data Start: 0x0413eadc
Data Size: 28899 Bytes = 28.2 KiB
Architecture: AArch64
Verifying Hash Integrity ... OK
Loading fdt from 0x0413eadc to 0x09000000
Booting using the fdt blob at 0x9000000
of_flat_tree at 0x09000000 size 0x000070e3
Loading Kernel Image ... OK
kernel loaded at 0x00080000, end = 0x00c65600
## initrd_high = 0x80000000, copy_to_ram = 1
Loading Ramdisk to 7e179000, end 7f6cb39b ... OK
ramdisk load start = 0x7e179000, ramdisk load end = 0x7f6cb39b
using: FDT
## DT length 41187
Using Device Tree in place at 0000000009000000, end 000000000900a0e2
mci_find_sb_node.....no Device found
DevID=100001f found on MCi bus 0
DevID=1000021 found on MCi bus 1
## Transferring control to Linux (at address 80000)...
######## Starting kernel ...
打印环境:
baudrate=115200
bl_ver=rxam-c1_V0.0.9.5
bootargs=console=ttyS0,115200 root=/dev/ram rw mtdparts=pxa3xx_nand- 0:1m(oops),1m(reserved),-(fs) ubi.mtd=fs
bootcmd=run bootcmd_nand
bootcmd_nand=nand read $fdt_addr 0x000000 0x100000&&nand read $loadaddr 0x100000 0x1200000&&setenv bootargs $console ubi.mtd=9,4096 root=ubi0:rootfs rootfstype=ubifs rw chk_data_crc rootdelay=2&&mochi reset&& mochi init&& mochi init armada70x0_1 &&booti $loadaddr - $fdt_addr
bootcmd_usb=setenv dtb_image armada-3900-axis_$fw_ver.dtb && set kernel_image Image_$fw_ver && usb reset; ext2load usb 0:1 $loadaddr $kernel_image; ext2load usb 0:1 $fdt_addr $dtb_image; setenv bootargs $console root=/dev/sda1 rw rootdelay=2; mochi reset&& mochi init&& mochi init armada70x0_1&& booti $loadaddr - $fdt_addr
bootdelay=2
bootfile=/tftpboot/gpxelinux.0
boottftp=tftp 0x2000000 /tftpboot/part.bin && bootm 0x2000000
console=console=ttyS0,115200
eraseenv=env default -fa &&saveenv
ethact=mvpp2-0
ethprime=mvpp2-0
fdt_addr=0x1000000
fdt_high=0xffffffffffffffff
fdtcontroladdr=7f6ccca0
fw_ver=rxam-c1_V0.0.9.5
gatewayip=10.4.50.254
hostname=Axel
ipaddr=192.168.1.1
kernel_addr=0x2000000
loadaddr=0x2000000
mtddevname=fs
mtddevnum=0
mtdids=nand0=pxa3xx_nand-0
mtdparts=mtdparts=pxa3xx_nand-0:1m(oops),1m(reserved),-(fs)
nad=setenv dtb_image armada-3900-axis_$fw_ver.dtb && tftpboot $fdt_addr $dtb_image&&nand erase 0x000000 0x100000&&nand write $fdt_addr 0x000000 $filesize
naf=setenv fs_image rootfs_$fw_ver.ubi && tftpboot $loadaddr $fs_image &&nand erase 0x1300000 0x1EB00000&&nand write $loadaddr 0x1300000 $filesize
nak=setenv kernel_image Image_$fw_ver && tftpboot $loadaddr $kernel_image &&nand erase 0x100000 0x1200000&&nand write $loadaddr 0x100000 $filesize
netmask=255.255.255.0
nob=setenv bl_image flash-image_$bl_ver.bin && tftpboot $loadaddr $bl_image &&sf probe 0:0 && sf update $loadaddr 0 $filesize
partition=nand0,0
preboot=printenv bl_ver;printenv fw_ver
rootpath=/srv/nfs/
serverip=172.19.35.87
set_bootargs=setenv bootargs $console $root ip=$ipaddr:$serverip:$gatewayip:$netmask:$hostname:$netdev:none nfsroot=$serverip:$rootpath $extra_params
stderr=serial@512000
stdin=serial@512000
stdout=serial@512000
tftpdir=/tftpboot/gumulla
upgradeall=run naf &&run nak &&run nad &&run nob&& reset
。它是:
/*
* U-boot FIT source file
*/
/dts-v1/;
/ {
description = "platform-config";
#address-cells = <1>;
images {
kernel@0 {
description = "linux-mvl-4.4";
data = /incbin/("Image");
type = "kernel";
arch = "arm64";
os = "linux";
compression = "none";
load = <0x80000>;
entry = <0x80000>;
};
ramdisk@0 {
description = "initramfs";
data = /incbin/("initramfs.lzma");
type = "ramdisk";
arch = "arm64";
os = "linux";
compression = "lzma";
};
/* P0 fdt */
fdt@0 {
description = "P0 fdt";
data = /incbin/("z1-sgmii-1g.dtb");
type = "flat_dt";
arch = "arm64";
compression = "none";
load = <0x9000001>;
};
/* P1 fdt */
fdt@1 {
description = "P1 fdt";
data = /incbin/("db-axis.dtb");
type = "flat_dt";
arch = "arm64";
compression = "none";
load = <0x9000000>;
};
};
configurations {
default = "config@0";
/* P0 image */
config@0 {
description = "P0 image";
kernel = "kernel@0";
ramdisk = "ramdisk@0";
fdt = "fdt@0";
hash@1 {
algo = "sha1";
};
};
/* P1 image */
config@1 {
description = "P1 image";
kernel = "kernel@0";
fdt = "fdt@1";
ramdisk = "ramdisk@0";
hash@1 {
algo = "sha1";
};
};
};
};
uboot重定位启用后新日志:
## Current stack ends at 0x7f6cc6c0 * kernel: cmdline image address = 0x02000000
## Loading kernel from FIT Image at 02000000 ...
Using 'config@1' configuration
Verifying Hash Integrity ... OK
Trying 'kernel@0' kernel subimage
Description: linux-mvl-4.4
Type: Kernel Image
Compression: uncompressed
Data Start: 0x020000bc
Data Size: 12473856 Bytes = 11.9 MiB
Architecture: AArch64
OS: Linux
Load Address: 0x00080000
Entry Point: 0x00080000
Verifying Hash Integrity ... OK
kernel data at 0x020000bc, len = 0x00be5600 (12473856)
* ramdisk: using config 'config@1' from image at 0x02000000
## Loading ramdisk from FIT Image at 02000000 ...
Using 'config@1' configuration
Trying 'ramdisk@0' ramdisk subimage
Description: initramfs
Type: RAMDisk Image
Compression: lzma compressed
Data Start: 0x02be5764
Data Size: 22365017 Bytes = 21.3 MiB
Architecture: AArch64
OS: Linux
Can't get 'load' property from FIT 0x02000000, node: offset 12474104, name ramdisk@0 (FDT_ERR_NOTFOUND)
Load Address: unavailable
Can't get 'entry' property from FIT 0x02000000, node: offset 12474104, name ramdisk@0 (FDT_ERR_NOTFOUND)
Entry Point: unavailable
Verifying Hash Integrity ... OK
Can't get 'load' property from FIT 0x02000000, node: offset 12474104, name ramdisk@0 (FDT_ERR_NOTFOUND)
ramdisk start = 0x02be5764, ramdisk end = 0x04139abd
* fdt: using config 'config@1' from image at 0x02000000
## Checking for 'FDT'/'FDT Image' at 02000000
## Loading fdt from FIT Image at 02000000 ...
Using 'config@1' configuration
Trying 'fdt@1' fdt subimage
Description: P1 fdt
Type: Flat Device Tree
Compression: uncompressed
Data Start: 0x04140a8c
Data Size: 28899 Bytes = 28.2 KiB
Architecture: AArch64
Verifying Hash Integrity ... OK
Loading fdt from 0x04140a8c to 0x09000000
Booting using the fdt blob at 0x9000000
of_flat_tree at 0x09000000 size 0x000070e3
Loading Kernel Image ... OK
kernel loaded at 0x00080000, end = 0x00c65600
## initrd_high = 0x80000000, copy_to_ram = 1
Loading Ramdisk to 7e177000, end 7f6cb359 ... OK
ramdisk load start = 0x7e177000, ramdisk load end = 0x7f6cb359
using: FDT
## DT length 41187
## device tree at 0000000009000000 ... 00000000090070e2 (len=41187 [0xA0E3])
Loading Device Tree to 000000007e16c000, end 000000007e1760e2 ... OK
mci_find_sb_node.....no Device found
DevID=100001f found on MCi bus 0
DevID=1000021 found on MCi bus 1
## Transferring control to Linux (at address 80000)...
######## Starting kernel ...
## Transferring control to Linux Done!
答案1
因此,正如OP评论的那样,移动加载地址可以解决问题。这凸显了使用的危险fdt_high(或者在其他情况下,初始化高) 阻止 U-Boot 重新定位内容。在像 FIT 映像这样的情况下,U-Boot 很清楚您通常想要使用的每个部分有多大引导大小告诉 U-Boot 在重新定位操作系统引导内容时要使用多少内存(从第一个存储体开始)。在这种特定情况下,您希望 initrd 位于高内存中,那么您需要使用特定值fdt_high这是内核将看到的空间内(在某些情况下,根据体系结构和内核版本的不同,请参阅操作系统文档,例如 linux/Documentation/arm64/booting.txt)。
答案2
事实证明,当图像大小增加时,它会访问 ARM psi 的保留区域。每次图像大小以某种方式增加时,我都必须确保在启动过程中不会触及该地址。
答案3
您必须根据可用 DRAM 大小、内核大小和选择加载 itb 的 clobstart 来重新计算内核和 fdt 节点的条目和加载属性值。