Booting Pi Zero from USB?

General discussion about anything related to Ultibo.
Poi
Posts: 31
Joined: Mon Jan 07, 2019 11:57 pm

Booting Pi Zero from USB?

Postby Poi » Tue Apr 09, 2019 8:48 pm

That's pretty much it, is there a trick to getting a pi zero to boot from a USB device? Is it even possible? I am not clear on that.

The only information I could find is this

https://raspberrypi.stackexchange.com/questions/62965/boot-zero-w-from-usb-device

and this

https://github.com/raspberrypi/documentation/blob/master/hardware/raspberrypi/bootmodes/msd.md

Which suggest that it can be done by inserting a micro sd with only bootcode.bin and if there is a USB device connected (presumably with the rest of the files), then everything should work. Obviously I haven't been able to get it to work, that is why I am posting :(

Any idea anyone?
Gavinmc42
Posts: 1601
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: Booting Pi Zero from USB?

Postby Gavinmc42 » Wed Apr 10, 2019 12:11 am

The Zero still uses the BCM2835 and the internal ROM based boot code has not changed.
For the BCM2837 they modified the internal rom to boot from more options.
That is why they say use the SD card with bootcode.bin on it.
This is a more advanced booter with more options.

I use Zero's booting from USB form PC's with no card but that is OTG mode.
You can get USB sticks that are dual USB/microUSB OTG.

I have some but never thought to see if this would work.
Is a setting in config.txt needed?

Timeout related?
If you have a problem with a mass storage device still not working even with this bootcode.bin, then please add a new file 'timeout' to the SD card. This should extend the time it waits for the mass storage device to initialise to six seconds.


Might get some debug output on the serial port, Is this a bootcode.bin hack?

Code: Select all

sed -i -e "s/BOOT_UART=0/BOOT_UART=1/" bootcode.bin

Going to take a hexeditor to bootcode.bin now ;)
Poi
Posts: 31
Joined: Mon Jan 07, 2019 11:57 pm

Re: Booting Pi Zero from USB?

Postby Poi » Wed Apr 10, 2019 12:28 am

It turns out the method does work, for future reference that is

1) Copy all the files into a Fat32 formatted USB stick, that is kernel.img, bootcode.bin, fixup.dat and start.elf, plus the rest of the optional files.
2) Copy just the single file bootcode.bin into an empty Fat32 micro sd
3) Plug everything, turn the power on, and it should work.

The problem that I am facing now is that it is super slow! It takes about 30 seconds to boot this way. I was hoping to save some time and hassle with this method of booting, but 30 seconds is too long.

Could I improve that time using a better USB stick?
Poi
Posts: 31
Joined: Mon Jan 07, 2019 11:57 pm

Re: Booting Pi Zero from USB?

Postby Poi » Wed Apr 10, 2019 12:33 am

Timeout related?


In the end I didn't have to do that. Just adding a file named "timeout" sounded super suspicious too :P

Might get some debug output on the serial port, Is this a bootcode.bin hack?


No, it is not hacked in any way, just the regular file you can find in https://github.com/raspberrypi/firmware
Gavinmc42
Posts: 1601
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: Booting Pi Zero from USB?

Postby Gavinmc42 » Wed Apr 10, 2019 1:41 am

A hack for me is hex editing a file.
Yes there is a "BOOT_UART=0" in bootcode.bin ;)
Never thought of using SED as a file hacking tool before 8-)

I need to try this too.
Not all USB sticks are the same I have found.
Wonder if a USB reader and SD card would work too?
User avatar
Ultibo
Site Admin
Posts: 2224
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: Booting Pi Zero from USB?

Postby Ultibo » Thu Apr 11, 2019 11:29 pm

Poi wrote:The problem that I am facing now is that it is super slow! It takes about 30 seconds to boot this way. I was hoping to save some time and hassle with this method of booting, but 30 seconds is too long.

Could I improve that time using a better USB stick?

Did a couple of tests and the time taken to boot from USB seems to be relatively consistent at about 30 seconds regardless of which USB stick is used.

Not sure if you've tried the usbboot option which uses OTG mode to boot the Pi Zero from a Linux or Windows host but in a quick test it appeared just slightly faster than booting from a USB stick although possibly not enough to make it worthwhile.

Otherwise we really need a network option for the Zero (and A+/3A+) to speed up the development process.
Ultibo.org | Make something amazing
https://ultibo.org
User avatar
Ultibo
Site Admin
Posts: 2224
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: Booting Pi Zero from USB?

Postby Ultibo » Thu Apr 11, 2019 11:41 pm

Gavinmc42 wrote:Yes there is a "BOOT_UART=0" in bootcode.bin ;)

Thanks for pointing this out (documented here), seems to be a very new option but it might finally give us a way to work out why our Ultibo driver for the Pi usbboot won't complete the final step in the boot process.
Ultibo.org | Make something amazing
https://ultibo.org
Gavinmc42
Posts: 1601
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: Booting Pi Zero from USB?

Postby Gavinmc42 » Fri Apr 12, 2019 2:27 am

Some times are given here.
https://www.raspberrypi.org/documentati ... ootflow.md

Use a SD card with nothing on it to boot faster to USB?

Boot order SD1, SD2, NAND, SPI, USB.

That SPI mode would be interesting for Pi's as SPI chips can be soldered which increases reliability.
SD2? Some LCD hats have a SD or uSD card socket?

Did a couple of tests and the time taken to boot from USB seems to be relatively consistent at about 30 seconds regardless of which USB stick is used.

I noticed that too, wondering if the internal boot rom defaults to the simpler, slower USB mode?
What goes on inside USD drives?
Make a USB MSD from an Arduino?
If you use a SD card with only bootcode.bin on it will it boot faster from USB?

The boot ROM is only about 32KB? Which is not much for all those boot options.
hansotten
Posts: 58
Joined: Thu Feb 04, 2016 7:07 am

Re: Booting Pi Zero from USB?

Postby hansotten » Fri Apr 12, 2019 6:13 am

The PI SOC has 2 SD channels, therefore SD1, SD2

Return to “Discussion”

Who is online

Users browsing this forum: No registered users and 3 guests