Re: [meta-xilinx] [meta-xilinx-tools][RFC][patch 3/3] xilinx-bootbin: add multiple images support

2019-07-09 Thread Manjukumar Harthikote Matha
Hi JD,

> -Original Message-
> From: Jean-Francois Dagenais 
> Sent: Tuesday, July 9, 2019 8:45 AM
> To: meta-xilinx@yoctoproject.org; git 
> Cc: Jean-Francois Dagenais 
> Subject: [meta-xilinx-tools][RFC][patch 3/3] xilinx-bootbin: add multiple 
> images
> support
> 
> In certain scenarios, it might be desirable to produce multiple boot.bin 
> files. For
> example, a boot.bin which bundles kernel and dts, and another which loads u-
> boot.
> 
> The default behaviour is kept and the produced image, named boot-default.bin,
> will get the symlink named just "boot.bin".
> 

This is a good patch for generating multiple boot.bin .
I think we needed something like this for fpga-manager flow

> Signed-off-by: Jean-Francois Dagenais 
> ---
>  recipes-bsp/bootbin/xilinx-bootbin_1.0.bb | 78 ++--
> ---
>  1 file changed, 55 insertions(+), 23 deletions(-)
> 
> diff --git a/recipes-bsp/bootbin/xilinx-bootbin_1.0.bb b/recipes-
> bsp/bootbin/xilinx-bootbin_1.0.bb
> index 41e5f1e..f4dca7f 100644
> --- a/recipes-bsp/bootbin/xilinx-bootbin_1.0.bb
> +++ b/recipes-bsp/bootbin/xilinx-bootbin_1.0.bb
> @@ -5,12 +5,16 @@ the image."
> 
>  LICENSE = "BSD"
> 
> +PR = "r2"
> +

We should never set PR in recipes, this is best maintained by a PR server

>  include machine-xilinx-${SOC_FAMILY}.inc
> 
>  inherit deploy
> 
>  PROVIDES = "virtual/boot-bin"
> 
> +B = "${WORKDIR}/build"
> +
>  do_configure[depends] += "${@get_bootbin_depends(d)}"
> 
>  PACKAGE_ARCH = "${MACHINE_ARCH}"
> @@ -21,15 +25,24 @@ BOOTGEN_EXTRA_ARGS ?= ""
> 
>  BIF_PARTITIONS_zynqmp = "${@'fsbl pmu atf u-boot' if
> d.getVar('FPGA_MNGR_RECONFIG_ENABLE') == '1' else 'fsbl bitstream pmu atf
> u-boot'}"
> 
> +XILINX_BOOTBIN_IMAGES ??= "default"
> +
>  inherit nopackages
>  deltask do_fetch
>  deltask do_patch
>  deltask do_unpack
>  deltask do_install
> 
> +python () {
> +if not d.getVar("BIF_PARTITIONS_default"):
> +d.setVar("BIF_PARTITIONS_default", d.getVar("BIF_PARTITIONS"))
> +}
> +
>  def get_bootbin_depends(d):
>  bootbindeps = ""
> -bifpartitions = (d.getVar("BIF_PARTITIONS", True) or "").split()
> +bifpartitions = set()
> +for image in d.getVar("XILINX_BOOTBIN_IMAGES").split():
> +bifpartitions |= set((d.getVar("BIF_PARTITIONS_%s" % image) or
> + "").split())
>  attrdepends = d.getVarFlags("BIF_PARTITION_DEPENDS") or {}
>  for partition in bifpartitions:
>  if partition in attrdepends:
> @@ -37,7 +50,7 @@ def get_bootbin_depends(d):
> 
>  return bootbindeps
> 
> -def create_bif(config, attrflags, attrimage, common_attr, biffd, d):
> +def create_bif_partitions(config, attrflags, attrimage, common_attr, biffd, 
> d):
>  import re, os
>  for cfg in config:
>  if cfg not in attrflags and common_attr:
> @@ -64,9 +77,7 @@ def create_bif(config, attrflags, attrimage, common_attr,
> biffd, d):
> 
>  return
> 
> -python do_configure() {
> -
> -fp = d.getVar("BIF_FILE_PATH", True)
> +def create_bif_file(d, fp, bifpartitions):
>  biffd = open(fp, 'w')
>  biffd.write("the_ROM_image:\n")
>  biffd.write("{\n")
> @@ -74,32 +85,47 @@ python do_configure() {
>  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)
> +create_bif_partitions(bifattr, attrflags,'', 1, biffd, d)
> 
> -bifpartition = (d.getVar("BIF_PARTITIONS", 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)
> +attrflags = d.getVarFlags("BIF_PARTITION_ATTR") or {}
> +attrimage = d.getVarFlags("BIF_PARTITION_IMAGE") or {}
> +create_bif_partitions(bifpartitions, attrflags, attrimage, 0,
> + biffd, d)
> 
>  biffd.write("}")
>  biffd.close()
> -}
> 
> -do_configure[vardeps] += "BIF_PARTITIONS BIF_PARTITION_ATTR
> BIF_PARTITION_IMAGE BIF_COMMON_ATTR"
> +python do_configure() {
> +for image in d.getVar("XILINX_BOOTBIN_IMAGES").split():
> +bifpartitions = d.getVar("BIF_PARTITIONS_" + image)
> +if not bifpartitions:
> +continue
> +create_bif_file(d, "bootgen-%s.bif" % image,
> +bifpartitions.split()) } do_configure[vardeps] += "\
> +XILINX_BOOTBIN_IMAGES \
> +BIF_PARTITIONS \
> +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}
> ${BOOTGEN_EXTRA_ARGS} -w -o ${B}/BOOT.bin
> -if [ ! -e ${B}/BOOT.bin ]; then
> -bbfatal "bootgen failed. See log"
> -fi
> +pwd
> +ls -la
> +rm -f boot*.bin BOOT.bin
> +for image in ${XILINX_BOOTBIN_IMAGES}
> +do
> +bootbin=boot-${image}.bin
> +boo

[meta-xilinx] [meta-xilinx-tools][RFC][patch 3/3] xilinx-bootbin: add multiple images support

2019-07-09 Thread Jean-Francois Dagenais
In certain scenarios, it might be desirable to produce multiple boot.bin
files. For example, a boot.bin which bundles kernel and dts, and another
which loads u-boot.

The default behaviour is kept and the produced image, named
boot-default.bin, will get the symlink named just "boot.bin".

Signed-off-by: Jean-Francois Dagenais 
---
 recipes-bsp/bootbin/xilinx-bootbin_1.0.bb | 78 ++-
 1 file changed, 55 insertions(+), 23 deletions(-)

diff --git a/recipes-bsp/bootbin/xilinx-bootbin_1.0.bb 
b/recipes-bsp/bootbin/xilinx-bootbin_1.0.bb
index 41e5f1e..f4dca7f 100644
--- a/recipes-bsp/bootbin/xilinx-bootbin_1.0.bb
+++ b/recipes-bsp/bootbin/xilinx-bootbin_1.0.bb
@@ -5,12 +5,16 @@ the image."
 
 LICENSE = "BSD"
 
+PR = "r2"
+
 include machine-xilinx-${SOC_FAMILY}.inc
 
 inherit deploy
 
 PROVIDES = "virtual/boot-bin"
 
+B = "${WORKDIR}/build"
+
 do_configure[depends] += "${@get_bootbin_depends(d)}"
 
 PACKAGE_ARCH = "${MACHINE_ARCH}"
@@ -21,15 +25,24 @@ BOOTGEN_EXTRA_ARGS ?= ""
 
 BIF_PARTITIONS_zynqmp = "${@'fsbl pmu atf u-boot' if 
d.getVar('FPGA_MNGR_RECONFIG_ENABLE') == '1' else 'fsbl bitstream pmu atf 
u-boot'}"
 
+XILINX_BOOTBIN_IMAGES ??= "default"
+
 inherit nopackages
 deltask do_fetch
 deltask do_patch
 deltask do_unpack
 deltask do_install
 
+python () {
+if not d.getVar("BIF_PARTITIONS_default"):
+d.setVar("BIF_PARTITIONS_default", d.getVar("BIF_PARTITIONS"))
+}
+
 def get_bootbin_depends(d):
 bootbindeps = ""
-bifpartitions = (d.getVar("BIF_PARTITIONS", True) or "").split()
+bifpartitions = set()
+for image in d.getVar("XILINX_BOOTBIN_IMAGES").split():
+bifpartitions |= set((d.getVar("BIF_PARTITIONS_%s" % image) or 
"").split())
 attrdepends = d.getVarFlags("BIF_PARTITION_DEPENDS") or {}
 for partition in bifpartitions:
 if partition in attrdepends:
@@ -37,7 +50,7 @@ def get_bootbin_depends(d):
 
 return bootbindeps
 
-def create_bif(config, attrflags, attrimage, common_attr, biffd, d):
+def create_bif_partitions(config, attrflags, attrimage, common_attr, biffd, d):
 import re, os
 for cfg in config:
 if cfg not in attrflags and common_attr:
@@ -64,9 +77,7 @@ def create_bif(config, attrflags, attrimage, common_attr, 
biffd, d):
 
 return
 
-python do_configure() {
-
-fp = d.getVar("BIF_FILE_PATH", True)
+def create_bif_file(d, fp, bifpartitions):
 biffd = open(fp, 'w')
 biffd.write("the_ROM_image:\n")
 biffd.write("{\n")
@@ -74,32 +85,47 @@ python do_configure() {
 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)
+create_bif_partitions(bifattr, attrflags,'', 1, biffd, d)
 
-bifpartition = (d.getVar("BIF_PARTITIONS", 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)
+attrflags = d.getVarFlags("BIF_PARTITION_ATTR") or {}
+attrimage = d.getVarFlags("BIF_PARTITION_IMAGE") or {}
+create_bif_partitions(bifpartitions, attrflags, attrimage, 0, biffd, d)
 
 biffd.write("}")
 biffd.close()
-}
 
-do_configure[vardeps] += "BIF_PARTITIONS BIF_PARTITION_ATTR 
BIF_PARTITION_IMAGE BIF_COMMON_ATTR"
+python do_configure() {
+for image in d.getVar("XILINX_BOOTBIN_IMAGES").split():
+bifpartitions = d.getVar("BIF_PARTITIONS_" + image)
+if not bifpartitions:
+continue
+create_bif_file(d, "bootgen-%s.bif" % image, bifpartitions.split())
+}
+do_configure[vardeps] += "\
+XILINX_BOOTBIN_IMAGES \
+BIF_PARTITIONS \
+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} ${BOOTGEN_EXTRA_ARGS} 
-w -o ${B}/BOOT.bin
-if [ ! -e ${B}/BOOT.bin ]; then
-bbfatal "bootgen failed. See log"
-fi
+pwd
+ls -la
+rm -f boot*.bin BOOT.bin
+for image in ${XILINX_BOOTBIN_IMAGES}
+do
+bootbin=boot-${image}.bin
+bootgen -image bootgen-${image}.bif -arch ${SOC_FAMILY} 
${BOOTGEN_EXTRA_ARGS} -w -o boot-${image}.bin
+if [ ! -e ${bootbin} ]; then
+bbfatal "bootgen ${bootbin} failed. See log"
+fi
+done
 }
 
 do_compile_append_versal() {
 dd if=/dev/zero bs=256M count=1  > ${B}/QEMU_qspi.bin
-dd if=${B}/BOOT.bin of=${B}/QEMU_qspi.bin bs=1 seek=0 conv=notrunc
+dd if=${B}/boot-default.bin of=${B}/QEMU_qspi.bin bs=1 seek=0 conv=notrunc
 dd if=${DEPLOY_DIR_IMAGE}/boot.scr of=${B}/QEMU_qspi.bin bs=1 
seek=66584576 conv=notrunc
 }
 
@@ -111,9 +137,15 @@ BOOTBIN_BASE_NAME[vardepsexclude] = "DATETIME"
 
 do_deploy() {
 install -d ${DEPLOYDIR}
-install -m 0644 ${B}/BOOT.bin ${DEPLOYDIR}/${BOOTB