10

I have spent the last couple of days testing my Raspberry Pi 4B to be able to boot from the SD card.

Apparently, I think that the SD card reader stopped working, and I can not have any OS inside my Raspberry Pi 4B.

I noted that there are a couple of options that allow the Raspberry Pi to boot from USB, but none of the solutions that I found will avoid using the SD card.

There is a real option for me there?

Greenonline
  • 2,740
  • 4
  • 23
  • 36
vincenzopalazzo
  • 203
  • 2
  • 6

2 Answers2

15

It is certainly possible to avoid using the SD card for boot - none of my Pi devices use the unreliable SD card interface and all boot either from the network or an SSD via the USB port.

Boot order

The boot order is determined by the value held in BOOT_ORDER, in the EEPROM, and is read from right to left:

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 - See Network boot server tutorial

0x4 USB-MSD USB mass storage boot

0xf RESTART Restart from the first boot-mode in the BOOT_ORDER field i.e. loop

You need to change your BOOT_ORDER, from the default, which might be probably 0xf21, to include 0x4. So, either:

  • 0xf14 which will attempt to boot from USB first and then the SD card, or;
  • 0xf41 which will attempt to boot from SD card first and then the USB, or;
  • 0xf42 which will attempt to boot from network first and then the USB, or;
  • 0xf24 which will attempt to boot from the USB first and then the network.

You can include four options, so:

  • 0xf241 which will attempt to boot from the SD card first, then the USB and then the network.

In all cases, the f at the beginning just means that the boot attempts will cycle around, if all of them fail the first time. Basically, it will sit there repeatedly trying each device.

Update first

Note: USB boot was only introduced in the EEPROM from 9-03-2020 onwards, so it depends upon the age of the Pi and when/if the EEPROM was updated, whether your Pi has this capability or not. So you may need to update your EEPROM.

Nevertheless, even if you already have this ability, it is best to update to the latest version of the EEPROM firmware.

To update your system to get the latest version of the rpi-eeprom package:

sudo apt update
sudo apt full-upgrade

Then you can change the boot order using

sudo -E rpi-eeprom-config --edit 

and append

BOOT_ORDER=0xf241

for SD card, then USB, then network and then repeat cycle.


Possible problem configuring

Note that, if your Pi is not already configured with the appropriate boot order (i.e. it does not include 0x4), then it may never boot from anything useful (i.e. USB), which means that you can not to set the boot order appropriately.

That is to say, if the Pi isn't already configured to boot from USB, and seeing that your SD card slot is broken, then you are pretty much in a pickle... and you won't be able to boot your Pi, in order to configure it.

It is a bit of a chicken and egg situation.

If that is the case, then your only hope is that your default boot order is for SD card first and then the network, i.e. 0xf21 (or vice versa). If so, then you can set up a network boot server (using bootp, dhcp, nfs, and tftp) to boot the Pi, for you to then be able to configure the BOOT_ORDER to include USB booting (i.e. 0x4).

Notes:

  • I found that the default value (from the factory) of my BOOT_ORDER was 0xf14, so it just worked out of the box - USB first and then SD card.

  • If BOOT_ORDER is not present, then the default boot order is SD card and then USB. Under BOOT_ORDER EXAMPLES, for 0xf41 it states:

    Try SD first, followed by USB-MSD then repeat (default if BOOT_ORDER is empty)

    Again, this will only work if you have EEPROM firmware from 9-03-2020 onwards, which is when USB boot support was added to the firmware.


For reference, I documented my whole discovery and configuration issues whilst attempting this in May 2022, in this blog, Raspberry Pi 4 - SD to SSD. Most of the information from that blog is in this answer, although my notes about the whole process and the reference links may prove to be of some use to you

Greenonline
  • 2,740
  • 4
  • 23
  • 36
  • 1
    there is any way to see the bootloader configuration without having access to the os? – vincenzopalazzo Jan 21 '23 at 20:56
  • 1
    @vincenzopalazzo - I'm not totally sure, as I can't fully remember... however, IIRC, if you haven't updated the EEPROM previously, then I think that the boot order is displayed briefly upon power on. After the USB boot upgrade, I think that the startup screen now jumps straight to the red startup page, without showing the boot order. I'll have to reboot my systems to verify this new behaviour though, and I don't really have time at the moment (unfortunately). Sadly, I can't verify the old behaviour, as I have updated all of my Pi devices and I can't downgrade them. – Greenonline Jan 21 '23 at 22:50
  • So if I get the solution, I just need to plug the ethernet cable and the usb into the 3.0 port and guess that something happens? – vincenzopalazzo Jan 21 '23 at 23:32
  • @vincenzopalazzo - well yes, but you need to set up a netboot server first (using another Pi or a PC) - which is too much to cover in this answer (as it is a different topic). – Greenonline Jan 22 '23 at 00:05
  • Nevertheless, I have also documented the process of setting a netboot server here, Setting up PXE cluster on RPi 4/400. It is a bit of a steep learning curve, but it definitely works as I use it on a daily basis - although I ended up scripting the whole thing, to automate a cluster build. However, you will only need the basics for netbooting just one Pi. You could just follow the link at the top of the page, but my notes include some corrections that were in the original article. – Greenonline Jan 22 '23 at 00:05
  • For clarity, in my notes, the compute node will be the Pi with the broken SD card reader, the master node will be the netboot server. – Greenonline Jan 22 '23 at 00:07
  • 2
    Thanks for the link to your blog. I just checked my Pi4 (original 2GB - ordered when announced). This doesn't have BOOT_ORDER but does boot from USB (at least last time I tried). The doc says Try SD first, followed by USB-MSD then repeat (default if BOOT_ORDER is empty) . Might be worthwhile adding to the blog. – Milliways Jan 22 '23 at 00:35
  • I never deliberately changed the BOOT_ORDER on a Pi 4 I have here and it is currently 0xf41. In case that's relevant, its SD card was written with Raspberry Pi Imager with the 64-bit Raspberry Pi OS lite. – AndreKR Jan 23 '23 at 05:00
2

The SD reader on my son's pi400 is broken also, however in our case it works with an easy hack.

Cut a piece of card the same size as the SD and use as a shim on top of the SD card and insert. The extra thickness forces the card further onto the pins and can be enough to give a proper connection. You will have to play about with the correct thickness of card / paper / yogurt pot.

Buff
  • 21
  • 1