When building a FIT image with device trees, each device tree lands in a FIT section and is referenced by a FIT configuration node.
FIT images however also allow referencing the same device tree from multiple configurations. This can be useful to reduce FIT image size while staying compatible with existing bootloaders. Allow kernel-fitimage.bbclass users to take advantage of this by mapping each symlink to a regular device tree included in the FIT to a configuration that references a common device tree section. Signed-off-by: Ahmad Fatoum <[email protected]> --- meta/classes-recipe/kernel-fitimage.bbclass | 33 ++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/meta/classes-recipe/kernel-fitimage.bbclass b/meta/classes-recipe/kernel-fitimage.bbclass index 6307e3c50a3f..7980910aa8c4 100644 --- a/meta/classes-recipe/kernel-fitimage.bbclass +++ b/meta/classes-recipe/kernel-fitimage.bbclass @@ -354,6 +354,27 @@ EOF fi } +# +# echoes symlink destination if it points below directory +# +# $1 ... file that's a potential symlink +# $2 ... expected parent directory +symlink_points_below() { + file="$2/$1" + dir=$2 + + if ! [ -L "$file" ]; then + return + fi + + realpath="$(realpath --relative-to=$dir $file)" + if [ -z "${realpath%%../*}" ]; then + return + fi + + echo "$realpath" +} + # # Emit the fitImage ITS configuration section # @@ -392,7 +413,13 @@ fitimage_emit_section_config() { setup_line="" default_line="" + dtb_image_sect=$(symlink_points_below $dtb_image "${EXTERNAL_KERNEL_DEVICETREE}") + if [ -z "$dtb_image_sect" ]; then + dtb_image_sect=$dtb_image + fi + dtb_image=$(echo $dtb_image | tr '/' '_') + dtb_image_sect=$(echo "${dtb_image_sect}" | tr '/' '_') # conf node name is selected based on dtb ID if it is present, # otherwise its selected based on kernel ID @@ -411,7 +438,7 @@ fitimage_emit_section_config() { if [ -n "$dtb_image" ]; then conf_desc="$conf_desc${sep}FDT blob" sep=", " - fdt_line="fdt = \"fdt-$dtb_image\";" + fdt_line="fdt = \"fdt-$dtb_image_sect\";" fi if [ -n "$ramdisk_id" ]; then @@ -568,6 +595,10 @@ fitimage_assemble() { echo "$DTBS" | tr ' ' '\n' | grep -xq "$DTB" && continue DTBS="$DTBS $DTB" + + # Also skip if a symlink. We'll later have each config section point at it + [ $(symlink_points_below $DTB "${EXTERNAL_KERNEL_DEVICETREE}") ] && continue + DTB=$(echo $DTB | tr '/' '_') fitimage_emit_section_dtb $1 $DTB "${EXTERNAL_KERNEL_DEVICETREE}/$DTB" done -- 2.30.2
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#172154): https://lists.openembedded.org/g/openembedded-core/message/172154 Mute This Topic: https://lists.openembedded.org/mt/94581142/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
