[PATCH 1/2] distro_bootcmd: Add support for customizable find_distro_rootpart
Kory Maincent (TI.com)
kory.maincent at bootlin.com
Fri Oct 31 17:36:03 CET 2025
Commit d0ba0ca45a49 ("distro_bootcmd: Set distro_bootpart_uuid for block
devices") added support for the distro_boot_part_uuid environment variable
to allow using PARTUUID in the kernel command line.
However, the way it was written only supports the case where the boot files
and the rootfs are located in the same partition. There are many cases
where the boot partition and rootfs partition are separate.
Add a customizable find_distro_rootpart command to allow each board to
define its own logic for locating the rootfs partition. This provides
flexibility for boards with custom partition layouts while maintaining
backward compatibility for the default case where boot and rootfs share
the same partition.
Signed-off-by: Kory Maincent (TI.com) <kory.maincent at bootlin.com>
---
doc/develop/distro.rst | 11 +++++++++++
include/config_distro_bootcmd.h | 10 +++++++---
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/doc/develop/distro.rst b/doc/develop/distro.rst
index 01efce40a29..4468cf7c95a 100644
--- a/doc/develop/distro.rst
+++ b/doc/develop/distro.rst
@@ -312,6 +312,17 @@ scriptaddr:
A size of 1MB for extlinux.conf is more than adequate.
+find_distro_rootpart:
+ Optional. Sets the rootfs partition by applying distro boot enumeration logic,
+ allowing the boot partition environment variables (distro_bootpart, devtype,
+ devnum, etc.) to be reused for rootfs detection.
+
+ For example::
+
+ "find_distro_rootpart=" \
+ "setexpr distro_rootpart ${distro_bootpart} + 1 ;" \
+ "part uuid ${devtype} ${devnum}:${distro_rootpart} rootpart_uuid ;\0"
+
For suggestions on memory locations for ARM systems, you must follow the
guidelines specified in Documentation/arm/Booting in the Linux kernel tree.
diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
index 7b6ac6eed9d..d0e125af6f8 100644
--- a/include/config_distro_bootcmd.h
+++ b/include/config_distro_bootcmd.h
@@ -549,9 +549,13 @@
"if fstype ${devtype} " \
"${devnum}:${distro_bootpart} " \
"bootfstype; then " \
- "part uuid ${devtype} " \
- "${devnum}:${distro_bootpart} " \
- "distro_bootpart_uuid ; " \
+ "if test -n ${find_distro_rootpart}; then " \
+ "run find_distro_rootpart; " \
+ "else " \
+ "part uuid ${devtype} " \
+ "${devnum}:${distro_bootpart} " \
+ "distro_bootpart_uuid ; " \
+ "fi; " \
"run scan_dev_for_boot; " \
"fi; " \
"done; " \
--
2.43.0
More information about the U-Boot
mailing list