"Special" bootcode.bin usb boot mode

Jul 27, 2022 Last reply: 3 years ago 3 Replies

Is anybody using the "special" bootcode.bin for booting from a usb mass storage device? It's described at

formatting link


I've used it on a Pi2, where it works perfectly. On a Pi3, with the usb boot OTP set, its behavior is more complicated and I'm looking for any advice available.



This particular Pi3/disk combo didn't seem to detect the USB hard drive reliably, so I tried merely changing the version of bootcode.bin on the (bootable) microSD, saving the original bootcode.bin to bootcode.bin.microsd to keep it handy in case I needed to boot the microSD as a recovery device.



That didn't work, so I moved all the msdos files into a subdirectory named "unused", leaving only the "special" bootcode.bin and timeout files visible. That didn't work either, so I pulled out the microSD and cycled power. Boot was successful, this time. I'd like it to work reliably 8-) The usual failure mode was an immediate attempt to netboot.



If anybody's got tips on how to detect and boot a USB hard drive on a Pi 2 or 3 please post! I'm aware the instructions say to have only the special bootcode.bin and a timeout file on the microSD, but I hoped hiding the un-needed files would be sufficient.



As it happens I'm booting FreeBSD, but I think the present magic is entirely within the realm of the RasPiOS gods.



Thanks for reading,



bob prohaska


I've done it a similar way but with a 256MB SD card:

# lsblk NAME FSTYPE LABEL PARTLABEL PARTUUID FSSIZE FSUSED MOUNTPOINT sda ├─sda1 swap swap b32bbadb-3f7d-5146-baee-295fcb1939ca [SWAP] ├─sda2 ext4 rootfs 72020302-c396-2148-9d13-caf4f68cd18c 56.4G 6.9G / ├─sda3 ext4 root root 7308d719-4f3e-4beb-91af-51e986fc889f 28.2G 9.2G /mnt/root └─sda4 ext4 ebor backup 35171e6a-5845-4ddb-aafe-d2b0a0ff542a 28.2G 7.1G /mnt/ebor mmcblk0 └─mmcblk0p1 vfat

241.2M 53M /boot

# cat /boot/cmdline.txt console=tty1 root=PARTUUID=72020302-c396-2148-9d13-caf4f68cd18c rootfstype=ext4 fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles net.ifnames=0 biosdevname=0 usbhid.mousepoll=0 dwc_otg.lpm_enable=0

Did it _never_ work, or did it work intermittently? One of my puzzles has been that the disk always shows up within a dozen tries. Sometimes the first, usually by the fifth. Power-cycling the disk between attempts seems to help, but not in a deterministic way.

I believe that's a Linux-specific technique. AIUI, the kernel is loaded from the microSD and then cmdline.txt tells the kernel where to find the root filesystem. Something similar is possible with FreeBSD, but it's cumbersome to keep the kernel on microSD in sync with world on USB.

Another technique is to let the Pi boot from microSD and then mount /usr and enable swap from USB. That's actually pretty easy and worked well. Root is a read-mostly filesystem. If the "scribble" directories are on /usr flash wear and random write speed isn't a huge issue. You've given me some food for thought....

Thanks for writing!

bob prohaska

Like a previous respondant, I always boot from an SD card with the PiOS firmware on it, but edit the cmdline.txt file to specify a partition on a USB attached hard drive as the root.

I have 2 Pi3s, a Pi3B and a Pi3B+, one with a WD USB external 2.5inch hardrive and one with a WD 3.5inch SATA drive with a StarTec USB3.1 adapter. They both boot flawlessly. I also mount the SD /boot partition ReadOnly to minimise any SD problems.

I have a wrapper script for updates whcih remounts the sdcard RW and afterwards reverts it to RO

My approach is make the least changes to the default procedure - then there's less to debug when stuff goes wrong.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required