summaryrefslogtreecommitdiffstats
path: root/meta/classes-recipe/kernel-fitimage.bbclass
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2022-10-26 15:22:19 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-10-28 09:44:52 +0100
commit54fe36f9c2b9b5a5581b1e875b411d9207dcbff1 (patch)
tree62469ea3ed088a9f2350d495fe3eb24a44965d91 /meta/classes-recipe/kernel-fitimage.bbclass
parent8219c822a9655a1cf083f5464f60d7d49f453485 (diff)
downloadpoky-54fe36f9c2b9b5a5581b1e875b411d9207dcbff1.tar.gz
kernel-fitimage: skip FDT section creation for applicable symlinks
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. (From OE-Core rev: 21e240da63239826f3ef50ceef40c9519e9030d8) Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes-recipe/kernel-fitimage.bbclass')
-rw-r--r--meta/classes-recipe/kernel-fitimage.bbclass33
1 files changed, 32 insertions, 1 deletions
diff --git a/meta/classes-recipe/kernel-fitimage.bbclass b/meta/classes-recipe/kernel-fitimage.bbclass
index 6307e3c50a..7980910aa8 100644
--- a/meta/classes-recipe/kernel-fitimage.bbclass
+++ b/meta/classes-recipe/kernel-fitimage.bbclass
@@ -355,6 +355,27 @@ EOF
355} 355}
356 356
357# 357#
358# echoes symlink destination if it points below directory
359#
360# $1 ... file that's a potential symlink
361# $2 ... expected parent directory
362symlink_points_below() {
363 file="$2/$1"
364 dir=$2
365
366 if ! [ -L "$file" ]; then
367 return
368 fi
369
370 realpath="$(realpath --relative-to=$dir $file)"
371 if [ -z "${realpath%%../*}" ]; then
372 return
373 fi
374
375 echo "$realpath"
376}
377
378#
358# Emit the fitImage ITS configuration section 379# Emit the fitImage ITS configuration section
359# 380#
360# $1 ... .its filename 381# $1 ... .its filename
@@ -392,7 +413,13 @@ fitimage_emit_section_config() {
392 setup_line="" 413 setup_line=""
393 default_line="" 414 default_line=""
394 415
416 dtb_image_sect=$(symlink_points_below $dtb_image "${EXTERNAL_KERNEL_DEVICETREE}")
417 if [ -z "$dtb_image_sect" ]; then
418 dtb_image_sect=$dtb_image
419 fi
420
395 dtb_image=$(echo $dtb_image | tr '/' '_') 421 dtb_image=$(echo $dtb_image | tr '/' '_')
422 dtb_image_sect=$(echo "${dtb_image_sect}" | tr '/' '_')
396 423
397 # conf node name is selected based on dtb ID if it is present, 424 # conf node name is selected based on dtb ID if it is present,
398 # otherwise its selected based on kernel ID 425 # otherwise its selected based on kernel ID
@@ -411,7 +438,7 @@ fitimage_emit_section_config() {
411 if [ -n "$dtb_image" ]; then 438 if [ -n "$dtb_image" ]; then
412 conf_desc="$conf_desc${sep}FDT blob" 439 conf_desc="$conf_desc${sep}FDT blob"
413 sep=", " 440 sep=", "
414 fdt_line="fdt = \"fdt-$dtb_image\";" 441 fdt_line="fdt = \"fdt-$dtb_image_sect\";"
415 fi 442 fi
416 443
417 if [ -n "$ramdisk_id" ]; then 444 if [ -n "$ramdisk_id" ]; then
@@ -568,6 +595,10 @@ fitimage_assemble() {
568 echo "$DTBS" | tr ' ' '\n' | grep -xq "$DTB" && continue 595 echo "$DTBS" | tr ' ' '\n' | grep -xq "$DTB" && continue
569 596
570 DTBS="$DTBS $DTB" 597 DTBS="$DTBS $DTB"
598
599 # Also skip if a symlink. We'll later have each config section point at it
600 [ $(symlink_points_below $DTB "${EXTERNAL_KERNEL_DEVICETREE}") ] && continue
601
571 DTB=$(echo $DTB | tr '/' '_') 602 DTB=$(echo $DTB | tr '/' '_')
572 fitimage_emit_section_dtb $1 $DTB "${EXTERNAL_KERNEL_DEVICETREE}/$DTB" 603 fitimage_emit_section_dtb $1 $DTB "${EXTERNAL_KERNEL_DEVICETREE}/$DTB"
573 done 604 done