From 6fdccd557b55ee47dac57f42854d52179547c3eb Mon Sep 17 00:00:00 2001 From: Mark Hatle Date: Wed, 18 May 2022 11:16:49 -0700 Subject: u-boot-xlnx: Move all u-boot FIT image (blob) implementation to here The implementation appeared to have been split between meta-som and meta-xilinx-core. The core implementation should be generic and in meta-xilinx-core. Specifics for the som board (or other boards) will be captured in the board specific layers. Note: This code may be moved in the future as part of a consolidation of device tree related items. Signed-off-by: Mark Hatle (cherry picked from commit b3470a5676ffb13addb446d0e8842e83b9c05eb2) Signed-off-by: Mark Hatle --- meta-xilinx-core/recipes-bsp/libdfx/libdfx_1.0.bb | 2 +- .../recipes-bsp/u-boot/u-boot-xlnx-blob.inc | 156 +++++++++++++++++++++ .../recipes-bsp/u-boot/u-boot-xlnx.inc | 5 +- 3 files changed, 159 insertions(+), 4 deletions(-) create mode 100644 meta-xilinx-core/recipes-bsp/u-boot/u-boot-xlnx-blob.inc (limited to 'meta-xilinx-core/recipes-bsp') diff --git a/meta-xilinx-core/recipes-bsp/libdfx/libdfx_1.0.bb b/meta-xilinx-core/recipes-bsp/libdfx/libdfx_1.0.bb index adf89c55..83ae7722 100644 --- a/meta-xilinx-core/recipes-bsp/libdfx/libdfx_1.0.bb +++ b/meta-xilinx-core/recipes-bsp/libdfx/libdfx_1.0.bb @@ -8,7 +8,7 @@ BRANCH ?= "xlnx_rel_v2022.1" REPO ?= "git://github.com/Xilinx/libdfx.git;protocol=https" BRANCHARG = "${@['nobranch=1', 'branch=${BRANCH}'][d.getVar('BRANCH', True) != '']}" SRC_URI = "${REPO};${BRANCHARG}" -SRCREV = "1a1454ed0c3a56912250182f591c051f355fbf47" +SRCREV = "96d8462a72b9b64e1057f8864795b5f60a2fc884" COMPATIBLE_MACHINE = "^$" COMPATIBLE_MACHINE:zynqmp = "zynqmp" diff --git a/meta-xilinx-core/recipes-bsp/u-boot/u-boot-xlnx-blob.inc b/meta-xilinx-core/recipes-bsp/u-boot/u-boot-xlnx-blob.inc new file mode 100644 index 00000000..717b8dd3 --- /dev/null +++ b/meta-xilinx-core/recipes-bsp/u-boot/u-boot-xlnx-blob.inc @@ -0,0 +1,156 @@ +# U-boot fitimage/blob generator + +UBOOT_IMAGE_BLOB ?= "" +DT_BLOB_DIR ?= "${B}/arch/arm/dts/dt-blob" +UBOOT_BLOB_NAME ?= "${MACHINE}-fit-dtb${IMAGE_VERSION_SUFFIX}.blob" + +IMPORT_CC_DTBS ?= "" +CC_DTBS_DUP ?= "" + +MKIMAGE_DTBLOB_OPTS ?= "-E -B 0x8" + +# Everything is swtiched on with UBOOT_IMAGE_BLOB = '1' +inherit ${@'image-artifact-names' if d.getVar('UBOOT_IMAGE_BLOB') == "1" else ''} + +python() { + if d.getVar('UBOOT_IMAGE_BLOB') == "1": + d.appendVarFlag('do_compile', 'postfuncs', ' do_blob_generate') + d.appendVarFlag('do_compile', 'cleandirs', ' ${DT_BLOB_DIR}') + d.appendVar('PROVIDES', ' u-boot-xlnx-fit-blob') + d.appendVar('DEPENDS', ' u-boot-mkimage-native') +} + +dtblob_emit_its_section() { + case $2 in + header) + cat << EOF > $1 +/dts-v1/; + +/ { + description = "DT Blob Creation"; +EOF + ;; + imagestart) + cat << EOF >> $1 + + images { +EOF + ;; + confstart) + cat << EOF >> $1 + + configurations { +EOF + ;; + sectend) + cat << EOF >> $1 + }; +EOF + ;; + fitend) + cat << EOF >> $1 +}; +EOF + ;; + esac +} + +dtblob_emit_dtb () { + dtb_csum="md5" + cat << EOF >> $1 + fdt-$2 { + description = "$(basename $3 .dtb)"; + data = /incbin/("$3"); + type = "flat_dt"; + arch = "arm64"; + compression = "none"; + hash-1 { + algo = "$dtb_csum"; + }; + }; +EOF +} + +#1.file name +#2.config node +#3.config node description +#4.DTB count +dtblob_emit_config () { + default_dtb=1 + if [ $4 -eq $default_dtb ]; then + cat << EOF >> $1 + default = "config_$4"; +EOF + fi + cat << EOF >> $1 + config_$4 { + description = "$3"; + fdt = "fdt-$2"; + }; +EOF +} + +do_blob_generate () { + oe_runmake -C ${S} O=${B} dtbs + install -d ${DT_BLOB_DIR} + for CC_DTB in ${IMPORT_CC_DTBS}; do + DTBO=$(echo $CC_DTB | cut -d: -f1) + DTB=$(echo $CC_DTB | cut -d: -f2) + bbnote "fdtoverlay -o ${DT_BLOB_DIR}/${DTB} -i ${RECIPE_SYSROOT}/${DTB_PATH}/${DTB_NAME} ${B}/arch/arm/dts/${DTBO}" + if [ -f ${B}/arch/arm/dts/${DTBO} ]; then + fdtoverlay -o ${DT_BLOB_DIR}/${DTB} \ + -i ${RECIPE_SYSROOT}/${DTB_PATH}/${DTB_NAME} ${B}/arch/arm/dts/${DTBO} + fi + done + + cd ${DT_BLOB_DIR} + its_filename="dtblob.its" + dtblob_emit_its_section "${its_filename}" "header" + dtblob_emit_its_section "${its_filename}" "imagestart" + for dtb in ${RECIPE_SYSROOT}/${DTB_PATH}/${DTB_NAME} $(find ${DT_BLOB_DIR} -name '*.dtb' | sort); do + dtblob_emit_dtb "${its_filename}" "$(basename $dtb .dtb)" "$dtb" + done + dtblob_emit_its_section "${its_filename}" "sectend" + dtblob_emit_its_section "${its_filename}" "confstart" + dtbcount=1 + for dtb in ${RECIPE_SYSROOT}/${DTB_PATH}/${DTB_NAME} $(find ${DT_BLOB_DIR} -name '*.dtb' | sort); do + dtblob_emit_config "${its_filename}" "$(basename $dtb .dtb)" "$(basename $dtb .dtb)" "$dtbcount" + dtbcount=`expr $dtbcount + 1` + done + + for CC_DTB_DUP in ${CC_DTBS_DUP}; do + DTB=$(echo $CC_DTB_DUP | cut -d: -f1) + DUP_DTB=$(echo $CC_DTB_DUP | cut -d: -f2) + if [ -f ${DT_BLOB_DIR}/${DTB}.dtb ]; then + bbnote "Node ${DT_BLOB_DIR}/${DTB} with ${DT_BLOB_DIR}/${DUP_DTB}" + dtblob_emit_config "${its_filename}" "$DTB" "$DUP_DTB" "$dtbcount" + dtbcount=`expr $dtbcount + 1` + fi + done + + dtblob_emit_its_section "${its_filename}" "sectend" + dtblob_emit_its_section "${its_filename}" "fitend" + + mkimage ${MKIMAGE_DTBLOB_OPTS} -f "${its_filename}" "${UBOOT_BLOB_NAME}" +} + +do_install:append() { + ( + cd ${B} + + if [ -e "${DT_BLOB_DIR}/${UBOOT_BLOB_NAME}" ]; then + install -d ${D}/boot + install -m 0644 ${DT_BLOB_DIR}/${UBOOT_BLOB_NAME} ${D}/boot + ln -sf `basename ${UBOOT_BLOB_NAME}` ${D}/boot/fit-dtb.blob + fi + ) +} + +do_deploy:prepend() { + cd ${B} + + if [ -e "${DT_BLOB_DIR}/${UBOOT_BLOB_NAME}" ]; then + install -m 0644 ${DT_BLOB_DIR}/${UBOOT_BLOB_NAME} ${DEPLOYDIR}/ + ln -sf `basename ${UBOOT_BLOB_NAME}` ${DEPLOYDIR}/fit-dtb.blob + fi +} diff --git a/meta-xilinx-core/recipes-bsp/u-boot/u-boot-xlnx.inc b/meta-xilinx-core/recipes-bsp/u-boot/u-boot-xlnx.inc index f0ea2ca3..909dd72a 100644 --- a/meta-xilinx-core/recipes-bsp/u-boot/u-boot-xlnx.inc +++ b/meta-xilinx-core/recipes-bsp/u-boot/u-boot-xlnx.inc @@ -32,11 +32,10 @@ python __anonymous () { d.appendVarFlag('do_configure', 'depends', ' virtual/dtb:do_populate_sysroot') if d.getVar("DTB_NAME") is not None: d.setVar('DTB_NAME', d.getVar('BASE_DTS')+ '.dtb') - - if d.getVar('UBOOT_IMAGE_BLOB') == "1": - d.appendVarFlag('do_compile', 'postfuncs', ' do_blob_generate') } +require u-boot-xlnx-blob.inc + UBOOTELF_NODTB_IMAGE ?= "u-boot-nodtb.elf" UBOOTELF_NODTB_BINARY ?= "u-boot" do_deploy:prepend() { -- cgit v1.2.3-54-g00ecf