Boot from SD if SD-Card is present - Beaglebone Black

Konstantin Kletschke konstantin.kletschke at inside-m2m.de
Tue May 3 07:14:37 PDT 2022


On Mon, May 02, 2022 at 08:35:55AM +0200, Ahmad Fatoum wrote:

> There is, but I'd check first if it's possible to boot from eMMC only
> as a fallback if SD boot failed. On some bootroms, this is possible
> and can easily be scripted in barebox with $global.bootsource
> and $global.bootsource_instance variables.

When I type "magicvars" I have no global.boosource. Is that a "no
bootsource in your bootrom" or has this a fetaure to be enabled as
a CONFIG_ at compile time? 

However, booting from internal MMC is normal use case, SD-Cards are only
inserted for updates and if some invalid SD-Card is inserted and system
does not boot because of that I can live with that.

> title		BeagleBone Black - M2M
> version		5.17
> options		rootwait
> linux		/boot/zImage
> devicetree	/boot/am335x-boneblack.dtb
> linux-appendroot true
> 
> This way, you can just type boot mmc1.1 to boot. linux-appendroot
> will have barebox add a root= option pointing at the device it read
> the bootloader spec file from. You'll want to set CONFIG_MMCBLKDEV_ROOTARG=y
> to get root=/dev/mmcblk* fixups instead of partuuid (which might be the
> same if you have the exact same image on SD and eMMC).

I already investigated bootloader spec but have it much more complicated
in memory. This is darn simple and allows me to boot from different
partitions with this same identical setup, right? I will go for it.

I have no CONFIG_MMCBLKDEV_ROOTARG=y, UUID is fine since all roots are
individually formatted, no same image.

But alas, the rootfs is not appended. I created an entry just like you
proposed and this happens:


barebox at TI AM335x BeagleBone black:/ boot mmc1.2
ext4 ext40: EXT2 rev 1, inode_size 256, descriptor size 64
Booting entry 'BeagleBone Black - M2M (/mnt/mmc1.2/loader/entries/boneblack.conf)'
blspec: booting BeagleBone Black - M2M from mmc1

Loading ARM Linux zImage '/mnt/mmc1.2//boot/zImage'
Loading devicetree from '/mnt/mmc1.2//boot/am335x-boneblack.dtb'
commandline: console=ttyS0,115200n8 rootwait
[...]
Waiting for root device ...

What could I do about this? 

> boot already accepts multiple boot targets to try in order,

Okay, I was just not aware somehow. To use it for that.

So /env/nv/boot.default will take "mmc0.1 bootchooser" with bootchooser
deciding between internal mmc1.1 and mmc1.2.
If i get bootloader spec booting to fly.


>   if detect mmc0; then
>     boot mmc0.1
>   fi
> 
>   boot mmc1.1

Where is this scripting stuff going into? It is not boot.default (gives
me errors like "no entry if ... found"), is this going into entry
boot.default points to?

Since I have bootloader spec not running yet, I have "insidem2m_sd
bootchooser" in /env/nv/boot.default. This works well, if no SD-Card is
inserted and I get a nasty red error with both variants.

Without the detect mechanism in insidem2m_sd I get

Booting entry 'insidem2m_sd'
mount: No such file or directory
could not open /mnt/mmc0.1/boot/zImage: No such file or directory
ERROR: Booting entry 'insidem2m_sd' failed
Booting entry 'bootchooser'

with this detect mechanism I get

Booting entry 'insidem2m_sd'
detect: Connection timed out
ERROR: Running script '/env/boot/insidem2m_sd' failed: error -127
ERROR: Booting entry 'insidem2m_sd' failed
Booting entry 'bootchooser'

Each time it goes to bootchooser which successfully boots internal
MMC... When SD-Card is inserted it chooses it successfully in both ways,
so both variants work well.

> On less recent kernels, the order might change, but at least now it's
> fixed (with aliases).

I spent the whole day to update Kernel, bootloader, rescue SD-Cards,
Install scripts so now internal mmc is mmcblk1, external SD-Card is
mmcblk0 (5.10.12 -> 5.10.63). Like barebox was alaways.


Kind Regards
Konstantin Kletschke

-- 
INSIDE M2M GmbH
Konstantin Kletschke
Berenbosteler Straße 76 B
30823 Garbsen

Telefon: +49 (0) 5137 90950136
Mobil: +49 (0) 151 15256238
Fax: +49 (0) 5137 9095010

konstantin.kletschke at inside-m2m.de
http://www.inside-m2m.de 

Geschäftsführung: Michael Emmert, Ingo Haase, Dr. Fred Könemann, Derek Uhlig
HRB: 111204, AG Hannover




More information about the barebox mailing list