Skip to contentSkip to conversation

classes: Create uboot-fragments.bbclass

RFC New Ryan Eatmon 1 participant 2 messages Aug 15, 2024

lore
Share & tools
lore
#0 lore raw

RFC 1/2 classes: Create uboot-fragments.bbclass

Update our custom config fragment handling code to work with the new UBOOT_CONFIG changes. To better align with naming, change the name of UBOOT_CONFIG_FRAGMENTS to just UBOOT_FRAGMENTS. Also create a UBOOT_FRAGMENTS_CONFIG that goes hand in hand with UBOOT_CONFIG so that you can specify different fragments for each of the config types.

For example:

UBOOT_CONFIG = "a b"
UBOOT_CONFIG[a] = "config_a"
UBOOT_CONFIG[b] = "config_b"

UBOOT_FRAGMENTS_CONFIG[a] = ""
UBOOT_FRAGMENTS_CONFIG[b] = "fragment1"

The logic in the class will automatically populate UBOOT_FRAGMENTS from UBDOOT_FRAGMENTS_CONFIG.

Additionally, change the value that UBOOT_FRAGMENTS can take to be a comma separated list of fragments to apply.

---
 meta-ti-bsp/classes/uboot-fragments.bbclass   | 77 +++++++++++++++++++
 .../recipes-bsp/u-boot/u-boot-mergeconfig.inc |  7 --
 meta-ti-bsp/recipes-bsp/u-boot/u-boot-ti.inc  |  4 +-
 3 files changed, 80 insertions(+), 8 deletions(-)
 create mode 100644 meta-ti-bsp/classes/uboot-fragments.bbclass
 delete mode 100644 meta-ti-bsp/recipes-bsp/u-boot/u-boot-mergeconfig.inc
meta-ti-bsp/classes/uboot-fragments.bbclass new file +77 -0
new file mode 100644
index 00000000..8db052fa
@@ -0,0 +1,77 @@
+# Handle U-Boot config fragments for a machine
+#
+# This interacts with the UBOOT_CONFIG flow
+#
+# The format to specify it, in the machine, is:
+#
+# UBOOT_FRAGMENTS_CONFIG[foo] = "fragment[,fragment...]"
+#
+# or
+#
+# UBOOT_FRAGMENTS = "fragment[,fragment...]"
+#
+# Copyright 2024 (C) Texas Instruments, Inc.
+#
+# SPDX-License-Identifier: MIT
+
+python () {
+    loUbootConfig = (d.getVar('UBOOT_CONFIG') or "").split()
+    loUbootFragments = d.getVar('UBOOT_FRAGMENTS')
+    loUbootFragmentsConfigFlags = d.getVarFlags('UBOOT_FRAGMENTS_CONFIG')
+        
+    if loUbootFragmentsConfigFlags and loUbootFragments:
+        raise bb.parse.SkipRecipe("You cannot use UBOOT_FRAGMENTS and UBOOT_FRAGMENTS_CONFIG at the same time.")
+
+    if loUbootFragmentsConfigFlags is not None and len(loUbootConfig) > 0:
+        for lpConfig in loUbootConfig:
+            loFound = False
+            for lpFlag, lpValue in loUbootFragmentsConfigFlags.items():
+                if lpConfig == lpFlag: 
+                    loFound = True
+                    if lpValue == "":
+                        d.appendVar('UBOOT_FRAGMENTS', ' none')
+                    else:
+                        d.appendVar('UBOOT_FRAGMENTS', ' ' + lpValue)
+
+            if not loFound:
+                raise bb.parse.SkipRecipe("The selected UBOOT_CONFIG key %s has no match in %s." % (loUbootConfig, loUbootFragmentsConfigFlags.keys()))
+}
+
+uboot_configure_config:append () {
+   if [ -n "${UBOOT_FRAGMENTS}" ]
+   then
+        unset loTypeIdx
+        for lpType in ${UBOOT_CONFIG}; do
+            loTypeIdx=$(expr $loTypeIdx + 1)
+
+            if [ "${lpType}" == "${type}" ]; then
+                break
+            fi
+        done
+        
+        loApplyFragments=""
+        
+        for lpFragment in ${UBOOT_FRAGMENTS}; do
+            lpFragmentIdx=$(expr $lpFragmentIdx + 1)
+            if [ $y -eq $x ]; then
+                if [ "${lpFragment}" != "none" ]; then
+                    loApplyFragments=`echo ${lpFragment} | tr "," " "`
+                fi
+                break
+            fi
+        done
+
+        if [ -n "${loApplyFragments}" ]; then
+            oe_runmake -C ${S} O=${B}/${config} ${config} ${loApplyFragments}
+            oe_runmake -C ${S} O=${B}/${config} oldconfig
+        fi
+    fi
+}
+
+uboot_configure:append () {
+   if [ -n "${UBOOT_FRAGMENTS}" ] && [ -n "${UBOOT_MACHINE}" ]
+   then
+       oe_runmake -C ${S} O=${B} ${UBOOT_MACHINE} `echo ${UBOOT_FRAGMENTS} | tr "," " "`
+       oe_runmake -C ${S} O=${B} oldconfig
+   fi
+}
meta-ti-bsp/recipes-bsp/u-boot/u-boot-mergeconfig.inc deleted +0 -7
deleted file mode 100644
index c7ce5047..00000000
@@ -1,7 +0,0 @@
-do_configure:append () {
-   if [ -n "${UBOOT_CONFIG_FRAGMENTS}" ] && [ -n "${UBOOT_MACHINE}" ]
-   then
-       oe_runmake -C ${S} O=${B} ${UBOOT_MACHINE} ${UBOOT_CONFIG_FRAGMENTS}
-       oe_runmake -C ${S} O=${B} olddefconfig
-   fi
-}
meta-ti-bsp/recipes-bsp/u-boot/u-boot-ti.inc +3 -1
index bb50e1e9..5521ecee 100644
@@ -1,3 +1,4 @@
+
 do_compile:prepend () {
     scm_version=$(printf '%s%s' -ti-g $(git -C ${S} rev-parse --verify HEAD 2>/dev/null | cut -c1-12))
 
@@ -10,7 +11,8 @@ SPL_BINARY ?= "MLO"
 
 require ${COREBASE}/meta/recipes-bsp/u-boot/u-boot-common.inc
 require ${COREBASE}/meta/recipes-bsp/u-boot/u-boot.inc
-require u-boot-mergeconfig.inc
+
+inherit uboot-fragments
 
 FILESEXTRAPATHS:prepend := "${THISDIR}/u-boot:"
 
Signature · 1 line
2.17.1
#1 lore raw

RFC 2/2 conf: machine: Move to new UBOOT_FRAGMENTS

Migrate the machine configs to use the new UBOOT_FRAGMENTS methodology.

---
 meta-ti-bsp/conf/machine/am62pxx-evm.conf          | 9 ++-------
 meta-ti-bsp/conf/machine/am62xx-unified-k3r5.conf  | 8 ++++++++
 meta-ti-bsp/conf/machine/am62xxsip-evm-k3r5.conf   | 2 --
 meta-ti-bsp/conf/machine/beaglebone-ai64-k3r5.conf | 4 ++--
 meta-ti-bsp/conf/machine/beaglebone-ai64.conf      | 4 ++--
 meta-ti-bsp/conf/machine/beagleplay-k3r5.conf      | 6 +++---
 meta-ti-bsp/conf/machine/beagleplay.conf           | 6 +++---
 7 files changed, 20 insertions(+), 19 deletions(-)
meta-ti-bsp/conf/machine/am62pxx-evm.conf +2 -7
index 676e64a4..7aff3414 100644
@@ -22,11 +22,6 @@ KERNEL_DEVICETREE = " \
 
 UBOOT_MACHINE = "am62px_evm_a53_defconfig"
 
-# UBOOT_CONFIG_FRAGMENTS holds the list of u-boot config fragments which has to be build
-# along with the base defconfig mentioned in UBOOT_MACHINE. Refer u-boot-mergeconfig.inc
-# under meta-ti-bsp/recipes-bsp/u-boot/ for more details.
-# For AM62P tisdk-display-cluster image, splash screen is handled by SBL.
-# Hence, disable the A53 based splash screen using the am62x_evm_prune_splashscreen.config fragment present in ti-u-boot tree
-UBOOT_CONFIG_FRAGMENTS = "${@oe.utils.conditional('DISPLAY_CLUSTER_ENABLE', '1', 'am62x_evm_prune_splashscreen.config', '', d)}"
+UBOOT_FRAGMENTS = "${@oe.utils.conditional('DISPLAY_CLUSTER_ENABLE', '1', 'am62x_evm_prune_splashscreen.config', '', d)}"
 
-UBOOT_CONFIG_FRAGMENTS:bsp-ti-6_1 = "${@oe.utils.conditional('DISPLAY_CLUSTER_ENABLE', '1', 'am62px_evm_prune_splashscreen.config', '', d)}"
+UBOOT_FRAGMENTS:bsp-ti-6_1 = "${@oe.utils.conditional('DISPLAY_CLUSTER_ENABLE', '1', 'am62px_evm_prune_splashscreen.config', '', d)}"
meta-ti-bsp/conf/machine/am62xx-unified-k3r5.conf +8 -0
index 7d65e6af..6a8f2760 100644
@@ -18,3 +18,11 @@ UBOOT_CONFIG:bsp-ti-6_1 ??= "evm"
 UBOOT_CONFIG[sip] = "am62xsip_evm_r5_defconfig"
 UBOOT_CONFIG[lpsk] = "am62x_lpsk_r5_defconfig"
 UBOOT_CONFIG[evm] = "am62x_evm_r5_defconfig"
+
+UBOOT_FRAGMENTS_CONFIG_SIP = ""
+UBOOT_FRAGMENTS_CONFIG_SIP:bsp-ti-6_1 = "am62xsip_sk_r5"
+
+UBOOT_FRAGMENTS_CONFIG[sip] = "${UBOOT_FRAGMENTS_CONFIG_SIP}"
+UBOOT_FRAGMENTS_CONFIG[lpsk] = ""
+UBOOT_FRAGMENTS_CONFIG[evm] = ""
+
meta-ti-bsp/conf/machine/am62xxsip-evm-k3r5.conf +0 -2
index ab538ff3..990675be 100644
@@ -9,5 +9,3 @@ UBOOT_CONFIG = "sip"
 UBOOT_CONFIG:bsp-ti-6_1 = ""
 
 UBOOT_MACHINE:bsp-ti-6_1 = "am62x_evm_r5_defconfig"
-
-UBOOT_CONFIG_FRAGMENTS:bsp-ti-6_1 = "am62xsip_sk_r5.config"
meta-ti-bsp/conf/machine/beaglebone-ai64-k3r5.conf +2 -2
index d415a212..3361e85a 100644
@@ -19,5 +19,5 @@ UBOOT_SYMLINK = "tiboot3-${MAINMACHINE}.${UBOOT_SUFFIX}"
 UBOOT_MACHINE = "j721e_evm_r5_defconfig"
 UBOOT_MACHINE:bsp-ti-6_6 = "j721e_beagleboneai64_r5_defconfig"
 
-UBOOT_CONFIG_FRAGMENTS:bsp-bb_org = "j721e_beagleboneai64_r5.config"
-UBOOT_CONFIG_FRAGMENTS:bsp-ti-6_1 = "j721e_beagleboneai64_r5.config"
+UBOOT_FRAGMENTS:bsp-bb_org = "j721e_beagleboneai64_r5.config"
+UBOOT_FRAGMENTS:bsp-ti-6_1 = "j721e_beagleboneai64_r5.config"
meta-ti-bsp/conf/machine/beaglebone-ai64.conf +2 -2
index 56e1ed4e..0eaae980 100644
@@ -12,8 +12,8 @@ IMAGE_SR2_HS_SE_FILES:bsp-bb_org = ""
 UBOOT_MACHINE = "j721e_evm_a72_config"
 UBOOT_MACHINE:bsp-ti-6_6 = "j721e_beagleboneai64_a72_defconfig"
 
-UBOOT_CONFIG_FRAGMENTS:bsp-ti-6_1 = "j721e_beagleboneai64_a72.config"
-UBOOT_CONFIG_FRAGMENTS:bsp-bb_org = "j721e_beagleboneai64_a72.config"
+UBOOT_FRAGMENTS:bsp-ti-6_1 = "j721e_beagleboneai64_a72.config"
+UBOOT_FRAGMENTS:bsp-bb_org = "j721e_beagleboneai64_a72.config"
 
 SPL_BINARY:bsp-ti-6_6 = "tispl.bin_unsigned"
 SPL_BINARYNAME:bsp-ti-6_6 = "tispl.bin"
meta-ti-bsp/conf/machine/beagleplay-k3r5.conf +3 -3
index 338a6fbf..11fc6d29 100644
@@ -11,6 +11,6 @@ SYSFW_SUFFIX = "gp"
 UBOOT_MACHINE = "am62x_evm_r5_defconfig"
 UBOOT_MACHINE:bsp-ti-6_6 = "am62x_beagleplay_r5_defconfig"
 
-UBOOT_CONFIG_FRAGMENTS:bsp-bb_org = "am625_beagleplay_r5.config"
-UBOOT_CONFIG_FRAGMENTS:bsp-ti-6_1 = "am625_beagleplay_r5.config"
-UBOOT_CONFIG_FRAGMENTS:bsp-mainline = "beagleplay_r5.config"
+UBOOT_FRAGMENTS:bsp-bb_org = "am625_beagleplay_r5.config"
+UBOOT_FRAGMENTS:bsp-ti-6_1 = "am625_beagleplay_r5.config"
+UBOOT_FRAGMENTS:bsp-mainline = "beagleplay_r5.config"
meta-ti-bsp/conf/machine/beagleplay.conf +3 -3
index d420c6c7..883ef538 100644
@@ -20,9 +20,9 @@ OPTEEMACHINE = "k3-am62x"
 UBOOT_MACHINE = "am62x_evm_a53_defconfig"
 UBOOT_MACHINE:bsp-ti-6_6 = "am62x_beagleplay_a53_defconfig"
 
-UBOOT_CONFIG_FRAGMENTS:bsp-ti-6_1 = "am625_beagleplay_a53.config"
-UBOOT_CONFIG_FRAGMENTS:bsp-bb_org = "am625_beagleplay_a53.config"
-UBOOT_CONFIG_FRAGMENTS:bsp-mainline = "beagleplay_a53.config"
+UBOOT_FRAGMENTS:bsp-ti-6_1 = "am625_beagleplay_a53.config"
+UBOOT_FRAGMENTS:bsp-bb_org = "am625_beagleplay_a53.config"
+UBOOT_FRAGMENTS:bsp-mainline = "beagleplay_a53.config"
 
 SPL_BINARY:bsp-ti-6_6 = "tispl.bin_unsigned"
 SPL_BINARYNAME:bsp-ti-6_6 = "tispl.bin"
Signature · 1 line
2.17.1