Prepare Raspberry Pi for boot from USB/NVMe

Introduction:

With the Raspberry 4 version B released in 2019 SBC community gained capability of booting from USB attached storage in 2020. Raspberry Pi 5 released in 2023 with native implementation of PICe presented new possibility of making Volumio better.

The groundwork has been laid in the Community thread 64283 where a basic question, if the boot from MVME M.2 is even possible, is discussed. New question - can boot weld to MicroSD be liberated? Continue reading…

Preparations:

Make sure you are running the latest version of Raspberry Pi OS on your Raspberry Pi 4B or 5. You can download it from Raspberry Pi. You will also need to make sure the OS is all up to date.

sudo apt update
sudo apt full-upgrade
sudo reboot

1. Check current running version of bootloader EEPROM image.

vcgencmd bootloader_version

USB booting was supported starting with version 9-03-2020. You should see that version 16-02-2024 or later is installed. Now check to see if there is an update available.

sudo rpi-eeprom-update

image

You should see that the bootloader is up-to-date. By default you will only see updates from the “default” directory. Default updates are not released too often. Even if you see UPDATE AVAILABLE you can ignore it as we are going to check for an update in a more frequently released channel or directory called “latest”.

2. Upgrade to the newer “latest” EEPROM version.

You will need to change the firmware directory from critical or stable to latest to find the latest updates. To do this, you need to edit a file called /etc/default/rpi-eeprom-update.

sudo nano /etc/default/rpi-eeprom-update

image

Change the word “critical” or “stable” to “latest” and save the file.
Check once again for an eeprom update and you should notice a newer version.

sudo rpi-eeprom-update

image

3. Apply the update and reboot.

sudo rpi-eeprom-update -a
sudo reboot -n

image

You can check the running eeprom version again to ensure the correct version.
vcgencmd bootloader_version
ALL UP-TO-DATE!

4(a). Check BOOT ORDER configuration - Raspberry Pi 4B.

sudo rpi-eeprom-config

Take note of the BOOT_ORDER code. The defualt code is 0xf41 and is read right to left to determine the boot order.
1 = Check SD card
4 = Check USB drive
f = Start again
This boot order is exactly what we want. If the boot order code is anything other than 0xf41, you can change the boot configuration using this command.

sudo -E rpi-eeprom-config --edit
BOOT_ORDER=0xf41

image

Write your changes (Ctrl-O) and exit (Ctrl-x)
Reboot Raspberry Pi
sudo reboot

4(b). Check BOOT ORDER configuration - Raspberry Pi 5.

sudo rpi-eeprom-config

Take note of the BOOT_ORDER code. The defualt code is 0xf41 and is read right to left to determine the boot order.
1 = Check SD card
4 = Check USB drive
f = Start again
This boot order is not what we want. If the boot order code is anything other than 0xf461, you can change the boot configuration using this command.

sudo -E rpi-eeprom-config --edit
BOOT_ORDER=0xf461

image

1 = Check SD card
6 = Check PCIe NVME
4 = Check USB drive
f = Start again

In addition, you need to instruct your Raspberry Pi 5 to enumerate and use PCIe by adding after BOOT_ORDER: PCIE_PROBE=1. Please pay attention to the line orders.

sudo -E rpi-eeprom-config --edit
BOOT_ORDER=0xf461
PCIE_PROBE=1

image

Write your changes (Ctrl-O) and exit (Ctrl-X)
Reboot Raspberry Pi
sudo reboot

5. Use NVMe

If you want o test already attached NVMe you will need to update /boot/config.txt or /boot/firmware/config.txt with overlays:

dtparam=nvme
dtparam=pciex1_gen=2

Reboot Raspberry Pi
sudo reboot

Also you can experiment and force connection to Gen 3.0 (10 GT/sec)

dtparam=pciex1_gen=3

Shutdown your Raspberry Pi 5. It is ready to boot from USB/NVMe.

Usage, community discussion and further steps:

Description Community thread
Testing Volumio OS with Disk Installer [ALPHA] Raspberry Pi boot from USB/NVMe
NVMe SSD LAB and findings to date PCIe NVMe compatibility
1 Like
BOOT_ORDER RPi4 Description
0xf41 Try SD first, followed by USB-MSD then repeat (default if BOOT_ORDER is empty)
0xf14 Try USB first, followed by SD then repeat
0xf21 Try SD first, followed by NETWORK then repeat
BOOT_ORDER RPi5 Description
0xf416 Try SD first, followed by USB-MSD, followed by NVMe then repeat (default if BOOT_ORDER is empty)
0xf164 Try USB first, followed by NVMe, followed by SD then repeat
0xf216 Try SD first, followed by NETWORK, followed by NVMe then repeat

The BOOT_ORDER property defines the sequence for the different boot modes. It is read right to left and up to 8 digits may be defined.

Value Mode Description
0x0 SD CARD DETECT Try SD then wait for card-detect to indicate that the card has changed - deprecated now that 0xf (RESTART) is available.
0x1 SD CARD SD card (or eMMC on Compute Module 4).
0x2 NETWORK Network boot.
0x3 RPIBOOT RPIBOOT - protocol that provides a virtual file system to the Raspberry Pi bootloader and GPU firmware. It’s therefore possible to boot Linux.
0x4 USB-MSD USB mass storage boot.
0x5 BCM-USB-MSD USB 2.0 boot from USB Type C socket (CM4: USB type A socket on CM IO board, using bootloader EEPROM from 2020-12-14 onwards).
0x6 NVMe CM4 and RPi5 only: boot from an NVMe SSD connected to the PCIe interface.
0xe STOP Stop and display error pattern. A power cycle is required to exit this state.
0xf RESTART Restart from the first boot-mode in the BOOT_ORDER field i.e. loop

[@nerd EDIT - I moved this discussion to the relevant thread]

Currently I am booting from a 32gb USB 3.0 (formatted as ExFAT) and runs on Volumio v3.636. Everything works fine except when I restart, I get stuck on the boot screen as picture. I had to unplug the power cable and replug it back and everything is working again. It happens on 2 RPi4s and a RPi5.

Did I do something wrong?

Andy

I don’t think you did anything wrong. The picture you shared is from subsequence of boot capabilities check - attempting to boot from network. Upon time-out on network stack the Raspberry Pi will move to the next option. Since bootloader in shared picture shows Apr 29 2021, please revisit your eeprom configuration and:

  1. Upgrade your device eeprom to version 2024-02-16-2711 (Pi4), 2024-02-16-2712 (Pi5) or newer
  2. Set boot order 0xf41 for raspberry Pi 4 (SD Card → USB → Repeat)
  3. Set boot order 0xf461 for raspberry Pi 5 (SD Card → NVMe → USB → Repeat)

Notes on USB devices: Some USB storage devices based on SSD flash require cold start, will not report “Ready” status unless initiated from cold start.

EDIT: Updated #3

According to pi5 docs: 4 - USB, 1 - SD, 6 - NVME

Of course, in the same docs the boot order is also discussed and in the eeprom configuration they need to be in the reverse order.

Thanks for the info. I haven’t update the eeprom of my RPi4s for years. I guess it’s about time. Anyway, I just finished building up a RPi5 with x1001 and a 500gb NVMe and everything works fine.

Andy

2 posts were merged into an existing topic: [ALPHA] Raspberry Pi boot from USB/NVMe

A post was merged into an existing topic: [ALPHA] Raspberry Pi boot from USB/NVMe