* [PATCH] kernel-fitimage: Fix the default dtb config check
@ 2023-03-31 6:17 arslan_ahmad
2023-04-05 14:22 ` [OE-core] " Alexandre Belloni
0 siblings, 1 reply; 2+ messages in thread
From: arslan_ahmad @ 2023-03-31 6:17 UTC (permalink / raw)
To: openembedded-core; +Cc: Arslan Ahmad
From: Arslan Ahmad <arslan_ahmad@mentor.com>
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.
Signed-off-by: Arslan Ahmad <arslan_ahmad@mentor.com>
---
meta/classes/kernel-fitimage.bbclass | 30 +++++++++++++++++++---------
1 file changed, 21 insertions(+), 9 deletions(-)
diff --git a/meta/classes/kernel-fitimage.bbclass b/meta/classes/kernel-fitimage.bbclass
index 27e17db951..c75d4e071f 100644
--- a/meta/classes/kernel-fitimage.bbclass
+++ b/meta/classes/kernel-fitimage.bbclass
@@ -345,6 +345,7 @@ EOF
# $5 ... u-boot script ID
# $6 ... config ID
# $7 ... default flag
+# $8 ... default DTB image name
fitimage_emit_section_config() {
conf_csum="${FIT_HASH_ALG}"
@@ -361,6 +362,7 @@ fitimage_emit_section_config() {
bootscr_id="$5"
config_id="$6"
default_flag="$7"
+ default_dtb_image="$8"
# Test if we have any DTBs at all
sep=""
@@ -372,7 +374,6 @@ fitimage_emit_section_config() {
bootscr_line=""
setup_line=""
default_line=""
- default_dtb_image="${FIT_CONF_DEFAULT_DTB}"
# conf node name is selected based on dtb ID if it is present,
# otherwise its selected based on kernel ID
@@ -418,11 +419,7 @@ fitimage_emit_section_config() {
# Select default node as user specified dtb when
# multiple dtb exists.
if [ -n "$default_dtb_image" ]; then
- if [ -s "${EXTERNAL_KERNEL_DEVICETREE}/$default_dtb_image" ]; then
- 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
+ default_line="default = \"${FIT_CONF_PREFIX}$default_dtb_image\";"
else
default_line="default = \"${FIT_CONF_PREFIX}$dtb_image\";"
fi
@@ -504,6 +501,7 @@ fitimage_assemble() {
ramdiskcount=$3
setupcount=""
bootscr_id=""
+ 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
@@ -542,6 +540,11 @@ fitimage_assemble() {
DTB_PATH="arch/${ARCH}/boot/$DTB"
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
@@ -556,6 +559,11 @@ fitimage_assemble() {
dtbcount=1
for DTB in $(find "${EXTERNAL_KERNEL_DEVICETREE}" -name '*.dtb' -printf '%P\n' | sort) \
$(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
@@ -566,6 +574,10 @@ fitimage_assemble() {
done
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
#
@@ -638,15 +650,15 @@ fitimage_assemble() {
for DTB in ${DTBS}; do
dtb_ext=${DTB##*.}
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
- 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
i=`expr $i + 1`
done
else
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
fitimage_emit_section_maint $1 sectend
--
2.40.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [OE-core] [PATCH] kernel-fitimage: Fix the default dtb config check
2023-03-31 6:17 [PATCH] kernel-fitimage: Fix the default dtb config check arslan_ahmad
@ 2023-04-05 14:22 ` Alexandre Belloni
0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2023-04-05 14:22 UTC (permalink / raw)
To: Arslan Ahmad; +Cc: openembedded-core
Hello,
On 31/03/2023 11:17:04+0500, Arslan Ahmad wrote:
> From: Arslan Ahmad <arslan_ahmad@mentor.com>
>
> 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.
>
> Signed-off-by: Arslan Ahmad <arslan_ahmad@mentor.com>
> ---
> meta/classes/kernel-fitimage.bbclass | 30 +++++++++++++++++++---------
> 1 file changed, 21 insertions(+), 9 deletions(-)
This doesn't apply on master, can you rebase?
>
> diff --git a/meta/classes/kernel-fitimage.bbclass b/meta/classes/kernel-fitimage.bbclass
> index 27e17db951..c75d4e071f 100644
> --- a/meta/classes/kernel-fitimage.bbclass
> +++ b/meta/classes/kernel-fitimage.bbclass
> @@ -345,6 +345,7 @@ EOF
> # $5 ... u-boot script ID
> # $6 ... config ID
> # $7 ... default flag
> +# $8 ... default DTB image name
> fitimage_emit_section_config() {
>
> conf_csum="${FIT_HASH_ALG}"
> @@ -361,6 +362,7 @@ fitimage_emit_section_config() {
> bootscr_id="$5"
> config_id="$6"
> default_flag="$7"
> + default_dtb_image="$8"
>
> # Test if we have any DTBs at all
> sep=""
> @@ -372,7 +374,6 @@ fitimage_emit_section_config() {
> bootscr_line=""
> setup_line=""
> default_line=""
> - default_dtb_image="${FIT_CONF_DEFAULT_DTB}"
>
> # conf node name is selected based on dtb ID if it is present,
> # otherwise its selected based on kernel ID
> @@ -418,11 +419,7 @@ fitimage_emit_section_config() {
> # Select default node as user specified dtb when
> # multiple dtb exists.
> if [ -n "$default_dtb_image" ]; then
> - if [ -s "${EXTERNAL_KERNEL_DEVICETREE}/$default_dtb_image" ]; then
> - 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
> + default_line="default = \"${FIT_CONF_PREFIX}$default_dtb_image\";"
> else
> default_line="default = \"${FIT_CONF_PREFIX}$dtb_image\";"
> fi
> @@ -504,6 +501,7 @@ fitimage_assemble() {
> ramdiskcount=$3
> setupcount=""
> bootscr_id=""
> + 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
> @@ -542,6 +540,11 @@ fitimage_assemble() {
> DTB_PATH="arch/${ARCH}/boot/$DTB"
> 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
> @@ -556,6 +559,11 @@ fitimage_assemble() {
> dtbcount=1
> for DTB in $(find "${EXTERNAL_KERNEL_DEVICETREE}" -name '*.dtb' -printf '%P\n' | sort) \
> $(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
> @@ -566,6 +574,10 @@ fitimage_assemble() {
> done
> 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
> #
> @@ -638,15 +650,15 @@ fitimage_assemble() {
> for DTB in ${DTBS}; do
> dtb_ext=${DTB##*.}
> 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
> - 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
> i=`expr $i + 1`
> done
> else
> 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
>
> fitimage_emit_section_maint $1 sectend
> --
> 2.40.0
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#179400): https://lists.openembedded.org/g/openembedded-core/message/179400
> Mute This Topic: https://lists.openembedded.org/mt/97968048/3617179
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alexandre.belloni@bootlin.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-04-05 14:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-31 6:17 [PATCH] kernel-fitimage: Fix the default dtb config check arslan_ahmad
2023-04-05 14:22 ` [OE-core] " Alexandre Belloni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox