title: Raspberry Pi 4B + U-Boot bootloader - device tree addresses (.dtb)
body: <p>I compiled U-Boot (@v2022.01-rc1) with untouched rpi_4_defconfig. The U-Boot loads into shell successfuly, however
  entering this sequence of commands will get stuck on &quot;Starting kernel ...&quot;:</p>
  <pre><code>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...
  </code></pre>
  <p>However, if I replace ${fdt_addr_r} with ${fdt_addr} in booti command it will load the kernel successfully. Like this:</p>
  <pre><code>booti ${kernel_addr_r} - ${fdt_addr}            // Works fine
  </code></pre>
  <p><strong>What is the difference between ${fdt_addr_r} and ${fdt_addr}? Why doesn't my first approach work? Why does ${fdt_addr} work?</strong></p>
  <hr />
  <p>DEBUG INFO:</p>
  <p>RPi firmware boot logs:</p>
  <pre><code>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
  </code></pre>
  <p>U-Boot log:</p>
  <pre><code>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 &quot;uboot.env&quot; 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
  </code></pre>
  <p>U-boot environment (without entering any commands, or modifying env in any way):</p>
  <pre><code>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
  </code></pre>
  <p>U-boot process of entering commands and booting the kernel:</p>
  <pre><code>U-Boot&gt; setenv serverip 192.168.0.1
  U-Boot&gt; setenv ipaddr 192.168.0.10
  U-Boot&gt; setenv kernel_comp_addr_r 0x0A000000
  U-Boot&gt; setenv kernel_comp_size 7921972
  U-Boot&gt; 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&gt; 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&gt; 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 ...     // &lt;------ !!!! stuck here forever
  </code></pre>