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:
-
It’s not possible
-
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