1
0
mirror of https://git.yoctoproject.org/poky synced 2026-05-09 17:39:31 +00:00

kernel-fitimage: Fix the default dtb config check

The current check for default dtb image checks if the file exists and is
not empty but appends a slash to the path due to which the file is never
found. It also doesn't replace slash in filename with _ as done when
populating the DTB variable. A better way to check the existence of the
device tree would be from the list of DTBs since this is used during
compilation.

(From OE-Core rev: e8e31e11b158837804d029e85f5f8ed3c219a4ea)

Signed-off-by: Arslan Ahmad <arslan_ahmad@mentor.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Arslan Ahmad
2023-04-11 16:25:09 +05:00
committed by Richard Purdie
parent 042d94dce8
commit 03395abc2c
+26 -10
View File
@@ -388,6 +388,7 @@ symlink_points_below() {
# $5 ... u-boot script ID # $5 ... u-boot script ID
# $6 ... config ID # $6 ... config ID
# $7 ... default flag # $7 ... default flag
# $8 ... default DTB image name
fitimage_emit_section_config() { fitimage_emit_section_config() {
conf_csum="${FIT_HASH_ALG}" conf_csum="${FIT_HASH_ALG}"
@@ -404,6 +405,7 @@ fitimage_emit_section_config() {
bootscr_id="$5" bootscr_id="$5"
config_id="$6" config_id="$6"
default_flag="$7" default_flag="$7"
default_dtb_image="$8"
# Test if we have any DTBs at all # Test if we have any DTBs at all
sep="" sep=""
@@ -415,7 +417,6 @@ fitimage_emit_section_config() {
bootscr_line="" bootscr_line=""
setup_line="" setup_line=""
default_line="" default_line=""
default_dtb_image="${FIT_CONF_DEFAULT_DTB}"
dtb_image_sect=$(symlink_points_below $dtb_image "${EXTERNAL_KERNEL_DEVICETREE}") dtb_image_sect=$(symlink_points_below $dtb_image "${EXTERNAL_KERNEL_DEVICETREE}")
if [ -z "$dtb_image_sect" ]; then if [ -z "$dtb_image_sect" ]; then
@@ -469,11 +470,7 @@ fitimage_emit_section_config() {
# Select default node as user specified dtb when # Select default node as user specified dtb when
# multiple dtb exists. # multiple dtb exists.
if [ -n "$default_dtb_image" ]; then if [ -n "$default_dtb_image" ]; then
if [ -s "${EXTERNAL_KERNEL_DEVICETREE}/$default_dtb_image" ]; then default_line="default = \"${FIT_CONF_PREFIX}$default_dtb_image\";"
default_line="default = \"${FIT_CONF_PREFIX}$default_dtb_image\";"
else
bbwarn "Couldn't find a valid user specified dtb in ${EXTERNAL_KERNEL_DEVICETREE}/$default_dtb_image"
fi
else else
default_line="default = \"${FIT_CONF_PREFIX}$dtb_image\";" default_line="default = \"${FIT_CONF_PREFIX}$dtb_image\";"
fi fi
@@ -555,7 +552,8 @@ fitimage_assemble() {
ramdiskcount=$3 ramdiskcount=$3
setupcount="" setupcount=""
bootscr_id="" bootscr_id=""
rm -f $1 ${KERNEL_OUTPUT_DIR}/$2 default_dtb_image=""
rm -f $1 arch/${ARCH}/boot/$2
if [ -n "${UBOOT_SIGN_IMG_KEYNAME}" -a "${UBOOT_SIGN_KEYNAME}" = "${UBOOT_SIGN_IMG_KEYNAME}" ]; then if [ -n "${UBOOT_SIGN_IMG_KEYNAME}" -a "${UBOOT_SIGN_KEYNAME}" = "${UBOOT_SIGN_IMG_KEYNAME}" ]; then
bbfatal "Keys used to sign images and configuration nodes must be different." bbfatal "Keys used to sign images and configuration nodes must be different."
@@ -593,6 +591,13 @@ fitimage_assemble() {
DTB_PATH="${KERNEL_OUTPUT_DIR}/$DTB" DTB_PATH="${KERNEL_OUTPUT_DIR}/$DTB"
fi fi
# Set the default dtb image if it exists in the devicetree.
if [ ${FIT_CONF_DEFAULT_DTB} = $DTB ];then
default_dtb_image=$(echo "$DTB" | tr '/' '_')
fi
DTB=$(echo "$DTB" | tr '/' '_')
# Skip DTB if we've picked it up previously # Skip DTB if we've picked it up previously
echo "$DTBS" | tr ' ' '\n' | grep -xq "$DTB" && continue echo "$DTBS" | tr ' ' '\n' | grep -xq "$DTB" && continue
@@ -606,6 +611,13 @@ fitimage_assemble() {
dtbcount=1 dtbcount=1
for DTB in $(find "${EXTERNAL_KERNEL_DEVICETREE}" -name '*.dtb' -printf '%P\n' | sort) \ for DTB in $(find "${EXTERNAL_KERNEL_DEVICETREE}" -name '*.dtb' -printf '%P\n' | sort) \
$(find "${EXTERNAL_KERNEL_DEVICETREE}" -name '*.dtbo' -printf '%P\n' | sort); do $(find "${EXTERNAL_KERNEL_DEVICETREE}" -name '*.dtbo' -printf '%P\n' | sort); do
# Set the default dtb image if it exists in the devicetree.
if [ ${FIT_CONF_DEFAULT_DTB} = $DTB ];then
default_dtb_image=$(echo "$DTB" | tr '/' '_')
fi
DTB=$(echo "$DTB" | tr '/' '_')
# Skip DTB/DTBO if we've picked it up previously # Skip DTB/DTBO if we've picked it up previously
echo "$DTBS" | tr ' ' '\n' | grep -xq "$DTB" && continue echo "$DTBS" | tr ' ' '\n' | grep -xq "$DTB" && continue
@@ -619,6 +631,10 @@ fitimage_assemble() {
done done
fi fi
if [ -n "${FIT_CONF_DEFAULT_DTB}" ] && [ -z $default_dtb_image ]; then
bbwarn "${FIT_CONF_DEFAULT_DTB} is not available in the list of device trees."
fi
# #
# Step 3: Prepare a u-boot script section # Step 3: Prepare a u-boot script section
# #
@@ -691,15 +707,15 @@ fitimage_assemble() {
for DTB in ${DTBS}; do for DTB in ${DTBS}; do
dtb_ext=${DTB##*.} dtb_ext=${DTB##*.}
if [ "$dtb_ext" = "dtbo" ]; then if [ "$dtb_ext" = "dtbo" ]; then
fitimage_emit_section_config $1 "" "$DTB" "" "$bootscr_id" "" "`expr $i = $dtbcount`" fitimage_emit_section_config $1 "" "$DTB" "" "$bootscr_id" "" "`expr $i = $dtbcount`" "$default_dtb_image"
else else
fitimage_emit_section_config $1 $kernelcount "$DTB" "$ramdiskcount" "$bootscr_id" "$setupcount" "`expr $i = $dtbcount`" fitimage_emit_section_config $1 $kernelcount "$DTB" "$ramdiskcount" "$bootscr_id" "$setupcount" "`expr $i = $dtbcount`" "$default_dtb_image"
fi fi
i=`expr $i + 1` i=`expr $i + 1`
done done
else else
defaultconfigcount=1 defaultconfigcount=1
fitimage_emit_section_config $1 $kernelcount "" "$ramdiskcount" "$bootscr_id" "$setupcount" $defaultconfigcount fitimage_emit_section_config $1 $kernelcount "" "$ramdiskcount" "$bootscr_id" "$setupcount" $defaultconfigcount "$default_dtb_image"
fi fi
fitimage_emit_section_maint $1 sectend fitimage_emit_section_maint $1 sectend