BBGW - Changing boot order ?

Hello all,
I like to change the boot order on my BBGW device.

At the moment, if I power on it boots from the internal eMMC Card, if a
external storage Card in inserted, or not.
I have to press the the boot button during boot time to force a start with
the external Card.

I like to have it the other way:
If a valid external SD is fund, it will boot from this, other wise it will
boot from internal eMMC.
How do I do this?
Is there a documention about the boot process and disk partitions
somewhere, so I can find out by myself?

thank you in advance

There is a spec, which is used by default..

https://elinux.org/Beagleboard:U-boot_partitioning_layout_2.0#uEnv.txt_Rootfs_Partition_.2Fboot.2FuEnv.txt

but if your using a custom u-boot, then it's probably not enabled..

Regards,

Best overall documentation I could find is Derek Malloy’s “Exploring Beaglebone” textbook.
It was relatively cheap bought for Amazon Kindle and is an amazing resource for the things I want to do.
Yet it was written a while ago and some (many?) things have changed since it was written.

https://www.mouser.com/pdfdocs/BBG_SRM_V3.pdf is a good reference on how BBGW is intended to work.
It doesn’t tell you much about how it does what it does, or how to change it.

I believe there is no documented way to switch boot order to favor sdcard over u-boot other than the boot button.

https://www.linuxjournal.com/content/handy-u-boot-trick is a good article on some ways to change u-boot rules but as the title suggests it’s more of a “u boot trick” than a standardized way to switch boot order such as a boot manager.

I booted my board using the u-boot on eMMC then used u-boot commands on the serial port to boot my linux from sdcard.
The linux I booted was the yocto build that the textbook above described how to build.
See my notes below.
This may be enough to get you going?

I’d like come up with a way to select an image via the debug serial port.
Some sort of boot manager / image selector like grub is for the x86 world.
But I haven’t spent any time investigating that path.

Here are my notes.

=> ext4ls mmc 0:2 /boot

4096 . 4096 .. 58296 am335x-boneblack.dtb 56480 am335x-bone.dtb 6785592 zImage-5.2.17-yocto-standard 56736 am335x-bonegreen.dtb 28 zImage

=> setenv loadzimage “load mmc 0:2 ${loadaddr} /boot/zImage”
=> setenv loadftd “load mmc 0:2 ${fdtaddr} /boot/am335x-boneblack.dtb”
=> setenv bootargs “console=ttyO0,115200n8 root=/dev/mmcblk0p2 ro rootfstype=ext4 rootwait fixrtc ${optargs}”
=> run loadzimage
6785592 bytes read in 459 ms (14.1 MiB/s)
=> run loadftd
58296 bytes read in 24 ms (2.3 MiB/s)
=> bootz ${loadaddr} - ${fdtaddr}

Flattened Device Tree blob at 88000000

Booting using the fdt blob at 0x88000000
Loading Device Tree to 8ffee000, end 8ffff3b7 … OK

Starting kernel …

Is there a workable way to “corrupt” the MLO in eMMC so the first level program loader in ROM skips over it and tries sdcard instead?

On a board I used to work on the ROM looked for a magic number at the start of each flash sector and if you overwrote the magic number with 1s (i.e. erased the sector) it would not use the flash and would fail over to trying removable media.

This let us come up with a scheme to store the intentionally corrupted boot sector elsewhere on the flash when we wanted to boot to external media then restore it (with the correct magic number) when we wanted to boot from flash.

Another scheme as above would be to always boot using eMMC’s MLO and u-boot.img then use rules in eMMC’s /boot/uEnv.txt that establish the default bootcmd and provide alternates you can use to override the default bootcmd as needed to pull linux and device tree from whatever source you prefer (sdcard, tftp, nfs, etc).

For I workshop we had to use dd to write zeroes to the typical location of uboot.
That would be breaking the uboot partition.

Note that uboot is very flexible. It has some useful predefined variables through which you can easily configure booting. For example, uboot just calls: run bootcmd.
So if you set bootcmd to match your wishes, you will have the booting behavior you want.
I typically use: run netboot.
That’s defined by default and I set all other variables to make the netboot run as I please.
Don’t forget saveenv.
http://etutorials.org/Linux+systems/embedded+linux+systems/Chapter+9.+Setting+Up+the+Bootloader/9.5+U-Boot/

There is are also options to scan for possible bootable partitions, but I don’t know the details.
I have not seen uboot present any menu like grub does.

Thank you Hugo. I agree with everything you wrote. In particular the built in u-boot variables are helpful and aren’t too hard to change once you put in the time to understand how they work. As I said I have not done any research to see if a menu based option is available. If nothing is available it would probably not be too hard to create u-boot scripts with if/then/else/fi to make a simple text menu option available to select eMMC vs sdcard at boot time.

Regards,
Dave

sudo dd if=/dev/zero of=/dev/mmcblk1 seek=256 count=1

Matthijs