[meta-xilinx] [meta-xilinx-tools][PATCH v3] xilinx-bootbin: Convert to recipe instead of bbclass
Manjukumar Matha
manjukumar.harthikote-matha at xilinx.com
Fri Apr 6 12:57:44 PDT 2018
boot.bin should be deployed either using SPL methodology or using
bootgen. Change the bbclass to recipe so that it can be used as recipe
with a provider setting.
This patch is based of the inital patch sent to mailing list by
Jean-Francois Dagenais
https://lists.yoctoproject.org/pipermail/meta-xilinx/2017-July/003029.html
Signed-off-by: Manjukumar Matha <manjukumar.harthikote-matha at xilinx.com>
---
Changelog
1) Remove unnecessary tasks which are not used in bootbin recipe
2) Add the depedendency to DEPENDS instead of do_configure
classes/xilinx-bootbin.bbclass | 83 -------------------
conf/machine/include/machine-xilinx-zynq.inc | 19 -----
conf/machine/include/machine-xilinx-zynqmp.inc | 39 ---------
recipes-bsp/bootbin/machine-xilinx-zynq.inc | 17 ++++
recipes-bsp/bootbin/machine-xilinx-zynqmp.inc | 35 ++++++++
recipes-bsp/bootbin/xilinx-bootbin_1.0.bb | 107 +++++++++++++++++++++++++
6 files changed, 159 insertions(+), 141 deletions(-)
delete mode 100644 classes/xilinx-bootbin.bbclass
delete mode 100644 conf/machine/include/machine-xilinx-zynq.inc
delete mode 100644 conf/machine/include/machine-xilinx-zynqmp.inc
create mode 100644 recipes-bsp/bootbin/machine-xilinx-zynq.inc
create mode 100644 recipes-bsp/bootbin/machine-xilinx-zynqmp.inc
create mode 100644 recipes-bsp/bootbin/xilinx-bootbin_1.0.bb
diff --git a/classes/xilinx-bootbin.bbclass b/classes/xilinx-bootbin.bbclass
deleted file mode 100644
index 31a38a6..0000000
--- a/classes/xilinx-bootbin.bbclass
+++ /dev/null
@@ -1,83 +0,0 @@
-inherit xsct-tc
-
-BIF_COMMON_ATTR ?= ''
-BIF_PARTITION_ATTR ?= ''
-BIF_PARTITION_IMAGE ?= ''
-BIF_PARTITION_DEPENDS ?= ''
-BIF_FILE_PATH = "${WORKDIR}/bootgen.bif"
-
-def create_bif(config, attrflags, attrimage, common_attr, biffd, d):
- import re, os
- for cfg in config:
- if cfg not in attrflags and common_attr:
- error_msg = "%s: invalid ATTRIBUTE" % (cfg)
- bb.error("BIF attribute Error: %s " % (error_msg))
- else:
- if common_attr:
- cfgval = attrflags[cfg].split(',')
- cfgstr = "\t [%s] %s\n" % (cfg,', '.join(cfgval))
- else:
- if cfg not in attrimage:
- error_msg = "%s: invalid or missing elf or image" % (cfg)
- bb.error("BIF atrribute Error: %s " % (error_msg))
- imagestr = d.expand(attrimage[cfg])
- if os.stat(imagestr).st_size == 0:
- bb.warn("Empty file %s, excluding from bif file" %(imagestr))
- continue
- if cfg in attrflags:
- cfgval = attrflags[cfg].split(',')
- cfgstr = "\t [%s] %s\n" % (', '.join(cfgval), imagestr)
- else:
- cfgstr = "\t %s\n" % (imagestr)
- biffd.write(cfgstr)
-
- return
-
-python do_create_bif() {
-
- fp = d.getVar("BIF_FILE_PATH", True)
- biffd = open(fp, 'w')
- biffd.write("the_ROM_image:\n")
- biffd.write("{\n")
-
- bifattr = (d.getVar("BIF_COMMON_ATTR", True) or "").split()
- if bifattr:
- attrflags = d.getVarFlags("BIF_COMMON_ATTR") or {}
- create_bif(bifattr, attrflags,'', 1, biffd, d)
-
- bifpartition = (d.getVar("BIF_PARTITION_ATTR", True) or "").split()
- if bifpartition:
- attrflags = d.getVarFlags("BIF_PARTITION_ATTR") or {}
- attrimage = d.getVarFlags("BIF_PARTITION_IMAGE") or {}
- create_bif(bifpartition, attrflags, attrimage, 0, biffd, d)
-
- biffd.write("}")
- biffd.close()
-}
-addtask do_create_bif before do_xilinx_bootbin
-
-do_create_bif[vardeps] += "BIF_PARTITION_ATTR BIF_PARTITION_IMAGE BIF_COMMON_ATTR"
-do_create_bif[depends] += "${@get_bootbin_depends(d)}"
-
-def get_bootbin_depends(d):
- bootbindeps = ""
- bifpartition = (d.getVar("BIF_PARTITION_ATTR", True) or "").split()
- attrdepends = d.getVarFlags("BIF_PARTITION_DEPENDS") or {}
- for cfg in bifpartition:
- if cfg in attrdepends:
- bootbindeps = bootbindeps + " " + attrdepends[cfg] + ":do_deploy"
-
- return bootbindeps
-
-do_xilinx_bootbin[depends] += "${@get_bootbin_depends(d)}"
-
-do_xilinx_bootbin () {
- cd ${WORKDIR}
- rm -f BOOT.bin
- bootgen -image ${BIF_FILE_PATH} -arch ${KMACHINE} -w -o BOOT.bin
- if [ ! -e BOOT.bin ]; then
- bbfatal "bootgen failed. See log"
- fi
- install -m 0644 BOOT.bin ${DEPLOY_DIR_IMAGE}/BOOT.bin
-}
-addtask do_xilinx_bootbin before do_image
diff --git a/conf/machine/include/machine-xilinx-zynq.inc b/conf/machine/include/machine-xilinx-zynq.inc
deleted file mode 100644
index 1955748..0000000
--- a/conf/machine/include/machine-xilinx-zynq.inc
+++ /dev/null
@@ -1,19 +0,0 @@
-IMAGE_CLASSES_append ?= " xilinx-bootbin"
-
-#specify BIF partition attributes required for BOOT.bin
-BIF_PARTITION_ATTR ?= "fsbl bitstream u-boot"
-
-#specify BIF partition attributes for FSBL
-#bootloader is FSBL. Location where FSBL binary is present and dependency to build FSBL
-BIF_PARTITION_ATTR[fsbl] ?= "bootloader"
-BIF_PARTITION_IMAGE[fsbl] ?= "${DEPLOY_DIR_IMAGE}/fsbl-${MACHINE}.elf"
-BIF_PARTITION_DEPENDS[fsbl] ?= "virtual/fsbl"
-
-#specify BIF partition attributes for u-boot
-#Location where u-boot binary is present
-BIF_PARTITION_IMAGE[u-boot] ?= "${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.elf"
-BIF_PARTITION_DEPENDS[u-boot] ?= "virtual/bootloader"
-
-# enable bitstream-Note this is not enabled by default (missing in BIF_PARTITION_ATTR)
-BIF_PARTITION_IMAGE[bitstream] ?= "${DEPLOY_DIR_IMAGE}/download-${MACHINE}.bit"
-BIF_PARTITION_DEPENDS[bitstream] ?= "virtual/bitstream"
diff --git a/conf/machine/include/machine-xilinx-zynqmp.inc b/conf/machine/include/machine-xilinx-zynqmp.inc
deleted file mode 100644
index c620813..0000000
--- a/conf/machine/include/machine-xilinx-zynqmp.inc
+++ /dev/null
@@ -1,39 +0,0 @@
-# add Boot.bin dependency
-IMAGE_CLASSES_append ?= " xilinx-bootbin"
-
-# specify BIF common attribute for FSBL
-BIF_COMMON_ATTR ?= "fsbl_config"
-BIF_COMMON_ATTR[fsbl_config] ?= "a53_x64"
-
-
-# specify BIF partition attributes required for BOOT.bin
-BIF_PARTITION_ATTR ?= "fsbl bitstream pmu atf u-boot"
-
-# specify BIF partition attributes for FSBL
-# bootloader is FSBL. Location where FSBL binary is present and dependency to build FSBL
-BIF_PARTITION_ATTR[fsbl] ?= "bootloader"
-BIF_PARTITION_IMAGE[fsbl] ?= "${DEPLOY_DIR_IMAGE}/fsbl-${MACHINE}.elf"
-BIF_PARTITION_DEPENDS[fsbl] ?= "virtual/fsbl"
-
-# specify BIF partition attributes for PMU Firmware
-# destination cpu for PMU. Location where PMU binary is present and dependency to build PMU Firmware
-BIF_PARTITION_ATTR[pmu] ?= "destination_cpu=pmu"
-BIF_PARTITION_IMAGE[pmu] ?= "${DEPLOY_DIR_IMAGE}/pmu-firmware-${MACHINE}.elf"
-BIF_PARTITION_DEPENDS[pmu] ?= "virtual/pmufw"
-
-# specify BIF partition attributes for ATF
-# destination cpu for ATF, security levels. Location where ATF binary is present (dependency is not required as ATF is always built for ZU+, see zcu102-zynqmp.conf)
-BIF_PARTITION_ATTR[atf] ?= "destination_cpu=a53-0,exception_level=el-3,trustzone"
-BIF_PARTITION_IMAGE[atf] ?= "${DEPLOY_DIR_IMAGE}/arm-trusted-firmware.elf"
-BIF_PARTITION_DEPENDS[atf] ?= "arm-trusted-firmware"
-
-# specify BIF partition attributes for u-boot
-# destination cpu for u-boot, security levels. Location where u-boot binary is present (dependency is not required as u-boot is always built for ZU+, see zcu102-zynqmp.conf)
-BIF_PARTITION_ATTR[u-boot] ?= "destination_cpu=a53-0,exception_level=el-2"
-BIF_PARTITION_IMAGE[u-boot] ?= "${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.elf"
-BIF_PARTITION_DEPENDS[u-boot] ?= "virtual/bootloader"
-
-# enable bitstream-Note this is not enabled by default (missing in BIF_PARTITION_ATTR)
-BIF_PARTITION_ATTR[bitstream] ?= "destination_device=pl"
-BIF_PARTITION_IMAGE[bitstream] ?= "${DEPLOY_DIR_IMAGE}/download-${MACHINE}.bit"
-BIF_PARTITION_DEPENDS[bitstream] ?= "virtual/bitstream"
diff --git a/recipes-bsp/bootbin/machine-xilinx-zynq.inc b/recipes-bsp/bootbin/machine-xilinx-zynq.inc
new file mode 100644
index 0000000..aa537d6
--- /dev/null
+++ b/recipes-bsp/bootbin/machine-xilinx-zynq.inc
@@ -0,0 +1,17 @@
+#specify BIF partition attributes required for BOOT.bin
+BIF_PARTITION_ATTR ?= "fsbl bitstream u-boot"
+
+#specify BIF partition attributes for FSBL
+#bootloader is FSBL. Location where FSBL binary is present and dependency to build FSBL
+BIF_PARTITION_ATTR[fsbl] ?= "bootloader"
+BIF_PARTITION_IMAGE[fsbl] ?= "${DEPLOY_DIR_IMAGE}/fsbl-${MACHINE}.elf"
+BIF_PARTITION_DEPENDS[fsbl] ?= "virtual/fsbl"
+
+#specify BIF partition attributes for u-boot
+#Location where u-boot binary is present
+BIF_PARTITION_IMAGE[u-boot] ?= "${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.elf"
+BIF_PARTITION_DEPENDS[u-boot] ?= "virtual/bootloader"
+
+# enable bitstream-Note this is not enabled by default (missing in BIF_PARTITION_ATTR)
+BIF_PARTITION_IMAGE[bitstream] ?= "${DEPLOY_DIR_IMAGE}/download-${MACHINE}.bit"
+BIF_PARTITION_DEPENDS[bitstream] ?= "virtual/bitstream"
diff --git a/recipes-bsp/bootbin/machine-xilinx-zynqmp.inc b/recipes-bsp/bootbin/machine-xilinx-zynqmp.inc
new file mode 100644
index 0000000..7ee4cc1
--- /dev/null
+++ b/recipes-bsp/bootbin/machine-xilinx-zynqmp.inc
@@ -0,0 +1,35 @@
+# specify BIF common attribute for FSBL
+BIF_COMMON_ATTR ?= "fsbl_config"
+BIF_COMMON_ATTR[fsbl_config] ?= "a53_x64"
+
+# specify BIF partition attributes required for BOOT.bin
+BIF_PARTITION_ATTR ?= "fsbl bitstream pmu atf u-boot"
+
+# specify BIF partition attributes for FSBL
+# bootloader is FSBL. Location where FSBL binary is present and dependency to build FSBL
+BIF_PARTITION_ATTR[fsbl] ?= "bootloader"
+BIF_PARTITION_IMAGE[fsbl] ?= "${DEPLOY_DIR_IMAGE}/fsbl-${MACHINE}.elf"
+BIF_PARTITION_DEPENDS[fsbl] ?= "virtual/fsbl"
+
+# specify BIF partition attributes for PMU Firmware
+# destination cpu for PMU. Location where PMU binary is present and dependency to build PMU Firmware
+BIF_PARTITION_ATTR[pmu] ?= "destination_cpu=pmu"
+BIF_PARTITION_IMAGE[pmu] ?= "${DEPLOY_DIR_IMAGE}/pmu-firmware-${MACHINE}.elf"
+BIF_PARTITION_DEPENDS[pmu] ?= "virtual/pmu-firmware"
+
+# specify BIF partition attributes for ATF
+# destination cpu for ATF, security levels. Location where ATF binary is present (dependency is not required as ATF is always built for ZU+, see zcu102-zynqmp.conf)
+BIF_PARTITION_ATTR[atf] ?= "destination_cpu=a53-0,exception_level=el-3,trustzone"
+BIF_PARTITION_IMAGE[atf] ?= "${DEPLOY_DIR_IMAGE}/arm-trusted-firmware.elf"
+BIF_PARTITION_DEPENDS[atf] ?= "arm-trusted-firmware"
+
+# specify BIF partition attributes for u-boot
+# destination cpu for u-boot, security levels. Location where u-boot binary is present (dependency is not required as u-boot is always built for ZU+, see zcu102-zynqmp.conf)
+BIF_PARTITION_ATTR[u-boot] ?= "destination_cpu=a53-0,exception_level=el-2"
+BIF_PARTITION_IMAGE[u-boot] ?= "${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.elf"
+BIF_PARTITION_DEPENDS[u-boot] ?= "virtual/bootloader"
+
+# enable bitstream-Note this is not enabled by default (missing in BIF_PARTITION_ATTR)
+BIF_PARTITION_ATTR[bitstream] ?= "destination_device=pl"
+BIF_PARTITION_IMAGE[bitstream] ?= "${DEPLOY_DIR_IMAGE}/download-${MACHINE}.bit"
+BIF_PARTITION_DEPENDS[bitstream] ?= "virtual/bitstream"
diff --git a/recipes-bsp/bootbin/xilinx-bootbin_1.0.bb b/recipes-bsp/bootbin/xilinx-bootbin_1.0.bb
new file mode 100644
index 0000000..ecaee00
--- /dev/null
+++ b/recipes-bsp/bootbin/xilinx-bootbin_1.0.bb
@@ -0,0 +1,107 @@
+SUMMARY = "Generates boot.bin using bootgen tool"
+DESCRIPTION = "Manages task dependencies and creation of boot.bin. Use the \
+BIF_PARTITION_xyz global variables and flags to determine what makes it into \
+the image."
+
+LICENSE = "BSD"
+
+include machine-xilinx-${SOC_FAMILY}.inc
+
+inherit xsct-tc deploy
+
+PROVIDES = "virtual/boot-bin"
+
+DEPENDS += "${@get_bootbin_depends(d)}"
+
+PACKAGE_ARCH = "${MACHINE_ARCH}"
+
+BIF_FILE_PATH ?= "${B}/bootgen.bif"
+
+do_fetch[noexec] = "1"
+do_unpack[noexec] = "1"
+do_patch[noexec] = "1"
+
+def get_bootbin_depends(d):
+ bootbindeps = ""
+ bifpartition = (d.getVar("BIF_PARTITION_ATTR", True) or "").split()
+ attrdepends = d.getVarFlags("BIF_PARTITION_DEPENDS") or {}
+ for cfg in bifpartition:
+ if cfg in attrdepends:
+ bootbindeps = bootbindeps + " " + attrdepends[cfg]
+
+ return bootbindeps
+
+def create_bif(config, attrflags, attrimage, common_attr, biffd, d):
+ import re, os
+ for cfg in config:
+ if cfg not in attrflags and common_attr:
+ error_msg = "%s: invalid ATTRIBUTE" % (cfg)
+ bb.error("BIF attribute Error: %s " % (error_msg))
+ else:
+ if common_attr:
+ cfgval = attrflags[cfg].split(',')
+ cfgstr = "\t [%s] %s\n" % (cfg,', '.join(cfgval))
+ else:
+ if cfg not in attrimage:
+ error_msg = "%s: invalid or missing elf or image" % (cfg)
+ bb.error("BIF atrribute Error: %s " % (error_msg))
+ imagestr = d.expand(attrimage[cfg])
+ if os.stat(imagestr).st_size == 0:
+ bb.warn("Empty file %s, excluding from bif file" %(imagestr))
+ continue
+ if cfg in attrflags:
+ cfgval = attrflags[cfg].split(',')
+ cfgstr = "\t [%s] %s\n" % (', '.join(cfgval), imagestr)
+ else:
+ cfgstr = "\t %s\n" % (imagestr)
+ biffd.write(cfgstr)
+
+ return
+
+python do_configure() {
+
+ fp = d.getVar("BIF_FILE_PATH", True)
+ biffd = open(fp, 'w')
+ biffd.write("the_ROM_image:\n")
+ biffd.write("{\n")
+
+ bifattr = (d.getVar("BIF_COMMON_ATTR", True) or "").split()
+ if bifattr:
+ attrflags = d.getVarFlags("BIF_COMMON_ATTR") or {}
+ create_bif(bifattr, attrflags,'', 1, biffd, d)
+
+ bifpartition = (d.getVar("BIF_PARTITION_ATTR", True) or "").split()
+ if bifpartition:
+ attrflags = d.getVarFlags("BIF_PARTITION_ATTR") or {}
+ attrimage = d.getVarFlags("BIF_PARTITION_IMAGE") or {}
+ create_bif(bifpartition, attrflags, attrimage, 0, biffd, d)
+
+ biffd.write("}")
+ biffd.close()
+}
+
+do_configure[vardeps] += "BIF_PARTITION_ATTR BIF_PARTITION_IMAGE BIF_COMMON_ATTR"
+
+do_compile() {
+ cd ${WORKDIR}
+ rm -f ${B}/BOOT.bin
+ bootgen -image ${BIF_FILE_PATH} -arch ${SOC_FAMILY} -w -o ${B}/BOOT.bin
+ if [ ! -e ${B}/BOOT.bin ]; then
+ bbfatal "bootgen failed. See log"
+ fi
+}
+
+do_install() {
+ :
+}
+
+BOOTBIN_BASE_NAME ?= "BOOT-${MACHINE}-${DATETIME}"
+BOOTBIN_BASE_NAME[vardepsexclude] = "DATETIME"
+
+do_deploy() {
+ install -d ${DEPLOYDIR}
+ install -m 0644 ${B}/BOOT.bin ${DEPLOYDIR}/${BOOTBIN_BASE_NAME}.bin
+ ln -sf ${BOOTBIN_BASE_NAME}.bin ${DEPLOYDIR}/BOOT-${MACHINE}.bin
+}
+addtask do_deploy before do_build after do_compile
+
--
2.7.4
More information about the meta-xilinx
mailing list