[OE-core] [PATCH V2 2/2] meta: drop IMAGE_FSTYPES from UBOOT_CONFIG

liu.ming50 at gmail.com liu.ming50 at gmail.com
Sat May 18 21:12:25 UTC 2019


From: Ming Liu <liu.ming50 at gmail.com>

Currently, in most BSP layers, the uboot-config.bbclass is not being
inherited in machine conf, so the IMAGE_FSTYPES item would not take
effect since it's a image specific variable, So we can drop it from
UBOOT_CONFIG.

Instead, we introduce a new item 'env', it could be used to deploy
environment files to '/boot' directory and also to deploy directory.

To give a example, now the UBOOT_CONFIG could be set like this:
```
UBOOT_CONFIG ??= "emmc rawnand"
UBOOT_CONFIG[emmc] = "imx7_emmc_defconfig,uEnv-emmc.txt,u-boot.imx"
UBOOT_CONFIG[nand] = "imx7_defconfig,uEnv-nand.txt,u-boot-nand.imx"
```

It would not conflict with the current UBOOT_ENV variable, the later
has higher priority to override environment setting in UBOOT_CONFIG.

Also drop some trivial debug code in this patch.

Signed-off-by: Ming Liu <liu.ming50 at gmail.com>
---
 meta/classes/uboot-config.bbclass  | 25 +++++++++++--------------
 meta/conf/documentation.conf       |  2 +-
 meta/recipes-bsp/u-boot/u-boot.inc | 22 ++++++++++++++++++++++
 3 files changed, 34 insertions(+), 15 deletions(-)

diff --git a/meta/classes/uboot-config.bbclass b/meta/classes/uboot-config.bbclass
index 89ff970..af609fc 100644
--- a/meta/classes/uboot-config.bbclass
+++ b/meta/classes/uboot-config.bbclass
@@ -3,7 +3,7 @@
 # The format to specify it, in the machine, is:
 #
 # UBOOT_CONFIG ??= <default>
-# UBOOT_CONFIG[foo] = "config,images,binary"
+# UBOOT_CONFIG[foo] = "config,env,binary"
 #
 # or
 #
@@ -15,23 +15,24 @@ UBOOT_BINARY ?= "u-boot.${UBOOT_SUFFIX}"
 
 python () {
     ubootmachine = d.getVar("UBOOT_MACHINE")
-    ubootconfigflags = d.getVarFlags('UBOOT_CONFIG')
     ubootbinary = d.getVar('UBOOT_BINARY')
     ubootbinaries = d.getVar('UBOOT_BINARIES')
+    ubootenvs = d.getVar('UBOOT_ENVS')
+    ubootconfig = (d.getVar('UBOOT_CONFIG') or "").split()
+    ubootconfigflags = d.getVarFlags('UBOOT_CONFIG') or {}
+
     # The "doc" varflag is special, we don't want to see it here
     ubootconfigflags.pop('doc', None)
-    ubootconfig = (d.getVar('UBOOT_CONFIG') or "").split()
 
     if not ubootmachine and not ubootconfig:
-        PN = d.getVar("PN")
-        FILE = os.path.basename(d.getVar("FILE"))
-        bb.debug(1, "To build %s, see %s for instructions on \
-                 setting up your machine config" % (PN, FILE))
         raise bb.parse.SkipRecipe("Either UBOOT_MACHINE or UBOOT_CONFIG must be set in the %s machine configuration." % d.getVar("MACHINE"))
 
     if ubootmachine and ubootconfig:
         raise bb.parse.SkipRecipe("You cannot use UBOOT_MACHINE and UBOOT_CONFIG at the same time.")
 
+    if ubootconfigflags and ubootenvs:
+        raise bb.parse.SkipRecipe("You cannot use UBOOT_ENVS as it is internal to uboot_config.bbclass.")
+
     if ubootconfigflags and ubootbinaries:
         raise bb.parse.SkipRecipe("You cannot use UBOOT_BINARIES as it is internal to uboot_config.bbclass.")
 
@@ -40,18 +41,14 @@ python () {
             for f, v in ubootconfigflags.items():
                 if config == f: 
                     items = v.split(',')
-                    if items[0] and len(items) > 3:
-                        raise bb.parse.SkipRecipe('Only config,images,binary can be specified!')
+                    if len(items) == 0 or len(items) > 3:
+                        raise bb.parse.SkipRecipe('Only config,env,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])
+                        d.appendVar('UBOOT_ENVS', ' ' + 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)
                     break
 }
diff --git a/meta/conf/documentation.conf b/meta/conf/documentation.conf
index 550df20..5da7eb8 100644
--- a/meta/conf/documentation.conf
+++ b/meta/conf/documentation.conf
@@ -439,7 +439,7 @@ TUNEVALID[doc] = "Descriptions, stored as flags, of valid tuning features."
 
 #U
 
-UBOOT_CONFIG[doc] = "Configures the UBOOT_MACHINE and can also define IMAGE_FSTYPES for individual cases."
+UBOOT_CONFIG[doc] = "Configures the UBOOT_MACHINE and can also define UBOOT_ENVS, UBOOT_BINARIES for individual cases."
 UBOOT_ENTRYPOINT[doc] = "Specifies the entry point for the U-Boot image."
 UBOOT_LOADADDRESS[doc] = "Specifies the load address for the U-Boot image."
 UBOOT_LOCALVERSION[doc] = "Appends a string to the name of the local version of the U-Boot image."
diff --git a/meta/recipes-bsp/u-boot/u-boot.inc b/meta/recipes-bsp/u-boot/u-boot.inc
index e5af762..3b22e6e 100644
--- a/meta/recipes-bsp/u-boot/u-boot.inc
+++ b/meta/recipes-bsp/u-boot/u-boot.inc
@@ -121,6 +121,13 @@ do_compile () {
                         fi
                     done
                     unset k
+                    for env in ${UBOOT_ENVS}; do
+                        k=$(expr $k + 1);
+                        if [ $k -eq $i ]; then
+                            ${S}/scripts/get_default_envs.sh ${B}/${config} > ${B}/${config}/${env}
+                        fi
+                    done
+                    unset k
                 fi
             done
             unset  j
@@ -145,6 +152,13 @@ do_install () {
                     install -m 644 ${B}/${config}/u-boot-${type}.${UBOOT_SUFFIX} ${D}/boot/u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX}
                     ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${D}/boot/${UBOOT_BINARY}-${type}
                     ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${D}/boot/${UBOOT_BINARY}
+                    for env in ${UBOOT_ENVS}; do
+                        k=$(expr $k + 1);
+                        if [ $k -eq $i ]; then
+                            install -m 0644 ${B}/${config}/${env} ${D}/boot/${env}
+                        fi
+                    done
+                    unset k
                 fi
             done
             unset  j
@@ -235,6 +249,14 @@ do_deploy () {
                 if [ $j -eq $i ]
                 then
                     install -m 644 ${B}/${config}/u-boot-${type}.${UBOOT_SUFFIX} ${DEPLOYDIR}/u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX}
+                    for env in ${UBOOT_ENVS}; do
+                        k=$(expr $k + 1);
+                        if [ $k -eq $i ]; then
+                            install -m 0644 ${B}/${config}/${env} ${DEPLOYDIR}/${env}
+                        fi
+                    done
+                    unset k
+
                     ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${DEPLOYDIR}/${UBOOT_SYMLINK}-${type}
                     ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${DEPLOYDIR}/${UBOOT_SYMLINK}
                     ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${DEPLOYDIR}/${UBOOT_BINARY}-${type}
-- 
2.7.4



More information about the Openembedded-core mailing list