RPI 5 u‐boot - oleksiimoisieiev/rpi5-knowledge-base GitHub Wiki

u-boot sources

repo: https://source.denx.de/u-boot/u-boot.git

branch: master

commit: 2d357e4dbea0dd2fd23002bdf2e18f901aec2d99

u-boot build

Follow instructions in doc/board/broadcom/raspberrypi.rst document.

make rpi_arm64_defconfig CROSS_COMPILE=<path>/zephyr-sdk-0.16.3/aarch64-zephyr-elf/bin/aarch64-zephyr-elf-
make CROSS_COMPILE=<path>/zephyr-sdk-0.16.3/aarch64-zephyr-elf/bin/aarch64-zephyr-elf-

u-boot boot

Copy u-boot.bin binary to RPI5 bootfs boot partition.

In RPI5 config.txt file select u-boot.bin binary to boot instead of standard kernel.

[all]
enable_uart=1
uart_2ndstage=1
kernel=u-boot.bin

u-boot boot log

NOTICE:  BL31: v2.6(release):v2.6-239-g2a9ede0bd
NOTICE:  BL31: Built : 14:26:57, Jun 22 2023

U-Boot 2024.04-00549-g2d357e4dbe (Apr 12 2024 - 16:01:24 +0300)

DRAM:  1020 MiB (effective 8 GiB)
mbox: Header response code invalid
RPI 5 Model B (0xd04170)
Core:  21 devices, 10 uclasses, devicetree: board
MMC:   mmc@fff000: 0, mmc@1100000: 1
Loading Environment from FAT... Unable to read "uboot.env" from mmc0:1... 
In:    serial,usbkbd
Out:   serial,vidconsole
Err:   serial,vidconsole
mbox: Header response code invalid
bcm2835: Could not query MAC address
Net:   No ethernet found.
starting USB...
No working controllers found
Hit any key to stop autoboot:  0 
U-Boot> 

u-boot native Linux kernel boot

Below u-boot script will boot standard RPI5 Linux kernel.

Note

Note that boot uses FDT prepared by RPI5 firmware and placed at ${fdt_addr}.

It's also required to set kernel_comp_addr_r and kernel_comp_size to boot compressed kernel.

setenv kernel_comp_addr_r 0x0A000000
setenv kernel_comp_size 12000000
fatload mmc 0 ${kernel_addr_r} kernel_2712.img
booti ${kernel_addr_r} - ${fdt_addr}

u-boot native Linux kernel boot under XEN

Note

Note that boot uses FDT prepared by RPI5 firmware and placed at ${fdt_addr}.

u-boot commands to start XEN, which starts Linux kernel:

setenv xen_addr_r 0x02700000

fatload mmc 0 ${kernel_addr_r} kernel_2712.img

fdt addr ${fdt_addr} 0x40000
fdt resize
fdt chosen

fdt set /chosen \#address-cells <1>
fdt set /chosen \#size-cells <1>

fdt mknod /chosen module@0
fdt set /chosen/module@0 compatible "xen,linux-zimage" "xen,multiboot-module"
fdt set /chosen/module@0 reg <${kernel_addr_r} 0x${filesize} >
fdt set /chosen/module@0 bootargs "reboot=w coherent_pool=1M 8250.nr_uarts=1 pci=pcie_bus_safe snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1  smsc95xx.macaddr=2C:CF:67:32:84:23 vc_mem.mem_base=0x3fc00000 vc_mem.mem_size=0x40000000  console=ttyAMA10,115200 console=tty1 root=PARTUUID=1c507a66-02 rootfstype=ext4 fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-console"

fdt print /chosen

fatload mmc 0 ${xen_addr_r} xen
booti ${xen_addr_r} - ${fdt_addr}

This exercise follows: https://wiki.xenproject.org/wiki/Xen_ARM_with_Virtualization_Extensions/Allwinner

Note

Linux can boot to login and console, but not all HW is working and dmesg shows high number of crashes.

XEN console is not shown when Linux kernel is loaded. It can be enabled with below command, but XEN will complain about UART IRQ153 and we may lose Linux console. May help to delete unused UARTs with the same IRQ:

setenv bootargs "console=dtuart dtuart=/soc/serial@7d001000 dom0_mem=128M"

fdt rm /soc/serial@7d001400
fdt rm /soc/serial@7d001a00

Xen Dom0 boot log:

(XEN) *** LOADING DOMAIN 0 ***
(XEN) Loading d0 kernel from boot module @ 0000000000080000
(XEN) Loading ramdisk from boot module @ 000000002dfaa000
(XEN) Allocating 1:1 mappings totalling 128MB for dom0:
(XEN) BANK[0] 0x00000008000000-0x00000010000000 (128MB)
(XEN) Grant table range: 0x00000002800000-0x00000002840000
(XEN) Allocating PPI 16 for event channel interrupt
(XEN) d0: extended region 0: 0x2a00000->0x7e00000
(XEN) d0: extended region 1: 0x10000000->0x3fa00000
(XEN) d0: extended region 2: 0x40000000->0x1ffe00000
(XEN) Loading zImage from 00000001f4000000 to 0000000008000000-000000000989ba00
(XEN) Loading d0 initrd from 000000002dfaa000 to 0x000000000ee00000-0x000000000fe554fe
(XEN) Loading d0 DTB to 0x000000000ec00000-0x000000000ec131e6
(XEN) Initial low memory virq threshold set at 0x4000 pages.
(XEN) Scrubbing Free RAM in background
(XEN) Std. Loglevel: All
(XEN) Guest Loglevel: All
(XEN) *** Serial input to DOM0 (type 'CTRL-a' three times to switch input)
(XEN) Freed 344kB init memory.
(XEN) d0v0 Unhandled SMC/HVC: 0x84000050
(XEN) d0v0 Unhandled SMC/HVC: 0x8600ff01
(XEN) d0v0: vGICD: unhandled word write 0x000000ffffffff to ICACTIVER4
(XEN) d0v0: vGICD: unhandled word write 0x000000ffffffff to ICACTIVER8
(XEN) d0v0: vGICD: unhandled word write 0x000000ffffffff to ICACTIVER12
(XEN) d0v0: vGICD: unhandled word write 0x000000ffffffff to ICACTIVER16
(XEN) d0v0: vGICD: unhandled word write 0x000000ffffffff to ICACTIVER20
(XEN) d0v0: vGICD: unhandled word write 0x000000ffffffff to ICACTIVER24
(XEN) d0v0: vGICD: unhandled word write 0x000000ffffffff to ICACTIVER28
(XEN) d0v0: vGICD: unhandled word write 0x000000ffffffff to ICACTIVER32
(XEN) d0v0: vGICD: unhandled word write 0x000000ffffffff to ICACTIVER36
(XEN) d0v0: vGICD: unhandled word write 0x000000ffffffff to ICACTIVER0
(XEN) d0v1: vGICD: unhandled word write 0x000000ffffffff to ICACTIVER0
(XEN) d0v2: vGICD: unhandled word write 0x000000ffffffff to ICACTIVER0
(XEN) d0v3: vGICD: unhandled word write 0x000000ffffffff to ICACTIVER0

u-boot links

[PATCH v5 0/7] rpi5: initial support https://lists.denx.de/pipermail/u-boot/2024-January/544224.html

https://hechao.li/2021/12/20/Boot-Raspberry-Pi-4-Using-uboot-and-Initramfs/

https://forums.raspberrypi.com/viewtopic.php?t=330177

https://stackoverflow.com/questions/69899667/raspberry-pi-4b-u-boot-bootloader-device-tree-addresses-dtb

⚠️ **GitHub.com Fallback** ⚠️