Beaglebone Black Booting From USB

Hello all,

I have done some searching into the topic of booting from a USB on the BBB, and have come across two general replies:

  1. It’s not possible

  2. It’s possible, but in order to do it you need to have a powered USB hard drive to do it (wtf?)

I wasn’t convinced either of these were factually correct, so I cloned the u-boot source, and applied the Robert C. Nelson patch set (March, 2016), and wrote a simple Hush script inside of include/configs/ti_armv7_common.h

Right underneath the regular boot script, I wrote this:

"usb_boot=usb start; "
"if usb info; then "
"echo Found USB device, checking if bootable…; "
"else run boot; "
"fi; "
"if test -e usb 0:1 /boot/uEnv.txt; then "
"echo Bootable partition on USB! booting…; "
"setenv interface usb; "
"setenv bootpart 0:1; "
"else run boot; "
"fi; "
"run loadbootenv; "
"run importbootenv; "
"setenv cmdline ${cmdline} root=/dev/sda1; "
"echo Loaded boot environment from USB.; "
"if test -n ${cape}; then "
"if test -e ${interface} ${bootpart} ${fdtdir}/${fdtbase}-${cape}.dtb; then "
"setenv fdtfile ${fdtbase}-${cape}.dtb; "
"fi; "
"echo using: $fdtfile…; "
"fi; "
“echo Checking if uenvcmd is set …;”
"if test -n ${uenvcmd}; then "
"gpio set 56; "
“echo Running uenvcmd …;”
"run uenvcmd; "
"fi; "
"echo checking for boot script; "
"if test -e ${interface} ${bootpart} /boot/${script}; then "
“gpio set 55;”
“setenv scriptfile /boot/${script};”
“run loadbootscript;”
“echo Loaded script from ${scriptfile};”
"gpio set 56; "
“run bootscript;”
"fi; "
"echo Running uname_boot; "
“run uname_boot;\0” \

Forgive me for the leading/trailing quotation marks, they’re necessary to get it to work inside of those header files (all of the default scripts are written in-line as #define’s).

After implementing that, I changed BOOTENV_DEV_LEGACY_MMC to run usb_boot instead of boot, and it seems to work like a charm.

My question to you is this:
Is there a better way to do it that you know of? If not, is this a good way to do it?

-Fred

That'll work fine. u-boot's on the am335x is getting to a point where we
could scan usb by default..

When most people ask about "booting" from USB, the issue is:

the 'bootrom' doesn't automatically init the usb bus and read from a usb
flash device..

In your case, you are using u-boot, which the bootrom loaded off the
microSD card, to read the usb flash device.

Regards,

2) It’s possible, but in order to do it you need to have a powered USB hard drive to do it (wtf?)

What do you mean wtf ?! Do you propose to pull 3A+ over USB 2 which by design is intended to provide only 500ma, and where the beaglebone in question could potentially be powered by USB it’s self. Thus having at most maybe 100ma to spare ?

Because, at spin up a hard drive can use up to 3A+, and while under normal operating conditions can use 1A or more.

Anyway, technically it’s not possible to “boot” from USB, if one means loading boot loaders via USB. However, if one means loading a root file system over USB at boot time. Then yes, this is possible.

As far as I know however, I’m the only person to blog on this. Here: http://www.embeddedhobbyist.com/2013/07/beaglebone-black-usb-boot/

A couple things to note:

First, there is no need to convert the zImage file to uImage. In fact, I’m not sure what we would use now, as the Linux images have changed considerably. So I’d have to do a bit of research, and experiment.

Secondly, Robert has since changed from a two partition set up, to a single partition set up. With the boot loaders being placed within the first 1M of media used( actually only 512k space used . . ) . Or in other words, the boot loaders are now placed in the MBR. So, this is not a big deal, one just needs to be aware of it.