无法在Rasbperry Pi 4上使用FIT映像引导到内核

问题描述

我正在使用RaspBerry Pi 4,试图在其上添加经过验证的启动。我使用buildroot来构建基本的SD卡映像,并使用mkimage对该映像进行了签名。 我首先在u-boot控制台中通过以下两个选项进行测试:

测试1: 我使用了“ bootm 0x01000000”,然后让u-boot找出FIT映像中的设备树。

In:    serial
Out:   vidconsole
Err:   vidconsole
Net:   eth0: ethernet@7d580000
Hit any key to stop autoboot:  0 
U-Boot> setenv bootargs console=tty1  console=ttyAMA0,115200 root=/dev/mmcblk0p2 rootwait
U-Boot> printenv bootargs 
bootargs=console=tty1 console=ttyAMA0,115200 root=/dev/mmcblk0p2 rootwait
U-Boot> fatload mmc 0:1 0x01000000 Image
15731478 bytes read in 700 ms (21.4 MiB/s)
U-Boot> bootm 0x01000000
## Loading kernel from FIT Image at 01000000 ...
   Using 'config-1' configuration
   Verifying Hash Integrity ... OK
   Trying 'kernel-1' kernel subimage
     Description:  default kernel
     Type:         Kernel Image
     Compression:  uncompressed
     Data Start:   0x010000dc
     Data Size:    15682048 Bytes = 15 MiB
     Architecture: AArch64
     OS:           Linux
     Load Address: 0x00080000
     Entry Point:  0x00080000
     Hash algo:    sha1
     Hash value:   1f7b5be7099568611cbc76c0b83202ae5829073a
   Verifying Hash Integrity ... sha1+ OK
## Loading fdt from FIT Image at 01000000 ...
   Using 'config-1' configuration
   Verifying Hash Integrity ... OK
   Trying 'fdt-1' fdt subimage
     Description:  device tree
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x01ef4bc4
     Data Size:    47437 Bytes = 46.3 KiB
     Architecture: AArch64
     Hash algo:    sha1
     Hash value:   b0ba4b289dbcb0c1571103ca5a013aaddaebb03e
   Verifying Hash Integrity ... sha1+ OK
   Booting using the fdt blob at 0x1ef4bc4
   Loading Kernel Image
   Using Device Tree in place at 0000000001ef4bc4,end 0000000001f03510

Starting kernel ...

引导过程停留在此“正在启动内核...”消息上。

测试2: 我使用了“ bootm 0x01000000-0x2eff4000”,并使用$ {fdt_addr}在u-boot位置指定了设备树

In:    serial
Out:   vidconsole
Err:   vidconsole
Net:   eth0: ethernet@7d580000
Hit any key to stop autoboot:  2  0 
U-Boot> setenv bootargs console=tty1  console=ttyAMA0,115200 root=/dev/mmcblk0p2 rootwait
U-Boot> fatload mmc 0:1 0x01000000 Image
15731478 bytes read in 700 ms (21.4 MiB/s)
U-Boot> bootm 0x01000000 - 0x2eff4000
## Loading kernel from FIT Image at 01000000 ...
   Using 'config-1' configuration
   Verifying Hash Integrity ... OK
   Trying 'kernel-1' kernel subimage
     Description:  default kernel
     Type:         Kernel Image
     Compression:  uncompressed
     Data Start:   0x010000dc
     Data Size:    15682048 Bytes = 15 MiB
     Architecture: AArch64
     OS:           Linux
     Load Address: 0x00080000
     Entry Point:  0x00080000
     Hash algo:    sha1
     Hash value:   1f7b5be7099568611cbc76c0b83202ae5829073a
   Verifying Hash Integrity ... sha1+ OK
## Flattened Device Tree blob at 2eff4000
   Booting using the fdt blob at 0x2eff4000
   Loading Kernel Image
   Using Device Tree in place at 000000002eff4000,end 000000002f002f79

Starting kernel ...

[    0.000000] Booting Linux on physical cpu 0x0000000000 [0x410fd083]
[    0.000000] Linux version 5.4.51-v8 (xiangrong.li@ubuntu) (gcc version 9.3.0 (buildroot 2020.08)) #1 SMP PREEMPT Tue Nov 3 10:06:41 EST 2020
[    0.000000] Machine model: RaspBerry Pi 4 Model B Rev 1.2
[    0.000000] efi: Getting EFI parameters from FDT:
[    0.000000] efi: UEFI not found.

u-boot可以正常启动进入内核。

评论

  • 我从“图像”文件提取了设备树,并与bcm2711-rpi-4-b.dtb进行了比较。它们是完全一样的。
  • 似乎从FIT“映像”中提取的设备树无法将引导过程引导至内核。

我的FIT为其文件成像:

/dts-v1/;
/ {
    description = "RPi FIT Image";
    #address-cells = <2>;
    images {
        kernel-1 {
            description = "default kernel";
            data = /incbin/("Image");
            type = "kernel";
            arch = "arm64";
            os = "linux";
            compression = "none";
            load =  <0x00080000>;
            entry = <0x00080000>;
            hash-1 {
                algo = "sha1";
            };
        };
        fdt-1 {
            description = "device tree";
            data = /incbin/("bcm2711-rpi-4-b.dtb");
            type = "flat_dt";
            arch = "arm64";
            compression = "none";
            hash-1 {
                algo = "sha1";
            };
        };
    };
    configurations {
        default = "config-1";
        config-1 {
            description = "default configuration";
            kernel = "kernel-1";
            fdt = "fdt-1";
            signature-1 {
                algo = "sha1,rsa2048";
                key-name-hint = "dev";
                sign-images = "fdt","kernel";
            };
        };
    };
};

u-boot环境

arch=arm
baudrate=115200
board=rpi
board_name=4 Model B
board_rev=0x11
board_rev_scheme=1
board_revision=0xB03112
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr}
boot_efi_binary=if fdt addr ${fdt_addr_r}; then bootefi bootmgr ${fdt_addr_r};else bootefi bootmgr ${fdtcontroladdr};fi;load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} efi/boot/bootaa64.efi; if fdt addr ${fdt_addr_r}; then bootefi ${kernel_addr_r} ${fdt_addr_r};else bootefi ${kernel_addr_r} ${fdtcontroladdr};fi
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}${boot_syslinux_conf}
boot_prefixes=/ /boot/
boot_script_dhcp=boot.scr.uimg
boot_scripts=boot.scr.uimg boot.scr
boot_syslinux_conf=extlinux/extlinux.conf
boot_targets=mmc0 mmc1 pxe dhcp 
bootcmd=run distro_bootcmd
bootcmd_dhcp=if dhcp ${scriptaddr} ${boot_script_dhcp}; then source ${scriptaddr}; fi;setenv efi_fdtfile ${fdtfile}; setenv efi_old_vci ${bootp_vci};setenv efi_old_arch ${bootp_arch};setenv bootp_vci PXEClient:Arch:00011:UNDI:003000;setenv bootp_arch 0xb;if dhcp ${kernel_addr_r}; then tftpboot ${fdt_addr_r} dtb/${efi_fdtfile};if fdt addr ${fdt_addr_r}; then bootefi ${kernel_addr_r} ${fdt_addr_r}; else bootefi ${kernel_addr_r} ${fdtcontroladdr};fi;fi;setenv bootp_vci ${efi_old_vci};setenv bootp_arch ${efi_old_arch};setenv efi_fdtfile;setenv efi_old_arch;setenv efi_old_vci;
bootcmd_mmc0=devnum=0; run mmc_boot
bootcmd_mmc1=devnum=1; run mmc_boot
bootcmd_pxe=dhcp; if pxe get; then pxe boot; fi
bootdelay=2
cpu=armv8
dfu_alt_info=u-boot.bin fat 0 1;uboot.env fat 0 1;config.txt fat 0 1;Image fat 0 1
dhcpuboot=usb start; dhcp u-boot.uimg; bootm
distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; done
efi_dtb_prefixes=/ /dtb/ /dtb/current/
ethaddr=xxxxxxxxxxxxxxxxxxx
fdt_addr=2eff4000
fdt_addr_r=0x02600000
fdt_high=ffffffffffffffff
fdtcontroladdr=39730e00
fdtfile=broadcom/bcm2711-rpi-4-b.dtb
initrd_high=ffffffffffffffff
kernel_addr_r=0x00080000
load_efi_dtb=load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${prefix}${efi_fdtfile}
loadaddr=0x00200000
mmc_boot=if mmc dev ${devnum}; then devtype=mmc; run scan_dev_for_boot_part; fi
pxefile_addr_r=0x02500000
ramdisk_addr_r=0x02700000
scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; for prefix in ${boot_prefixes}; do run scan_dev_for_extlinux; run scan_dev_for_scripts; done;run scan_dev_for_efi;
scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env exists devplist || setenv devplist 1; for distro_bootpart in ${devplist}; do if fstype ${devtype} ${devnum}:${distro_bootpart} bootfstype; then run scan_dev_for_boot; fi; done; setenv devplist
scan_dev_for_efi=setenv efi_fdtfile ${fdtfile}; for prefix in ${efi_dtb_prefixes}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${efi_fdtfile}; then run load_efi_dtb; fi;done;if test -e ${devtype} ${devnum}:${distro_bootpart} efi/boot/bootaa64.efi; then echo Found EFI removable media binary efi/boot/bootaa64.efi; run boot_efi_binary; echo EFI LOAD Failed: continuing...; fi; setenv efi_fdtfile
scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${boot_syslinux_conf}; then echo Found ${prefix}${boot_syslinux_conf}; run boot_extlinux; echo SCRIPT Failed: continuing...; fi
scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${script}; then echo Found U-Boot script ${prefix}${script}; run boot_a_script; echo SCRIPT Failed: continuing...; fi; done
scriptaddr=0x02400000
serial#=10000000exxxxxxx
soc=bcm283x
stderr=serial,vidconsole
stdin=serial,usbkbd
stdout=serial,vidconsole
usbethaddr=xxxxxxxxxxxxxxx
vendor=raspBerrypi

我对哪里出错有任何想法吗?谢谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)