* [PATCH v3 01/20] MAINTAINERS: Add maintainer for extension board support
2025-10-13 13:32 [PATCH v3 00/20] Convert extension support to UCLASS and adds its support to boot flows Kory Maincent (TI.com)
@ 2025-10-13 13:32 ` Kory Maincent (TI.com)
2025-10-13 13:32 ` [PATCH v3 02/20] board: ti: Exclude cape detection from XPL builds Kory Maincent (TI.com)
` (19 subsequent siblings)
20 siblings, 0 replies; 40+ messages in thread
From: Kory Maincent (TI.com) @ 2025-10-13 13:32 UTC (permalink / raw)
To: Tom Rini, Simon Glass, Jagan Teki, Andre Przywara, Hans de Goede,
Mario Six, Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team,
Ying-Chun Liu (PaulLiu)
Cc: Roger Quadros, Bajjuri Praneeth, Thomas Petazzoni, u-boot,
Kory Maincent (TI.com), Mattijs Korpershoek
Add myself as maintainer for the extension board support that was
originally added to track ongoing development and maintenance.
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
---
MAINTAINERS | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index 12043a1f82e..e411e266c94 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1182,6 +1182,14 @@ F: scripts/event_dump.py
F: test/common/event.c
F: test/py/tests/test_event_dump.py
+EXTENSION
+M: Kory Maincent <kory.maincent@bootlin.com>
+S: Maintained
+F: board/sunxi/chip.c
+F: board/ti/common/cape_detect.c
+F: cmd/extension_board.c
+F: include/extension_board.h
+
FASTBOOT
M: Mattijs Korpershoek <mkorpershoek@kernel.org>
S: Maintained
--
2.43.0
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH v3 02/20] board: ti: Exclude cape detection from XPL builds
2025-10-13 13:32 [PATCH v3 00/20] Convert extension support to UCLASS and adds its support to boot flows Kory Maincent (TI.com)
2025-10-13 13:32 ` [PATCH v3 01/20] MAINTAINERS: Add maintainer for extension board support Kory Maincent (TI.com)
@ 2025-10-13 13:32 ` Kory Maincent (TI.com)
2025-10-13 13:32 ` [PATCH v3 03/20] board: ti: Fix CAPE_EEPROM_BUS_NUM Kconfig dependency Kory Maincent (TI.com)
` (18 subsequent siblings)
20 siblings, 0 replies; 40+ messages in thread
From: Kory Maincent (TI.com) @ 2025-10-13 13:32 UTC (permalink / raw)
To: Tom Rini, Simon Glass, Jagan Teki, Andre Przywara, Hans de Goede,
Mario Six, Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team,
Ying-Chun Liu (PaulLiu)
Cc: Roger Quadros, Bajjuri Praneeth, Thomas Petazzoni, u-boot,
Kory Maincent (TI.com)
Disable cape detection functionality in XPL (eXtended Program Loader)
images to reduce size and complexity in the early boot stage.
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Changes in v2:
- Use PHASE macro instead of XPL check.
- Check SUPPORT_EXTENSION_SCAN instead of CONFIG_CMD_EXTENSION
---
board/ti/common/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/board/ti/common/Makefile b/board/ti/common/Makefile
index caf6b9fa8c1..f58935b4103 100644
--- a/board/ti/common/Makefile
+++ b/board/ti/common/Makefile
@@ -2,6 +2,6 @@
# Copyright (C) 2015-2016 Texas Instruments Incorporated - https://www.ti.com/
obj-${CONFIG_TI_I2C_BOARD_DETECT} += board_detect.o
-obj-${CONFIG_CMD_EXTENSION} += cape_detect.o
+obj-${CONFIG_$(PHASE_)SUPPORT_EXTENSION_SCAN} += cape_detect.o
obj-${CONFIG_OF_LIBFDT} += fdt_ops.o
obj-${CONFIG_ARCH_K3} += k3-ddr.o
--
2.43.0
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH v3 03/20] board: ti: Fix CAPE_EEPROM_BUS_NUM Kconfig dependency
2025-10-13 13:32 [PATCH v3 00/20] Convert extension support to UCLASS and adds its support to boot flows Kory Maincent (TI.com)
2025-10-13 13:32 ` [PATCH v3 01/20] MAINTAINERS: Add maintainer for extension board support Kory Maincent (TI.com)
2025-10-13 13:32 ` [PATCH v3 02/20] board: ti: Exclude cape detection from XPL builds Kory Maincent (TI.com)
@ 2025-10-13 13:32 ` Kory Maincent (TI.com)
2025-10-13 13:32 ` [PATCH v3 04/20] board: sunxi: Exclude DIP detection from XPL builds Kory Maincent (TI.com)
` (17 subsequent siblings)
20 siblings, 0 replies; 40+ messages in thread
From: Kory Maincent (TI.com) @ 2025-10-13 13:32 UTC (permalink / raw)
To: Tom Rini, Simon Glass, Jagan Teki, Andre Przywara, Hans de Goede,
Mario Six, Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team,
Ying-Chun Liu (PaulLiu)
Cc: Roger Quadros, Bajjuri Praneeth, Thomas Petazzoni, u-boot,
Kory Maincent (TI.com)
The CAPE_EEPROM_BUS_NUM configuration option was incorrectly depending
on CMD_EXTENSION, which represents the extension board command. However,
the cape scan functionality can be built and used independently of the
command interface through the SUPPORT_EXTENSION_SCAN option.
Change the dependency from CMD_EXTENSION to SUPPORT_EXTENSION_SCAN to
properly reflect that the I2C bus configuration is needed for the cape
scan function itself, not specifically for the command.
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Change in v3:
- New patch
---
board/ti/common/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/board/ti/common/Kconfig b/board/ti/common/Kconfig
index f481812247c..9512c5c23f1 100644
--- a/board/ti/common/Kconfig
+++ b/board/ti/common/Kconfig
@@ -20,7 +20,7 @@ config CAPE_EEPROM_BUS_NUM
int "Cape EEPROM's I2C bus address"
range 0 8
default 2
- depends on CMD_EXTENSION
+ depends on SUPPORT_EXTENSION_SCAN
config TI_COMMON_CMD_OPTIONS
bool "Enable cmd options on TI platforms"
--
2.43.0
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH v3 04/20] board: sunxi: Exclude DIP detection from XPL builds
2025-10-13 13:32 [PATCH v3 00/20] Convert extension support to UCLASS and adds its support to boot flows Kory Maincent (TI.com)
` (2 preceding siblings ...)
2025-10-13 13:32 ` [PATCH v3 03/20] board: ti: Fix CAPE_EEPROM_BUS_NUM Kconfig dependency Kory Maincent (TI.com)
@ 2025-10-13 13:32 ` Kory Maincent (TI.com)
2025-10-13 13:32 ` [PATCH v3 05/20] board: compulab: Exclude compulab extension board " Kory Maincent (TI.com)
` (16 subsequent siblings)
20 siblings, 0 replies; 40+ messages in thread
From: Kory Maincent (TI.com) @ 2025-10-13 13:32 UTC (permalink / raw)
To: Tom Rini, Simon Glass, Jagan Teki, Andre Przywara, Hans de Goede,
Mario Six, Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team,
Ying-Chun Liu (PaulLiu)
Cc: Roger Quadros, Bajjuri Praneeth, Thomas Petazzoni, u-boot,
Kory Maincent (TI.com)
Disable DIP detection functionality in XPL (eXtended Program Loader)
images to reduce size and complexity in the early boot stage.
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Change in v2:
- New patch.
---
board/sunxi/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/board/sunxi/Makefile b/board/sunxi/Makefile
index d96b7897b6c..ee82493117a 100644
--- a/board/sunxi/Makefile
+++ b/board/sunxi/Makefile
@@ -11,4 +11,4 @@ obj-$(CONFIG_SUN7I_GMAC) += gmac.o
obj-$(CONFIG_MACH_SUN4I) += dram_sun4i_auto.o
obj-$(CONFIG_MACH_SUN5I) += dram_sun5i_auto.o
obj-$(CONFIG_MACH_SUN7I) += dram_sun5i_auto.o
-obj-$(CONFIG_CHIP_DIP_SCAN) += chip.o
+obj-$(CONFIG_$(PHASE_)CHIP_DIP_SCAN) += chip.o
--
2.43.0
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH v3 05/20] board: compulab: Exclude compulab extension board detection from XPL builds
2025-10-13 13:32 [PATCH v3 00/20] Convert extension support to UCLASS and adds its support to boot flows Kory Maincent (TI.com)
` (3 preceding siblings ...)
2025-10-13 13:32 ` [PATCH v3 04/20] board: sunxi: Exclude DIP detection from XPL builds Kory Maincent (TI.com)
@ 2025-10-13 13:32 ` Kory Maincent (TI.com)
2025-10-13 13:32 ` [PATCH v3 06/20] include: extension_board: Document the extension structure Kory Maincent (TI.com)
` (15 subsequent siblings)
20 siblings, 0 replies; 40+ messages in thread
From: Kory Maincent (TI.com) @ 2025-10-13 13:32 UTC (permalink / raw)
To: Tom Rini, Simon Glass, Jagan Teki, Andre Przywara, Hans de Goede,
Mario Six, Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team,
Ying-Chun Liu (PaulLiu)
Cc: Roger Quadros, Bajjuri Praneeth, Thomas Petazzoni, u-boot,
Kory Maincent (TI.com)
Disable compulab extension board detection functionality in XPL (eXtended
Program Loader) images to reduce size and complexity in the early boot
stage.
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Change in v2:
- New patch.
---
board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c b/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c
index bda7aac5be4..be4f293bd4a 100644
--- a/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c
+++ b/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c
@@ -249,6 +249,8 @@ int board_mmc_get_env_dev(int devno)
#define IOT_GATE_IMX8_EXT_I2C_ADDR_GPIO 0x22 /* I2C address of the GPIO
extender */
+#if !IS_ENABLED(CONFIG_XPL_BUILD)
+
static int iot_gate_imx8_ext_id = IOT_GATE_EXT_EMPTY; /* Extension board ID */
static int iot_gate_imx8_ext_ied_id [3] = {
IOT_GATE_IMX8_CARD_ID_EMPTY,
@@ -541,6 +543,7 @@ int extension_board_scan(struct list_head *extension_list)
return ret;
}
+#endif
static int setup_mac_address(void)
{
--
2.43.0
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH v3 06/20] include: extension_board: Document the extension structure
2025-10-13 13:32 [PATCH v3 00/20] Convert extension support to UCLASS and adds its support to boot flows Kory Maincent (TI.com)
` (4 preceding siblings ...)
2025-10-13 13:32 ` [PATCH v3 05/20] board: compulab: Exclude compulab extension board " Kory Maincent (TI.com)
@ 2025-10-13 13:32 ` Kory Maincent (TI.com)
2025-10-13 13:32 ` [PATCH v3 07/20] boot: Move extension board support from cmd/ to boot/ Kory Maincent (TI.com)
` (14 subsequent siblings)
20 siblings, 0 replies; 40+ messages in thread
From: Kory Maincent (TI.com) @ 2025-10-13 13:32 UTC (permalink / raw)
To: Tom Rini, Simon Glass, Jagan Teki, Andre Przywara, Hans de Goede,
Mario Six, Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team,
Ying-Chun Liu (PaulLiu)
Cc: Roger Quadros, Bajjuri Praneeth, Thomas Petazzoni, u-boot,
Kory Maincent (TI.com)
Add documentation to describe the extension structure.
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Change in v3:
- New patch.
---
include/extension_board.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/include/extension_board.h b/include/extension_board.h
index 22e4104bc54..23e36d3c0bf 100644
--- a/include/extension_board.h
+++ b/include/extension_board.h
@@ -9,6 +9,15 @@
#include <linux/list.h>
+/**
+ * extension - Description fields of an extension board
+ * @list: List head
+ * @name: Name of the extension
+ * @owner: Owner of the extension
+ * @version: Version of the extension
+ * @overlay: Devicetree overlay name to be loaded for this extension
+ * @other: Other information of this extension
+ */
struct extension {
struct list_head list;
char name[32];
--
2.43.0
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH v3 07/20] boot: Move extension board support from cmd/ to boot/
2025-10-13 13:32 [PATCH v3 00/20] Convert extension support to UCLASS and adds its support to boot flows Kory Maincent (TI.com)
` (5 preceding siblings ...)
2025-10-13 13:32 ` [PATCH v3 06/20] include: extension_board: Document the extension structure Kory Maincent (TI.com)
@ 2025-10-13 13:32 ` Kory Maincent (TI.com)
2025-10-13 13:32 ` [PATCH v3 08/20] boot: Add UCLASS support for extension boards Kory Maincent (TI.com)
` (13 subsequent siblings)
20 siblings, 0 replies; 40+ messages in thread
From: Kory Maincent (TI.com) @ 2025-10-13 13:32 UTC (permalink / raw)
To: Tom Rini, Simon Glass, Jagan Teki, Andre Przywara, Hans de Goede,
Mario Six, Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team,
Ying-Chun Liu (PaulLiu)
Cc: Roger Quadros, Bajjuri Praneeth, Thomas Petazzoni, u-boot,
Kory Maincent (TI.com)
Relocate extension board support from cmd/ to boot/ directory in
preparation for converting the extension framework to use UCLASS.
Also improve code style by applying reverse xmas tree ordering.
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Change in v3:
- Move the list head in from cmd/extension_board.c to boot/extension.c
- Add OF_LIBFDT_OVERLAY config dependency.
---
MAINTAINERS | 1 +
boot/Kconfig | 4 ++
boot/Makefile | 1 +
boot/extension.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++
cmd/Kconfig | 3 --
cmd/extension_board.c | 99 ++---------------------------------------------
include/extension_board.h | 16 ++++++++
7 files changed, 124 insertions(+), 99 deletions(-)
diff --git a/MAINTAINERS b/MAINTAINERS
index e411e266c94..c67d5ae9d6b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1187,6 +1187,7 @@ M: Kory Maincent <kory.maincent@bootlin.com>
S: Maintained
F: board/sunxi/chip.c
F: board/ti/common/cape_detect.c
+F: boot/extension.c
F: cmd/extension_board.c
F: include/extension_board.h
diff --git a/boot/Kconfig b/boot/Kconfig
index dd047365754..a75f6b641ed 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -1906,6 +1906,10 @@ endmenu
endif # OF_LIBFDT
+config SUPPORT_EXTENSION_SCAN
+ select OF_LIBFDT_OVERLAY
+ bool
+
config USE_BOOTARGS
bool "Enable boot arguments"
help
diff --git a/boot/Makefile b/boot/Makefile
index 3da6f7a0914..f60d13130b1 100644
--- a/boot/Makefile
+++ b/boot/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_BOOT_RETRY) += bootretry.o
obj-$(CONFIG_CMD_BOOTM) += bootm.o bootm_os.o
obj-$(CONFIG_CMD_BOOTZ) += bootm.o bootm_os.o
obj-$(CONFIG_CMD_BOOTI) += bootm.o bootm_os.o
+obj-$(CONFIG_SUPPORT_EXTENSION_SCAN) += extension.o
obj-$(CONFIG_PXE_UTILS) += pxe_utils.o
diff --git a/boot/extension.c b/boot/extension.c
new file mode 100644
index 00000000000..8f28a7e1626
--- /dev/null
+++ b/boot/extension.c
@@ -0,0 +1,99 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2025 Köry Maincent <kory.maincent@bootlin.com>
+ */
+
+#include <bootdev.h>
+#include <command.h>
+#include <env.h>
+#include <extension_board.h>
+#include <fdt_support.h>
+#include <malloc.h>
+#include <mapmem.h>
+
+LIST_HEAD(extension_list);
+
+int extension_apply(struct extension *extension)
+{
+ ulong extrasize, overlay_addr;
+ struct fdt_header *blob;
+ char *overlay_cmd;
+
+ if (!working_fdt) {
+ printf("No FDT memory address configured. Please configure\n"
+ "the FDT address via \"fdt addr <address>\" command.\n");
+ return CMD_RET_FAILURE;
+ }
+
+ overlay_cmd = env_get("extension_overlay_cmd");
+ if (!overlay_cmd) {
+ printf("Environment extension_overlay_cmd is missing\n");
+ return CMD_RET_FAILURE;
+ }
+
+ overlay_addr = env_get_hex("extension_overlay_addr", 0);
+ if (!overlay_addr) {
+ printf("Environment extension_overlay_addr is missing\n");
+ return CMD_RET_FAILURE;
+ }
+
+ env_set("extension_overlay_name", extension->overlay);
+ if (run_command(overlay_cmd, 0) != 0)
+ return CMD_RET_FAILURE;
+
+ extrasize = env_get_hex("filesize", 0);
+ if (!extrasize)
+ return CMD_RET_FAILURE;
+
+ fdt_shrink_to_minimum(working_fdt, extrasize);
+
+ blob = map_sysmem(overlay_addr, 0);
+ if (!fdt_valid(&blob))
+ return CMD_RET_FAILURE;
+
+ /* apply method prints messages on error */
+ if (fdt_overlay_apply_verbose(working_fdt, blob))
+ return CMD_RET_FAILURE;
+
+ return CMD_RET_SUCCESS;
+}
+
+int extension_scan(bool show)
+{
+ struct extension *extension, *next;
+ int extension_num;
+
+ list_for_each_entry_safe(extension, next, &extension_list, list) {
+ list_del(&extension->list);
+ free(extension);
+ }
+ extension_num = extension_board_scan(&extension_list);
+ if (show && extension_num >= 0)
+ printf("Found %d extension board(s).\n", extension_num);
+
+ /* either the number of extensions, or -ve for error */
+ return extension_num;
+}
+
+static int extension_bootdev_hunt(struct bootdev_hunter *info, bool show)
+{
+ int ret;
+
+ ret = env_set_hex("extension_overlay_addr",
+ env_get_hex("fdtoverlay_addr_r", 0));
+ if (ret)
+ return log_msg_ret("env", ret);
+
+ ret = extension_scan(show);
+ if (ret < 0)
+ return log_msg_ret("ext", ret);
+
+ return 0;
+}
+
+/* extensions should have a uclass - for now we use UCLASS_SIMPLE_BUS uclass */
+BOOTDEV_HUNTER(extension_bootdev_hunter) = {
+ .prio = BOOTDEVP_1_PRE_SCAN,
+ .uclass = UCLASS_SIMPLE_BUS,
+ .hunt = extension_bootdev_hunt,
+};
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 29de857ba7c..986eeeba807 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -545,9 +545,6 @@ config CMD_FDT
help
Do FDT related setup before booting into the Operating System.
-config SUPPORT_EXTENSION_SCAN
- bool
-
config CMD_EXTENSION
bool "Extension board management command"
select CMD_FDT
diff --git a/cmd/extension_board.c b/cmd/extension_board.c
index 317b260bf36..129f3db9e4c 100644
--- a/cmd/extension_board.c
+++ b/cmd/extension_board.c
@@ -4,68 +4,15 @@
* Köry Maincent, Bootlin, <kory.maincent@bootlin.com>
*/
-#include <bootdev.h>
+#include <exports.h>
#include <command.h>
-#include <dm.h>
-#include <env.h>
-#include <malloc.h>
#include <extension_board.h>
-#include <mapmem.h>
-#include <linux/libfdt.h>
-#include <fdt_support.h>
-
-static LIST_HEAD(extension_list);
-
-static int extension_apply(struct extension *extension)
-{
- char *overlay_cmd;
- ulong extrasize, overlay_addr;
- struct fdt_header *blob;
-
- if (!working_fdt) {
- printf("No FDT memory address configured. Please configure\n"
- "the FDT address via \"fdt addr <address>\" command.\n");
- return CMD_RET_FAILURE;
- }
-
- overlay_cmd = env_get("extension_overlay_cmd");
- if (!overlay_cmd) {
- printf("Environment extension_overlay_cmd is missing\n");
- return CMD_RET_FAILURE;
- }
-
- overlay_addr = env_get_hex("extension_overlay_addr", 0);
- if (!overlay_addr) {
- printf("Environment extension_overlay_addr is missing\n");
- return CMD_RET_FAILURE;
- }
-
- env_set("extension_overlay_name", extension->overlay);
- if (run_command(overlay_cmd, 0) != 0)
- return CMD_RET_FAILURE;
-
- extrasize = env_get_hex("filesize", 0);
- if (!extrasize)
- return CMD_RET_FAILURE;
-
- fdt_shrink_to_minimum(working_fdt, extrasize);
-
- blob = map_sysmem(overlay_addr, 0);
- if (!fdt_valid(&blob))
- return CMD_RET_FAILURE;
-
- /* apply method prints messages on error */
- if (fdt_overlay_apply_verbose(working_fdt, blob))
- return CMD_RET_FAILURE;
-
- return CMD_RET_SUCCESS;
-}
static int do_extension_list(struct cmd_tbl *cmdtp, int flag,
int argc, char *const argv[])
{
- int i = 0;
struct extension *extension;
+ int i = 0;
if (list_empty(&extension_list)) {
printf("No extension registered - Please run \"extension scan\"\n");
@@ -82,23 +29,6 @@ static int do_extension_list(struct cmd_tbl *cmdtp, int flag,
return CMD_RET_SUCCESS;
}
-static int extension_scan(bool show)
-{
- struct extension *extension, *next;
- int extension_num;
-
- list_for_each_entry_safe(extension, next, &extension_list, list) {
- list_del(&extension->list);
- free(extension);
- }
- extension_num = extension_board_scan(&extension_list);
- if (show && extension_num >= 0)
- printf("Found %d extension board(s).\n", extension_num);
-
- /* either the number of extensions, or -ve for error */
- return extension_num;
-}
-
static int do_extension_scan(struct cmd_tbl *cmdtp, int flag,
int argc, char *const argv[])
{
@@ -115,8 +45,8 @@ static int do_extension_apply(struct cmd_tbl *cmdtp, int flag,
int argc, char *const argv[])
{
struct extension *extension = NULL;
- struct list_head *entry;
int i = 0, extension_id, ret;
+ struct list_head *entry;
if (argc < 2)
return CMD_RET_USAGE;
@@ -177,26 +107,3 @@ U_BOOT_CMD(extension, 3, 1, do_extensionops,
"extension list - lists available extension(s) board(s)\n"
"extension apply <extension number|all> - applies DT overlays corresponding to extension boards\n"
);
-
-static int extension_bootdev_hunt(struct bootdev_hunter *info, bool show)
-{
- int ret;
-
- ret = env_set_hex("extension_overlay_addr",
- env_get_hex("fdtoverlay_addr_r", 0));
- if (ret)
- return log_msg_ret("env", ret);
-
- ret = extension_scan(show);
- if (ret < 0)
- return log_msg_ret("ext", ret);
-
- return 0;
-}
-
-/* extensions should have a uclass - for now we use UCLASS_SIMPLE_BUS uclass */
-BOOTDEV_HUNTER(extension_bootdev_hunter) = {
- .prio = BOOTDEVP_1_PRE_SCAN,
- .uclass = UCLASS_SIMPLE_BUS,
- .hunt = extension_bootdev_hunt,
-};
diff --git a/include/extension_board.h b/include/extension_board.h
index 23e36d3c0bf..0821dddd8ff 100644
--- a/include/extension_board.h
+++ b/include/extension_board.h
@@ -9,6 +9,8 @@
#include <linux/list.h>
+extern struct list_head extension_list;
+
/**
* extension - Description fields of an extension board
* @list: List head
@@ -39,4 +41,18 @@ struct extension {
*/
int extension_board_scan(struct list_head *extension_list);
+/**
+ * extension_apply - Apply extension board overlay to the devicetree
+ * @extension: Extension to be applied
+ * Return: Zero on success, negative on failure.
+ */
+int extension_apply(struct extension *extension);
+
+/**
+ * extension_scan - Scan extension boards available.
+ * @show: Flag to enable verbose log
+ * Return: Zero on success, negative on failure.
+ */
+int extension_scan(bool show);
+
#endif /* __EXTENSION_SUPPORT_H */
--
2.43.0
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH v3 08/20] boot: Add UCLASS support for extension boards
2025-10-13 13:32 [PATCH v3 00/20] Convert extension support to UCLASS and adds its support to boot flows Kory Maincent (TI.com)
` (6 preceding siblings ...)
2025-10-13 13:32 ` [PATCH v3 07/20] boot: Move extension board support from cmd/ to boot/ Kory Maincent (TI.com)
@ 2025-10-13 13:32 ` Kory Maincent (TI.com)
2025-10-19 13:05 ` Simon Glass
2025-10-13 13:32 ` [PATCH v3 09/20] board: ti: Refactor cape detection code for readability Kory Maincent (TI.com)
` (12 subsequent siblings)
20 siblings, 1 reply; 40+ messages in thread
From: Kory Maincent (TI.com) @ 2025-10-13 13:32 UTC (permalink / raw)
To: Tom Rini, Simon Glass, Jagan Teki, Andre Przywara, Hans de Goede,
Mario Six, Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team,
Ying-Chun Liu (PaulLiu)
Cc: Roger Quadros, Bajjuri Praneeth, Thomas Petazzoni, u-boot,
Kory Maincent (TI.com)
Introduce UCLASS-based extension board support to enable more
standardized and automatic loading of extension board device tree
overlays in preparation for integration with bootstd and pxe_utils.
Several #if CONFIG_IS_ENABLED are used in cmd/extension_board.c to ease the
development but don't worry they are removed later in the series.
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Change in v3:
- Add OF_LIBFDT_OVERLAY config dependency.
- Update several return errors value following Simon review.
- Use uclass_first_device_err instead of extension_get_dev function.
- Remove the manual bind of extension driver. Use U_BOOT_DRVINFO instead.
- Update documentation.
- Add a helper to get extension ops.
---
MAINTAINERS | 1 +
boot/Kconfig | 4 ++
boot/Makefile | 1 +
boot/extension-uclass.c | 151 ++++++++++++++++++++++++++++++++++++++++++++
cmd/Kconfig | 2 +-
cmd/extension_board.c | 50 ++++++++++++++-
doc/usage/cmd/extension.rst | 29 +++++----
include/dm/uclass-id.h | 1 +
include/extension_board.h | 70 ++++++++++++++++++++
9 files changed, 293 insertions(+), 16 deletions(-)
diff --git a/MAINTAINERS b/MAINTAINERS
index c67d5ae9d6b..a63ffa14ef5 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1187,6 +1187,7 @@ M: Kory Maincent <kory.maincent@bootlin.com>
S: Maintained
F: board/sunxi/chip.c
F: board/ti/common/cape_detect.c
+F: boot/extension-uclass.c
F: boot/extension.c
F: cmd/extension_board.c
F: include/extension_board.h
diff --git a/boot/Kconfig b/boot/Kconfig
index a75f6b641ed..08d666d4b93 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -1910,6 +1910,10 @@ config SUPPORT_EXTENSION_SCAN
select OF_LIBFDT_OVERLAY
bool
+config SUPPORT_DM_EXTENSION_SCAN
+ select OF_LIBFDT_OVERLAY
+ bool
+
config USE_BOOTARGS
bool "Enable boot arguments"
help
diff --git a/boot/Makefile b/boot/Makefile
index f60d13130b1..aa26070fbb8 100644
--- a/boot/Makefile
+++ b/boot/Makefile
@@ -10,6 +10,7 @@ obj-$(CONFIG_CMD_BOOTM) += bootm.o bootm_os.o
obj-$(CONFIG_CMD_BOOTZ) += bootm.o bootm_os.o
obj-$(CONFIG_CMD_BOOTI) += bootm.o bootm_os.o
obj-$(CONFIG_SUPPORT_EXTENSION_SCAN) += extension.o
+obj-$(CONFIG_SUPPORT_DM_EXTENSION_SCAN) += extension-uclass.o
obj-$(CONFIG_PXE_UTILS) += pxe_utils.o
diff --git a/boot/extension-uclass.c b/boot/extension-uclass.c
new file mode 100644
index 00000000000..914971215af
--- /dev/null
+++ b/boot/extension-uclass.c
@@ -0,0 +1,151 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2025 Köry Maincent <kory.maincent@bootlin.com>
+ */
+
+#include <alist.h>
+#include <command.h>
+#include <env.h>
+#include <extension_board.h>
+#include <fdt_support.h>
+#include <malloc.h>
+#include <mapmem.h>
+#include <dm/device-internal.h>
+#include <dm/lists.h>
+#include <dm/uclass.h>
+
+struct alist *dm_extension_get_list(void)
+{
+ struct udevice *dev;
+
+ if (uclass_first_device_err(UCLASS_EXTENSION, &dev))
+ return NULL;
+
+ return dev_get_priv(dev);
+}
+
+int dm_extension_probe(struct udevice *dev)
+{
+ struct alist *extension_list = dev_get_priv(dev);
+
+ alist_init_struct(extension_list, struct extension);
+ return 0;
+}
+
+int dm_extension_remove(struct udevice *dev)
+{
+ struct alist *extension_list = dev_get_priv(dev);
+
+ alist_uninit(extension_list);
+ return 0;
+}
+
+int dm_extension_scan(void)
+{
+ struct alist *extension_list = dm_extension_get_list();
+ const struct extension_ops *ops;
+ struct udevice *dev;
+ int ret;
+
+ ret = uclass_first_device_err(UCLASS_EXTENSION, &dev);
+ if (ret)
+ return ret;
+
+ if (!extension_list)
+ return -ENODEV;
+
+ ops = extension_get_ops(dev);
+ alist_empty(extension_list);
+ return ops->scan(dev, extension_list);
+}
+
+static int _extension_apply(const struct extension *extension)
+{
+ ulong extrasize, overlay_addr;
+ struct fdt_header *blob;
+ char *overlay_cmd;
+ int ret;
+
+ if (!working_fdt) {
+ printf("No FDT memory address configured. Please configure\n"
+ "the FDT address via \"fdt addr <address>\" command.\n");
+ return -EINVAL;
+ }
+
+ overlay_cmd = env_get("extension_overlay_cmd");
+ if (!overlay_cmd) {
+ printf("Environment extension_overlay_cmd is missing\n");
+ return -EINVAL;
+ }
+
+ overlay_addr = env_get_hex("extension_overlay_addr", 0);
+ if (!overlay_addr) {
+ printf("Environment extension_overlay_addr is missing\n");
+ return -EINVAL;
+ }
+
+ env_set("extension_overlay_name", extension->overlay);
+ ret = run_command(overlay_cmd, 0);
+ if (ret)
+ return ret;
+
+ extrasize = env_get_hex("filesize", 0);
+ if (!extrasize)
+ return -EINVAL;
+
+ fdt_shrink_to_minimum(working_fdt, extrasize);
+
+ blob = map_sysmem(overlay_addr, 0);
+ if (!fdt_valid(&blob)) {
+ printf("Invalid overlay devicetree %s\n", extension->overlay);
+ return -EINVAL;
+ }
+
+ /* Apply method prints messages on error */
+ ret = fdt_overlay_apply_verbose(working_fdt, blob);
+ if (ret)
+ printf("Failed to apply overlay %s\n", extension->overlay);
+
+ return ret;
+}
+
+int dm_extension_apply(int extension_num)
+{
+ struct alist *extension_list = dm_extension_get_list();
+ const struct extension *extension;
+
+ if (!extension_list)
+ return -ENOENT;
+
+ extension = alist_get(extension_list, extension_num,
+ struct extension);
+ if (!extension) {
+ printf("Wrong extension number\n");
+ return -EINVAL;
+ }
+
+ return _extension_apply(extension);
+}
+
+int dm_extension_apply_all(void)
+{
+ struct alist *extension_list = dm_extension_get_list();
+ const struct extension *extension;
+ int ret;
+
+ if (!extension_list)
+ return -ENOENT;
+
+ alist_for_each(extension, extension_list) {
+ ret = _extension_apply(extension);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
+UCLASS_DRIVER(extension) = {
+ .name = "extension",
+ .id = UCLASS_EXTENSION,
+};
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 986eeeba807..721bdb87c8a 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -548,7 +548,7 @@ config CMD_FDT
config CMD_EXTENSION
bool "Extension board management command"
select CMD_FDT
- depends on SUPPORT_EXTENSION_SCAN
+ depends on SUPPORT_EXTENSION_SCAN || SUPPORT_DM_EXTENSION_SCAN
help
Enables the "extension" command, which allows to detect
extension boards connected to the system, and apply
diff --git a/cmd/extension_board.c b/cmd/extension_board.c
index 129f3db9e4c..1f1eddbe976 100644
--- a/cmd/extension_board.c
+++ b/cmd/extension_board.c
@@ -4,6 +4,7 @@
* Köry Maincent, Bootlin, <kory.maincent@bootlin.com>
*/
+#include <alist.h>
#include <exports.h>
#include <command.h>
#include <extension_board.h>
@@ -11,9 +12,28 @@
static int do_extension_list(struct cmd_tbl *cmdtp, int flag,
int argc, char *const argv[])
{
+#if CONFIG_IS_ENABLED(SUPPORT_DM_EXTENSION_SCAN)
+ struct alist *dm_extension_list;
+#endif
struct extension *extension;
int i = 0;
+#if CONFIG_IS_ENABLED(SUPPORT_DM_EXTENSION_SCAN)
+ dm_extension_list = dm_extension_get_list();
+
+ if (!alist_get_ptr(dm_extension_list, 0)) {
+ printf("No extension registered - Please run \"extension scan\"\n");
+ return CMD_RET_SUCCESS;
+ }
+
+ alist_for_each(extension, dm_extension_list) {
+ printf("Extension %d: %s\n", i++, extension->name);
+ printf("\tManufacturer: \t\t%s\n", extension->owner);
+ printf("\tVersion: \t\t%s\n", extension->version);
+ printf("\tDevicetree overlay: \t%s\n", extension->overlay);
+ printf("\tOther information: \t%s\n", extension->other);
+ }
+#else
if (list_empty(&extension_list)) {
printf("No extension registered - Please run \"extension scan\"\n");
return CMD_RET_SUCCESS;
@@ -26,6 +46,7 @@ static int do_extension_list(struct cmd_tbl *cmdtp, int flag,
printf("\tDevicetree overlay: \t%s\n", extension->overlay);
printf("\tOther information: \t%s\n", extension->other);
}
+#endif
return CMD_RET_SUCCESS;
}
@@ -34,9 +55,19 @@ static int do_extension_scan(struct cmd_tbl *cmdtp, int flag,
{
int extension_num;
+#if CONFIG_IS_ENABLED(SUPPORT_DM_EXTENSION_SCAN)
+ extension_num = dm_extension_scan();
+ if (extension_num == -ENODEV)
+ extension_num = 0;
+ else if (extension_num < 0)
+ return CMD_RET_FAILURE;
+
+ printf("Found %d extension board(s).\n", extension_num);
+#else
extension_num = extension_scan(true);
- if (extension_num < 0)
+ if (extension_num < 0 && extension_num != -ENODEV)
return CMD_RET_FAILURE;
+#endif
return CMD_RET_SUCCESS;
}
@@ -44,22 +75,34 @@ static int do_extension_scan(struct cmd_tbl *cmdtp, int flag,
static int do_extension_apply(struct cmd_tbl *cmdtp, int flag,
int argc, char *const argv[])
{
+#if !CONFIG_IS_ENABLED(SUPPORT_DM_EXTENSION_SCAN)
struct extension *extension = NULL;
- int i = 0, extension_id, ret;
struct list_head *entry;
+ int i = 0;
+#endif
+ int extension_id, ret;
if (argc < 2)
return CMD_RET_USAGE;
if (strcmp(argv[1], "all") == 0) {
ret = CMD_RET_FAILURE;
+#if CONFIG_IS_ENABLED(SUPPORT_DM_EXTENSION_SCAN)
+ if (dm_extension_apply_all())
+ return CMD_RET_FAILURE;
+#else
list_for_each_entry(extension, &extension_list, list) {
ret = extension_apply(extension);
if (ret != CMD_RET_SUCCESS)
break;
}
+#endif
} else {
extension_id = simple_strtol(argv[1], NULL, 10);
+#if CONFIG_IS_ENABLED(SUPPORT_DM_EXTENSION_SCAN)
+ if (dm_extension_apply(extension_id))
+ return CMD_RET_FAILURE;
+#else
list_for_each(entry, &extension_list) {
if (i == extension_id) {
extension = list_entry(entry, struct extension, list);
@@ -74,9 +117,10 @@ static int do_extension_apply(struct cmd_tbl *cmdtp, int flag,
}
ret = extension_apply(extension);
+#endif
}
- return ret;
+ return CMD_RET_SUCCESS;
}
static struct cmd_tbl cmd_extension[] = {
diff --git a/doc/usage/cmd/extension.rst b/doc/usage/cmd/extension.rst
index 4c261e74951..fbe95aace79 100644
--- a/doc/usage/cmd/extension.rst
+++ b/doc/usage/cmd/extension.rst
@@ -25,9 +25,8 @@ Device Tree overlays depending on the detected extension boards.
The "extension" command comes with three sub-commands:
- - "extension scan" makes the generic code call the board-specific
- extension_board_scan() function to retrieve the list of detected
- extension boards.
+ - "extension scan" makes the generic code call a board-specific extension
+ function to retrieve the list of detected extension boards.
- "extension list" allows to list the detected extension boards.
@@ -98,17 +97,23 @@ Simple extension_board_scan function example
.. code-block:: c
- int extension_board_scan(struct list_head *extension_list)
+ static int foo_extension_board_scan(struct alist *extension_list)
{
- struct extension *extension;
+ struct extension extension = {0};
- extension = calloc(1, sizeof(struct extension));
- snprintf(extension->overlay, sizeof(extension->overlay), "overlay.dtbo");
- snprintf(extension->name, sizeof(extension->name), "extension board");
- snprintf(extension->owner, sizeof(extension->owner), "sandbox");
- snprintf(extension->version, sizeof(extension->version), "1.1");
- snprintf(extension->other, sizeof(extension->other), "Extension board information");
- list_add_tail(&extension->list, extension_list);
+ snprintf(extension.overlay, sizeof(extension.overlay), "overlay.dtbo");
+ snprintf(extension.name, sizeof(extension.name), "extension board");
+ snprintf(extension.owner, sizeof(extension.owner), "sandbox");
+ snprintf(extension.version, sizeof(extension.version), "1.1");
+ snprintf(extension.other, sizeof(extension.other), "Extension board information");
+ if (!alist_add(extension_list, extension))
+ return -ENOMEM;
return 1;
}
+
+ U_BOOT_EXTENSION(foo_extension_name, foo_extension_board_scan);
+
+ U_BOOT_DRVINFO(foo_extension_name) = {
+ .name = "foo_extension_name",
+ };
diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
index 6be59093160..eb6416b5917 100644
--- a/include/dm/uclass-id.h
+++ b/include/dm/uclass-id.h
@@ -63,6 +63,7 @@ enum uclass_id {
UCLASS_ETH, /* Ethernet device */
UCLASS_ETH_PHY, /* Ethernet PHY device */
UCLASS_EXTCON, /* External Connector Class */
+ UCLASS_EXTENSION, /* Extension board */
UCLASS_FFA, /* Arm Firmware Framework for Armv8-A */
UCLASS_FFA_EMUL, /* sandbox FF-A device emulator */
UCLASS_FIRMWARE, /* Firmware */
diff --git a/include/extension_board.h b/include/extension_board.h
index 0821dddd8ff..ddf5b367cd3 100644
--- a/include/extension_board.h
+++ b/include/extension_board.h
@@ -7,10 +7,55 @@
#ifndef __EXTENSION_SUPPORT_H
#define __EXTENSION_SUPPORT_H
+#include <alist.h>
+#include <dm/device.h>
#include <linux/list.h>
+#include <dm/platdata.h>
extern struct list_head extension_list;
+/**
+ * dm_extension_get_list - Get the extension list
+ * Return: The extension alist pointer, or NULL if no such list exists.
+ *
+ * The caller must not free the list.
+ */
+struct alist *dm_extension_get_list(void);
+
+/**
+ * dm_extension_probe - Probe extension device
+ * @dev: Extension device that needs to be probed
+ * Return: Zero on success, negative on failure.
+ */
+int dm_extension_probe(struct udevice *dev);
+
+/**
+ * dm_extension_remove - Remove extension device
+ * @dev: Extension device that needs to be removed
+ * Return: Zero on success, negative on failure.
+ */
+int dm_extension_remove(struct udevice *dev);
+
+/**
+ * dm_extension_scan - Scan extension boards available.
+ * Return: Zero on success, negative on failure.
+ */
+int dm_extension_scan(void);
+
+/**
+ * dm_extension_apply - Apply extension board overlay to the devicetree
+ * @extension_num: Extension number to be applied
+ * Return: Zero on success, negative on failure.
+ */
+int dm_extension_apply(int extension_num);
+
+/**
+ * dm_extension_apply_all - Apply all extension board overlays to the
+ * devicetree
+ * Return: Zero on success, negative on failure.
+ */
+int dm_extension_apply_all(void);
+
/**
* extension - Description fields of an extension board
* @list: List head
@@ -29,6 +74,31 @@ struct extension {
char other[32];
};
+struct extension_ops {
+ /**
+ * scan - Add system-specific function to scan extension boards.
+ * @extension_list: alist of extension to expand
+ * Return: The number of extension or a negative value in case of
+ * error.
+ */
+ int (*scan)(struct udevice *dev, struct alist *extension_list);
+};
+
+#define extension_get_ops(dev) ((struct extension_ops *)(dev)->driver->ops)
+
+/* Currently, only one extension driver enabled at a time is supported */
+#define U_BOOT_EXTENSION(_name, _scan_func) \
+ U_BOOT_DRIVER(_name) = { \
+ .name = #_name, \
+ .id = UCLASS_EXTENSION, \
+ .probe = dm_extension_probe, \
+ .remove = dm_extension_remove, \
+ .ops = &(struct extension_ops) { \
+ .scan = _scan_func, \
+ }, \
+ .priv_auto = sizeof(struct alist), \
+ }
+
/**
* extension_board_scan - Add system-specific function to scan extension board.
* @param extension_list List of extension board information to update.
--
2.43.0
^ permalink raw reply related [flat|nested] 40+ messages in thread* Re: [PATCH v3 08/20] boot: Add UCLASS support for extension boards
2025-10-13 13:32 ` [PATCH v3 08/20] boot: Add UCLASS support for extension boards Kory Maincent (TI.com)
@ 2025-10-19 13:05 ` Simon Glass
0 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2025-10-19 13:05 UTC (permalink / raw)
To: Kory Maincent (TI.com)
Cc: Tom Rini, Jagan Teki, Andre Przywara, Hans de Goede, Mario Six,
Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team,
Ying-Chun Liu (PaulLiu), Roger Quadros, Bajjuri Praneeth,
Thomas Petazzoni, u-boot
On Mon, 13 Oct 2025 at 14:32, Kory Maincent (TI.com)
<kory.maincent@bootlin.com> wrote:
>
> Introduce UCLASS-based extension board support to enable more
> standardized and automatic loading of extension board device tree
> overlays in preparation for integration with bootstd and pxe_utils.
>
> Several #if CONFIG_IS_ENABLED are used in cmd/extension_board.c to ease the
> development but don't worry they are removed later in the series.
>
> Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
> ---
>
> Change in v3:
> - Add OF_LIBFDT_OVERLAY config dependency.
> - Update several return errors value following Simon review.
> - Use uclass_first_device_err instead of extension_get_dev function.
> - Remove the manual bind of extension driver. Use U_BOOT_DRVINFO instead.
> - Update documentation.
> - Add a helper to get extension ops.
> ---
> MAINTAINERS | 1 +
> boot/Kconfig | 4 ++
> boot/Makefile | 1 +
> boot/extension-uclass.c | 151 ++++++++++++++++++++++++++++++++++++++++++++
> cmd/Kconfig | 2 +-
> cmd/extension_board.c | 50 ++++++++++++++-
> doc/usage/cmd/extension.rst | 29 +++++----
> include/dm/uclass-id.h | 1 +
> include/extension_board.h | 70 ++++++++++++++++++++
> 9 files changed, 293 insertions(+), 16 deletions(-)
Reviewed-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v3 09/20] board: ti: Refactor cape detection code for readability
2025-10-13 13:32 [PATCH v3 00/20] Convert extension support to UCLASS and adds its support to boot flows Kory Maincent (TI.com)
` (7 preceding siblings ...)
2025-10-13 13:32 ` [PATCH v3 08/20] boot: Add UCLASS support for extension boards Kory Maincent (TI.com)
@ 2025-10-13 13:32 ` Kory Maincent (TI.com)
2025-10-13 13:32 ` [PATCH v3 10/20] board: ti: Convert cape detection to use UCLASS framework Kory Maincent (TI.com)
` (11 subsequent siblings)
20 siblings, 0 replies; 40+ messages in thread
From: Kory Maincent (TI.com) @ 2025-10-13 13:32 UTC (permalink / raw)
To: Tom Rini, Simon Glass, Jagan Teki, Andre Przywara, Hans de Goede,
Mario Six, Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team,
Ying-Chun Liu (PaulLiu)
Cc: Roger Quadros, Bajjuri Praneeth, Thomas Petazzoni, u-boot,
Kory Maincent (TI.com)
Clean up and reorganize cape detection code structure for improved
maintainability and readability.
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
board/ti/common/cape_detect.c | 36 +++++++++++++++++++-----------------
1 file changed, 19 insertions(+), 17 deletions(-)
diff --git a/board/ti/common/cape_detect.c b/board/ti/common/cape_detect.c
index da805befabc..7786bdda5d1 100644
--- a/board/ti/common/cape_detect.c
+++ b/board/ti/common/cape_detect.c
@@ -24,19 +24,18 @@ static void sanitize_field(char *text, size_t size)
int extension_board_scan(struct list_head *extension_list)
{
- struct extension *cape;
- struct am335x_cape_eeprom_id eeprom_header;
-
- int num_capes = 0;
- int ret, i;
- struct udevice *dev;
unsigned char addr;
-
- char process_cape_part_number[17] = {'0'};
- char process_cape_version[5] = {'0'};
- uint8_t cursor = 0;
+ int num_capes = 0;
for (addr = CAPE_EEPROM_FIRST_ADDR; addr <= CAPE_EEPROM_LAST_ADDR; addr++) {
+ struct am335x_cape_eeprom_id eeprom_header;
+ char process_cape_part_number[17] = {'0'};
+ char process_cape_version[5] = {'0'};
+ struct extension *cape;
+ struct udevice *dev;
+ u8 cursor = 0;
+ int ret, i;
+
ret = i2c_get_chip_for_busnum(CONFIG_CAPE_EEPROM_BUS_NUM, addr, 1, &dev);
if (ret)
continue;
@@ -59,8 +58,8 @@ int extension_board_scan(struct list_head *extension_list)
sanitize_field(eeprom_header.part_number, sizeof(eeprom_header.part_number));
/* Process cape part_number */
- memset(process_cape_part_number, 0, sizeof(process_cape_part_number));
- strncpy(process_cape_part_number, eeprom_header.part_number, 16);
+ strlcpy(process_cape_part_number, eeprom_header.part_number,
+ sizeof(process_cape_part_number));
/* Some capes end with '.' */
for (i = 15; i >= 0; i--) {
if (process_cape_part_number[i] == '.')
@@ -70,8 +69,8 @@ int extension_board_scan(struct list_head *extension_list)
}
/* Process cape version */
- memset(process_cape_version, 0, sizeof(process_cape_version));
- strncpy(process_cape_version, eeprom_header.version, 4);
+ strlcpy(process_cape_version, eeprom_header.version,
+ sizeof(process_cape_version));
for (i = 0; i < 4; i++) {
if (process_cape_version[i] == 0)
process_cape_version[i] = '0';
@@ -87,9 +86,12 @@ int extension_board_scan(struct list_head *extension_list)
snprintf(cape->overlay, sizeof(cape->overlay), "%s-%s.dtbo",
process_cape_part_number, process_cape_version);
- strncpy(cape->name, eeprom_header.board_name, 32);
- strncpy(cape->version, process_cape_version, 4);
- strncpy(cape->owner, eeprom_header.manufacturer, 16);
+ strlcpy(cape->name, eeprom_header.board_name,
+ sizeof(eeprom_header.board_name));
+ strlcpy(cape->version, process_cape_version,
+ sizeof(process_cape_version));
+ strlcpy(cape->owner, eeprom_header.manufacturer,
+ sizeof(eeprom_header.manufacturer) + 1);
list_add_tail(&cape->list, extension_list);
num_capes++;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH v3 10/20] board: ti: Convert cape detection to use UCLASS framework
2025-10-13 13:32 [PATCH v3 00/20] Convert extension support to UCLASS and adds its support to boot flows Kory Maincent (TI.com)
` (8 preceding siblings ...)
2025-10-13 13:32 ` [PATCH v3 09/20] board: ti: Refactor cape detection code for readability Kory Maincent (TI.com)
@ 2025-10-13 13:32 ` Kory Maincent (TI.com)
2025-10-13 13:32 ` [PATCH v3 11/20] board: sunxi: Refactor CHIP board extension code Kory Maincent (TI.com)
` (10 subsequent siblings)
20 siblings, 0 replies; 40+ messages in thread
From: Kory Maincent (TI.com) @ 2025-10-13 13:32 UTC (permalink / raw)
To: Tom Rini, Simon Glass, Jagan Teki, Andre Przywara, Hans de Goede,
Mario Six, Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team,
Ying-Chun Liu (PaulLiu)
Cc: Roger Quadros, Bajjuri Praneeth, Thomas Petazzoni, u-boot,
Kory Maincent (TI.com)
Migrate TI board cape detection from legacy extension support to the
new UCLASS-based extension board framework.
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Change in v3:
- Use U_BOOT_DRVINFO.
---
arch/arm/mach-omap2/am33xx/Kconfig | 2 +-
arch/arm/mach-omap2/omap5/Kconfig | 2 +-
board/ti/common/Kconfig | 2 +-
board/ti/common/Makefile | 2 +-
board/ti/common/cape_detect.c | 28 +++++++++++++++-------------
5 files changed, 19 insertions(+), 17 deletions(-)
diff --git a/arch/arm/mach-omap2/am33xx/Kconfig b/arch/arm/mach-omap2/am33xx/Kconfig
index dff4f1cf202..77f7938305b 100644
--- a/arch/arm/mach-omap2/am33xx/Kconfig
+++ b/arch/arm/mach-omap2/am33xx/Kconfig
@@ -15,7 +15,7 @@ config TARGET_AM335X_EVM
select DM_GPIO
select DM_SERIAL
select TI_I2C_BOARD_DETECT
- select SUPPORT_EXTENSION_SCAN
+ select SUPPORT_DM_EXTENSION_SCAN
imply CMD_DM
imply SPL_DM
imply SPL_DM_SEQ_ALIAS
diff --git a/arch/arm/mach-omap2/omap5/Kconfig b/arch/arm/mach-omap2/omap5/Kconfig
index 5394529658b..819490a8cf8 100644
--- a/arch/arm/mach-omap2/omap5/Kconfig
+++ b/arch/arm/mach-omap2/omap5/Kconfig
@@ -38,7 +38,7 @@ config TARGET_AM57XX_EVM
select CMD_DDR3
select DRA7XX
select TI_I2C_BOARD_DETECT
- select SUPPORT_EXTENSION_SCAN
+ select SUPPORT_DM_EXTENSION_SCAN
imply DM_THERMAL
imply SCSI
imply SPL_THERMAL
diff --git a/board/ti/common/Kconfig b/board/ti/common/Kconfig
index 9512c5c23f1..feb05b4bf95 100644
--- a/board/ti/common/Kconfig
+++ b/board/ti/common/Kconfig
@@ -20,7 +20,7 @@ config CAPE_EEPROM_BUS_NUM
int "Cape EEPROM's I2C bus address"
range 0 8
default 2
- depends on SUPPORT_EXTENSION_SCAN
+ depends on SUPPORT_DM_EXTENSION_SCAN
config TI_COMMON_CMD_OPTIONS
bool "Enable cmd options on TI platforms"
diff --git a/board/ti/common/Makefile b/board/ti/common/Makefile
index f58935b4103..b42273d3a5a 100644
--- a/board/ti/common/Makefile
+++ b/board/ti/common/Makefile
@@ -2,6 +2,6 @@
# Copyright (C) 2015-2016 Texas Instruments Incorporated - https://www.ti.com/
obj-${CONFIG_TI_I2C_BOARD_DETECT} += board_detect.o
-obj-${CONFIG_$(PHASE_)SUPPORT_EXTENSION_SCAN} += cape_detect.o
+obj-${CONFIG_$(PHASE_)SUPPORT_DM_EXTENSION_SCAN} += cape_detect.o
obj-${CONFIG_OF_LIBFDT} += fdt_ops.o
obj-${CONFIG_ARCH_K3} += k3-ddr.o
diff --git a/board/ti/common/cape_detect.c b/board/ti/common/cape_detect.c
index 7786bdda5d1..0bd4a38c187 100644
--- a/board/ti/common/cape_detect.c
+++ b/board/ti/common/cape_detect.c
@@ -22,7 +22,8 @@ static void sanitize_field(char *text, size_t size)
}
}
-int extension_board_scan(struct list_head *extension_list)
+static int ti_extension_board_scan(struct udevice *dev,
+ struct alist *extension_list)
{
unsigned char addr;
int num_capes = 0;
@@ -31,7 +32,7 @@ int extension_board_scan(struct list_head *extension_list)
struct am335x_cape_eeprom_id eeprom_header;
char process_cape_part_number[17] = {'0'};
char process_cape_version[5] = {'0'};
- struct extension *cape;
+ struct extension cape = {0};
struct udevice *dev;
u8 cursor = 0;
int ret, i;
@@ -78,22 +79,23 @@ int extension_board_scan(struct list_head *extension_list)
printf("BeagleBone Cape: %s (0x%x)\n", eeprom_header.board_name, addr);
- cape = calloc(1, sizeof(struct extension));
- if (!cape) {
- printf("Error in memory allocation\n");
- return num_capes;
- }
-
- snprintf(cape->overlay, sizeof(cape->overlay), "%s-%s.dtbo",
+ snprintf(cape.overlay, sizeof(cape.overlay), "%s-%s.dtbo",
process_cape_part_number, process_cape_version);
- strlcpy(cape->name, eeprom_header.board_name,
+ strlcpy(cape.name, eeprom_header.board_name,
sizeof(eeprom_header.board_name));
- strlcpy(cape->version, process_cape_version,
+ strlcpy(cape.version, process_cape_version,
sizeof(process_cape_version));
- strlcpy(cape->owner, eeprom_header.manufacturer,
+ strlcpy(cape.owner, eeprom_header.manufacturer,
sizeof(eeprom_header.manufacturer) + 1);
- list_add_tail(&cape->list, extension_list);
+ if (!alist_add(extension_list, cape))
+ return -ENOMEM;
num_capes++;
}
return num_capes;
}
+
+U_BOOT_EXTENSION(cape, ti_extension_board_scan);
+
+U_BOOT_DRVINFO(cape) = {
+ .name = "cape",
+};
--
2.43.0
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH v3 11/20] board: sunxi: Refactor CHIP board extension code
2025-10-13 13:32 [PATCH v3 00/20] Convert extension support to UCLASS and adds its support to boot flows Kory Maincent (TI.com)
` (9 preceding siblings ...)
2025-10-13 13:32 ` [PATCH v3 10/20] board: ti: Convert cape detection to use UCLASS framework Kory Maincent (TI.com)
@ 2025-10-13 13:32 ` Kory Maincent (TI.com)
2025-10-13 13:32 ` [PATCH v3 12/20] board: sunxi: Convert extension support to UCLASS framework Kory Maincent (TI.com)
` (9 subsequent siblings)
20 siblings, 0 replies; 40+ messages in thread
From: Kory Maincent (TI.com) @ 2025-10-13 13:32 UTC (permalink / raw)
To: Tom Rini, Simon Glass, Jagan Teki, Andre Przywara, Hans de Goede,
Mario Six, Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team,
Ying-Chun Liu (PaulLiu)
Cc: Roger Quadros, Bajjuri Praneeth, Thomas Petazzoni, u-boot,
Kory Maincent (TI.com)
Clean up and improve code structure in the sunxi CHIP board extension
detection implementation.
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Changes in v2:
- Fix a build error.
---
board/sunxi/chip.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/board/sunxi/chip.c b/board/sunxi/chip.c
index 270af2506d2..5e5ec0d1d89 100644
--- a/board/sunxi/chip.c
+++ b/board/sunxi/chip.c
@@ -42,14 +42,9 @@ struct dip_w1_header {
int extension_board_scan(struct list_head *extension_list)
{
- struct extension *dip;
- struct dip_w1_header w1_header;
struct udevice *bus, *dev;
- u32 vid;
- u16 pid;
- int ret;
-
int num_dip = 0;
+ int ret;
sunxi_gpio_set_pull(SUNXI_GPD(2), SUNXI_GPIO_PULL_UP);
@@ -60,6 +55,11 @@ int extension_board_scan(struct list_head *extension_list)
}
for_each_w1_device(bus, &dev) {
+ struct dip_w1_header w1_header;
+ struct extension *dip;
+ u32 vid;
+ u16 pid;
+
if (w1_get_device_family(dev) != W1_FAMILY_DS2431)
continue;
@@ -90,8 +90,8 @@ int extension_board_scan(struct list_head *extension_list)
snprintf(dip->overlay, sizeof(dip->overlay), "dip-%x-%x.dtbo",
vid, pid);
- strncpy(dip->name, w1_header.product_name, 32);
- strncpy(dip->owner, w1_header.vendor_name, 32);
+ strlcpy(dip->name, w1_header.product_name, sizeof(dip->name));
+ strlcpy(dip->owner, w1_header.vendor_name, sizeof(dip->owner));
list_add_tail(&dip->list, extension_list);
num_dip++;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH v3 12/20] board: sunxi: Convert extension support to UCLASS framework
2025-10-13 13:32 [PATCH v3 00/20] Convert extension support to UCLASS and adds its support to boot flows Kory Maincent (TI.com)
` (10 preceding siblings ...)
2025-10-13 13:32 ` [PATCH v3 11/20] board: sunxi: Refactor CHIP board extension code Kory Maincent (TI.com)
@ 2025-10-13 13:32 ` Kory Maincent (TI.com)
2025-10-13 13:32 ` [PATCH v3 13/20] board: sandbox: Improve extension board scan implementation Kory Maincent (TI.com)
` (8 subsequent siblings)
20 siblings, 0 replies; 40+ messages in thread
From: Kory Maincent (TI.com) @ 2025-10-13 13:32 UTC (permalink / raw)
To: Tom Rini, Simon Glass, Jagan Teki, Andre Przywara, Hans de Goede,
Mario Six, Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team,
Ying-Chun Liu (PaulLiu)
Cc: Roger Quadros, Bajjuri Praneeth, Thomas Petazzoni, u-boot,
Kory Maincent (TI.com)
Migrate sunxi board extension detection from legacy implementation to
the new UCLASS-based extension board framework.
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Change in v3:
- Use U_BOOT_DRVINFO.
Changes in v2:
- Fix build error.
---
arch/arm/mach-sunxi/Kconfig | 2 +-
board/sunxi/chip.c | 26 ++++++++++++++------------
2 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
index b04ec671696..f5696199516 100644
--- a/arch/arm/mach-sunxi/Kconfig
+++ b/arch/arm/mach-sunxi/Kconfig
@@ -1223,7 +1223,7 @@ config BLUETOOTH_DT_DEVICE_FIXUP
config CHIP_DIP_SCAN
bool "Enable DIPs detection for CHIP board"
- select SUPPORT_EXTENSION_SCAN
+ select SUPPORT_DM_EXTENSION_SCAN
select W1
select W1_GPIO
select W1_EEPROM
diff --git a/board/sunxi/chip.c b/board/sunxi/chip.c
index 5e5ec0d1d89..b60a739df41 100644
--- a/board/sunxi/chip.c
+++ b/board/sunxi/chip.c
@@ -40,7 +40,8 @@ struct dip_w1_header {
u8 data[16]; /* user data, per-dip specific */
} __packed;
-int extension_board_scan(struct list_head *extension_list)
+static int sunxi_extension_board_scan(struct udevice *udev,
+ struct alist *extension_list)
{
struct udevice *bus, *dev;
int num_dip = 0;
@@ -55,8 +56,8 @@ int extension_board_scan(struct list_head *extension_list)
}
for_each_w1_device(bus, &dev) {
+ struct extension dip = {0};
struct dip_w1_header w1_header;
- struct extension *dip;
u32 vid;
u16 pid;
@@ -82,18 +83,19 @@ int extension_board_scan(struct list_head *extension_list)
w1_header.product_name, pid,
w1_header.vendor_name, vid);
- dip = calloc(1, sizeof(struct extension));
- if (!dip) {
- printf("Error in memory allocation\n");
- return num_dip;
- }
-
- snprintf(dip->overlay, sizeof(dip->overlay), "dip-%x-%x.dtbo",
+ snprintf(dip.overlay, sizeof(dip.overlay), "dip-%x-%x.dtbo",
vid, pid);
- strlcpy(dip->name, w1_header.product_name, sizeof(dip->name));
- strlcpy(dip->owner, w1_header.vendor_name, sizeof(dip->owner));
- list_add_tail(&dip->list, extension_list);
+ strlcpy(dip.name, w1_header.product_name, sizeof(dip.name));
+ strlcpy(dip.owner, w1_header.vendor_name, sizeof(dip.owner));
+ if (!alist_add(extension_list, dip))
+ return -ENOMEM;
num_dip++;
}
return num_dip;
}
+
+U_BOOT_EXTENSION(dip, sunxi_extension_board_scan);
+
+U_BOOT_DRVINFO(dip) = {
+ .name = "dip",
+};
--
2.43.0
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH v3 13/20] board: sandbox: Improve extension board scan implementation
2025-10-13 13:32 [PATCH v3 00/20] Convert extension support to UCLASS and adds its support to boot flows Kory Maincent (TI.com)
` (11 preceding siblings ...)
2025-10-13 13:32 ` [PATCH v3 12/20] board: sunxi: Convert extension support to UCLASS framework Kory Maincent (TI.com)
@ 2025-10-13 13:32 ` Kory Maincent (TI.com)
2025-10-13 13:32 ` [PATCH v3 14/20] board: sandbox: Convert extension support to UCLASS framework Kory Maincent (TI.com)
` (7 subsequent siblings)
20 siblings, 0 replies; 40+ messages in thread
From: Kory Maincent (TI.com) @ 2025-10-13 13:32 UTC (permalink / raw)
To: Tom Rini, Simon Glass, Jagan Teki, Andre Przywara, Hans de Goede,
Mario Six, Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team,
Ying-Chun Liu (PaulLiu)
Cc: Roger Quadros, Bajjuri Praneeth, Thomas Petazzoni, u-boot,
Kory Maincent (TI.com)
Enhance the extension board scanning code in sandbox with better error
handling and code organization.
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
board/sandbox/sandbox.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c
index 0dc23a27dfc..c5d7b9651a9 100644
--- a/board/sandbox/sandbox.c
+++ b/board/sandbox/sandbox.c
@@ -113,11 +113,15 @@ int ft_board_setup(void *fdt, struct bd_info *bd)
#ifdef CONFIG_CMD_EXTENSION
int extension_board_scan(struct list_head *extension_list)
{
- struct extension *extension;
int i;
for (i = 0; i < 2; i++) {
+ struct extension *extension;
+
extension = calloc(1, sizeof(struct extension));
+ if (!extension)
+ return -ENOMEM;
+
snprintf(extension->overlay, sizeof(extension->overlay), "overlay%d.dtbo", i);
snprintf(extension->name, sizeof(extension->name), "extension board %d", i);
snprintf(extension->owner, sizeof(extension->owner), "sandbox");
--
2.43.0
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH v3 14/20] board: sandbox: Convert extension support to UCLASS framework
2025-10-13 13:32 [PATCH v3 00/20] Convert extension support to UCLASS and adds its support to boot flows Kory Maincent (TI.com)
` (12 preceding siblings ...)
2025-10-13 13:32 ` [PATCH v3 13/20] board: sandbox: Improve extension board scan implementation Kory Maincent (TI.com)
@ 2025-10-13 13:32 ` Kory Maincent (TI.com)
2025-10-19 13:06 ` Simon Glass
2025-10-13 13:32 ` [PATCH v3 15/20] board: compulab: Convert imx8mm-cl-iot-gate to UCLASS extension framework Kory Maincent (TI.com)
` (6 subsequent siblings)
20 siblings, 1 reply; 40+ messages in thread
From: Kory Maincent (TI.com) @ 2025-10-13 13:32 UTC (permalink / raw)
To: Tom Rini, Simon Glass, Jagan Teki, Andre Przywara, Hans de Goede,
Mario Six, Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team,
Ying-Chun Liu (PaulLiu)
Cc: Roger Quadros, Bajjuri Praneeth, Thomas Petazzoni, u-boot,
Kory Maincent (TI.com)
Migrate sandbox extension board detection from legacy implementation to
the new UCLASS-based extension board framework.
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Change in v3:
- Use U_BOOT_DRVINFO.
---
arch/Kconfig | 2 +-
board/sandbox/sandbox.c | 28 ++++++++++++++++------------
2 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/arch/Kconfig b/arch/Kconfig
index 7e05e0c2263..5bb65a29f8d 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -215,7 +215,7 @@ config SANDBOX
select SYSRESET_CMD_POWEROFF if CMD_POWEROFF
select SYS_CACHE_SHIFT_4
select IRQ
- select SUPPORT_EXTENSION_SCAN if CMDLINE
+ select SUPPORT_DM_EXTENSION_SCAN if CMDLINE
select SUPPORT_ACPI
imply BITREVERSE
select BLOBLIST
diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c
index c5d7b9651a9..77e5a0478ca 100644
--- a/board/sandbox/sandbox.c
+++ b/board/sandbox/sandbox.c
@@ -111,27 +111,31 @@ int ft_board_setup(void *fdt, struct bd_info *bd)
}
#ifdef CONFIG_CMD_EXTENSION
-int extension_board_scan(struct list_head *extension_list)
+static int sandbox_extension_board_scan(struct udevice *dev,
+ struct alist *extension_list)
{
int i;
for (i = 0; i < 2; i++) {
- struct extension *extension;
-
- extension = calloc(1, sizeof(struct extension));
- if (!extension)
+ struct extension extension = {0};
+
+ snprintf(extension.overlay, sizeof(extension.overlay), "overlay%d.dtbo", i);
+ snprintf(extension.name, sizeof(extension.name), "extension board %d", i);
+ snprintf(extension.owner, sizeof(extension.owner), "sandbox");
+ snprintf(extension.version, sizeof(extension.version), "1.1");
+ snprintf(extension.other, sizeof(extension.other), "Fictional extension board");
+ if (!alist_add(extension_list, extension))
return -ENOMEM;
-
- snprintf(extension->overlay, sizeof(extension->overlay), "overlay%d.dtbo", i);
- snprintf(extension->name, sizeof(extension->name), "extension board %d", i);
- snprintf(extension->owner, sizeof(extension->owner), "sandbox");
- snprintf(extension->version, sizeof(extension->version), "1.1");
- snprintf(extension->other, sizeof(extension->other), "Fictional extension board");
- list_add_tail(&extension->list, extension_list);
}
return i;
}
+
+U_BOOT_EXTENSION(sandbox_extension, sandbox_extension_board_scan);
+
+U_BOOT_DRVINFO(sandbox_extension) = {
+ .name = "sandbox_extension",
+};
#endif
#ifdef CONFIG_BOARD_LATE_INIT
--
2.43.0
^ permalink raw reply related [flat|nested] 40+ messages in thread* Re: [PATCH v3 14/20] board: sandbox: Convert extension support to UCLASS framework
2025-10-13 13:32 ` [PATCH v3 14/20] board: sandbox: Convert extension support to UCLASS framework Kory Maincent (TI.com)
@ 2025-10-19 13:06 ` Simon Glass
0 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2025-10-19 13:06 UTC (permalink / raw)
To: Kory Maincent (TI.com)
Cc: Tom Rini, Jagan Teki, Andre Przywara, Hans de Goede, Mario Six,
Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team,
Ying-Chun Liu (PaulLiu), Roger Quadros, Bajjuri Praneeth,
Thomas Petazzoni, u-boot
On Mon, 13 Oct 2025 at 14:33, Kory Maincent (TI.com)
<kory.maincent@bootlin.com> wrote:
>
> Migrate sandbox extension board detection from legacy implementation to
> the new UCLASS-based extension board framework.
>
> Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
> ---
>
> Change in v3:
> - Use U_BOOT_DRVINFO.
> ---
> arch/Kconfig | 2 +-
> board/sandbox/sandbox.c | 28 ++++++++++++++++------------
> 2 files changed, 17 insertions(+), 13 deletions(-)
>
Reviewed-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v3 15/20] board: compulab: Convert imx8mm-cl-iot-gate to UCLASS extension framework
2025-10-13 13:32 [PATCH v3 00/20] Convert extension support to UCLASS and adds its support to boot flows Kory Maincent (TI.com)
` (13 preceding siblings ...)
2025-10-13 13:32 ` [PATCH v3 14/20] board: sandbox: Convert extension support to UCLASS framework Kory Maincent (TI.com)
@ 2025-10-13 13:32 ` Kory Maincent (TI.com)
2025-10-13 13:32 ` [PATCH v3 16/20] boot: Remove legacy extension board support Kory Maincent (TI.com)
` (5 subsequent siblings)
20 siblings, 0 replies; 40+ messages in thread
From: Kory Maincent (TI.com) @ 2025-10-13 13:32 UTC (permalink / raw)
To: Tom Rini, Simon Glass, Jagan Teki, Andre Przywara, Hans de Goede,
Mario Six, Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team,
Ying-Chun Liu (PaulLiu)
Cc: Roger Quadros, Bajjuri Praneeth, Thomas Petazzoni, u-boot,
Kory Maincent (TI.com)
Migrate CompuLab imx8mm-cl-iot-gate board extension detection from legacy
implementation to the new UCLASS-based extension board framework.
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Change in v3:
- Use U_BOOT_DRVINFO.
Change in v2:
- Fix build errors.
---
arch/arm/mach-imx/imx8m/Kconfig | 4 +-
.../imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c | 67 +++++++++++-----------
2 files changed, 35 insertions(+), 36 deletions(-)
diff --git a/arch/arm/mach-imx/imx8m/Kconfig b/arch/arm/mach-imx/imx8m/Kconfig
index e7bc154b805..5324eff3084 100644
--- a/arch/arm/mach-imx/imx8m/Kconfig
+++ b/arch/arm/mach-imx/imx8m/Kconfig
@@ -359,14 +359,14 @@ config TARGET_IMX8MM_CL_IOT_GATE
select IMX8MM
select SUPPORT_SPL
select IMX8M_LPDDR4
- select SUPPORT_EXTENSION_SCAN
+ select SUPPORT_DM_EXTENSION_SCAN
config TARGET_IMX8MM_CL_IOT_GATE_OPTEE
bool "CompuLab iot-gate-imx8 with optee support"
select IMX8MM
select SUPPORT_SPL
select IMX8M_LPDDR4
- select SUPPORT_EXTENSION_SCAN
+ select SUPPORT_DM_EXTENSION_SCAN
config TARGET_IMX8MP_RSB3720A1_4G
bool "Support i.MX8MP RSB3720A1 4G"
diff --git a/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c b/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c
index be4f293bd4a..260d8757129 100644
--- a/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c
+++ b/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c
@@ -436,9 +436,10 @@ static int iot_gate_imx8_update_ext_ied(void)
return 0;
}
-int extension_board_scan(struct list_head *extension_list)
+static int iot_gate_imx8_extension_board_scan(struct udevice *dev,
+ struct alist *extension_list)
{
- struct extension *extension = NULL;
+ struct extension extension = {0};
int i;
int ret = 0;
@@ -448,25 +449,21 @@ int extension_board_scan(struct list_head *extension_list)
case IOT_GATE_EXT_EMPTY:
break;
case IOT_GATE_EXT_CAN:
- extension = calloc(1, sizeof(struct extension));
- snprintf(extension->name, sizeof(extension->name),
+ snprintf(extension.name, sizeof(extension.name),
"IOT_GATE_EXT_CAN");
break;
case IOT_GATE_EXT_IED:
- extension = calloc(1, sizeof(struct extension));
- snprintf(extension->name, sizeof(extension->name),
+ snprintf(extension.name, sizeof(extension.name),
"IOT_GATE_EXT_IED");
- snprintf(extension->overlay, sizeof(extension->overlay),
+ snprintf(extension.overlay, sizeof(extension.overlay),
"imx8mm-cl-iot-gate-ied.dtbo");
break;
case IOT_GATE_EXT_POE:
- extension = calloc(1, sizeof(struct extension));
- snprintf(extension->name, sizeof(extension->name),
+ snprintf(extension.name, sizeof(extension.name),
"IOT_GATE_EXT_POE");
break;
case IOT_GATE_EXT_POEV2:
- extension = calloc(1, sizeof(struct extension));
- snprintf(extension->name, sizeof(extension->name),
+ snprintf(extension.name, sizeof(extension.name),
"IOT_GATE_EXT_POEV2");
break;
default:
@@ -474,10 +471,11 @@ int extension_board_scan(struct list_head *extension_list)
break;
}
- if (extension) {
- snprintf(extension->owner, sizeof(extension->owner),
+ if (extension.name[0]) {
+ snprintf(extension.owner, sizeof(extension.owner),
"Compulab");
- list_add_tail(&extension->list, extension_list);
+ if (!alist_add(extension_list, extension))
+ return -ENOMEM;
ret = 1;
} else
return ret;
@@ -486,44 +484,38 @@ int extension_board_scan(struct list_head *extension_list)
iot_gate_imx8_update_ext_ied();
for (i=0; i<ARRAY_SIZE(iot_gate_imx8_ext_ied_id); i++) {
- extension = NULL;
+ memset(&extension, 0, sizeof(extension));
switch (iot_gate_imx8_ext_ied_id[i]) {
case IOT_GATE_IMX8_CARD_ID_EMPTY:
break;
case IOT_GATE_IMX8_CARD_ID_RS_485:
- extension = calloc(1, sizeof(struct extension));
- snprintf(extension->name, sizeof(extension->name),
+ snprintf(extension.name, sizeof(extension.name),
"IOT_GATE_IMX8_CARD_ID_RS_485");
break;
case IOT_GATE_IMX8_CARD_ID_RS_232:
- extension = calloc(1, sizeof(struct extension));
- snprintf(extension->name, sizeof(extension->name),
+ snprintf(extension.name, sizeof(extension.name),
"IOT_GATE_IMX8_CARD_ID_RS_232");
break;
case IOT_GATE_IMX8_CARD_ID_CAN:
- extension = calloc(1, sizeof(struct extension));
- snprintf(extension->name, sizeof(extension->name),
+ snprintf(extension.name, sizeof(extension.name),
"IOT_GATE_IMX8_CARD_ID_CAN");
- snprintf(extension->overlay, sizeof(extension->overlay),
+ snprintf(extension.overlay, sizeof(extension.overlay),
"imx8mm-cl-iot-gate-ied-can%d.dtbo", i);
break;
case IOT_GATE_IMX8_CARD_ID_TPM:
- extension = calloc(1, sizeof(struct extension));
- snprintf(extension->name, sizeof(extension->name),
+ snprintf(extension.name, sizeof(extension.name),
"IOT_GATE_IMX8_CARD_ID_TPM");
- snprintf(extension->overlay, sizeof(extension->overlay),
+ snprintf(extension.overlay, sizeof(extension.overlay),
"imx8mm-cl-iot-gate-ied-tpm%d.dtbo", i);
break;
case IOT_GATE_IMX8_CARD_ID_CL420:
- extension = calloc(1, sizeof(struct extension));
- snprintf(extension->name, sizeof(extension->name),
+ snprintf(extension.name, sizeof(extension.name),
"IOT_GATE_IMX8_CARD_ID_CL420");
- snprintf(extension->overlay, sizeof(extension->overlay),
+ snprintf(extension.overlay, sizeof(extension.overlay),
"imx8mm-cl-iot-gate-ied-can%d.dtbo", i);
break;
case IOT_GATE_IMX8_CARD_ID_DI4O4:
- extension = calloc(1, sizeof(struct extension));
- snprintf(extension->name, sizeof(extension->name),
+ snprintf(extension.name, sizeof(extension.name),
"IOT_GATE_IMX8_CARD_ID_DI4O4");
break;
default:
@@ -531,18 +523,25 @@ int extension_board_scan(struct list_head *extension_list)
__func__, i, iot_gate_imx8_ext_ied_id[i]);
break;
}
- if (extension) {
- snprintf(extension->owner, sizeof(extension->owner),
+ if (extension.name[0]) {
+ snprintf(extension.owner, sizeof(extension.owner),
"Compulab");
- snprintf(extension->other, sizeof(extension->other),
+ snprintf(extension.other, sizeof(extension.other),
"On slot %d", i);
- list_add_tail(&extension->list, extension_list);
+ if (!alist_add(extension_list, extension))
+ return -ENOMEM;
ret = ret + 1;
}
}
return ret;
}
+
+U_BOOT_EXTENSION(iot_gate_imx8_extension, iot_gate_imx8_extension_board_scan);
+
+U_BOOT_DRVINFO(iot_gate_imx8_extension) = {
+ .name = "iot_gate_imx8_extension",
+};
#endif
static int setup_mac_address(void)
--
2.43.0
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH v3 16/20] boot: Remove legacy extension board support
2025-10-13 13:32 [PATCH v3 00/20] Convert extension support to UCLASS and adds its support to boot flows Kory Maincent (TI.com)
` (14 preceding siblings ...)
2025-10-13 13:32 ` [PATCH v3 15/20] board: compulab: Convert imx8mm-cl-iot-gate to UCLASS extension framework Kory Maincent (TI.com)
@ 2025-10-13 13:32 ` Kory Maincent (TI.com)
2025-10-13 13:32 ` [PATCH v3 17/20] boot: extension: Move overlay apply custom logic to command level Kory Maincent (TI.com)
` (4 subsequent siblings)
20 siblings, 0 replies; 40+ messages in thread
From: Kory Maincent (TI.com) @ 2025-10-13 13:32 UTC (permalink / raw)
To: Tom Rini, Simon Glass, Jagan Teki, Andre Przywara, Hans de Goede,
Mario Six, Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team,
Ying-Chun Liu (PaulLiu)
Cc: Roger Quadros, Bajjuri Praneeth, Thomas Petazzoni, u-boot,
Kory Maincent (TI.com)
Remove the legacy extension board implementation now that all boards
have been converted to use the new UCLASS-based framework. This
eliminates lines of legacy code while preserving functionality
through the modern driver model approach.
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
Changes in v2:
- Remove a missing DM_EXTENSION_SCAN in cmd/Kconfig
---
MAINTAINERS | 1 -
arch/Kconfig | 2 +-
arch/arm/mach-imx/imx8m/Kconfig | 4 +-
arch/arm/mach-omap2/am33xx/Kconfig | 2 +-
arch/arm/mach-omap2/omap5/Kconfig | 2 +-
arch/arm/mach-sunxi/Kconfig | 2 +-
board/ti/common/Kconfig | 2 +-
board/ti/common/Makefile | 2 +-
boot/Kconfig | 4 --
boot/Makefile | 3 +-
boot/extension-uclass.c | 18 +++----
boot/extension.c | 99 --------------------------------------
cmd/Kconfig | 2 +-
cmd/extension_board.c | 72 +++------------------------
include/extension_board.h | 56 ++++++---------------
15 files changed, 41 insertions(+), 230 deletions(-)
diff --git a/MAINTAINERS b/MAINTAINERS
index a63ffa14ef5..a75e59453d7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1188,7 +1188,6 @@ S: Maintained
F: board/sunxi/chip.c
F: board/ti/common/cape_detect.c
F: boot/extension-uclass.c
-F: boot/extension.c
F: cmd/extension_board.c
F: include/extension_board.h
diff --git a/arch/Kconfig b/arch/Kconfig
index 5bb65a29f8d..7e05e0c2263 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -215,7 +215,7 @@ config SANDBOX
select SYSRESET_CMD_POWEROFF if CMD_POWEROFF
select SYS_CACHE_SHIFT_4
select IRQ
- select SUPPORT_DM_EXTENSION_SCAN if CMDLINE
+ select SUPPORT_EXTENSION_SCAN if CMDLINE
select SUPPORT_ACPI
imply BITREVERSE
select BLOBLIST
diff --git a/arch/arm/mach-imx/imx8m/Kconfig b/arch/arm/mach-imx/imx8m/Kconfig
index 5324eff3084..e7bc154b805 100644
--- a/arch/arm/mach-imx/imx8m/Kconfig
+++ b/arch/arm/mach-imx/imx8m/Kconfig
@@ -359,14 +359,14 @@ config TARGET_IMX8MM_CL_IOT_GATE
select IMX8MM
select SUPPORT_SPL
select IMX8M_LPDDR4
- select SUPPORT_DM_EXTENSION_SCAN
+ select SUPPORT_EXTENSION_SCAN
config TARGET_IMX8MM_CL_IOT_GATE_OPTEE
bool "CompuLab iot-gate-imx8 with optee support"
select IMX8MM
select SUPPORT_SPL
select IMX8M_LPDDR4
- select SUPPORT_DM_EXTENSION_SCAN
+ select SUPPORT_EXTENSION_SCAN
config TARGET_IMX8MP_RSB3720A1_4G
bool "Support i.MX8MP RSB3720A1 4G"
diff --git a/arch/arm/mach-omap2/am33xx/Kconfig b/arch/arm/mach-omap2/am33xx/Kconfig
index 77f7938305b..dff4f1cf202 100644
--- a/arch/arm/mach-omap2/am33xx/Kconfig
+++ b/arch/arm/mach-omap2/am33xx/Kconfig
@@ -15,7 +15,7 @@ config TARGET_AM335X_EVM
select DM_GPIO
select DM_SERIAL
select TI_I2C_BOARD_DETECT
- select SUPPORT_DM_EXTENSION_SCAN
+ select SUPPORT_EXTENSION_SCAN
imply CMD_DM
imply SPL_DM
imply SPL_DM_SEQ_ALIAS
diff --git a/arch/arm/mach-omap2/omap5/Kconfig b/arch/arm/mach-omap2/omap5/Kconfig
index 819490a8cf8..5394529658b 100644
--- a/arch/arm/mach-omap2/omap5/Kconfig
+++ b/arch/arm/mach-omap2/omap5/Kconfig
@@ -38,7 +38,7 @@ config TARGET_AM57XX_EVM
select CMD_DDR3
select DRA7XX
select TI_I2C_BOARD_DETECT
- select SUPPORT_DM_EXTENSION_SCAN
+ select SUPPORT_EXTENSION_SCAN
imply DM_THERMAL
imply SCSI
imply SPL_THERMAL
diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
index f5696199516..b04ec671696 100644
--- a/arch/arm/mach-sunxi/Kconfig
+++ b/arch/arm/mach-sunxi/Kconfig
@@ -1223,7 +1223,7 @@ config BLUETOOTH_DT_DEVICE_FIXUP
config CHIP_DIP_SCAN
bool "Enable DIPs detection for CHIP board"
- select SUPPORT_DM_EXTENSION_SCAN
+ select SUPPORT_EXTENSION_SCAN
select W1
select W1_GPIO
select W1_EEPROM
diff --git a/board/ti/common/Kconfig b/board/ti/common/Kconfig
index feb05b4bf95..9512c5c23f1 100644
--- a/board/ti/common/Kconfig
+++ b/board/ti/common/Kconfig
@@ -20,7 +20,7 @@ config CAPE_EEPROM_BUS_NUM
int "Cape EEPROM's I2C bus address"
range 0 8
default 2
- depends on SUPPORT_DM_EXTENSION_SCAN
+ depends on SUPPORT_EXTENSION_SCAN
config TI_COMMON_CMD_OPTIONS
bool "Enable cmd options on TI platforms"
diff --git a/board/ti/common/Makefile b/board/ti/common/Makefile
index b42273d3a5a..f58935b4103 100644
--- a/board/ti/common/Makefile
+++ b/board/ti/common/Makefile
@@ -2,6 +2,6 @@
# Copyright (C) 2015-2016 Texas Instruments Incorporated - https://www.ti.com/
obj-${CONFIG_TI_I2C_BOARD_DETECT} += board_detect.o
-obj-${CONFIG_$(PHASE_)SUPPORT_DM_EXTENSION_SCAN} += cape_detect.o
+obj-${CONFIG_$(PHASE_)SUPPORT_EXTENSION_SCAN} += cape_detect.o
obj-${CONFIG_OF_LIBFDT} += fdt_ops.o
obj-${CONFIG_ARCH_K3} += k3-ddr.o
diff --git a/boot/Kconfig b/boot/Kconfig
index 08d666d4b93..a75f6b641ed 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -1910,10 +1910,6 @@ config SUPPORT_EXTENSION_SCAN
select OF_LIBFDT_OVERLAY
bool
-config SUPPORT_DM_EXTENSION_SCAN
- select OF_LIBFDT_OVERLAY
- bool
-
config USE_BOOTARGS
bool "Enable boot arguments"
help
diff --git a/boot/Makefile b/boot/Makefile
index aa26070fbb8..7fb56e7ef37 100644
--- a/boot/Makefile
+++ b/boot/Makefile
@@ -9,8 +9,7 @@ obj-$(CONFIG_BOOT_RETRY) += bootretry.o
obj-$(CONFIG_CMD_BOOTM) += bootm.o bootm_os.o
obj-$(CONFIG_CMD_BOOTZ) += bootm.o bootm_os.o
obj-$(CONFIG_CMD_BOOTI) += bootm.o bootm_os.o
-obj-$(CONFIG_SUPPORT_EXTENSION_SCAN) += extension.o
-obj-$(CONFIG_SUPPORT_DM_EXTENSION_SCAN) += extension-uclass.o
+obj-$(CONFIG_SUPPORT_EXTENSION_SCAN) += extension-uclass.o
obj-$(CONFIG_PXE_UTILS) += pxe_utils.o
diff --git a/boot/extension-uclass.c b/boot/extension-uclass.c
index 914971215af..35f751237eb 100644
--- a/boot/extension-uclass.c
+++ b/boot/extension-uclass.c
@@ -14,7 +14,7 @@
#include <dm/lists.h>
#include <dm/uclass.h>
-struct alist *dm_extension_get_list(void)
+struct alist *extension_get_list(void)
{
struct udevice *dev;
@@ -24,7 +24,7 @@ struct alist *dm_extension_get_list(void)
return dev_get_priv(dev);
}
-int dm_extension_probe(struct udevice *dev)
+int extension_probe(struct udevice *dev)
{
struct alist *extension_list = dev_get_priv(dev);
@@ -32,7 +32,7 @@ int dm_extension_probe(struct udevice *dev)
return 0;
}
-int dm_extension_remove(struct udevice *dev)
+int extension_remove(struct udevice *dev)
{
struct alist *extension_list = dev_get_priv(dev);
@@ -40,9 +40,9 @@ int dm_extension_remove(struct udevice *dev)
return 0;
}
-int dm_extension_scan(void)
+int extension_scan(void)
{
- struct alist *extension_list = dm_extension_get_list();
+ struct alist *extension_list = extension_get_list();
const struct extension_ops *ops;
struct udevice *dev;
int ret;
@@ -109,9 +109,9 @@ static int _extension_apply(const struct extension *extension)
return ret;
}
-int dm_extension_apply(int extension_num)
+int extension_apply(int extension_num)
{
- struct alist *extension_list = dm_extension_get_list();
+ struct alist *extension_list = extension_get_list();
const struct extension *extension;
if (!extension_list)
@@ -127,9 +127,9 @@ int dm_extension_apply(int extension_num)
return _extension_apply(extension);
}
-int dm_extension_apply_all(void)
+int extension_apply_all(void)
{
- struct alist *extension_list = dm_extension_get_list();
+ struct alist *extension_list = extension_get_list();
const struct extension *extension;
int ret;
diff --git a/boot/extension.c b/boot/extension.c
deleted file mode 100644
index 8f28a7e1626..00000000000
--- a/boot/extension.c
+++ /dev/null
@@ -1,99 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * (C) Copyright 2025 Köry Maincent <kory.maincent@bootlin.com>
- */
-
-#include <bootdev.h>
-#include <command.h>
-#include <env.h>
-#include <extension_board.h>
-#include <fdt_support.h>
-#include <malloc.h>
-#include <mapmem.h>
-
-LIST_HEAD(extension_list);
-
-int extension_apply(struct extension *extension)
-{
- ulong extrasize, overlay_addr;
- struct fdt_header *blob;
- char *overlay_cmd;
-
- if (!working_fdt) {
- printf("No FDT memory address configured. Please configure\n"
- "the FDT address via \"fdt addr <address>\" command.\n");
- return CMD_RET_FAILURE;
- }
-
- overlay_cmd = env_get("extension_overlay_cmd");
- if (!overlay_cmd) {
- printf("Environment extension_overlay_cmd is missing\n");
- return CMD_RET_FAILURE;
- }
-
- overlay_addr = env_get_hex("extension_overlay_addr", 0);
- if (!overlay_addr) {
- printf("Environment extension_overlay_addr is missing\n");
- return CMD_RET_FAILURE;
- }
-
- env_set("extension_overlay_name", extension->overlay);
- if (run_command(overlay_cmd, 0) != 0)
- return CMD_RET_FAILURE;
-
- extrasize = env_get_hex("filesize", 0);
- if (!extrasize)
- return CMD_RET_FAILURE;
-
- fdt_shrink_to_minimum(working_fdt, extrasize);
-
- blob = map_sysmem(overlay_addr, 0);
- if (!fdt_valid(&blob))
- return CMD_RET_FAILURE;
-
- /* apply method prints messages on error */
- if (fdt_overlay_apply_verbose(working_fdt, blob))
- return CMD_RET_FAILURE;
-
- return CMD_RET_SUCCESS;
-}
-
-int extension_scan(bool show)
-{
- struct extension *extension, *next;
- int extension_num;
-
- list_for_each_entry_safe(extension, next, &extension_list, list) {
- list_del(&extension->list);
- free(extension);
- }
- extension_num = extension_board_scan(&extension_list);
- if (show && extension_num >= 0)
- printf("Found %d extension board(s).\n", extension_num);
-
- /* either the number of extensions, or -ve for error */
- return extension_num;
-}
-
-static int extension_bootdev_hunt(struct bootdev_hunter *info, bool show)
-{
- int ret;
-
- ret = env_set_hex("extension_overlay_addr",
- env_get_hex("fdtoverlay_addr_r", 0));
- if (ret)
- return log_msg_ret("env", ret);
-
- ret = extension_scan(show);
- if (ret < 0)
- return log_msg_ret("ext", ret);
-
- return 0;
-}
-
-/* extensions should have a uclass - for now we use UCLASS_SIMPLE_BUS uclass */
-BOOTDEV_HUNTER(extension_bootdev_hunter) = {
- .prio = BOOTDEVP_1_PRE_SCAN,
- .uclass = UCLASS_SIMPLE_BUS,
- .hunt = extension_bootdev_hunt,
-};
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 721bdb87c8a..986eeeba807 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -548,7 +548,7 @@ config CMD_FDT
config CMD_EXTENSION
bool "Extension board management command"
select CMD_FDT
- depends on SUPPORT_EXTENSION_SCAN || SUPPORT_DM_EXTENSION_SCAN
+ depends on SUPPORT_EXTENSION_SCAN
help
Enables the "extension" command, which allows to detect
extension boards connected to the system, and apply
diff --git a/cmd/extension_board.c b/cmd/extension_board.c
index 1f1eddbe976..c373397e0fb 100644
--- a/cmd/extension_board.c
+++ b/cmd/extension_board.c
@@ -12,41 +12,23 @@
static int do_extension_list(struct cmd_tbl *cmdtp, int flag,
int argc, char *const argv[])
{
-#if CONFIG_IS_ENABLED(SUPPORT_DM_EXTENSION_SCAN)
- struct alist *dm_extension_list;
-#endif
+ struct alist *extension_list;
struct extension *extension;
int i = 0;
-#if CONFIG_IS_ENABLED(SUPPORT_DM_EXTENSION_SCAN)
- dm_extension_list = dm_extension_get_list();
-
- if (!alist_get_ptr(dm_extension_list, 0)) {
- printf("No extension registered - Please run \"extension scan\"\n");
- return CMD_RET_SUCCESS;
- }
-
- alist_for_each(extension, dm_extension_list) {
- printf("Extension %d: %s\n", i++, extension->name);
- printf("\tManufacturer: \t\t%s\n", extension->owner);
- printf("\tVersion: \t\t%s\n", extension->version);
- printf("\tDevicetree overlay: \t%s\n", extension->overlay);
- printf("\tOther information: \t%s\n", extension->other);
- }
-#else
- if (list_empty(&extension_list)) {
+ extension_list = extension_get_list();
+ if (!alist_get_ptr(extension_list, 0)) {
printf("No extension registered - Please run \"extension scan\"\n");
return CMD_RET_SUCCESS;
}
- list_for_each_entry(extension, &extension_list, list) {
+ alist_for_each(extension, extension_list) {
printf("Extension %d: %s\n", i++, extension->name);
printf("\tManufacturer: \t\t%s\n", extension->owner);
printf("\tVersion: \t\t%s\n", extension->version);
printf("\tDevicetree overlay: \t%s\n", extension->overlay);
printf("\tOther information: \t%s\n", extension->other);
}
-#endif
return CMD_RET_SUCCESS;
}
@@ -55,69 +37,31 @@ static int do_extension_scan(struct cmd_tbl *cmdtp, int flag,
{
int extension_num;
-#if CONFIG_IS_ENABLED(SUPPORT_DM_EXTENSION_SCAN)
- extension_num = dm_extension_scan();
+ extension_num = extension_scan();
if (extension_num == -ENODEV)
extension_num = 0;
else if (extension_num < 0)
return CMD_RET_FAILURE;
printf("Found %d extension board(s).\n", extension_num);
-#else
- extension_num = extension_scan(true);
- if (extension_num < 0 && extension_num != -ENODEV)
- return CMD_RET_FAILURE;
-#endif
-
return CMD_RET_SUCCESS;
}
static int do_extension_apply(struct cmd_tbl *cmdtp, int flag,
int argc, char *const argv[])
{
-#if !CONFIG_IS_ENABLED(SUPPORT_DM_EXTENSION_SCAN)
- struct extension *extension = NULL;
- struct list_head *entry;
- int i = 0;
-#endif
- int extension_id, ret;
+ int extension_id;
if (argc < 2)
return CMD_RET_USAGE;
if (strcmp(argv[1], "all") == 0) {
- ret = CMD_RET_FAILURE;
-#if CONFIG_IS_ENABLED(SUPPORT_DM_EXTENSION_SCAN)
- if (dm_extension_apply_all())
+ if (extension_apply_all())
return CMD_RET_FAILURE;
-#else
- list_for_each_entry(extension, &extension_list, list) {
- ret = extension_apply(extension);
- if (ret != CMD_RET_SUCCESS)
- break;
- }
-#endif
} else {
extension_id = simple_strtol(argv[1], NULL, 10);
-#if CONFIG_IS_ENABLED(SUPPORT_DM_EXTENSION_SCAN)
- if (dm_extension_apply(extension_id))
+ if (extension_apply(extension_id))
return CMD_RET_FAILURE;
-#else
- list_for_each(entry, &extension_list) {
- if (i == extension_id) {
- extension = list_entry(entry, struct extension, list);
- break;
- }
- i++;
- }
-
- if (!extension) {
- printf("Wrong extension number\n");
- return CMD_RET_FAILURE;
- }
-
- ret = extension_apply(extension);
-#endif
}
return CMD_RET_SUCCESS;
diff --git a/include/extension_board.h b/include/extension_board.h
index ddf5b367cd3..251482d0287 100644
--- a/include/extension_board.h
+++ b/include/extension_board.h
@@ -15,50 +15,49 @@
extern struct list_head extension_list;
/**
- * dm_extension_get_list - Get the extension list
+ * extension_get_list - Get the extension list
* Return: The extension alist pointer, or NULL if no such list exists.
*
* The caller must not free the list.
*/
-struct alist *dm_extension_get_list(void);
+struct alist *extension_get_list(void);
/**
- * dm_extension_probe - Probe extension device
+ * extension_probe - Probe extension device
* @dev: Extension device that needs to be probed
* Return: Zero on success, negative on failure.
*/
-int dm_extension_probe(struct udevice *dev);
+int extension_probe(struct udevice *dev);
/**
- * dm_extension_remove - Remove extension device
+ * extension_remove - Remove extension device
* @dev: Extension device that needs to be removed
* Return: Zero on success, negative on failure.
*/
-int dm_extension_remove(struct udevice *dev);
+int extension_remove(struct udevice *dev);
/**
- * dm_extension_scan - Scan extension boards available.
+ * extension_scan - Scan extension boards available.
* Return: Zero on success, negative on failure.
*/
-int dm_extension_scan(void);
+int extension_scan(void);
/**
- * dm_extension_apply - Apply extension board overlay to the devicetree
+ * extension_apply - Apply extension board overlay to the devicetree
* @extension_num: Extension number to be applied
* Return: Zero on success, negative on failure.
*/
-int dm_extension_apply(int extension_num);
+int extension_apply(int extension_num);
/**
- * dm_extension_apply_all - Apply all extension board overlays to the
+ * extension_apply_all - Apply all extension board overlays to the
* devicetree
* Return: Zero on success, negative on failure.
*/
-int dm_extension_apply_all(void);
+int extension_apply_all(void);
/**
* extension - Description fields of an extension board
- * @list: List head
* @name: Name of the extension
* @owner: Owner of the extension
* @version: Version of the extension
@@ -66,7 +65,6 @@ int dm_extension_apply_all(void);
* @other: Other information of this extension
*/
struct extension {
- struct list_head list;
char name[32];
char owner[32];
char version[32];
@@ -91,38 +89,12 @@ struct extension_ops {
U_BOOT_DRIVER(_name) = { \
.name = #_name, \
.id = UCLASS_EXTENSION, \
- .probe = dm_extension_probe, \
- .remove = dm_extension_remove, \
+ .probe = extension_probe, \
+ .remove = extension_remove, \
.ops = &(struct extension_ops) { \
.scan = _scan_func, \
}, \
.priv_auto = sizeof(struct alist), \
}
-/**
- * extension_board_scan - Add system-specific function to scan extension board.
- * @param extension_list List of extension board information to update.
- * Return: the number of extension.
- *
- * This function is called if CONFIG_CMD_EXTENSION is defined.
- * Needs to fill the list extension_list with elements.
- * Each element need to be allocated to an extension structure.
- *
- */
-int extension_board_scan(struct list_head *extension_list);
-
-/**
- * extension_apply - Apply extension board overlay to the devicetree
- * @extension: Extension to be applied
- * Return: Zero on success, negative on failure.
- */
-int extension_apply(struct extension *extension);
-
-/**
- * extension_scan - Scan extension boards available.
- * @show: Flag to enable verbose log
- * Return: Zero on success, negative on failure.
- */
-int extension_scan(bool show);
-
#endif /* __EXTENSION_SUPPORT_H */
--
2.43.0
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH v3 17/20] boot: extension: Move overlay apply custom logic to command level
2025-10-13 13:32 [PATCH v3 00/20] Convert extension support to UCLASS and adds its support to boot flows Kory Maincent (TI.com)
` (15 preceding siblings ...)
2025-10-13 13:32 ` [PATCH v3 16/20] boot: Remove legacy extension board support Kory Maincent (TI.com)
@ 2025-10-13 13:32 ` Kory Maincent (TI.com)
2025-10-13 13:32 ` [PATCH v3 18/20] boot: pxe_utils: Add extension board devicetree overlay support Kory Maincent (TI.com)
` (3 subsequent siblings)
20 siblings, 0 replies; 40+ messages in thread
From: Kory Maincent (TI.com) @ 2025-10-13 13:32 UTC (permalink / raw)
To: Tom Rini, Simon Glass, Jagan Teki, Andre Przywara, Hans de Goede,
Mario Six, Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team,
Ying-Chun Liu (PaulLiu)
Cc: Roger Quadros, Bajjuri Praneeth, Thomas Petazzoni, u-boot,
Kory Maincent (TI.com)
The extension_overlay_cmd environment variable approach is specific to
the U-Boot extension_board command, while other boot flows (pxe_utils,
bootstd) handle overlay loading differently.
Move the extension_overlay_cmd execution out of the core extension
framework to the command level. This decouples the framework from
command-specific behavior and prepares for future extension support
in other boot flows.
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
boot/extension-uclass.c | 68 +++--------------------------------
cmd/extension_board.c | 92 +++++++++++++++++++++++++++++++++++++++++++++--
include/extension_board.h | 12 ++-----
3 files changed, 98 insertions(+), 74 deletions(-)
diff --git a/boot/extension-uclass.c b/boot/extension-uclass.c
index 35f751237eb..4b3dd1bc0cd 100644
--- a/boot/extension-uclass.c
+++ b/boot/extension-uclass.c
@@ -59,92 +59,34 @@ int extension_scan(void)
return ops->scan(dev, extension_list);
}
-static int _extension_apply(const struct extension *extension)
+int extension_apply(struct fdt_header *working_fdt, ulong size)
{
- ulong extrasize, overlay_addr;
struct fdt_header *blob;
- char *overlay_cmd;
+ ulong overlay_addr;
int ret;
- if (!working_fdt) {
- printf("No FDT memory address configured. Please configure\n"
- "the FDT address via \"fdt addr <address>\" command.\n");
- return -EINVAL;
- }
-
- overlay_cmd = env_get("extension_overlay_cmd");
- if (!overlay_cmd) {
- printf("Environment extension_overlay_cmd is missing\n");
- return -EINVAL;
- }
-
overlay_addr = env_get_hex("extension_overlay_addr", 0);
if (!overlay_addr) {
printf("Environment extension_overlay_addr is missing\n");
return -EINVAL;
}
- env_set("extension_overlay_name", extension->overlay);
- ret = run_command(overlay_cmd, 0);
- if (ret)
- return ret;
-
- extrasize = env_get_hex("filesize", 0);
- if (!extrasize)
- return -EINVAL;
-
- fdt_shrink_to_minimum(working_fdt, extrasize);
+ fdt_shrink_to_minimum(working_fdt, size);
blob = map_sysmem(overlay_addr, 0);
if (!fdt_valid(&blob)) {
- printf("Invalid overlay devicetree %s\n", extension->overlay);
+ printf("Invalid overlay devicetree\n");
return -EINVAL;
}
/* Apply method prints messages on error */
ret = fdt_overlay_apply_verbose(working_fdt, blob);
if (ret)
- printf("Failed to apply overlay %s\n", extension->overlay);
+ printf("Failed to apply overlay\n");
return ret;
}
-int extension_apply(int extension_num)
-{
- struct alist *extension_list = extension_get_list();
- const struct extension *extension;
-
- if (!extension_list)
- return -ENOENT;
-
- extension = alist_get(extension_list, extension_num,
- struct extension);
- if (!extension) {
- printf("Wrong extension number\n");
- return -EINVAL;
- }
-
- return _extension_apply(extension);
-}
-
-int extension_apply_all(void)
-{
- struct alist *extension_list = extension_get_list();
- const struct extension *extension;
- int ret;
-
- if (!extension_list)
- return -ENOENT;
-
- alist_for_each(extension, extension_list) {
- ret = _extension_apply(extension);
- if (ret)
- return ret;
- }
-
- return 0;
-}
-
UCLASS_DRIVER(extension) = {
.name = "extension",
.id = UCLASS_EXTENSION,
diff --git a/cmd/extension_board.c b/cmd/extension_board.c
index c373397e0fb..86e4795ba8a 100644
--- a/cmd/extension_board.c
+++ b/cmd/extension_board.c
@@ -7,8 +7,90 @@
#include <alist.h>
#include <exports.h>
#include <command.h>
+#include <env.h>
#include <extension_board.h>
+static int
+cmd_extension_load_overlay_from_env(const struct extension *extension,
+ ulong *filesize)
+{
+ ulong size, overlay_addr;
+ char *overlay_cmd;
+ int ret;
+
+ overlay_cmd = env_get("extension_overlay_cmd");
+ if (!overlay_cmd) {
+ printf("Environment extension_overlay_cmd is missing\n");
+ return -EINVAL;
+ }
+
+ overlay_addr = env_get_hex("extension_overlay_addr", 0);
+ if (!overlay_addr) {
+ printf("Environment extension_overlay_addr is missing\n");
+ return -EINVAL;
+ }
+
+ env_set("extension_overlay_name", extension->overlay);
+ ret = run_command(overlay_cmd, 0);
+ if (ret)
+ return ret;
+
+ size = env_get_hex("filesize", 0);
+ if (!size)
+ return -EINVAL;
+
+ *filesize = size;
+ return 0;
+}
+
+static int cmd_extension_apply(int extension_num)
+{
+ struct alist *extension_list = extension_get_list();
+ const struct extension *extension;
+ ulong size;
+ int ret;
+
+ if (!extension_list)
+ return -ENODEV;
+
+ extension = alist_get(extension_list, extension_num,
+ struct extension);
+ if (!extension) {
+ printf("Wrong extension number\n");
+ return -ENODEV;
+ }
+
+ ret = cmd_extension_load_overlay_from_env(extension, &size);
+ if (ret)
+ return ret;
+
+ return extension_apply(working_fdt, size);
+}
+
+static int cmd_extension_apply_all(void)
+{
+ struct alist *extension_list = extension_get_list();
+ const struct extension *extension;
+ int ret;
+
+ if (!extension_list)
+ return -ENODEV;
+
+ alist_for_each(extension, extension_list) {
+ ulong size;
+
+ ret = cmd_extension_load_overlay_from_env(extension, &size);
+ if (ret)
+ return ret;
+
+ ret = extension_apply(working_fdt, size);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
static int do_extension_list(struct cmd_tbl *cmdtp, int flag,
int argc, char *const argv[])
{
@@ -55,12 +137,18 @@ static int do_extension_apply(struct cmd_tbl *cmdtp, int flag,
if (argc < 2)
return CMD_RET_USAGE;
+ if (!working_fdt) {
+ printf("No FDT memory address configured. Please configure\n"
+ "the FDT address via \"fdt addr <address>\" command.\n");
+ return -EINVAL;
+ }
+
if (strcmp(argv[1], "all") == 0) {
- if (extension_apply_all())
+ if (cmd_extension_apply_all())
return CMD_RET_FAILURE;
} else {
extension_id = simple_strtol(argv[1], NULL, 10);
- if (extension_apply(extension_id))
+ if (cmd_extension_apply(extension_id))
return CMD_RET_FAILURE;
}
diff --git a/include/extension_board.h b/include/extension_board.h
index 251482d0287..61d7c5f668f 100644
--- a/include/extension_board.h
+++ b/include/extension_board.h
@@ -44,17 +44,11 @@ int extension_scan(void);
/**
* extension_apply - Apply extension board overlay to the devicetree
- * @extension_num: Extension number to be applied
+ * @working_fdt: Pointer to working flattened device tree
+ * @size: Size of the devicetree overlay
* Return: Zero on success, negative on failure.
*/
-int extension_apply(int extension_num);
-
-/**
- * extension_apply_all - Apply all extension board overlays to the
- * devicetree
- * Return: Zero on success, negative on failure.
- */
-int extension_apply_all(void);
+int extension_apply(struct fdt_header *working_fdt, ulong size);
/**
* extension - Description fields of an extension board
--
2.43.0
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH v3 18/20] boot: pxe_utils: Add extension board devicetree overlay support
2025-10-13 13:32 [PATCH v3 00/20] Convert extension support to UCLASS and adds its support to boot flows Kory Maincent (TI.com)
` (16 preceding siblings ...)
2025-10-13 13:32 ` [PATCH v3 17/20] boot: extension: Move overlay apply custom logic to command level Kory Maincent (TI.com)
@ 2025-10-13 13:32 ` Kory Maincent (TI.com)
2025-10-13 13:32 ` [PATCH v3 19/20] boot: bootmeth_efi: Refactor distro_efi_try_bootflow_files return logic Kory Maincent (TI.com)
` (2 subsequent siblings)
20 siblings, 0 replies; 40+ messages in thread
From: Kory Maincent (TI.com) @ 2025-10-13 13:32 UTC (permalink / raw)
To: Tom Rini, Simon Glass, Jagan Teki, Andre Przywara, Hans de Goede,
Mario Six, Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team,
Ying-Chun Liu (PaulLiu)
Cc: Roger Quadros, Bajjuri Praneeth, Thomas Petazzoni, u-boot,
Kory Maincent (TI.com)
Add support for scanning and applying extension board devicetree
overlays during PXE boot. After loading the main board devicetree,
the system now scans for available extension boards and applies their
overlays automatically.
This enables dynamic hardware configuration for systems with extension
boards during boot scenarios which are using pxe_utils.
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
Changes in v3:
- Added error log if the overlay does not load or apply.
---
boot/pxe_utils.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 92 insertions(+)
diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c
index eb4d7723481..038416203fc 100644
--- a/boot/pxe_utils.c
+++ b/boot/pxe_utils.c
@@ -10,6 +10,7 @@
#include <command.h>
#include <dm.h>
#include <env.h>
+#include <extension_board.h>
#include <image.h>
#include <log.h>
#include <malloc.h>
@@ -432,6 +433,95 @@ skip_overlay:
}
#endif
+/*
+ * label_boot_extension - scan extension boards and load overlay associated
+ */
+
+static void label_boot_extension(struct pxe_context *ctx,
+ struct pxe_label *label)
+{
+#if CONFIG_IS_ENABLED(SUPPORT_EXTENSION_SCAN)
+ const struct extension *extension;
+ struct fdt_header *working_fdt;
+ struct alist *extension_list;
+ int ret, dir_len, len;
+ char *overlay_dir;
+ const char *slash;
+ ulong fdt_addr;
+
+ ret = extension_scan();
+ if (ret < 0)
+ return;
+
+ extension_list = extension_get_list();
+ if (!extension_list)
+ return;
+
+ /* Get the main fdt and map it */
+ fdt_addr = env_get_hex("fdt_addr_r", 0);
+ working_fdt = map_sysmem(fdt_addr, 0);
+ if (fdt_check_header(working_fdt))
+ return;
+
+ /* Use fdtdir for now as the overlay devicetree directory */
+ if (label->fdtdir) {
+ len = strlen(label->fdtdir);
+ if (!len)
+ slash = "./";
+ else if (label->fdtdir[len - 1] != '/')
+ slash = "/";
+ else
+ slash = "";
+
+ dir_len = strlen(label->fdtdir) + strlen(slash) + 1;
+ overlay_dir = calloc(1, len);
+ if (!overlay_dir)
+ return;
+
+ snprintf(overlay_dir, dir_len, "%s%s", label->fdtdir,
+ slash);
+ } else {
+ dir_len = 2;
+ snprintf(overlay_dir, dir_len, "/");
+ }
+
+ alist_for_each(extension, extension_list) {
+ char *overlay_file;
+ ulong size;
+
+ len = dir_len + strlen(extension->overlay);
+ overlay_file = calloc(1, len);
+ if (!overlay_file)
+ goto cleanup;
+
+ snprintf(overlay_file, len, "%s%s", overlay_dir,
+ extension->overlay);
+
+ /* Load extension overlay file */
+ ret = get_relfile_envaddr(ctx, overlay_file,
+ "extension_overlay_addr",
+ (enum bootflow_img_t)IH_TYPE_FLATDT,
+ &size);
+ if (ret < 0) {
+ printf("Failed loading overlay %s\n", overlay_file);
+ free(overlay_file);
+ continue;
+ }
+
+ ret = extension_apply(working_fdt, size);
+ if (ret) {
+ printf("Failed applying overlay %s\n", overlay_file);
+ free(overlay_file);
+ continue;
+ }
+ free(overlay_file);
+ }
+
+cleanup:
+ free(overlay_dir);
+#endif
+}
+
/**
* label_boot() - Boot according to the contents of a pxe_label
*
@@ -685,6 +775,8 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label)
if (label->fdtoverlays)
label_boot_fdtoverlay(ctx, label);
#endif
+ label_boot_extension(ctx, label);
+
} else {
bootm_argv[3] = NULL;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH v3 19/20] boot: bootmeth_efi: Refactor distro_efi_try_bootflow_files return logic
2025-10-13 13:32 [PATCH v3 00/20] Convert extension support to UCLASS and adds its support to boot flows Kory Maincent (TI.com)
` (17 preceding siblings ...)
2025-10-13 13:32 ` [PATCH v3 18/20] boot: pxe_utils: Add extension board devicetree overlay support Kory Maincent (TI.com)
@ 2025-10-13 13:32 ` Kory Maincent (TI.com)
2025-10-13 13:32 ` [PATCH v3 20/20] boot: bootmeth_efi: Add extension board devicetree overlay support Kory Maincent (TI.com)
2025-10-19 13:05 ` [PATCH v3 00/20] Convert extension support to UCLASS and adds its support to boot flows Simon Glass
20 siblings, 0 replies; 40+ messages in thread
From: Kory Maincent (TI.com) @ 2025-10-13 13:32 UTC (permalink / raw)
To: Tom Rini, Simon Glass, Jagan Teki, Andre Przywara, Hans de Goede,
Mario Six, Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team,
Ying-Chun Liu (PaulLiu)
Cc: Roger Quadros, Bajjuri Praneeth, Thomas Petazzoni, u-boot,
Kory Maincent (TI.com)
Simplify the return path in distro_efi_try_bootflow_files() to prepare
for adding extension board support in a subsequent commit.
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
boot/bootmeth_efi.c | 31 ++++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)
diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c
index 0af23df3a4a..64de5c08b7b 100644
--- a/boot/bootmeth_efi.c
+++ b/boot/bootmeth_efi.c
@@ -148,25 +148,26 @@ static int distro_efi_try_bootflow_files(struct udevice *dev,
return log_msg_ret("fil", -ENOMEM);
}
- if (!ret) {
- bflow->fdt_size = size;
- bflow->fdt_addr = fdt_addr;
-
- /*
- * TODO: Apply extension overlay
- *
- * Here we need to load and apply the extension overlay. This is
- * not implemented. See do_extension_apply(). The extension
- * stuff needs an implementation in boot/extension.c so it is
- * separate from the command code. Really the extension stuff
- * should use the device tree and a uclass / driver interface
- * rather than implementing its own list
- */
- } else {
+ if (ret) {
log_debug("No device tree available\n");
bflow->flags |= BOOTFLOWF_USE_BUILTIN_FDT;
+ return 0;
}
+ bflow->fdt_size = size;
+ bflow->fdt_addr = fdt_addr;
+
+ /*
+ * TODO: Apply extension overlay
+ *
+ * Here we need to load and apply the extension overlay. This is
+ * not implemented. See do_extension_apply(). The extension
+ * stuff needs an implementation in boot/extension.c so it is
+ * separate from the command code. Really the extension stuff
+ * should use the device tree and a uclass / driver interface
+ * rather than implementing its own list
+ */
+
return 0;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 40+ messages in thread* [PATCH v3 20/20] boot: bootmeth_efi: Add extension board devicetree overlay support
2025-10-13 13:32 [PATCH v3 00/20] Convert extension support to UCLASS and adds its support to boot flows Kory Maincent (TI.com)
` (18 preceding siblings ...)
2025-10-13 13:32 ` [PATCH v3 19/20] boot: bootmeth_efi: Refactor distro_efi_try_bootflow_files return logic Kory Maincent (TI.com)
@ 2025-10-13 13:32 ` Kory Maincent (TI.com)
2025-10-19 13:05 ` [PATCH v3 00/20] Convert extension support to UCLASS and adds its support to boot flows Simon Glass
20 siblings, 0 replies; 40+ messages in thread
From: Kory Maincent (TI.com) @ 2025-10-13 13:32 UTC (permalink / raw)
To: Tom Rini, Simon Glass, Jagan Teki, Andre Przywara, Hans de Goede,
Mario Six, Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team,
Ying-Chun Liu (PaulLiu)
Cc: Roger Quadros, Bajjuri Praneeth, Thomas Petazzoni, u-boot,
Kory Maincent (TI.com)
Add support for scanning and applying extension board devicetree
overlays during EFI boot. After loading the main board devicetree,
the system now scans for available extension boards and applies their
overlays automatically.
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
Not yet tested, need to find a board with extension boards and supporting
EFI boot. Roger Quadros could you test it on your side?
Changes in v3:
- Added error log if the overlay does not load or apply.
---
boot/bootmeth_efi.c | 68 ++++++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 57 insertions(+), 11 deletions(-)
diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c
index 64de5c08b7b..f592fec07f6 100644
--- a/boot/bootmeth_efi.c
+++ b/boot/bootmeth_efi.c
@@ -16,6 +16,7 @@
#include <efi.h>
#include <efi_loader.h>
#include <env.h>
+#include <extension_board.h>
#include <fs.h>
#include <malloc.h>
#include <mapmem.h>
@@ -99,8 +100,11 @@ static int distro_efi_check(struct udevice *dev, struct bootflow_iter *iter)
static int distro_efi_try_bootflow_files(struct udevice *dev,
struct bootflow *bflow)
{
+ ulong fdt_addr, size, overlay_addr;
+ const struct extension *extension;
+ struct fdt_header *working_fdt;
struct blk_desc *desc = NULL;
- ulong fdt_addr, size;
+ struct alist *extension_list;
char fname[256];
int ret, seq;
@@ -157,16 +161,58 @@ static int distro_efi_try_bootflow_files(struct udevice *dev,
bflow->fdt_size = size;
bflow->fdt_addr = fdt_addr;
- /*
- * TODO: Apply extension overlay
- *
- * Here we need to load and apply the extension overlay. This is
- * not implemented. See do_extension_apply(). The extension
- * stuff needs an implementation in boot/extension.c so it is
- * separate from the command code. Really the extension stuff
- * should use the device tree and a uclass / driver interface
- * rather than implementing its own list
- */
+ if (!CONFIG_IS_ENABLED(SUPPORT_EXTENSION_SCAN))
+ return 0;
+
+ ret = extension_scan();
+ if (ret < 0)
+ return 0;
+
+ extension_list = extension_get_list();
+ if (!extension_list)
+ return 0;
+
+ working_fdt = map_sysmem(fdt_addr, 0);
+ if (fdt_check_header(working_fdt))
+ return 0;
+
+ overlay_addr = env_get_hex("extension_overlay_addr", 0);
+ if (!overlay_addr) {
+ log_debug("Environment extension_overlay_addr is missing\n");
+ return 0;
+ }
+
+ alist_for_each(extension, extension_list) {
+ char *overlay_file;
+ int len;
+
+ len = sizeof(EFI_DIRNAME) + strlen(extension->overlay);
+ overlay_file = calloc(1, len);
+ if (!overlay_file)
+ return -ENOMEM;
+
+ snprintf(overlay_file, len, "%s%s", EFI_DIRNAME,
+ extension->overlay);
+
+ ret = bootmeth_common_read_file(dev, bflow, overlay_file,
+ overlay_addr,
+ (enum bootflow_img_t)IH_TYPE_FLATDT,
+ &size);
+ if (ret) {
+ log_debug("Failed loading overlay %s\n", overlay_file);
+ free(overlay_file);
+ continue;
+ }
+
+ ret = extension_apply(working_fdt, size);
+ if (ret) {
+ log_debug("Failed applying overlay %s\n", overlay_file);
+ free(overlay_file);
+ continue;
+ }
+ bflow->fdt_size += size;
+ free(overlay_file);
+ }
return 0;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 40+ messages in thread* Re: [PATCH v3 00/20] Convert extension support to UCLASS and adds its support to boot flows
2025-10-13 13:32 [PATCH v3 00/20] Convert extension support to UCLASS and adds its support to boot flows Kory Maincent (TI.com)
` (19 preceding siblings ...)
2025-10-13 13:32 ` [PATCH v3 20/20] boot: bootmeth_efi: Add extension board devicetree overlay support Kory Maincent (TI.com)
@ 2025-10-19 13:05 ` Simon Glass
2025-10-19 16:48 ` Tom Rini
20 siblings, 1 reply; 40+ messages in thread
From: Simon Glass @ 2025-10-19 13:05 UTC (permalink / raw)
To: Kory Maincent (TI.com)
Cc: Tom Rini, Jagan Teki, Andre Przywara, Hans de Goede, Mario Six,
Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team,
Ying-Chun Liu (PaulLiu), Roger Quadros, Bajjuri Praneeth,
Thomas Petazzoni, u-boot, Mattijs Korpershoek
Hi Kory,
On Mon, 13 Oct 2025 at 14:32, Kory Maincent (TI.com)
<kory.maincent@bootlin.com> wrote:
>
> This series converts the extension board framework to use UCLASS as
> requested by Simon Glass, then adds extension support to pxe_utils
> and bootmeth_efi (not tested) to enable extension boards devicetree load
> in the standard boot process.
>
> I can't test the imx8 extension scan enabled by the
> imx8mm-cl-iot-gate_defconfig as I don't have this board.
> I also can't test the efi bootmeth change as I don't have such board.
You can test this with sandbox, using one of the bootmeth tests,
perhaps. Let me know if you need help with this.
>
> Changes in v3:
> - Reorder the patches inside the series as several config were broken
> in the middle of the series.
> - Use U_BOOT_DRVINFO macro instead of manually bind the drivers.
> - Use uclass_first_device_err instead of extension_get_dev function.
> - Made few fixes in documentation and Kconfig dependency.
> - Made few changes of error value returned.
> - Add a patch to document the extension structure.
> - Add a patch to fix CAPE_EEPROM_BUS_NUM Kconfig dependency
>
> Changes in v2:
> - Fixes few build errors.
> - Add patches to move the extension support and board scan out of XPL
> images build.
>
> Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
> ---
> Kory Maincent (TI.com) (20):
> MAINTAINERS: Add maintainer for extension board support
> board: ti: Exclude cape detection from XPL builds
> board: ti: Fix CAPE_EEPROM_BUS_NUM Kconfig dependency
> board: sunxi: Exclude DIP detection from XPL builds
> board: compulab: Exclude compulab extension board detection from XPL builds
> include: extension_board: Document the extension structure
> boot: Move extension board support from cmd/ to boot/
> boot: Add UCLASS support for extension boards
> board: ti: Refactor cape detection code for readability
> board: ti: Convert cape detection to use UCLASS framework
> board: sunxi: Refactor CHIP board extension code
> board: sunxi: Convert extension support to UCLASS framework
> board: sandbox: Improve extension board scan implementation
> board: sandbox: Convert extension support to UCLASS framework
> board: compulab: Convert imx8mm-cl-iot-gate to UCLASS extension framework
> boot: Remove legacy extension board support
> boot: extension: Move overlay apply custom logic to command level
> boot: pxe_utils: Add extension board devicetree overlay support
> boot: bootmeth_efi: Refactor distro_efi_try_bootflow_files return logic
> boot: bootmeth_efi: Add extension board devicetree overlay support
>
> MAINTAINERS | 9 +
> .../imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c | 70 ++++----
> board/sandbox/sandbox.c | 26 ++-
> board/sunxi/Makefile | 2 +-
> board/sunxi/chip.c | 36 ++--
> board/ti/common/Kconfig | 2 +-
> board/ti/common/Makefile | 2 +-
> board/ti/common/cape_detect.c | 56 ++++---
> boot/Kconfig | 4 +
> boot/Makefile | 1 +
> boot/bootmeth_efi.c | 79 +++++++--
> boot/extension-uclass.c | 93 +++++++++++
> boot/pxe_utils.c | 92 +++++++++++
> cmd/Kconfig | 3 -
> cmd/extension_board.c | 183 ++++++++++-----------
> doc/usage/cmd/extension.rst | 29 ++--
> include/dm/uclass-id.h | 1 +
> include/extension_board.h | 85 ++++++++--
> 18 files changed, 541 insertions(+), 232 deletions(-)
> ---
> base-commit: 8e7f8c1248e8adfb525a2a4ea56ebf7e54ff5d7a
> change-id: 20250916-feature_sysboot_extension_board-958dd0072565
>
> Best regards,
> --
> Köry Maincent, Bootlin
> Embedded Linux and kernel engineering
> https://bootlin.com
>
Regards,
Simon
^ permalink raw reply [flat|nested] 40+ messages in thread* Re: [PATCH v3 00/20] Convert extension support to UCLASS and adds its support to boot flows
2025-10-19 13:05 ` [PATCH v3 00/20] Convert extension support to UCLASS and adds its support to boot flows Simon Glass
@ 2025-10-19 16:48 ` Tom Rini
2025-10-20 9:50 ` Kory Maincent
0 siblings, 1 reply; 40+ messages in thread
From: Tom Rini @ 2025-10-19 16:48 UTC (permalink / raw)
To: Simon Glass
Cc: Kory Maincent (TI.com), Jagan Teki, Andre Przywara, Hans de Goede,
Mario Six, Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team,
Ying-Chun Liu (PaulLiu), Roger Quadros, Bajjuri Praneeth,
Thomas Petazzoni, u-boot, Mattijs Korpershoek
[-- Attachment #1: Type: text/plain, Size: 907 bytes --]
On Sun, Oct 19, 2025 at 02:05:51PM +0100, Simon Glass wrote:
> Hi Kory,
>
> On Mon, 13 Oct 2025 at 14:32, Kory Maincent (TI.com)
> <kory.maincent@bootlin.com> wrote:
> >
> > This series converts the extension board framework to use UCLASS as
> > requested by Simon Glass, then adds extension support to pxe_utils
> > and bootmeth_efi (not tested) to enable extension boards devicetree load
> > in the standard boot process.
> >
> > I can't test the imx8 extension scan enabled by the
> > imx8mm-cl-iot-gate_defconfig as I don't have this board.
> > I also can't test the efi bootmeth change as I don't have such board.
>
> You can test this with sandbox, using one of the bootmeth tests,
> perhaps. Let me know if you need help with this.
But the question is, does the real hardware platform work before/after
this, not does the sandbox test still work before/after this.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v3 00/20] Convert extension support to UCLASS and adds its support to boot flows
2025-10-19 16:48 ` Tom Rini
@ 2025-10-20 9:50 ` Kory Maincent
2025-10-20 14:15 ` Tom Rini
0 siblings, 1 reply; 40+ messages in thread
From: Kory Maincent @ 2025-10-20 9:50 UTC (permalink / raw)
To: Tom Rini
Cc: Simon Glass, Jagan Teki, Andre Przywara, Hans de Goede, Mario Six,
Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team,
Ying-Chun Liu (PaulLiu), Roger Quadros, Bajjuri Praneeth,
Thomas Petazzoni, u-boot, Mattijs Korpershoek
On Sun, 19 Oct 2025 10:48:37 -0600
Tom Rini <trini@konsulko.com> wrote:
> On Sun, Oct 19, 2025 at 02:05:51PM +0100, Simon Glass wrote:
> > Hi Kory,
> >
> > On Mon, 13 Oct 2025 at 14:32, Kory Maincent (TI.com)
> > <kory.maincent@bootlin.com> wrote:
> > >
> > > This series converts the extension board framework to use UCLASS as
> > > requested by Simon Glass, then adds extension support to pxe_utils
> > > and bootmeth_efi (not tested) to enable extension boards devicetree load
> > > in the standard boot process.
> > >
> > > I can't test the imx8 extension scan enabled by the
> > > imx8mm-cl-iot-gate_defconfig as I don't have this board.
> > > I also can't test the efi bootmeth change as I don't have such board.
> >
> > You can test this with sandbox, using one of the bootmeth tests,
> > perhaps. Let me know if you need help with this.
>
> But the question is, does the real hardware platform work before/after
> this, not does the sandbox test still work before/after this.
It seems the bootlflow scan is not working on the sandbox on next branch.
Is this issue known?
=> bootflow scan -l
Scanning for bootflows in all bootdevs
Seq Method State Uclass Part Name Filename
--- ----------- ------ -------- ---- ------------------------
---------------- Scanning global bootmeth 'efi_mgr':
efi_var_to_file() Cannot persist EFI variables without system partition
efi_tcg2_register() Missing TPMv2 device for EFI_TCG_PROTOCOL
efi_rng_register() Missing RNG device for EFI_RNG_PROTOCOL
Hunting with: simple_bus
Found 2 extension board(s).
Hunting with: mmc
Hunting with: nvme
Hunting with: qfw
Hunting with: scsi
scanning bus for devices...
Hunting with: spi_flash
Hunting with: virtio
Scanning bootdev 'qfw_sandbox.bootdev':
[1] 487232 segmentation fault (core dumped) ./u-boot
Regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 40+ messages in thread* Re: [PATCH v3 00/20] Convert extension support to UCLASS and adds its support to boot flows
2025-10-20 9:50 ` Kory Maincent
@ 2025-10-20 14:15 ` Tom Rini
2025-10-20 14:37 ` Tom Rini
0 siblings, 1 reply; 40+ messages in thread
From: Tom Rini @ 2025-10-20 14:15 UTC (permalink / raw)
To: Kory Maincent
Cc: Simon Glass, Jagan Teki, Andre Przywara, Hans de Goede, Mario Six,
Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team,
Ying-Chun Liu (PaulLiu), Roger Quadros, Bajjuri Praneeth,
Thomas Petazzoni, u-boot, Mattijs Korpershoek
[-- Attachment #1: Type: text/plain, Size: 1371 bytes --]
On Mon, Oct 20, 2025 at 11:50:09AM +0200, Kory Maincent wrote:
> On Sun, 19 Oct 2025 10:48:37 -0600
> Tom Rini <trini@konsulko.com> wrote:
>
> > On Sun, Oct 19, 2025 at 02:05:51PM +0100, Simon Glass wrote:
> > > Hi Kory,
> > >
> > > On Mon, 13 Oct 2025 at 14:32, Kory Maincent (TI.com)
> > > <kory.maincent@bootlin.com> wrote:
> > > >
> > > > This series converts the extension board framework to use UCLASS as
> > > > requested by Simon Glass, then adds extension support to pxe_utils
> > > > and bootmeth_efi (not tested) to enable extension boards devicetree load
> > > > in the standard boot process.
> > > >
> > > > I can't test the imx8 extension scan enabled by the
> > > > imx8mm-cl-iot-gate_defconfig as I don't have this board.
> > > > I also can't test the efi bootmeth change as I don't have such board.
> > >
> > > You can test this with sandbox, using one of the bootmeth tests,
> > > perhaps. Let me know if you need help with this.
> >
> > But the question is, does the real hardware platform work before/after
> > this, not does the sandbox test still work before/after this.
>
> It seems the bootlflow scan is not working on the sandbox on next branch.
> Is this issue known?
Is it fine on master? The next branch will be out of date until it
re-opens with -rc2 being released (2 weeks from today).
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v3 00/20] Convert extension support to UCLASS and adds its support to boot flows
2025-10-20 14:15 ` Tom Rini
@ 2025-10-20 14:37 ` Tom Rini
2025-10-20 15:23 ` Kory Maincent
0 siblings, 1 reply; 40+ messages in thread
From: Tom Rini @ 2025-10-20 14:37 UTC (permalink / raw)
To: Kory Maincent
Cc: Simon Glass, Jagan Teki, Andre Przywara, Hans de Goede, Mario Six,
Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team,
Ying-Chun Liu (PaulLiu), Roger Quadros, Bajjuri Praneeth,
Thomas Petazzoni, u-boot, Mattijs Korpershoek
[-- Attachment #1: Type: text/plain, Size: 1552 bytes --]
On Mon, Oct 20, 2025 at 08:15:48AM -0600, Tom Rini wrote:
> On Mon, Oct 20, 2025 at 11:50:09AM +0200, Kory Maincent wrote:
> > On Sun, 19 Oct 2025 10:48:37 -0600
> > Tom Rini <trini@konsulko.com> wrote:
> >
> > > On Sun, Oct 19, 2025 at 02:05:51PM +0100, Simon Glass wrote:
> > > > Hi Kory,
> > > >
> > > > On Mon, 13 Oct 2025 at 14:32, Kory Maincent (TI.com)
> > > > <kory.maincent@bootlin.com> wrote:
> > > > >
> > > > > This series converts the extension board framework to use UCLASS as
> > > > > requested by Simon Glass, then adds extension support to pxe_utils
> > > > > and bootmeth_efi (not tested) to enable extension boards devicetree load
> > > > > in the standard boot process.
> > > > >
> > > > > I can't test the imx8 extension scan enabled by the
> > > > > imx8mm-cl-iot-gate_defconfig as I don't have this board.
> > > > > I also can't test the efi bootmeth change as I don't have such board.
> > > >
> > > > You can test this with sandbox, using one of the bootmeth tests,
> > > > perhaps. Let me know if you need help with this.
> > >
> > > But the question is, does the real hardware platform work before/after
> > > this, not does the sandbox test still work before/after this.
> >
> > It seems the bootlflow scan is not working on the sandbox on next branch.
> > Is this issue known?
>
> Is it fine on master? The next branch will be out of date until it
> re-opens with -rc2 being released (2 weeks from today).
... out of sync local calendar, 3 weeks from today, not 2.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v3 00/20] Convert extension support to UCLASS and adds its support to boot flows
2025-10-20 14:37 ` Tom Rini
@ 2025-10-20 15:23 ` Kory Maincent
2025-10-20 16:05 ` Tom Rini
0 siblings, 1 reply; 40+ messages in thread
From: Kory Maincent @ 2025-10-20 15:23 UTC (permalink / raw)
To: Tom Rini
Cc: Simon Glass, Jagan Teki, Andre Przywara, Hans de Goede, Mario Six,
Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team,
Ying-Chun Liu (PaulLiu), Roger Quadros, Bajjuri Praneeth,
Thomas Petazzoni, u-boot, Mattijs Korpershoek
On Mon, 20 Oct 2025 08:37:29 -0600
Tom Rini <trini@konsulko.com> wrote:
> On Mon, Oct 20, 2025 at 08:15:48AM -0600, Tom Rini wrote:
> > On Mon, Oct 20, 2025 at 11:50:09AM +0200, Kory Maincent wrote:
> > > On Sun, 19 Oct 2025 10:48:37 -0600
> > > Tom Rini <trini@konsulko.com> wrote:
> > >
> > > > On Sun, Oct 19, 2025 at 02:05:51PM +0100, Simon Glass wrote:
> > > > > Hi Kory,
> > > > >
> > > > > On Mon, 13 Oct 2025 at 14:32, Kory Maincent (TI.com)
> > > > > <kory.maincent@bootlin.com> wrote:
> > > > > >
> > > > > > This series converts the extension board framework to use UCLASS as
> > > > > > requested by Simon Glass, then adds extension support to pxe_utils
> > > > > > and bootmeth_efi (not tested) to enable extension boards devicetree
> > > > > > load in the standard boot process.
> > > > > >
> > > > > > I can't test the imx8 extension scan enabled by the
> > > > > > imx8mm-cl-iot-gate_defconfig as I don't have this board.
> > > > > > I also can't test the efi bootmeth change as I don't have such
> > > > > > board.
> > > > >
> > > > > You can test this with sandbox, using one of the bootmeth tests,
> > > > > perhaps. Let me know if you need help with this.
> > > >
> > > > But the question is, does the real hardware platform work before/after
> > > > this, not does the sandbox test still work before/after this.
> > >
> > > It seems the bootlflow scan is not working on the sandbox on next branch.
> > > Is this issue known?
> >
> > Is it fine on master? The next branch will be out of date until it
> > re-opens with -rc2 being released (2 weeks from today).
>
> ... out of sync local calendar, 3 weeks from today, not 2.
bootstd test suit is not working on master with the sandbox_defconfig:
https://termbin.com/un0p
Noticeable things are;
test/boot/bootdev.c:160, bootdev_test_any(): 0 == bootdev_find_by_any(seq, &dev, &mflags): Expected 0x0 (0), got 0xffffffed (-19)
Test: bootdev_test_any: bootdev.c (flat tree)
test/boot/bootdev.c:160, bootdev_test_any(): 0 == bootdev_find_by_any(seq, &dev, &mflags): Expected 0x0 (0), got 0xffffffed (-19)
Test 'bootdev_test_any' failed 2 times
And a nice segfault:
Test: bootflow_set_arg: bootflow.c
Test: bootflow_system: bootflow.c
[3] 569337 segmentation fault (core dumped) ./u-boot
Maybe things are missing to run sandbox_defconfig on my computer?
With the sandbox64_defconfig there is not core dump anymore but there is still
the failed line:
Test 'bootdev_test_bootable' failed 2 times
And the uboot is reboot infinitely during the bootflow test:
./u-boot -T -c "ut bootstd"
https://termbin.com/alu5
Regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v3 00/20] Convert extension support to UCLASS and adds its support to boot flows
2025-10-20 15:23 ` Kory Maincent
@ 2025-10-20 16:05 ` Tom Rini
2025-10-20 17:08 ` Kory Maincent
0 siblings, 1 reply; 40+ messages in thread
From: Tom Rini @ 2025-10-20 16:05 UTC (permalink / raw)
To: Kory Maincent
Cc: Simon Glass, Jagan Teki, Andre Przywara, Hans de Goede, Mario Six,
Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team,
Ying-Chun Liu (PaulLiu), Roger Quadros, Bajjuri Praneeth,
Thomas Petazzoni, u-boot, Mattijs Korpershoek
[-- Attachment #1: Type: text/plain, Size: 3118 bytes --]
On Mon, Oct 20, 2025 at 05:23:45PM +0200, Kory Maincent wrote:
> On Mon, 20 Oct 2025 08:37:29 -0600
> Tom Rini <trini@konsulko.com> wrote:
>
> > On Mon, Oct 20, 2025 at 08:15:48AM -0600, Tom Rini wrote:
> > > On Mon, Oct 20, 2025 at 11:50:09AM +0200, Kory Maincent wrote:
> > > > On Sun, 19 Oct 2025 10:48:37 -0600
> > > > Tom Rini <trini@konsulko.com> wrote:
> > > >
> > > > > On Sun, Oct 19, 2025 at 02:05:51PM +0100, Simon Glass wrote:
> > > > > > Hi Kory,
> > > > > >
> > > > > > On Mon, 13 Oct 2025 at 14:32, Kory Maincent (TI.com)
> > > > > > <kory.maincent@bootlin.com> wrote:
> > > > > > >
> > > > > > > This series converts the extension board framework to use UCLASS as
> > > > > > > requested by Simon Glass, then adds extension support to pxe_utils
> > > > > > > and bootmeth_efi (not tested) to enable extension boards devicetree
> > > > > > > load in the standard boot process.
> > > > > > >
> > > > > > > I can't test the imx8 extension scan enabled by the
> > > > > > > imx8mm-cl-iot-gate_defconfig as I don't have this board.
> > > > > > > I also can't test the efi bootmeth change as I don't have such
> > > > > > > board.
> > > > > >
> > > > > > You can test this with sandbox, using one of the bootmeth tests,
> > > > > > perhaps. Let me know if you need help with this.
> > > > >
> > > > > But the question is, does the real hardware platform work before/after
> > > > > this, not does the sandbox test still work before/after this.
> > > >
> > > > It seems the bootlflow scan is not working on the sandbox on next branch.
> > > > Is this issue known?
> > >
> > > Is it fine on master? The next branch will be out of date until it
> > > re-opens with -rc2 being released (2 weeks from today).
> >
> > ... out of sync local calendar, 3 weeks from today, not 2.
>
> bootstd test suit is not working on master with the sandbox_defconfig:
> https://termbin.com/un0p
>
> Noticeable things are;
> test/boot/bootdev.c:160, bootdev_test_any(): 0 == bootdev_find_by_any(seq, &dev, &mflags): Expected 0x0 (0), got 0xffffffed (-19)
> Test: bootdev_test_any: bootdev.c (flat tree)
> test/boot/bootdev.c:160, bootdev_test_any(): 0 == bootdev_find_by_any(seq, &dev, &mflags): Expected 0x0 (0), got 0xffffffed (-19)
> Test 'bootdev_test_any' failed 2 times
>
> And a nice segfault:
> Test: bootflow_set_arg: bootflow.c
> Test: bootflow_system: bootflow.c
> [3] 569337 segmentation fault (core dumped) ./u-boot
>
> Maybe things are missing to run sandbox_defconfig on my computer?
> With the sandbox64_defconfig there is not core dump anymore but there is still
> the failed line:
> Test 'bootdev_test_bootable' failed 2 times
>
> And the uboot is reboot infinitely during the bootflow test:
> ./u-boot -T -c "ut bootstd"
> https://termbin.com/alu5
I see the same thing you do when running them outside of pytest, but
they're also fine within pytest.
https://docs.u-boot.org/en/latest/develop/pytest/usage.html should help
get you started, and you can just run all of the ut tests under that.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v3 00/20] Convert extension support to UCLASS and adds its support to boot flows
2025-10-20 16:05 ` Tom Rini
@ 2025-10-20 17:08 ` Kory Maincent
2025-10-20 17:17 ` Tom Rini
0 siblings, 1 reply; 40+ messages in thread
From: Kory Maincent @ 2025-10-20 17:08 UTC (permalink / raw)
To: Tom Rini
Cc: Simon Glass, Jagan Teki, Andre Przywara, Hans de Goede, Mario Six,
Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team,
Ying-Chun Liu (PaulLiu), Roger Quadros, Bajjuri Praneeth,
Thomas Petazzoni, u-boot, Mattijs Korpershoek
On Mon, 20 Oct 2025 10:05:27 -0600
Tom Rini <trini@konsulko.com> wrote:
> On Mon, Oct 20, 2025 at 05:23:45PM +0200, Kory Maincent wrote:
> > On Mon, 20 Oct 2025 08:37:29 -0600
> > Tom Rini <trini@konsulko.com> wrote:
> >
> > > On Mon, Oct 20, 2025 at 08:15:48AM -0600, Tom Rini wrote:
> > > > On Mon, Oct 20, 2025 at 11:50:09AM +0200, Kory Maincent wrote:
> > > > > On Sun, 19 Oct 2025 10:48:37 -0600
> > > > > Tom Rini <trini@konsulko.com> wrote:
> > > > >
> > > > > > On Sun, Oct 19, 2025 at 02:05:51PM +0100, Simon Glass wrote:
> > > > > > > Hi Kory,
> > > > > > >
> > > > > > > On Mon, 13 Oct 2025 at 14:32, Kory Maincent (TI.com)
> > > > > > > <kory.maincent@bootlin.com> wrote:
> > > > > > > >
> > > > > > > > This series converts the extension board framework to use
> > > > > > > > UCLASS as requested by Simon Glass, then adds extension support
> > > > > > > > to pxe_utils and bootmeth_efi (not tested) to enable extension
> > > > > > > > boards devicetree load in the standard boot process.
> > > > > > > >
> > > > > > > > I can't test the imx8 extension scan enabled by the
> > > > > > > > imx8mm-cl-iot-gate_defconfig as I don't have this board.
> > > > > > > > I also can't test the efi bootmeth change as I don't have such
> > > > > > > > board.
> > > > > > >
> > > > > > > You can test this with sandbox, using one of the bootmeth tests,
> > > > > > > perhaps. Let me know if you need help with this.
> > > > > >
> > > > > > But the question is, does the real hardware platform work
> > > > > > before/after this, not does the sandbox test still work
> > > > > > before/after this.
> > > > >
> > > > > It seems the bootlflow scan is not working on the sandbox on next
> > > > > branch. Is this issue known?
> > > >
> > > > Is it fine on master? The next branch will be out of date until it
> > > > re-opens with -rc2 being released (2 weeks from today).
> > >
> > > ... out of sync local calendar, 3 weeks from today, not 2.
> >
> > bootstd test suit is not working on master with the sandbox_defconfig:
> > https://termbin.com/un0p
> >
> > Noticeable things are;
> > test/boot/bootdev.c:160, bootdev_test_any(): 0 == bootdev_find_by_any(seq,
> > &dev, &mflags): Expected 0x0 (0), got 0xffffffed (-19) Test:
> > bootdev_test_any: bootdev.c (flat tree) test/boot/bootdev.c:160,
> > bootdev_test_any(): 0 == bootdev_find_by_any(seq, &dev, &mflags): Expected
> > 0x0 (0), got 0xffffffed (-19) Test 'bootdev_test_any' failed 2 times
> >
> > And a nice segfault:
> > Test: bootflow_set_arg: bootflow.c
> > Test: bootflow_system: bootflow.c
> > [3] 569337 segmentation fault (core dumped) ./u-boot
> >
> > Maybe things are missing to run sandbox_defconfig on my computer?
> > With the sandbox64_defconfig there is not core dump anymore but there is
> > still the failed line:
> > Test 'bootdev_test_bootable' failed 2 times
> >
> > And the uboot is reboot infinitely during the bootflow test:
> > ./u-boot -T -c "ut bootstd"
> > https://termbin.com/alu5
>
> I see the same thing you do when running them outside of pytest, but
> they're also fine within pytest.
> https://docs.u-boot.org/en/latest/develop/pytest/usage.html should help
> get you started, and you can just run all of the ut tests under that.
Weird I got errors also within pytest.
See the html test log attached generated by the following command:
./test/py/test.py --bd sandbox -k bootstd
Regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v3 00/20] Convert extension support to UCLASS and adds its support to boot flows
2025-10-20 17:08 ` Kory Maincent
@ 2025-10-20 17:17 ` Tom Rini
2025-10-21 7:40 ` Mattijs Korpershoek
0 siblings, 1 reply; 40+ messages in thread
From: Tom Rini @ 2025-10-20 17:17 UTC (permalink / raw)
To: Kory Maincent
Cc: Simon Glass, Jagan Teki, Andre Przywara, Hans de Goede, Mario Six,
Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team,
Ying-Chun Liu (PaulLiu), Roger Quadros, Bajjuri Praneeth,
Thomas Petazzoni, u-boot, Mattijs Korpershoek
[-- Attachment #1: Type: text/plain, Size: 3934 bytes --]
On Mon, Oct 20, 2025 at 07:08:54PM +0200, Kory Maincent wrote:
> On Mon, 20 Oct 2025 10:05:27 -0600
> Tom Rini <trini@konsulko.com> wrote:
>
> > On Mon, Oct 20, 2025 at 05:23:45PM +0200, Kory Maincent wrote:
> > > On Mon, 20 Oct 2025 08:37:29 -0600
> > > Tom Rini <trini@konsulko.com> wrote:
> > >
> > > > On Mon, Oct 20, 2025 at 08:15:48AM -0600, Tom Rini wrote:
> > > > > On Mon, Oct 20, 2025 at 11:50:09AM +0200, Kory Maincent wrote:
> > > > > > On Sun, 19 Oct 2025 10:48:37 -0600
> > > > > > Tom Rini <trini@konsulko.com> wrote:
> > > > > >
> > > > > > > On Sun, Oct 19, 2025 at 02:05:51PM +0100, Simon Glass wrote:
> > > > > > > > Hi Kory,
> > > > > > > >
> > > > > > > > On Mon, 13 Oct 2025 at 14:32, Kory Maincent (TI.com)
> > > > > > > > <kory.maincent@bootlin.com> wrote:
> > > > > > > > >
> > > > > > > > > This series converts the extension board framework to use
> > > > > > > > > UCLASS as requested by Simon Glass, then adds extension support
> > > > > > > > > to pxe_utils and bootmeth_efi (not tested) to enable extension
> > > > > > > > > boards devicetree load in the standard boot process.
> > > > > > > > >
> > > > > > > > > I can't test the imx8 extension scan enabled by the
> > > > > > > > > imx8mm-cl-iot-gate_defconfig as I don't have this board.
> > > > > > > > > I also can't test the efi bootmeth change as I don't have such
> > > > > > > > > board.
> > > > > > > >
> > > > > > > > You can test this with sandbox, using one of the bootmeth tests,
> > > > > > > > perhaps. Let me know if you need help with this.
> > > > > > >
> > > > > > > But the question is, does the real hardware platform work
> > > > > > > before/after this, not does the sandbox test still work
> > > > > > > before/after this.
> > > > > >
> > > > > > It seems the bootlflow scan is not working on the sandbox on next
> > > > > > branch. Is this issue known?
> > > > >
> > > > > Is it fine on master? The next branch will be out of date until it
> > > > > re-opens with -rc2 being released (2 weeks from today).
> > > >
> > > > ... out of sync local calendar, 3 weeks from today, not 2.
> > >
> > > bootstd test suit is not working on master with the sandbox_defconfig:
> > > https://termbin.com/un0p
> > >
> > > Noticeable things are;
> > > test/boot/bootdev.c:160, bootdev_test_any(): 0 == bootdev_find_by_any(seq,
> > > &dev, &mflags): Expected 0x0 (0), got 0xffffffed (-19) Test:
> > > bootdev_test_any: bootdev.c (flat tree) test/boot/bootdev.c:160,
> > > bootdev_test_any(): 0 == bootdev_find_by_any(seq, &dev, &mflags): Expected
> > > 0x0 (0), got 0xffffffed (-19) Test 'bootdev_test_any' failed 2 times
> > >
> > > And a nice segfault:
> > > Test: bootflow_set_arg: bootflow.c
> > > Test: bootflow_system: bootflow.c
> > > [3] 569337 segmentation fault (core dumped) ./u-boot
> > >
> > > Maybe things are missing to run sandbox_defconfig on my computer?
> > > With the sandbox64_defconfig there is not core dump anymore but there is
> > > still the failed line:
> > > Test 'bootdev_test_bootable' failed 2 times
> > >
> > > And the uboot is reboot infinitely during the bootflow test:
> > > ./u-boot -T -c "ut bootstd"
> > > https://termbin.com/alu5
> >
> > I see the same thing you do when running them outside of pytest, but
> > they're also fine within pytest.
> > https://docs.u-boot.org/en/latest/develop/pytest/usage.html should help
> > get you started, and you can just run all of the ut tests under that.
>
> Weird I got errors also within pytest.
> See the html test log attached generated by the following command:
> ./test/py/test.py --bd sandbox -k bootstd
Same. There's some implicit dependencies around I believe. Doing "-k ut"
should work, as I tried that (via my wrapper around all this) as well as
just running all the tests (which is longer).
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v3 00/20] Convert extension support to UCLASS and adds its support to boot flows
2025-10-20 17:17 ` Tom Rini
@ 2025-10-21 7:40 ` Mattijs Korpershoek
[not found] ` <20251021110225.2d94a13b@kmaincent-XPS-13-7390>
0 siblings, 1 reply; 40+ messages in thread
From: Mattijs Korpershoek @ 2025-10-21 7:40 UTC (permalink / raw)
To: Tom Rini, Kory Maincent
Cc: Simon Glass, Jagan Teki, Andre Przywara, Hans de Goede, Mario Six,
Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team,
Ying-Chun Liu (PaulLiu), Roger Quadros, Bajjuri Praneeth,
Thomas Petazzoni, u-boot, Mattijs Korpershoek
On Mon, Oct 20, 2025 at 11:17, Tom Rini <trini@konsulko.com> wrote:
> On Mon, Oct 20, 2025 at 07:08:54PM +0200, Kory Maincent wrote:
>> On Mon, 20 Oct 2025 10:05:27 -0600
>> Tom Rini <trini@konsulko.com> wrote:
>>
>> > On Mon, Oct 20, 2025 at 05:23:45PM +0200, Kory Maincent wrote:
>> > > On Mon, 20 Oct 2025 08:37:29 -0600
>> > > Tom Rini <trini@konsulko.com> wrote:
>> > >
>> > > > On Mon, Oct 20, 2025 at 08:15:48AM -0600, Tom Rini wrote:
>> > > > > On Mon, Oct 20, 2025 at 11:50:09AM +0200, Kory Maincent wrote:
>> > > > > > On Sun, 19 Oct 2025 10:48:37 -0600
>> > > > > > Tom Rini <trini@konsulko.com> wrote:
>> > > > > >
>> > > > > > > On Sun, Oct 19, 2025 at 02:05:51PM +0100, Simon Glass wrote:
>> > > > > > > > Hi Kory,
>> > > > > > > >
>> > > > > > > > On Mon, 13 Oct 2025 at 14:32, Kory Maincent (TI.com)
>> > > > > > > > <kory.maincent@bootlin.com> wrote:
>> > > > > > > > >
>> > > > > > > > > This series converts the extension board framework to use
>> > > > > > > > > UCLASS as requested by Simon Glass, then adds extension support
>> > > > > > > > > to pxe_utils and bootmeth_efi (not tested) to enable extension
>> > > > > > > > > boards devicetree load in the standard boot process.
>> > > > > > > > >
>> > > > > > > > > I can't test the imx8 extension scan enabled by the
>> > > > > > > > > imx8mm-cl-iot-gate_defconfig as I don't have this board.
>> > > > > > > > > I also can't test the efi bootmeth change as I don't have such
>> > > > > > > > > board.
>> > > > > > > >
>> > > > > > > > You can test this with sandbox, using one of the bootmeth tests,
>> > > > > > > > perhaps. Let me know if you need help with this.
>> > > > > > >
>> > > > > > > But the question is, does the real hardware platform work
>> > > > > > > before/after this, not does the sandbox test still work
>> > > > > > > before/after this.
>> > > > > >
>> > > > > > It seems the bootlflow scan is not working on the sandbox on next
>> > > > > > branch. Is this issue known?
>> > > > >
>> > > > > Is it fine on master? The next branch will be out of date until it
>> > > > > re-opens with -rc2 being released (2 weeks from today).
>> > > >
>> > > > ... out of sync local calendar, 3 weeks from today, not 2.
>> > >
>> > > bootstd test suit is not working on master with the sandbox_defconfig:
>> > > https://termbin.com/un0p
>> > >
>> > > Noticeable things are;
>> > > test/boot/bootdev.c:160, bootdev_test_any(): 0 == bootdev_find_by_any(seq,
>> > > &dev, &mflags): Expected 0x0 (0), got 0xffffffed (-19) Test:
>> > > bootdev_test_any: bootdev.c (flat tree) test/boot/bootdev.c:160,
>> > > bootdev_test_any(): 0 == bootdev_find_by_any(seq, &dev, &mflags): Expected
>> > > 0x0 (0), got 0xffffffed (-19) Test 'bootdev_test_any' failed 2 times
>> > >
>> > > And a nice segfault:
>> > > Test: bootflow_set_arg: bootflow.c
>> > > Test: bootflow_system: bootflow.c
>> > > [3] 569337 segmentation fault (core dumped) ./u-boot
>> > >
>> > > Maybe things are missing to run sandbox_defconfig on my computer?
>> > > With the sandbox64_defconfig there is not core dump anymore but there is
>> > > still the failed line:
>> > > Test 'bootdev_test_bootable' failed 2 times
>> > >
>> > > And the uboot is reboot infinitely during the bootflow test:
>> > > ./u-boot -T -c "ut bootstd"
>> > > https://termbin.com/alu5
>> >
>> > I see the same thing you do when running them outside of pytest, but
>> > they're also fine within pytest.
>> > https://docs.u-boot.org/en/latest/develop/pytest/usage.html should help
>> > get you started, and you can just run all of the ut tests under that.
>>
>> Weird I got errors also within pytest.
>> See the html test log attached generated by the following command:
>> ./test/py/test.py --bd sandbox -k bootstd
>
> Same. There's some implicit dependencies around I believe. Doing "-k ut"
> should work, as I tried that (via my wrapper around all this) as well as
> just running all the tests (which is longer).
That's my understanding as well
In Kory's log we see:
MMC: Can't map file 'mmc1.img': Invalid argument
sandbox_mmc_probe() mmc1: Unable to map file 'mmc1.img'
Can't map file 'mmc1.img': Invalid argument
sandbox_mmc_probe() mmc1: Unable to map file 'mmc1.img'
mmc_probe() mmc1 - probe failed: -1
mmc2: 2 (SD)Can't map file 'mmc1.img': Invalid argument
sandbox_mmc_probe() mmc1: Unable to map file 'mmc1.img'
, mmc0: 0 (SD)
These mmc1.img are needed for the bootstd tests to run properly.
These mmc*.img are generated in test_ut.py (see setup_cros_image() for
example)
So, In order to only run the bootstd tests, I think we need to to run:
$ ./test/py/test.py --bd sandbox --build -k test_ut
$ ./test/py/test.py --bd sandbox --build -k bootstd
Then we can just call:
$ ./test/py/test.py --bd sandbox --build -k bootstd
>
> --
> Tom
^ permalink raw reply [flat|nested] 40+ messages in thread