* [PATCH] environment: prefer non-removable over removable devices for autoprobe
@ 2025-11-27 12:41 Ahmad Fatoum
2025-11-28 7:08 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2025-11-27 12:41 UTC (permalink / raw)
To: barebox; +Cc: Sohaib Mohamed
From: Ahmad Fatoum <a.fatoum@barebox.org>
On systems with only 1-2 MiB of boot flash, it can be sensible to locate
the barebox environment outside of the boot medium.
In that case, it's sensible to give preference to non-removable devices,
so e.g. an eMMC is used instead of the SD-Card when booting from
neither, so adapt the scoring accordingly.
This could be further refined to make use of the eMMC non_removable
attribute, but this is already arguably an improvement.
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
common/environment.c | 8 ++++++--
include/block.h | 11 +++++++++++
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/common/environment.c b/common/environment.c
index 62b8120cbd7d..d7f5f51cfc6d 100644
--- a/common/environment.c
+++ b/common/environment.c
@@ -104,10 +104,14 @@ static struct cdev *default_environment_path_search(void)
if (IS_ERR(part))
continue;
- score++;
+ /* Prefer eMMC over SD if neither is the boot medium */
+ if (blockdevice_is_removable(blk))
+ score += 1;
+ else
+ score += 2;
if (boot_node && boot_node == blk->cdev.device_node)
- score++;
+ score += 4;
if (score > max_score) {
max_score = score;
diff --git a/include/block.h b/include/block.h
index fc7a0a32fb2d..84c247cee3a3 100644
--- a/include/block.h
+++ b/include/block.h
@@ -82,6 +82,17 @@ static inline int block_flush(struct block_device *blk)
return cdev_flush(&blk->cdev);
}
+static inline bool blockdevice_is_removable(struct block_device *blk)
+{
+ switch (blk->type) {
+ case BLK_TYPE_USB:
+ case BLK_TYPE_SD:
+ return true;
+ default:
+ return false;
+ }
+}
+
#ifdef CONFIG_BLOCK
unsigned file_list_add_blockdevs(struct file_list *files);
char *cdev_get_linux_rootarg(const struct cdev *partcdev);
--
2.47.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] environment: prefer non-removable over removable devices for autoprobe
2025-11-27 12:41 [PATCH] environment: prefer non-removable over removable devices for autoprobe Ahmad Fatoum
@ 2025-11-28 7:08 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2025-11-28 7:08 UTC (permalink / raw)
To: barebox, Ahmad Fatoum; +Cc: Sohaib Mohamed
On Thu, 27 Nov 2025 13:41:34 +0100, Ahmad Fatoum wrote:
> On systems with only 1-2 MiB of boot flash, it can be sensible to locate
> the barebox environment outside of the boot medium.
>
> In that case, it's sensible to give preference to non-removable devices,
> so e.g. an eMMC is used instead of the SD-Card when booting from
> neither, so adapt the scoring accordingly.
>
> [...]
Applied, thanks!
[1/1] environment: prefer non-removable over removable devices for autoprobe
https://git.pengutronix.de/cgit/barebox/commit/?id=7a94d2b0e9f2 (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-11-28 7:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-27 12:41 [PATCH] environment: prefer non-removable over removable devices for autoprobe Ahmad Fatoum
2025-11-28 7:08 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox