Skip to contentSkip to conversation

meta: drop IMAGE_FSTYPES from UBOOT_CONFIG

PATCH New [email protected] 1 participant 3 messages May 18, 2019

lore
Share & tools
lore
#0 lore raw

v2 cover meta: drop IMAGE_FSTYPES from UBOOT_CONFIG

From: Ming Liu <[email protected]>

Instead, introduce a new item 'env' into UBOOT_CONFIG.

Ming Liu (2):
u-boot: clean up some redundant code
meta: drop IMAGE_FSTYPES from UBOOT_CONFIG

 meta/classes/uboot-config.bbclass  | 25 +++++++++-----------
 meta/conf/documentation.conf       |  2 +-
 meta/recipes-bsp/u-boot/u-boot.inc | 47 ++++++++++++++++++++++++--------------
 3 files changed, 42 insertions(+), 32 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 1/2 u-boot: clean up some redundant code

From: Ming Liu <[email protected]>

- Merge some DEPENDS lines.
- Drop some unnecessary 'cd ${DEPLOYDIR}' and 'rm -f'.

---
 meta/recipes-bsp/u-boot/u-boot.inc | 25 ++++++++-----------------
 1 file changed, 8 insertions(+), 17 deletions(-)
meta/recipes-bsp/u-boot/u-boot.inc +8 -17
index 9a754fd..e5af762 100644
@@ -5,11 +5,9 @@ B = "${WORKDIR}/build"
 
 PACKAGE_ARCH = "${MACHINE_ARCH}"
 
-DEPENDS += "kern-tools-native"
-
 inherit uboot-config uboot-extlinux-config uboot-sign deploy cml1
 
-DEPENDS += "swig-native python-native"
+DEPENDS += "kern-tools-native swig-native python-native"
 
 EXTRA_OEMAKE = 'CROSS_COMPILE=${TARGET_PREFIX} CC="${TARGET_PREFIX}gcc ${TOOLCHAIN_OPTIONS}" V=1'
 EXTRA_OEMAKE += 'HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}"'
@@ -227,6 +225,7 @@ do_install () {
 FILES_${PN} = "/boot ${sysconfdir} ${datadir}"
 
 do_deploy () {
+    install -d ${DEPLOYDIR}
     if [ -n "${UBOOT_CONFIG}" ]
     then
         for config in ${UBOOT_MACHINE}; do
@@ -235,25 +234,20 @@ do_deploy () {
                 j=$(expr $j + 1);
                 if [ $j -eq $i ]
                 then
-                    install -d ${DEPLOYDIR}
                     install -m 644 ${B}/${config}/u-boot-${type}.${UBOOT_SUFFIX} ${DEPLOYDIR}/u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX}
-                    cd ${DEPLOYDIR}
-                    ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_SYMLINK}-${type}
-                    ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_SYMLINK}
-                    ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_BINARY}-${type}
-                    ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_BINARY}
+                    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}
+                    ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${DEPLOYDIR}/${UBOOT_BINARY}
                 fi
             done
             unset  j
         done
         unset  i
     else
-        install -d ${DEPLOYDIR}
         install -m 644 ${B}/${UBOOT_BINARY} ${DEPLOYDIR}/${UBOOT_IMAGE}
-        cd ${DEPLOYDIR}
-        rm -f ${UBOOT_BINARY} ${UBOOT_SYMLINK}
-        ln -sf ${UBOOT_IMAGE} ${UBOOT_SYMLINK}
-        ln -sf ${UBOOT_IMAGE} ${UBOOT_BINARY}
+        ln -sf ${UBOOT_IMAGE} ${DEPLOYDIR}/${UBOOT_SYMLINK}
+        ln -sf ${UBOOT_IMAGE} ${DEPLOYDIR}/${UBOOT_BINARY}
     fi
 
     if [ -n "${UBOOT_ELF}" ]
@@ -295,7 +289,6 @@ do_deploy () {
                     if [ $j -eq $i ]
                     then
                         install -m 644 ${B}/${config}/${SPL_BINARY} ${DEPLOYDIR}/${SPL_IMAGE}-${type}-${PV}-${PR}
-                        rm -f ${DEPLOYDIR}/${SPL_BINARYNAME} ${DEPLOYDIR}/${SPL_SYMLINK}-${type}
                         ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${DEPLOYDIR}/${SPL_BINARYNAME}-${type}
                         ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${DEPLOYDIR}/${SPL_BINARYNAME}
                         ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${DEPLOYDIR}/${SPL_SYMLINK}-${type}
@@ -307,7 +300,6 @@ do_deploy () {
             unset  i
         else
             install -m 644 ${B}/${SPL_BINARY} ${DEPLOYDIR}/${SPL_IMAGE}
-            rm -f ${DEPLOYDIR}/${SPL_BINARYNAME} ${DEPLOYDIR}/${SPL_SYMLINK}
             ln -sf ${SPL_IMAGE} ${DEPLOYDIR}/${SPL_BINARYNAME}
             ln -sf ${SPL_IMAGE} ${DEPLOYDIR}/${SPL_SYMLINK}
         fi
@@ -317,7 +309,6 @@ do_deploy () {
     if [ -n "${UBOOT_ENV}" ]
     then
         install -m 644 ${WORKDIR}/${UBOOT_ENV_BINARY} ${DEPLOYDIR}/${UBOOT_ENV_IMAGE}
-        rm -f ${DEPLOYDIR}/${UBOOT_ENV_BINARY} ${DEPLOYDIR}/${UBOOT_ENV_SYMLINK}
         ln -sf ${UBOOT_ENV_IMAGE} ${DEPLOYDIR}/${UBOOT_ENV_BINARY}
         ln -sf ${UBOOT_ENV_IMAGE} ${DEPLOYDIR}/${UBOOT_ENV_SYMLINK}
     fi
Signature · 1 line
2.7.4
#2 lore raw

PATCH v2 2/2 meta: drop IMAGE_FSTYPES from UBOOT_CONFIG

In reply to [email protected]

From: Ming Liu <[email protected]>

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.

---
 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(-)
meta/classes/uboot-config.bbclass +11 -14
index 89ff970..af609fc 100644
@@ -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
 }
meta/conf/documentation.conf +1 -1
index 550df20..5da7eb8 100644
@@ -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."
meta/recipes-bsp/u-boot/u-boot.inc +22 -0
index e5af762..3b22e6e 100644
@@ -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}
Signature · 1 line
2.7.4