mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Konstantin Kletschke <konstantin.kletschke@inside-m2m.de>,
	barebox@lists.infradead.org
Subject: Re: Boot from SD if SD-Card is present - Beaglebone Black
Date: Mon, 2 May 2022 08:35:55 +0200	[thread overview]
Message-ID: <6d70e56b-1d6f-64dd-65f5-c8235803d6db@pengutronix.de> (raw)
In-Reply-To: <Ym6y6LXmdC9h3u4n@Hephaistos>

Hello Konstantin,

On 01.05.22 18:18, Konstantin Kletschke wrote:
> Hi All,
> 
> I have a Beaglebone Black whith internal MMC and external SD-Card
> interface.
> 
> I boot from internal MMC always. The system itself aways boots from
> internal MMC.
> 
> Is there a way - may be scriptable in boot entry - to start system from
> external SD-Card, if it is present?

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.

> 
> Normally I boot this way, bootchooser select system0 or system1:
> 
> #!/bin/sh
> 
> mount mmc1.1
> 
> global.bootm.image=/mnt/mmc1.1/boot/zImage
> global.bootm.oftree=/mnt/mmc1.1/boot/am335x-boneblack.dtb
> global.linux.bootargs.dyn.root="root=/dev/mmcblk0p2 rootfstype=ext4 rootwait"

"The barebox way" is to keep this configuration confined to the rootfs
as it makes it easier to change this parameters without changing the
bootloader. We usually do that with bootloader spec file (name it e.g.
/loader/entries/boneblack.conf):

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).

> If I stop autoboot and want to use external SD-Card I manually select
> insidem2m_sd as a boot entry:
> 
> #!/bin/sh
> 
> mount mmc0.1
> 
> global.bootm.image=/mnt/mmc0.1/boot/zImage
> global.bootm.oftree=/mnt/mmc0.1/boot/am335x-boneblack.dtb
> global.linux.bootargs.dyn.root="root=/dev/mmcblk1p2 rootfstype=ext4 rootwait"
> 
> Can this be something like:
> 
> IF external SD-CARD IS PRESENT bootentry is insidem2m_sd ELSE
> bootchooser

boot already accepts multiple boot targets to try in order,
so you could do boot mmc0.1 mmc1.1

Or if it yields better error messages:

  if detect mmc0; then
    boot mmc0.1
  fi

  boot mmc1.1

> Please obey if you are inspecting the CMDLINE, in more recent Kernels
> the mmcblk0 and mmcblk1 numbering is exchanged.

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

Cheers,
Ahmad

> 
> 
> Kind Regards
> Konstantin
> 
> 


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


  reply	other threads:[~2022-05-02  6:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-01 16:18 Konstantin Kletschke
2022-05-02  6:35 ` Ahmad Fatoum [this message]
2022-05-03 14:14   ` Konstantin Kletschke
2022-05-05  7:06     ` Sascha Hauer
2022-05-05  7:24       ` Konstantin Kletschke
2022-05-05  8:25         ` Sascha Hauer
2022-05-05  8:58           ` Konstantin Kletschke
2022-05-05  9:38           ` Konstantin Kletschke
2022-05-06 12:20             ` Ahmad Fatoum
2022-05-09  8:04               ` Konstantin Kletschke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6d70e56b-1d6f-64dd-65f5-c8235803d6db@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=konstantin.kletschke@inside-m2m.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox