Booting a Pi3B from USB

Are there any downsides to setting a Pi3B so it can boot from USB?

The page at

formatting link

instructs to add program_usb_boot_mode=1 to config.txt, but also carefully warns Note that any change you make to the OTP is permanent and cannot be undone.

Are there any bad side effects to enabling USB boot on a Pi3B? I don't want to lose the ability to boot from microSD, but don't mind a little extra delay in booting.

It appears the warning is related to the Pi3A+, but I'd like to be sure.....

If there's an idiot's guide pointers would be appreciated!

Thanks for reading,

bob prohaska

Reply to
bob prohaska
Loading thread data ...

None. Except maybe in professional/industrial settings where you don't want your Pi to boot from random, possibly malicious, usb devices?

Reply to
A. Dumas

I find it better (and easier) to use the SD card as /boot ( i.e /dev/mmcblk0p1 = vfat) and still boot from it, but set the root= parameter in cmdline.txt to the USB device used as / e.g. root=UUID=c2059131-df01-4aa0-9071-f09098053aff is the UUID of my USB device. You can instead use root=PARTUUID= if you want. See blkid output. /dev/mmcblk0p2 can be kept as a backup if you like, or despatched with altogether. This does not require a change to "progam_usb_boot_mode".

--

Chris Elvidge, England
Reply to
Chris Elvidge

I can't see how you find this easier. It requires maintaining two devices and carefully editing the UUID, keeping track of which mountpoint is where. In turn this means you must know exactly what you are doing & where to do it, or have impeccable instructions. Of course, in the end it's not rocket science but on the Pi3 USB boot "just works". After that initial program_usb_boot_mode=1 edit, it looks to me to be objectively easier.

On the Pi4, keeping the sd card as /boot and editing the UUIDs is still the only option for now.

Reply to
A. Dumas

+1

Plus, if you then mount SD card /boot partition ReadOnly, any unexpected shutdown/power removal wont affect the SD card. If you do an update of the firmware you will need to re-mount the /boot partition as Read/Write first.

Jim

Reply to
Jim Jackson

Yes Easier - but you can't go back to SD card boot. I like to keep my options open. YMMV.

Have they still not got that working? Not checked recently, don't have a Pi4 yet.

Jim

Reply to
Jim Jackson

This is a point of interest. Can't go back to SD card boot at all, or can't go back to SD card boot when USB storage devices are present?

Thanks for writing!

bob prohaska

Reply to
bob prohaska

Untrue, sd card is always checked first (unless unset by gpio boot mode, which is an active intervention so normally not present). See

formatting link

Reply to
A. Dumas

Both untrue, sd is checked first. See

formatting link

Reply to
A. Dumas

Ooops! You are correct. It was a longish time since I checked. I have been under a misapprehension. Sorry.

Jim

Reply to
Jim Jackson

AIUI it is necessary to set the OTP boot mode on a plain 3B, so I did it using an existing microSD normally used to boot FreeBSD.

By some sort of blind luck I managed to boot a FreeBSD image on the USB flash stick (Sandisk Extreme 64GB) but can't repeat the trick.

With no microSD at all, the machine stops at the rainbow screen. There's no serial console output at all.

With a new, bootable microSD the machine comes up hands off from microSD, so the hardware isn't bricked.

It's possible to bring up a u-boot prompt, which offers a usbboot command, but I can't guess the syntax and can't find it anywhere. If I just issue usbboot it responds ** No device specified ** even when there's only one usb device and it's the one that booted previously.

The Pi is marked Raspberry Pi 3 model B version 1.2, so it is a relatively early Pi3, could that be my problem?

Thanks for all your help!

bob prohaska

Reply to
bob prohaska

For the sake of curiosity I had a look. I didn't get very far (not least because the U-Boot website seems to demand that I log-in in order to view the manual), but found this in the mailing list archive:

formatting link

No Pi3Bs here, nor a desire to USB boot them, so I can't give any more practical advice.

--
__          __ 
#_ < |\| |< _#
Reply to
Computer Nerd Kev

I didn't notice any login prompt on the Denx website, but neither did I notice any reference to usbboot. Perhaps the command is an enhancement by the folks at the Raspberry Pi Foundation? In that case one would expect something on their website, which I didn't find.

If I understand right, once booting from USB is enabled the Pi _should_ simply find the first bootable USB device and start from it. Perhaps that's why it worked unintentionally during my initial attempts. It's pointed out that the feature is somewhat fussy about which USB drives work at all, mine might be one of the edge cases and I got lucky the first time around.

I'll tinker a bit more when the Pi3B is idle again.

Thanks for posting!

bob prohaska

Reply to
bob prohaska

Having more than one USB device connected confuses the "boot from USB" switch. That's why I boot from SD card containing the /boot partition and then use "cmdline.txt" to define the root device. /boot partition defined in fstab. Also old / (mmcblk0p2), if it is still there, defined with noauto switch to stop it trying to mount automatically.

--

Chris Elvidge, England
Reply to
Chris Elvidge

The log-in must have been something gone wrong at the site, it's working for me now. You're right though, beyond a casual reference to using libusb, no real reference to the usbboot command that I could find.

BUT it is in fact vaguely documented in a README file included with the source code, which can be viewed here:

formatting link

Nah, that mailing list discussion was from 2005, so clearly USB booting was there before the Pi.

But clearly manually entering U-Boot commands isn't supposed to be required for USB booting with the Pi. Perhaps the Pi's firmware executes a usbboot command for a fixed USB [device]:[partition], and just hopes that it is where the OS is installed?

--
__          __ 
#_ < |\| |< _#
Reply to
Computer Nerd Kev

At this point I can talk to u-boot, like so:

U-Boot> usb reset resetting USB... Bus usb@7e980000: scanning bus usb@7e980000 for devices... 8 USB Device(s) found scanning usb for storage devices... 1 Storage Device(s) found

and

U-Boot> usb storage Device 0: Vendor: Initio Rev: 1.06 Prod: MHT2040AH Type: Hard Disk Capacity: 38154.3 MB = 37.2 GB (78140160 x 512)

What might the [device]:[partition] syntax for usbboot look like?

The USB device is a mechanical hard disk on a powered hub. Gpart reports gpart show da0 => 63 78140097 da0 MBR (37G) 63 2016 - free - (1.0M) 2079 102312 1 fat32lba [active] (50M) 104391 78035769 2 freebsd (37G)

The only hint I can find is U-Boot> help usbboot usbboot - boot from USB device

Usage: usbboot loadAddr dev:part

When I try U-Boot> usbboot usb@7e980000 0:1 the machine reports

Loading from usb device 0, partition 1: Name: usbda1 Type: U-Boot

** Unknown image type

Have I at least got the command syntax correct? If so the fault lies in my disk image.

Thanks for reading,

bob prohaska

Reply to
bob prohaska

Although I can't find it stated explicitly anywhere, based on all of the documentation that I've seen, I strongly suspect that in: usbboot loadAddr dev:part "loadAddr" is the memory address for the image to be loaded _to_, not from. With the Pi Zero, the Linux image is loaded to 0x8000 unless an alternative location is specified in config.txt. Unless this is different for the Pi3B, maybe: usbboot 8000 0:1 is correct?

I don't know why the error is "Unknown image type". Maybe it's just a misleading error message, or it really doesn't understand the image, or it actually did try to read and write to USB at the same time and caused any sort of chaos.

There's more about Linux booting here in the manual:

formatting link

Whether or not some/all of that is taken care of by this point, I'm not sure. I don't really know which point in the boot process you're at when you reach the U-Boot prompt, and whether config.txt and cmdline.txt have already been processed by the firmware.

--
__          __ 
#_ < |\| |< _#
Reply to
Computer Nerd Kev

Alas, seemingly not.

U-Boot> usb reset resetting USB... Bus usb@7e980000: scanning bus usb@7e980000 for devices... 8 USB Device(s) found scanning usb for storage devices... 1 Storage Device(s) found U-Boot> usbboot 8000 0:1

Loading from usb device 0, partition 1: Name: usbda1 Type: U-Boot

** Unknown image type

Perhaps merely a misleading error message.

After issuing a reset it prompts "hit any key to stop autoboot" that's where it stopped and gave a u-boot prompt. Config.txt is present:

bob@pelorus:/boot/msdos % more config.txt arm_control=0x200 dtparam=audio=on,i2c_arm=on,spi=on dtoverlay=mmc dtoverlay=pwm dtoverlay=pi3-disable-bt device_tree_address=0x4000 kernel=u-boot.bin program_usb_boot_timeout=1

There is no cmdline.txt, which surprises me. I thought one would be present by default.

I gather there's a version of bootcode.bin that supports usb booting on older model Pi's. Perhaps it's time to try that.

Thanks for reading!

bob prohaska

Reply to
bob prohaska

It's confirmed that the OTP bit for booting from USB has been set:

bob@raspberrypi:~$ vcgencmd otp_dump | grep 17:

17:3020000a

I'm still a bit puzzled at what should happen when there's no microSD card present, there is a bootable USB drive present and power is applied. Should I expect to see the green activity light flash in any particular way, or the drive activity light to do something special? Far as I can tell, neither happens.

Thanks for reading!

bob prohaska

Reply to
bob prohaska

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.