1
0
mirror of https://git.yoctoproject.org/meta-ti synced 2026-06-12 13:50:51 +00:00

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.

Signed-off-by: Ryan Eatmon <reatmon@ti.com>
This commit is contained in:
Ryan Eatmon
2024-08-14 15:38:04 -05:00
parent a1eb263dd3
commit f39943db86
3 changed files with 80 additions and 8 deletions
@@ -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
}
@@ -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
}
+3 -1
View File
@@ -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:"