Skip to content

Commit

Permalink
base: kernel-lmp-fitimage: add loadable
Browse files Browse the repository at this point in the history
- Rebased on top of the scarthgap branch

Signed-off-by: Daiane Angolini <daiane.angolini@foundries.io>
Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
  • Loading branch information
angolini authored and quaresmajose committed Nov 12, 2024
1 parent cf63556 commit 3948ad1
Showing 1 changed file with 66 additions and 2 deletions.
68 changes: 66 additions & 2 deletions meta-lmp-base/classes/kernel-lmp-fitimage.bbclass
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ python __anonymous () {
d.setVar('EXTERNAL_KERNEL_DEVICETREE', "${RECIPE_SYSROOT}/boot/devicetree")
}

# Default value for deployment filenames
FIT_LOADABLES ?= ""

# Description string
FIT_DESC ?= "Kernel fitImage for ${DISTRO_NAME}/${PV}/${MACHINE}"
Expand Down Expand Up @@ -393,6 +395,7 @@ symlink_points_below() {
# $6 ... config ID
# $7 ... default flag
# $8 ... default DTB image name
# $9 ... loadable ID
fitimage_emit_section_config() {

conf_csum="${FIT_HASH_ALG}"
Expand All @@ -410,6 +413,7 @@ fitimage_emit_section_config() {
config_id="$6"
default_flag="$7"
default_dtb_image="$8"
loadable_id="$9"

# Test if we have any DTBs at all
sep=""
Expand All @@ -422,6 +426,7 @@ fitimage_emit_section_config() {
setup_line=""
default_line=""
compatible_line=""
loadable_line=""

dtb_image_sect=$(symlink_points_below $dtb_image "${EXTERNAL_KERNEL_DEVICETREE}")
if [ -z "$dtb_image_sect" ]; then
Expand Down Expand Up @@ -476,6 +481,19 @@ fitimage_emit_section_config() {
setup_line="setup = \"setup-$config_id\";"
fi

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

if [ "$default_flag" = "1" ]; then
# default node is selected based on dtb ID if it is present,
# otherwise its selected based on kernel ID
Expand All @@ -502,6 +520,7 @@ fitimage_emit_section_config() {
$ramdisk_line
$bootscr_line
$setup_line
$loadable_line
hash-1 {
algo = "$conf_csum";
};
Expand Down Expand Up @@ -536,6 +555,16 @@ EOF
sign_line="$sign_line${sep}\"setup\""
fi

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

sign_line="$sign_line;"

cat << EOF >> $its_file
Expand All @@ -553,6 +582,30 @@ EOF
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 @@ -677,7 +730,18 @@ fitimage_assemble() {
fi

#
# Step 5: Prepare a ramdisk section.
# Step 5: 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 6: Prepare a ramdisk section.
#
if [ "x${ramdiskcount}" = "x1" ] && [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" ]; then
# Find and use the first initramfs image archive type we find
Expand Down Expand Up @@ -708,7 +772,7 @@ fitimage_assemble() {
fi

#
# Step 6: Prepare a configurations section
# Step 7: Prepare a configurations section
#
fitimage_emit_section_maint $1 confstart

Expand Down

0 comments on commit 3948ad1

Please sign in to comment.