All of lore.kernel.org
 help / color / mirror / Atom feed
From: Quentin Schulz <quentin.schulz@cherry.de>
To: Daniel Golle <daniel@makrotopia.org>,
	u-boot@lists.denx.de, Simon Glass <sjg@chromium.org>
Cc: Quentin Schulz <foss+dt@0leil.net>,
	Ahmad Fatoum <a.fatoum@pengutronix.de>,
	Heiko Stuebner <heiko@sntech.de>,
	devicetree-spec@vger.kernel.org
Subject: Re: [PATCH] Add 'bootsource' /chosen property
Date: Thu, 20 Feb 2025 16:04:27 +0100	[thread overview]
Message-ID: <07eb10ff-2791-420d-a302-a2e8c308b468@cherry.de> (raw)
In-Reply-To: <5E98D444-A005-42CD-8A6A-381791237A6E@makrotopia.org>

Hi Daniel,

On 2/15/25 4:13 PM, Daniel Golle wrote:
> Hi Quentin,
> 
> On 10 February 2025 16:25:23 UTC, Quentin Schulz <quentin.schulz@cherry.de> wrote:
>> [...]
>> What I can say from glancing at the code is that for Rockchip they do the following:
>>
>> Register a bootsource type (e.g. MMC, SPI, I2C, USB, etc...), a bootsource instance of that type (e.g. MMC0, SPI3, I2C7, ...). The mapping between what the ROM says the device is vs what it is in the DT is done in their Barebox-specific DT via this custom prop in /chosen:
>>
>> barebox,bootsource-<bootsourcetype><bootsourceinstance> = &label;  # à-la /aliases
>>
>> This gets read and resolved and then inserted as
>>
>> /chosen/bootsource = "/some/path"
>>
>> into the kernel DT.
> 
> We are doing something quite similar downsream at openwrt.org for MediaTek router SoCs, see for example:
> 
> https://github.com/openwrt/openwrt/blob/main/package/boot/uboot-mediatek/patches/310-mt7988-select-rootdisk.patch
> 
> https://github.com/openwrt/openwrt/blob/main/target/linux/mediatek/files-6.6/arch/arm64/boot/dts/mediatek/mt7988a-bananapi-bpi-r4.dtsi#L32
> 
> https://github.com/openwrt/openwrt/blob/main/target/linux/mediatek/files-6.6/arch/arm64/boot/dts/mediatek/mt7988a-bananapi-bpi-r4-emmc.dtso#L60
> 
> 
> Of course we could use the standard "bootsource" property instead, but having a way to reference the volume or partition used as rootfs instead of just passing a referencd to a physical device is advantagous...
> 

If I understood correctly, your prebuilt DT would have

/ {
     chosen {
         rootdisk-emmc = <&rootfs_in_emmc>;
         rootdisk-nor = <&rootfs_in_nor>;
         rootdisk-sd = <&rootfs_in_sd>;
         rootdisk-spim-nand = <&rootfs_in_ubi>;
     };
};

and then at runtime you would populate /chosen/rootdisk property with 
the "rootdisk-<medium>" string with <medium> matching whatever the 
BootROM reports. I assume the goal is to somehow make sure that the 
rootfs is loaded from the same storage medium as the one used by the 
BootROM to load the first stage bootloader?

Can you confirm I did get that right?

I was specifically NOT aiming /chosen/bootsource to represent the 
storage medium used to load the kernel or rootfs, but rather the medium 
that was used by the BootROM to load the first stage of the bootloader 
that is user-flashable/uploadable.

You could very well decide to load/mount your rootfs from SD even if the 
BootROM loaded the first stage bootloader from SPI-NOR. This property is 
about representing the latter, not the former and not merging the 
meaning of both into one.

However, I could see a BootROM being able to report from which partition 
and controller it loaded the first stage bootloader, and then it'd make 
sense to have that in /chosen, either as part of /chosen/bootsource or 
an additional property like /chosen/bootsource-partition.

Cheers,
Quentin

  reply	other threads:[~2025-02-20 15:04 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-05  9:11 [PATCH] Add 'bootsource' /chosen property Quentin Schulz
2025-02-06 12:33 ` Simon Glass
2025-02-06 15:46   ` Quentin Schulz
2025-02-09 14:28     ` Simon Glass
2025-02-10 16:25       ` Quentin Schulz
2025-02-15 11:59         ` Simon Glass
2025-02-15 12:47           ` Mark Kettenis
2025-02-15 13:04             ` Simon Glass
2025-02-20 14:52               ` Quentin Schulz
2025-02-15 15:13         ` Daniel Golle
2025-02-20 15:04           ` Quentin Schulz [this message]
2025-02-20 15:22             ` Daniel Golle
2025-02-20 15:54               ` Quentin Schulz
2025-02-23  0:33                 ` Simon Glass
2025-02-20 15:52         ` Ahmad Fatoum

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=07eb10ff-2791-420d-a302-a2e8c308b468@cherry.de \
    --to=quentin.schulz@cherry.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=daniel@makrotopia.org \
    --cc=devicetree-spec@vger.kernel.org \
    --cc=foss+dt@0leil.net \
    --cc=heiko@sntech.de \
    --cc=sjg@chromium.org \
    --cc=u-boot@lists.denx.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.