Skip to content

Commit

Permalink
base: kernel-lmp-fitimage: add support for FIT_LOADABLES
Browse files Browse the repository at this point in the history
Extend this class to handle FIT_LOADABLES as a list of deployed files
to be added to the kernel fitimage.  This allows subscribers to
retreive these files in u-boot where the contents are verified prior
to using.

Example would be to add the following line to machine.conf:
FIT_LOADABLES = "core0_m4_image.bin core1_m4_image.bin"

- A recipe would place those files in ${DEPLOYDIR} in do_deploy
- Then an additional do_compile[depends] is added to the kernel
  recipe such as:
  do_compile[depends] += "<recipe>:do_deploy"

Signed-off-by: Michael Scott <[email protected]>
  • Loading branch information
mike-scott committed Jul 30, 2020
1 parent 42ccce1 commit 3d381b7
Showing 1 changed file with 68 additions and 6 deletions.
74 changes: 68 additions & 6 deletions meta-lmp-base/classes/kernel-lmp-fitimage.bbclass
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ inherit kernel-fitimage

# Default value for deployment filenames
FPGA_BINARY ?= "fpga.bin"
FIT_LOADABLES ?= ""

#
# Emit the fitImage ITS configuration section
Expand All @@ -14,7 +15,8 @@ FPGA_BINARY ?= "fpga.bin"
# $4 ... ramdisk ID
# $5 ... setup ID
# $6 ... fpga ID
# $7 ... default flag
# $7 ... loadable ID
# $8 ... default flag
fitimage_emit_section_config() {

conf_csum="${FIT_HASH_ALG}"
Expand All @@ -31,6 +33,7 @@ fitimage_emit_section_config() {
ramdisk_line=""
setup_line=""
fpga_line=""
loadable_line=""
default_line=""

if [ -n "${2}" ]; then
Expand Down Expand Up @@ -61,19 +64,33 @@ fitimage_emit_section_config() {
fpga_line="fpga = \"fpga@${6}\";"
fi

if [ "${7}" = "1" ]; then
if [ -n "${7}" ]; then
i=0
for LOADABLE in ${7}; do
if [ -e ${DEPLOY_DIR_IMAGE}/${LOADABLE} ]; then
i=`expr ${i} + 1`
if [ -n "${loadable_line}" ]; then
conf_desc="${conf_desc}${sep}loadables"
fi
loadable_line="${loadable_line}loadable_${i} = \"loadable@${LOADABLE}\"; "
fi
done
fi

if [ "${8}" = "1" ]; then
default_line="default = \"conf@${3}\";"
fi

cat << EOF >> ${1}
${default_line}
conf@${3} {
description = "${7} ${conf_desc}";
description = "${8} ${conf_desc}";
${kernel_line}
${fdt_line}
${ramdisk_line}
${setup_line}
${fpga_line}
${loadable_line}
hash@1 {
algo = "${conf_csum}";
};
Expand Down Expand Up @@ -108,6 +125,16 @@ EOF
sign_line="${sign_line}${sep}\"fpga\""
fi

if [ -n "${7}" ]; then
i=0
for LOADABLE in ${7}; do
if [ -e ${DEPLOY_DIR_IMAGE}/${LOADABLE} ]; then
i=`expr ${i} + 1`
sign_line="${sign_line}${sep}\"loadable_${i}\""
fi
done
fi

sign_line="${sign_line};"

cat << EOF >> ${1}
Expand Down Expand Up @@ -154,6 +181,30 @@ fitimage_emit_section_fpga() {
EOF
}

#
# Emit the fitImage ITS loadables section
#
# $1 ... .its filename
# $2 ... Image name
# $3 ... Path to loadable image
fitimage_emit_section_loadable() {

loadable_csum="${FIT_HASH_ALG}"

cat << EOF >> ${1}
loadable@${2} {
description = "Loadable";
data = /incbin/("${3}");
type = "loadable";
arch = "${UBOOT_ARCH}";
compression = "none";
hash@1 {
algo = "${loadable_csum=}";
};
};
EOF
}

#
# Assemble fitImage
#
Expand Down Expand Up @@ -226,6 +277,17 @@ fitimage_assemble() {
fitimage_emit_section_fpga ${1} "${fpgacount}" ${DEPLOY_DIR_IMAGE}/${FPGA_BINARY}
fi

#
# Step 4a: Prepare a loadable sections.
#
if [ -n "${FIT_LOADABLES}" ]; then
for LOADABLE in ${FIT_LOADABLES}; do
if [ -e ${DEPLOY_DIR_IMAGE}/${LOADABLE} ]; then
fitimage_emit_section_loadable ${1} "${LOADABLE}" ${DEPLOY_DIR_IMAGE}/${LOADABLE}
fi
done
fi

#
# Step 5: Prepare a ramdisk section.
#
Expand Down Expand Up @@ -259,14 +321,14 @@ fitimage_assemble() {
for DTB in ${DTBS}; do
dtb_ext=${DTB##*.}
if [ "${dtb_ext}" = "dtbo" ]; then
fitimage_emit_section_config ${1} "" "${DTB}" "" "" "" "`expr ${i} = ${dtbcount}`"
fitimage_emit_section_config ${1} "" "${DTB}" "" "" "" "${FIT_LOADABLES}" "`expr ${i} = ${dtbcount}`"
else
fitimage_emit_section_config ${1} "${kernelcount}" "${DTB}" "${ramdiskcount}" "${setupcount}" "${fpgacount}" "`expr ${i} = ${dtbcount}`"
fitimage_emit_section_config ${1} "${kernelcount}" "${DTB}" "${ramdiskcount}" "${setupcount}" "${fpgacount}" "${FIT_LOADABLES}" "`expr ${i} = ${dtbcount}`"
fi
i=`expr ${i} + 1`
done
else
fitimage_emit_section_config ${1} "${kernelcount}" "" "${ramdiskcount}" "${setupcount}" "${fpgacount}" ""
fitimage_emit_section_config ${1} "${kernelcount}" "" "${ramdiskcount}" "${setupcount}" "${fpgacount}" "${FIT_LOADABLES}" ""
fi

fitimage_emit_section_maint ${1} sectend
Expand Down

0 comments on commit 3d381b7

Please sign in to comment.