]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
u-boot: Overhaul UBOOT_CONFIG flow
authorRyan Eatmon <reatmon@ti.com>
Thu, 8 Jan 2026 20:22:37 +0000 (14:22 -0600)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 19 Jan 2026 17:46:18 +0000 (17:46 +0000)
The existing flow for setting UBOOT_CONFIG options is a little
confusing.  The comma separated list is difficult to remember which
slot is used for which option, and the order of the options cannot
be changed just added on to.

This commit overhauls the UBOOT_CONFIG flow while maintaining the
backwards compatibility with the existing settings.  Rather than use a
comma separated list, a new set of placeholder variables have been
defined where the same config flags can be used to specify all of the
needed changes:

UBOOT_CONFIG = "foo bar"
UBOOT_CONFIG[foo] = "config1,fstype1,binary1"
UBOOT_CONFIG[bar] = "config2,fstype2,binary2"

becomes:

UBOOT_CONFIG = "foo bar"
UBOOT_CONFIG[foo] = "config1"
UBOOT_CONFIG[bar] = "config2"

UBOOT_CONFIG_IMAGE_FSTYPES[foo] = "fstype1"
UBOOT_CONFIG_IMAGE_FSTYPES[bar] = "fstype2"

UBOOT_CONFIG_BINARY[foo] = "binary1"
UBOOT_CONFIG_BINARY[bar] = "binary2"

The previous addition of makeopts has been removed and replaced with:

UBOOT_CONFIG_MAKE_OPTS[config] = "opts"

Signed-off-by: Ryan Eatmon <reatmon@ti.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes-recipe/uboot-config.bbclass
meta/classes-recipe/uboot-sign.bbclass
meta/recipes-bsp/u-boot/u-boot-configure.inc
meta/recipes-bsp/u-boot/u-boot.inc

index 81057b5cadaa5308ff1d3992e67c2a5635f795da..715fb5c1d210d26cfa83569f426a9396ae3c7a8a 100644 (file)
@@ -2,12 +2,33 @@
 #
 # The format to specify it, in the machine, is:
 #
+# UBOOT_MACHINE = "config"
+#
+# or to build u-boot multiple times with different configs/options:
+#
+# UBOOT_MACHINE = ""
 # UBOOT_CONFIG ??= <default>
-# UBOOT_CONFIG[foo] = "config,images,binary"
+# UBOOT_CONFIG[foo] = "foo_config"
+# UBOOT_CONFIG[bar] = "bar_config"
 #
-# or
+# UBOOT_CONFIG_IMAGE_FSTYPES[bar] = "fstype"
 #
-# UBOOT_MACHINE = "config"
+# UBOOT_CONFIG_BINARY[foo] = "binary"
+#
+# UBOOT_CONFIG_MAKE_OPTS[foo] = "FOO=1"
+# UBOOT_CONFIG_MAKE_OPTS[bar] = "BAR=1"
+#
+# For more information about this, please see the official documentation.
+#
+# There is a legacy method that is still supported where some of the above
+# controls can be specified in a comma-separated list.  This method was
+# deemed to be limiting in terms of expanding support to more and more knobs
+# that might need to be turned to customize a config build.
+#
+# UBOOT_MACHINE = ""
+# UBOOT_CONFIG ??= <default>
+# UBOOT_CONFIG[foo] = "foo_config,images,binary"
+# UBOOT_CONFIG[bar] = "bar_config,images,binary"
 #
 # Copyright 2013, 2014 (C) O.S. Systems Software LTDA.
 #
@@ -113,9 +134,13 @@ python () {
 
     ubootmachine = d.getVar("UBOOT_MACHINE")
     ubootconfigflags = d.getVarFlags('UBOOT_CONFIG')
+    ubootconfigimagefstypes = d.getVar('UBOOT_CONFIG_IMAGE_FSTYPES')
+    ubootconfigimagefstypesflags = d.getVarFlags('UBOOT_CONFIG_IMAGE_FSTYPES')
     ubootbinary = d.getVar('UBOOT_BINARY')
-    ubootbinaries = d.getVar('UBOOT_BINARIES')
+    ubootconfigbinary = d.getVar('UBOOT_CONFIG_BINARY')
+    ubootconfigbinaryflags = d.getVarFlags('UBOOT_CONFIG_BINARY')
     ubootconfigmakeopts = d.getVar('UBOOT_CONFIG_MAKE_OPTS')
+    ubootconfigmakeoptsflags = d.getVarFlags('UBOOT_CONFIG_MAKE_OPTS')
     # The "doc" varflag is special, we don't want to see it here
     ubootconfigflags.pop('doc', None)
     ubootconfig = (d.getVar('UBOOT_CONFIG') or "").split()
@@ -130,42 +155,70 @@ python () {
     if ubootmachine and ubootconfig:
         raise bb.parse.SkipRecipe("You cannot use UBOOT_MACHINE and UBOOT_CONFIG at the same time.")
 
-    if ubootconfigflags and ubootbinaries:
-        raise bb.parse.SkipRecipe("You cannot use UBOOT_BINARIES as it is internal to uboot_config.bbclass.")
+    if ubootconfigimagefstypes:
+        raise bb.parse.SkipRecipe("You cannot use UBOOT_CONFIG_IMAGE_FSTYPES as a variable, you can only set flags.")
+
+    if ubootconfigbinary:
+        raise bb.parse.SkipRecipe("You cannot use UBOOT_CONFIG_BINARY as a variable, you can only set flags.")
 
-    if ubootconfigflags and ubootconfigmakeopts:
-        raise bb.parse.SkipRecipe("You cannot use UBOOT_CONFIG_MAKE_OPTS as it is internal to uboot_config.bbclass.")
+    if ubootconfigmakeopts:
+        raise bb.parse.SkipRecipe("You cannot use UBOOT_CONFIG_MAKE_OPTS as a variable, you can only set flags.")
 
     if len(ubootconfig) > 0:
         for config in ubootconfig:
             found = False
+            binary = ubootbinary
+            imagefstype = ""
             for f, v in ubootconfigflags.items():
                 if config == f: 
                     found = True
                     items = v.split(',')
-                    if items[0] and len(items) > 4:
-                        raise bb.parse.SkipRecipe('Only config,images,binary,make_opts can be specified!')
+                    if items[0] and len(items) > 3:
+                        raise bb.parse.SkipRecipe('Only config,images,binary can be specified!')
                     d.appendVar('UBOOT_MACHINE', ' ' + items[0])
                     # IMAGE_FSTYPES appending
                     if len(items) > 1 and items[1]:
-                        bb.debug(1, "Appending '%s' to IMAGE_FSTYPES." % items[1])
-                        d.appendVar('IMAGE_FSTYPES', ' ' + items[1])
+                        bb.debug(1, "Staging '%s' for IMAGE_FSTYPES." % items[1])
+                        imagefstype = items[1]
                     if len(items) > 2 and items[2]:
-                        bb.debug(1, "Appending '%s' to UBOOT_BINARIES." % items[2])
-                        d.appendVar('UBOOT_BINARIES', ' ' + items[2])
-                    else:
-                        bb.debug(1, "Appending '%s' to UBOOT_BINARIES." % ubootbinary)
-                        d.appendVar('UBOOT_BINARIES', ' ' + ubootbinary)
-                    if len(items) > 3 and items[3]:
-                        bb.debug(1, "Appending '%s' to UBOOT_CONFIG_MAKE_OPTS." % items[3])
-                        d.appendVar('UBOOT_CONFIG_MAKE_OPTS', items[3] + " ? ")
-                    else:
-                        bb.debug(1, "Appending '%s' to UBOOT_CONFIG_MAKE_OPTS." % "")
-                        d.appendVar('UBOOT_CONFIG_MAKE_OPTS', " ? ")
+                        bb.debug(1, "Staging '%s' for UBOOT_CONFIG_BINARY." % items[2])
+                        binary = items[2]
                     break
 
             if not found:
-                raise bb.parse.SkipRecipe("The selected UBOOT_CONFIG key %s has no match in %s." % (ubootconfig, ubootconfigflags.keys()))
+                raise bb.parse.SkipRecipe("The selected UBOOT_CONFIG key %s has no match in %s." % (config, ubootconfigflags.keys()))
+
+            # Extract out any settings from UBOOT_IMAGE_FSTYPES[config]
+            if  ubootconfigimagefstypesflags:
+                for f, v in ubootconfigimagefstypesflags.items():
+                    if config == f:
+                        bb.debug(1, "Staging '%s' for IMAGE_FSTYPES." % v)
+                        imagefstype = v
+
+            if imagefstype:
+                bb.debug(1, "Appending '%s' to IMAGE_FSTYPES." % imagefstype)
+                d.appendVar('IMAGE_FSTYPES', ' ' + imagefstype)
+
+            # Extract out any settings from UBOOT_CONFIG_BINARY[config]
+            if  ubootconfigbinaryflags:
+                for f, v in ubootconfigbinaryflags.items():
+                    if config == f:
+                        bb.debug(1, "Staging '%s' for UBOOT_CONFIG_BINARY." % v)
+                        binary = v
+
+            bb.debug(1, "Appending '%s' to UBOOT_CONFIG_BINARY." % binary)
+            d.appendVar('UBOOT_CONFIG_BINARY', binary + " ? ")
+
+            # Extract out any settings from UBOOT_CONFIG_MAKE_OPTS[config]
+            make_opts = ""
+            if  ubootconfigmakeoptsflags:
+                for f, v in ubootconfigmakeoptsflags.items():
+                    if config == f:
+                        bb.debug(1, "Staging '%s' for UBOOT_CONFIG_MAKE_OPTS." % v)
+                        make_opts = v
+
+            bb.debug(1, "Appending '%s' to UBOOT_CONFIG_MAKE_OPTS." % make_opts)
+            d.appendVar('UBOOT_CONFIG_MAKE_OPTS', make_opts + " ? ")
 
             # This recipe might be inherited e.g. by the kernel recipe via kernel-fitimage.bbclass
             # Ensure the uboot specific menuconfig settings do not leak into other recipes
@@ -176,3 +229,21 @@ python () {
                     # Disable menuconfig for multiple configs
                     d.setVar('KCONFIG_CONFIG_ENABLE_MENUCONFIG', "false")
 }
+
+uboot_config_get_indexed_value () {
+    local list=$1
+    local index=$2
+
+    local k=""
+
+    IFS="?"
+    for value in $list; do
+        k=$(expr $k + 1);
+        if [ $k -eq $index ]; then
+            break
+        fi
+    done
+    unset IFS
+
+    echo "$value"
+}
index 66b9698c1dd5221bf78ab096dafab8d384342127..9cb5c6ccf3caafecb86fcae42c1001bb32033bef 100644 (file)
@@ -530,15 +530,10 @@ do_uboot_assemble_fitimage() {
 
                        builddir="${config}-${type}"
 
-                       for binary in ${UBOOT_BINARIES}; do
-                               k=$(expr $k + 1);
-                               if [ $k -eq $i ]; then
-                                       break;
-                               fi
-                       done
+                       config_binary=$(uboot_config_get_indexed_value "${UBOOT_CONFIG_BINARY}" $i)
 
                        cd ${B}/${builddir}
-                       uboot_assemble_fitimage_helper ${type} ${binary}
+                       uboot_assemble_fitimage_helper ${type} ${config_binary}
                done
        else
                cd ${B}
index f3d9e5510556011237f77ea35e286bff670a74ba..337b8ed6c338b3812a484841ffb58e42f68d0c29 100644 (file)
@@ -35,17 +35,7 @@ uboot_configure_config () {
 
     builddir="${config}-${type}"
 
-    unset k
-    IFS="?"
-    uboot_config_make_opts="${UBOOT_CONFIG_MAKE_OPTS}"
-    for config_make_opts in $uboot_config_make_opts; do
-        k=$(expr $k + 1);
-        if [ $k -eq $i ]; then
-            break
-        fi
-    done
-    unset IFS
-    unset k
+    config_make_opts=$(uboot_config_get_indexed_value "${UBOOT_CONFIG_MAKE_OPTS}" $i)
 
     oe_runmake -C ${S} O=${B}/${builddir} ${config_make_opts} ${UBOOT_MAKE_OPTS} ${config}
     if [ -n "${@' '.join(find_cfgs(d))}" ]; then
index ffa9ef2d59e3778baa310f7ab1a3125aad4cfec7..a58bba2160a6fb5f83bfe1c2a82559da031d796c 100644 (file)
@@ -78,28 +78,12 @@ uboot_compile_config () {
 
     builddir="${config}-${type}"
 
-    unset k
-    IFS="?"
-    uboot_config_make_opts="${UBOOT_CONFIG_MAKE_OPTS}"
-    for config_make_opts in $uboot_config_make_opts; do
-        k=$(expr $k + 1);
-        if [ $k -eq $i ]; then
-            break
-        fi
-    done
-    unset IFS
-    unset k
+    config_make_opts=$(uboot_config_get_indexed_value "${UBOOT_CONFIG_MAKE_OPTS}" $i)
+    config_binary=$(uboot_config_get_indexed_value "${UBOOT_CONFIG_BINARY}" $i)
 
     oe_runmake -C ${S} O=${B}/${builddir} ${config_make_opts} ${UBOOT_MAKE_OPTS} ${UBOOT_MAKE_TARGET}
 
-    unset k
-    for binary in ${UBOOT_BINARIES}; do
-        k=$(expr $k + 1);
-        if [ $k -eq $i ]; then
-            uboot_compile_config_copy_binary $config $type $binary
-        fi
-    done
-    unset k
+    uboot_compile_config_copy_binary $config $type $config_binary
 
     # Generate the uboot-initial-env
     if [ -n "${UBOOT_INITIAL_ENV}" ]; then