RPi notes
Unless otherwise said, this is about RPI3B+.
SD Card
I used to use a SanDisk Ultra 32GB and 64GB; now I am also on a Samsung EVO Select 128.
U-Boot port (likely no longer used by me)
For my RPi3b+ I have to make this change to be able to save the uboot.env on the EFI/FAT partition. Not sure what the RPI4 needs (may find out one day?).
--- a/sysutils/u-boot-rpi3/files/rpi3_fragment +++ b/sysutils/u-boot-rpi3/files/rpi3_fragment @@ -1,4 +1,4 @@ CONFIG_OF_EMBED=n CONFIG_OF_BOARD=y -CONFIG_ENV_FAT_DEVICE_AND_PART="1:1" +CONFIG_ENV_FAT_DEVICE_AND_PART="0:1" CONFIG_RPI_EFI_NR_SPIN_PAGES=2
UEFI
Download the firmware from Raspberry Pi 3 UEFI Firmware Images and later rather than copying in u-boot bits just unzip this in the FAT partition. I have seen the UEFI Boot Manager. Not expecting Netboot to work. You have to add a line to config.txt https://github.com/pftf/RPi3/pull/32/commits/bc18c5a8270dd3d74940030793914bcd0dcca4cd. You also need to set console="comconsole" in loader as "efi" seems to hang. This may have been fixed earlier in 2023 but I haven't verified yet.
GPT Hybrid SD card
Warning: all typed from memory. Double-check before pasting! Also I have since also added a index 2 freebsd-ufs partition at 1G and that worked fine as well with the same procedure.
For my RPi3B+ the following seemed to work for U-Boot:
- Create EFI partition using gpart like this (left the 1M gap as my previous SD card had this):
# gpart create -s GPT da3 # gpart add -i 1 -b 1M -s 255M -t EFI da3 # gpart show da3 => 40 250347440 da3 GPT (119G) 40 2008 - free - (1.0M) 2048 522240 1 efi (255M) 524288 249823192 - free - (119G)
Using gdisk from ports to generate the hybrid as explained here https://www.rodsbooks.com/gdisk/hybrid.html to look like below:
Note: put the 0xEE protective partition 2nd and not first.
# gdisk /dev/da3 [17/1847] GPT fdisk (gdisk) version 1.0.6 Partition table scan: MBR: protective BSD: not present APM: not present GPT: present Found valid GPT with protective MBR; using GPT. Command (? for help): r Recovery/transformation command (? for help): o Disk size is 250347520 sectors (119.4 GiB) MBR disk identifier: 0x00000000 MBR partitions: Number Boot Start Sector End Sector Status Code 1 1 250347519 primary 0xEE Recovery/transformation command (? for help): p Disk /dev/da3: 250347520 sectors, 119.4 GiB Sector size (logical): 512 bytes Disk identifier (GUID): 313A093D-9BCE-11EB-8E1D-589CFC10C27F Partition table holds up to 128 entries Main partition table begins at sector 2 and ends at sector 33 First usable sector is 40, last usable sector is 250347479 Partitions will be aligned on 2048-sector boundaries Total free space is 249825200 sectors (119.1 GiB) Number Start (sector) End (sector) Size Code Name 1 2048 524287 255.0 MiB EF00 Recovery/transformation command (? for help): h WARNING! Hybrid MBRs are flaky and dangerous! If you decide not to use one, just hit the Enter key at the below prompt and your MBR partition table will be untouched. Type from one to three GPT partition numbers, separated by spaces, to be added to the hybrid MBR, in sequence: 1 Place EFI GPT (0xEE) partition first in MBR (good for GRUB)? (Y/N): N Creating entry for GPT partition #1 (MBR partition #1) Enter an MBR hex code (default EF): 06 Set the bootable flag? (Y/N): Y Unused partition space(s) found. Use one to protect more partitions? (Y/N): N Recovery/transformation command (? for help): o Disk size is 250347520 sectors (119.4 GiB) MBR disk identifier: 0x00000000 MBR partitions: Number Boot Start Sector End Sector Status Code 1 * 2048 524287 primary 0x06 2 1 2047 primary 0xEE Recovery/transformation command (? for help): p Disk /dev/da3: 250347520 sectors, 119.4 GiB Sector size (logical): 512 bytes Disk identifier (GUID): 313A093D-9BCE-11EB-8E1D-589CFC10C27F Partition table holds up to 128 entries Main partition table begins at sector 2 and ends at sector 33 First usable sector is 40, last usable sector is 250347479 Partitions will be aligned on 2048-sector boundaries Total free space is 249825200 sectors (119.1 GiB) Number Start (sector) End (sector) Size Code Name 1 2048 524287 255.0 MiB EF00 Recovery/transformation command (? for help): w Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!! Do you want to proceed? (Y/N): Y OK; writing new GUID partition table (GPT) to /dev/da3. Warning: The kernel may continue to use old or deleted partitions. You should reboot or remove the drive. The operation has completed successfully. # gpart show da3 => 40 250347440 da3 GPT (119G) 40 2008 - free - (1.0M) 2048 522240 1 efi (255M) 524288 249823192 - free - (119G)
- Format the EFI partition and copy rpi-firmware and u-boot onto it:
newfs_msdos -F16 -L EFI -O EFI /dev/da3p1 mount -t msdosfs /dev/da3p1 /mnt/ cd /mnt cp -ipr /usr/local/share/rpi-firmware/* . mv -i config.txt config.txt.orig cp -ip config_arm64.txt config.txt cp -ip /usr/local/share/u-boot/u-boot-rpi3/u-boot.bin . cd / umount /mnt camcontrol eject da3
and in my case comment out the mmc overlay in the config.txt. Also I add
core_freq=250 dtparam=i2c_arm=on,spi=on
The former is for (add link to Pull request on github); the latter to get i2c support. More config.txt infos can be found at https://www.raspberrypi.org/documentation/configuration/config-txt/.
- I assume if I'd add loader.efi as EFI/BOOT/bootaa64.efi to the EFI partition and would add a freebsd-ufs partition and install to it FreeBSD would boot from that but I want to netboot only currently.
Netbooting
- changed the boot command:
env set bootcmd 'run boot_net_usb_start; dhcp ${scriptaddr} ${bootfile}; source ${scriptaddr};' env save
This ends up on uboot.env in the EFI/FAT partition.
- On the netboot server I have in dhcp.conf (most stuff global but device specific):
host rpi3bp { hardware ethernet ...; fixed-address 192.0.2.105; #filename "/exports/rpi3bp/boot/loader.efi"; filename "/exports/rpi3bp.bin"; option root-path "/exports/rpi3bp"; option host-name "rpi3bp.lab.example.net"; }
- rpi3bp.bin is a u-boot script like this:
rpi3bp.scr.nfsroot
echo ===== U-Boot settings ===== setenv image_name /exports/rpi3bp/boot/loader.efi echo ===== Fetching loader ===== tftpboot $kernel_addr_r $image_name echo ===== Booting FreeBSD ===== if fdt addr ${fdt_addr_r}; then bootefi ${kernel_addr_r} ${fdt_addr_r}; else bootefi ${kernel_addr_r} ${fdtcontroladdr}; fi
According to my current understanding: be very careful to not screw with the FDT or re-loading it as the auto-loaded armstub8.bin https://github.com/ARM-software/arm-trusted-firmware/blob/master/docs/plat/rpi3.rst providing the psci monitor https://github.com/gonzoua/rpi3-psci-monitor is hot-patching the FDT and you would lose that and your kernel will panic.
The U-boot script "compiles" like this:
mkimage -T script -C none -n "RPi3Bp-Netboot" -A arm64 -d rpi3bp.scr.nfsroot rpi3bp.bin
- Booting it then looks like this then:
...
Probably setting the switch port to 100FDX fix instead of auto would improve things slightly more.