Skip to contentSkip to conversation

uboot-config.bbclass: Allow multiple U-Boot config for machine

PATCH New Chunrong Guo 1 participant 2 messages Jan 22, 2015

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/2 uboot-config.bbclass: Allow multiple U-Boot config for machine

This adds support to build multiple U-Boot configs for a machine; this is useful when we have support for different media boots which require different U-Boot configuration (e.g: eMMC and NAND).

Below there's an usage example:
,----[ i.MX6Q SABRE AUTO based example ]

  | UBOOT_CONFIG ??= "sd eimnor nand spinor"
  | UBOOT_CONFIG[sd] = "mx6qsabreauto_config,sdcard"
  | UBOOT_CONFIG[eimnor] = "mx6qsabreauto_eimnor_config"
  | UBOOT_CONFIG[nand] = "mx6qsabreauto_nand_config,ubifs"
  | UBOOT_CONFIG[spinor] = "mx6qsabreauto_spinor_config"

`----

---
 meta/classes/uboot-config.bbclass | 37 ++++++++++++++-----------------------
 1 file changed, 14 insertions(+), 23 deletions(-)
meta/classes/uboot-config.bbclass +14 -23
index b467659..cb061af 100644
@@ -31,28 +31,19 @@ python () {
         return
 
     ubootconfig = (d.getVar('UBOOT_CONFIG', True) or "").split()
-    if len(ubootconfig) > 1:
-        raise bb.parse.SkipPackage('You can only have a single default for UBOOT_CONFIG.')
+    if len(ubootconfig) > 0:
+        for config in ubootconfig:
+            for f, v in ubootconfigflags.items():
+                if config == f: 
+                    items = v.split(',')
+                    if items[0] and len(items) > 2:
+                        raise bb.parse.SkipPackage('Only config,images 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])
+                    break
     elif len(ubootconfig) == 0:
-        raise bb.parse.SkipPackage('You must set a default in UBOOT_CONFIG.')
-    ubootconfig = ubootconfig[0]
-
-    for f, v in ubootconfigflags.items():
-        items = v.split(',')
-        if items[0] and len(items) > 2:
-            raise bb.parse.SkipPackage('Only config,images can be specified!')
-
-        if ubootconfig == f:
-            bb.debug(1, "Setting UBOOT_MACHINE to %s." % items[0])
-            d.setVar('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])
-
-            # Go out as we found a match!
-            break
-    else:
-        raise bb.parse.SkipPackage("UBOOT_CONFIG %s is not supported" % ubootconfig)
+       raise bb.parse.SkipPackage('You must set a default in UBOOT_CONFIG.')
 }
Signature · 1 line
1.9.2
#1 lore raw

PATCH v5 2/2 u-boot.inc : add compile multiple u-boot feature

---
 meta/recipes-bsp/u-boot/u-boot.inc | 150 +++++++++++++++++++++++++++++++------
 1 file changed, 129 insertions(+), 21 deletions(-)
meta/recipes-bsp/u-boot/u-boot.inc +129 -21
index c695b73..58725fa 100644
@@ -62,15 +62,56 @@ do_compile () {
 		echo ${UBOOT_LOCALVERSION} > ${B}/.scmversion
 		echo ${UBOOT_LOCALVERSION} > ${S}/.scmversion
 	fi
+    
+    if [ "x${UBOOT_CONFIG}" != "x" ]
+    then
+        for config in ${UBOOT_MACHINE}; do
+            for type in in ${UBOOT_CONFIG}; do
+                if [ "${type}"x = "in"x ]
+                then
+                    continue
+                fi
+                if [ -d "${S}/${config}/u-boot-${type}.${UBOOT_SUFFIX}"]
+                then
+                    break
+                else
+                    oe_runmake O=${config} ${config}
+                    oe_runmake O=${config} ${UBOOT_MAKE_TARGET}
+                    cp  ${S}/${config}/${UBOOT_BINARY}  ${S}/${config}/u-boot-${type}.${UBOOT_SUFFIX}
+                fi
+            done
+        done
+    else
+        oe_runmake ${UBOOT_MACHINE}
+        oe_runmake ${UBOOT_MAKE_TARGET}
+    fi
 
-	oe_runmake ${UBOOT_MACHINE}
-	oe_runmake ${UBOOT_MAKE_TARGET}
 }
 
 do_install () {
-    install -d ${D}/boot
-    install ${S}/${UBOOT_BINARY} ${D}/boot/${UBOOT_IMAGE}
-    ln -sf ${UBOOT_IMAGE} ${D}/boot/${UBOOT_BINARY}
+    if [ "x${UBOOT_CONFIG}" != "x" ]
+    then
+        for config in ${UBOOT_MACHINE}; do
+            for type in in ${UBOOT_CONFIG}; do
+                if [ "${type}"x = "in"x ]
+                then
+                    continue
+                fi
+                if [ -d "${D}/boot/u-boot-${type}.${UBOOT_SUFFIX}"]
+                then
+                    break
+                else
+                    install -d ${D}/boot
+                    install ${S}/${config}/u-boot-${type}.${UBOOT_SUFFIX} ${D}/boot/u-boot-${type}.${UBOOT_SUFFIX}
+                    ln -sf u-boot-${type}.${UBOOT_SUFFIX} ${D}/boot/${UBOOT_BINARY}
+                fi
+            done
+        done
+    else
+        install -d ${D}/boot
+        install ${S}/${UBOOT_BINARY} ${D}/boot/${UBOOT_IMAGE}
+        ln -sf ${UBOOT_IMAGE} ${D}/boot/${UBOOT_BINARY}
+    fi
 
     if [ -e ${WORKDIR}/fw_env.config ] ; then
         install -d ${D}${sysconfdir}
@@ -79,8 +120,28 @@ do_install () {
 
     if [ "x${SPL_BINARY}" != "x" ]
     then
-        install ${S}/${SPL_BINARY} ${D}/boot/${SPL_IMAGE}
-        ln -sf ${SPL_IMAGE} ${D}/boot/${SPL_BINARY}
+        if [ "x${UBOOT_CONFIG}" != "x" ]   
+        then
+            for config in ${UBOOT_MACHINE}; do
+                for type in in ${UBOOT_CONFIG}; do
+                     if [ "${type}"x = "in"x ]
+                     then
+                         continue
+                     fi
+                     if [ -d "${D}/boot/${SPL_IMAGE}-${type}"]
+                     then
+                         break
+                     else
+                         install ${S}/${config}/${SPL_BINARY} ${D}/boot/${SPL_IMAGE}-${type}
+                         ln -sf ${SPL_IMAGE}-${type} ${D}/boot/${SPL_BINARY}-${type}
+                         ln -sf ${SPL_IMAGE}-${type} ${D}/boot/${SPL_BINARY}
+                     fi
+                done
+            done
+        else
+            install ${S}/${SPL_BINARY} ${D}/boot/${SPL_IMAGE}
+            ln -sf ${SPL_IMAGE} ${D}/boot/${SPL_BINARY}
+        fi
     fi
 
     if [ "x${UBOOT_ENV}" != "x" ]
@@ -93,21 +154,68 @@ do_install () {
 FILES_${PN} = "/boot ${sysconfdir}"
 
 do_deploy () {
-    install -d ${DEPLOYDIR}
-    install ${S}/${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}
-
-    if [ "x${SPL_BINARY}" != "x" ]
+    if [ "x${UBOOT_CONFIG}" != "x" ]
     then
-        install ${S}/${SPL_BINARY} ${DEPLOYDIR}/${SPL_IMAGE}
-        rm -f ${DEPLOYDIR}/${SPL_BINARY} ${DEPLOYDIR}/${SPL_SYMLINK}
-        ln -sf ${SPL_IMAGE} ${DEPLOYDIR}/${SPL_BINARY}
-        ln -sf ${SPL_IMAGE} ${DEPLOYDIR}/${SPL_SYMLINK}
-    fi
+        for config in ${UBOOT_MACHINE}; do
+            for type in in ${UBOOT_CONFIG}; do
+                if [ "${type}"x = "in"x ]  
+                then
+                    continue
+                fi
+                if [ -d "${DEPLOYDIR}/u-boot-${type}.${UBOOT_SUFFIX}"]
+                then 
+                    break
+                else
+                    install -d ${DEPLOYDIR}
+                    install ${S}/${config}/u-boot-${type}.${UBOOT_SUFFIX} ${DEPLOYDIR}/u-boot-${type}.${UBOOT_SUFFIX}
+                    cd ${DEPLOYDIR}
+                    ln -sf u-boot-${type}.${UBOOT_SUFFIX} ${UBOOT_SYMLINK}
+                    ln -sf u-boot-${type}.${UBOOT_SUFFIX} ${UBOOT_BINARY}
+                fi 
+            done 
+        done
+    else
+        install -d ${DEPLOYDIR}
+        install ${S}/${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}
+   fi
+    
+
+
+     if [ "x${SPL_BINARY}" != "x" ]
+     then
+         if [ "x${UBOOT_CONFIG}" != "x" ]   
+         then
+             for config in ${UBOOT_MACHINE}; do
+                 for type in in ${UBOOT_CONFIG}; do
+                      if [ "${type}"x = "in"x ]
+                      then
+                          continue
+                      fi
+                      if [ -d "${DEPLOYDIR}/${SPL_IMAGE}-${type}"]
+                      then
+                          break
+                      else
+                          install ${S}/${config}/${SPL_BINARY} ${DEPLOYDIR}/${SPL_IMAGE}-${type}
+                          rm -f ${DEPLOYDIR}/${SPL_BINARY} ${DEPLOYDIR}/${SPL_SYMLINK}-${type}
+                          ln -sf ${SPL_IMAGE}-${type} ${DEPLOYDIR}/${SPL_BINARY}-${type}
+                          ln -sf ${SPL_IMAGE}-${type} ${DEPLOYDIR}/${SPL_BINARY}
+                          ln -sf ${SPL_IMAGE}-${type} ${DEPLOYDIR}/${SPL_SYMLINK}-${type}
+                          ln -sf ${SPL_IMAGE}-${type} ${DEPLOYDIR}/${SPL_SYMLINK}
+                      fi
+                 done
+             done
+         else
+             install ${S}/${SPL_BINARY} ${DEPLOYDIR}/${SPL_IMAGE}
+             rm -f ${DEPLOYDIR}/${SPL_BINARY} ${DEPLOYDIR}/${SPL_SYMLINK}
+             ln -sf ${SPL_IMAGE} ${DEPLOYDIR}/${SPL_BINARY}
+             ln -sf ${SPL_IMAGE} ${DEPLOYDIR}/${SPL_SYMLINK}
+         fi
+     fi
+
 
     if [ "x${UBOOT_ENV}" != "x" ]
     then
Signature · 1 line
1.9.2