Raspberry Pi 4B+U-Boot引导程序-设备树地址(.dtb)



我编译了U-Boot(@v2022.01-rc1(,其中rpi_4_defconfig未被修改。然而,U-Boot成功地加载到shell中输入该命令序列将被卡在"0"上;正在启动内核":

setenv serverip 192.168.0.1
setenv ipaddr 192.168.0.10
setenv kernel_comp_addr_r 0x0A000000
setenv kernel_comp_size 7921972
tftp ${kernel_addr_r} kernel8.img
tftp ${fdt_addr_r} bcm2711-rpi-4-b.dtb
booti ${kernel_addr_r} - ${fdt_addr_r}          // Gets stuck at Starting kernel...

但是,如果我在booti命令中将${fdt_addr_r}替换为${fdt_addr},它将成功加载内核。像这样:

booti ${kernel_addr_r} - ${fdt_addr}            // Works fine

${fdt_addr_r}和${fdt_addr}之间有什么区别?为什么我的第一种方法不起作用?为什么${fdt_addr}有效


调试信息:

RPi固件引导日志:

Read start4.elf bytes  2228768 hnd 0x00000072 
Read fixup4.dat bytes     5446 hnd 0x00000067 
Firmware: d7f29d96450abfc77cd6cf011af1faf1e03e5e56 Apr 30 2021 13:45:52
0x00c03112 0x00000000 0x000000ff
MEM GPU: 76 ARM: 948 TOTAL: 1024
Starting start4.elf @ 0xfec00200 partition 0
PCI reset
+
MESS:00:00:05.184648:0: arasan: arasan_emmc_open
MESS:00:00:05.332928:0: brfs: File read: /mfs/sd/config.txt
MESS:00:00:05.335639:0: brfs: File read: 81 bytes
MESS:00:00:05.402894:0: brfs: File read: /mfs/sd/config.txt
MESS:00:00:05.421071:0: brfs: File read: 81 bytes
MESS:00:00:05.902232:0: gpioman: gpioman_get_pin_num: pin DISPLAY_DSI_PORT not defined
MESS:00:00:05.909524:0: *** Restart logging
MESS:00:00:05.914477:0: hdmi: HDMI:hdmi_get_state is deprecated, use hdmi_get_display_state instead
MESS:00:00:05.923831:0: hdmi: HDMI:hdmi_get_state is deprecated, use hdmi_get_display_state instead
MESS:00:00:05.929762:0: HDMI0: hdmi_pixel_encoding: 300000000
MESS:00:00:05.935229:0: HDMI1: hdmi_pixel_encoding: 300000000
MESS:00:00:05.945421:0: dtb_file 'bcm2711-rpi-4-b.dtb'
MESS:00:00:05.952218:0: brfs: File read: /mfs/sd/bcm2711-rpi-4-b.dtb
MESS:00:00:05.955466:0: Loading 'bcm2711-rpi-4-b.dtb' to 0x100 size 0xc2a9
MESS:00:00:05.974659:0: brfs: File read: 49833 bytes
MESS:00:00:06.039897:0: brfs: File read: /mfs/sd/config.txt
MESS:00:00:06.042389:0: brfs: File read: 81 bytes
MESS:00:00:06.047663:0: brfs: File read: /mfs/sd/overlays/disable-bt.dtbo
MESS:00:00:06.067534:0: Loaded overlay 'disable-bt'
MESS:00:00:06.107041:0: brfs: File read: 1073 bytes
MESS:00:00:06.108885:0: Failed to open command line file 'cmdline.txt'
MESS:00:00:07.249713:0: brfs: File read: /mfs/sd/u-boot.bin
MESS:00:00:07.252181:0: Loading 'u-boot.bin' to 0x80000 size 0x8f720
MESS:00:00:07.258265:0: Device tree loaded to 0x2eff3800 (size 0xc743)
MESS:00:00:07.266568:0: uart: Set PL011 baud rate to 103448.300000 Hz
MESS:00:00:07.273628:0: uart: Baud rate change done...
MESS:00:00:07.275688:0: uart: Baud rate change done...
MESS:00:00:07.281220:0: gpioman: gpioman_get_pin_num: pin SDCARD_CONTROL_POWER not defined

U-Boot日志:

U-Boot 2022.01-rc1 (Nov 11 2021 - 15:59:50 +0100)
DRAM:  3.9 GiB
RPI 4 Model B (0xc03112)
MMC:   mmcnr@7e300000: 1, mmc@7e340000: 0
Loading Environment from FAT... Unable to read "uboot.env" from mmc0:1... In:    serial
Out:   serial
Err:   serial
Net:   eth0: ethernet@7d580000
PCIe BRCM: link up, 5.0 Gbps x1 (SSC)
starting USB...
Bus xhci_pci: Register 5000420 NbrPorts 5
Starting the controller
USB XHCI 1.00
scanning bus xhci_pci for devices... 2 USB Device(s) found
scanning usb for storage devices... 0 Storage Device(s) found
Hit any key to stop autoboot:  2

U-boot环境(不输入任何命令,也不以任何方式修改env(:

arch=arm
baudrate=115200
board=rpi
board_name=4 Model B
board_rev=0x11
board_rev_scheme=1
board_revision=0xC03112
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr}
boot_efi_binary=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_efi_bootmgr=if fdt addr ${fdt_addr_r}; then bootefi bootmgr ${fdt_addr_r};else bootefi bootmgr;fi
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}${boot_syslinux_conf}
boot_net_usb_start=usb start
boot_pci_enum=pci enum
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 usb0 pxe dhcp 
bootcmd=run distro_bootcmd
bootcmd_dhcp=devtype=dhcp; run boot_net_usb_start; run boot_pci_enum; 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=run boot_net_usb_start; run boot_pci_enum; dhcp; if pxe get; then pxe boot; fi
bootcmd_usb0=devnum=0; run usb_boot
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=dc:a6:32:5f:91:f4
fdt_addr=2eff3800
fdt_addr_r=0x02600000
fdt_high=ffffffffffffffff
fdtcontroladdr=3af44630
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=0x1000000
mmc_boot=if mmc dev ${devnum}; then devtype=mmc; run scan_dev_for_boot_part; fi
preboot=pci enum; usb start;
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;run boot_efi_bootmgr;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#=100000009b911a03
soc=bcm283x
stderr=serial,vidconsole
stdin=serial,usbkbd
stdout=serial,vidconsole
usb_boot=usb start; if usb dev ${devnum}; then devtype=usb; run scan_dev_for_boot_part; fi
usbethaddr=dc:a6:32:5f:91:f4
vendor=raspberrypi
Environment size: 4113/16380 bytes

输入命令并引导内核的U引导过程:

U-Boot> setenv serverip 192.168.0.1
U-Boot> setenv ipaddr 192.168.0.10
U-Boot> setenv kernel_comp_addr_r 0x0A000000
U-Boot> setenv kernel_comp_size 7921972
U-Boot> tftp ${kernel_addr_r} kernel8.img
Using ethernet@7d580000 device
TFTP from server 192.168.0.1; our IP address is 192.168.0.10
Filename 'kernel8.img'.
Load address: 0x80000
Loading: *##################################################  7.6 MiB
13.9 MiB/s
done
Bytes transferred = 7921972 (78e134 hex)
U-Boot> tftp ${fdt_addr_r} bcm2711-rpi-4-b.dtb
Using ethernet@7d580000 device
TFTP from server 192.168.0.1; our IP address is 192.168.0.10
Filename 'bcm2711-rpi-4-b.dtb'.
Load address: 0x2600000
Loading: *##################################################  48.7 KiB
5.3 MiB/s
done
Bytes transferred = 49833 (c2a9 hex)
U-Boot> booti ${kernel_addr_r} - ${fdt_addr_r}
Uncompressing Kernel Image
Moving Image from 0x80000 to 0x200000, end=17f0000
## Flattened Device Tree blob at 02600000
Booting using the fdt blob at 0x2600000
Using Device Tree in place at 0000000002600000, end 000000000260f2a8
Starting kernel ...     // <------ !!!! stuck here forever

关于${fdt_addr}${fdt_addr_r}:

u-bootrpi_4_defconfig配置CONFIG_OF_BOARD。通过此选项,u-boot不使用自己的设备树,但它接收由Raspberry Pi 4的eeprom引导加载程序提供的设备树。RPi引导加载程序已经根据引导分区的文件config.txt中的选项准备了设备树,包括dt覆盖和cmdline.txt中指定的引导参数。

因此,位于地址${fdt_addr}的设备树是由Raspberry Pi引导加载程序准备的设备树。这可能是使用${fdt_addr}启动的原因。因此,您不必在Raspberry Pi上自行准备和加载设备树。您可以在u-bootbooti命令中重用${fdt_addr},因为它已经加载。

如果您选择加载自己的设备树,请将其内容与config.txt(尤其是dtoverlay=..(中的配置进行比较。还要检查cmdline.txt的引导参数。在u-boot命令列表中,您没有使用setenv bootargs ...设置任何引导参数。

正如锯末所提到的,您可以使用setenv bootargs 'earlycon=uart8250,mmio32,0xfe215040 console=serial0,115200 ...'在miniuart串行线上获取调试信息。

最新更新