diff mbox series

[v2] kernel-fitImage: only include valid compatible line

Message ID 20240306164214.445656-1-christian.taedcke-oss@weidmueller.com
State Accepted, archived
Commit f8f3a52b2f924789552e6a3f889162ff07e0887f
Headers show
Series [v2] kernel-fitImage: only include valid compatible line | expand

Commit Message

Taedcke, Christian March 6, 2024, 4:42 p.m. UTC
From: Christian Taedcke <christian.taedcke@weidmueller.com>

Without this commit the configuration node includes the compatible
line 'compatible = [00];' if EXTERNAL_KERNEL_DEVICETREE is not
defined, i.e. if PREFERRED_PROVIDER_virtual/dtb is not used.
This prevents u-boot from using this configuration and it prints the
message "Could not find configuration node".

An additional check also ensures that the written compatible line
never contains an empty compatible.

The functionality to add the compatible line was added in commit
f4c82fb6da89 ("kernel-fitImage: add machine compatible to config
section").

Signed-off-by: Christian Taedcke <christian.taedcke@weidmueller.com>
---
 meta/classes-recipe/kernel-fitimage.bbclass | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Ahmad Fatoum March 6, 2024, 8:58 p.m. UTC | #1
On 06.03.24 17:42, christian.taedcke-oss@weidmueller.com wrote:
> From: Christian Taedcke <christian.taedcke@weidmueller.com>
> 
> Without this commit the configuration node includes the compatible
> line 'compatible = [00];' if EXTERNAL_KERNEL_DEVICETREE is not
> defined, i.e. if PREFERRED_PROVIDER_virtual/dtb is not used.
> This prevents u-boot from using this configuration and it prints the
> message "Could not find configuration node".
> 
> An additional check also ensures that the written compatible line
> never contains an empty compatible.
> 
> The functionality to add the compatible line was added in commit
> f4c82fb6da89 ("kernel-fitImage: add machine compatible to config
> section").
> 
> Signed-off-by: Christian Taedcke <christian.taedcke@weidmueller.com>

Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>

Thanks,
Ahmad

> ---
>  meta/classes-recipe/kernel-fitimage.bbclass | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/meta/classes-recipe/kernel-fitimage.bbclass b/meta/classes-recipe/kernel-fitimage.bbclass
> index 7e30a5d47e..4b74ddc201 100644
> --- a/meta/classes-recipe/kernel-fitimage.bbclass
> +++ b/meta/classes-recipe/kernel-fitimage.bbclass
> @@ -421,6 +421,7 @@ fitimage_emit_section_config() {
>  	bootscr_line=""
>  	setup_line=""
>  	default_line=""
> +	compatible_line=""
>  
>  	dtb_image_sect=$(symlink_points_below $dtb_image "${EXTERNAL_KERNEL_DEVICETREE}")
>  	if [ -z "$dtb_image_sect" ]; then
> @@ -428,7 +429,12 @@ fitimage_emit_section_config() {
>  	fi
>  
>  	dtb_path="${EXTERNAL_KERNEL_DEVICETREE}/${dtb_image_sect}"
> -	compatible_line="compatible = \"$(fdtget "$dtb_path" / compatible | sed 's/ /", "/g')\";"
> +	if [ -e "$dtb_path" ]; then
> +		compat=$(fdtget -t s "$dtb_path" / compatible | sed 's/ /", "/g')
> +		if [ -n "$compat" ]; then
> +			compatible_line="compatible = \"$compat\";"
> +		fi
> +	fi
>  
>  	dtb_image=$(echo $dtb_image | tr '/' '_')
>  	dtb_image_sect=$(echo "${dtb_image_sect}" | tr '/' '_')
diff mbox series

Patch

diff --git a/meta/classes-recipe/kernel-fitimage.bbclass b/meta/classes-recipe/kernel-fitimage.bbclass
index 7e30a5d47e..4b74ddc201 100644
--- a/meta/classes-recipe/kernel-fitimage.bbclass
+++ b/meta/classes-recipe/kernel-fitimage.bbclass
@@ -421,6 +421,7 @@  fitimage_emit_section_config() {
 	bootscr_line=""
 	setup_line=""
 	default_line=""
+	compatible_line=""
 
 	dtb_image_sect=$(symlink_points_below $dtb_image "${EXTERNAL_KERNEL_DEVICETREE}")
 	if [ -z "$dtb_image_sect" ]; then
@@ -428,7 +429,12 @@  fitimage_emit_section_config() {
 	fi
 
 	dtb_path="${EXTERNAL_KERNEL_DEVICETREE}/${dtb_image_sect}"
-	compatible_line="compatible = \"$(fdtget "$dtb_path" / compatible | sed 's/ /", "/g')\";"
+	if [ -e "$dtb_path" ]; then
+		compat=$(fdtget -t s "$dtb_path" / compatible | sed 's/ /", "/g')
+		if [ -n "$compat" ]; then
+			compatible_line="compatible = \"$compat\";"
+		fi
+	fi
 
 	dtb_image=$(echo $dtb_image | tr '/' '_')
 	dtb_image_sect=$(echo "${dtb_image_sect}" | tr '/' '_')