diff mbox series

[2/2] kernel-fitimage: Allow user to select dtb when multiple dtb exists

Message ID 20230104025330.2648640-2-sandeep.gundlupet-raju@amd.com
State New
Headers show
Series [1/2] kernel-fitimage: Adjust order of dtb/dtbo files | expand

Commit Message

Gundlupet Raju, Sandeep Jan. 4, 2023, 2:53 a.m. UTC
Allow user to select the default DTB for FIT image when multiple
dtb's exists.

From machine.conf or local.conf user can specify the default dtb
for FIT image as shown below.

FIT_CONF_DEFAULT_DTB = "board-default.dtb"

Signed-off-by: Sandeep Gundlupet Raju <sandeep.gundlupet-raju@amd.com>
---
 meta/classes-recipe/kernel-fitimage.bbclass | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Comments

Quentin Schulz Jan. 4, 2023, 11:40 a.m. UTC | #1
On 1/4/23 03:53, Sandeep Gundlupet Raju via lists.openembedded.org wrote:
> Allow user to select the default DTB for FIT image when multiple
> dtb's exists.
> 
>  From machine.conf or local.conf user can specify the default dtb
> for FIT image as shown below.
> 
> FIT_CONF_DEFAULT_DTB = "board-default.dtb"
> 
> Signed-off-by: Sandeep Gundlupet Raju <sandeep.gundlupet-raju@amd.com>
> ---
>   meta/classes-recipe/kernel-fitimage.bbclass | 12 +++++++++++-
>   1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/meta/classes-recipe/kernel-fitimage.bbclass b/meta/classes-recipe/kernel-fitimage.bbclass
> index cb6635a673..6cdb0e0174 100644
> --- a/meta/classes-recipe/kernel-fitimage.bbclass
> +++ b/meta/classes-recipe/kernel-fitimage.bbclass
> @@ -89,6 +89,9 @@ FIT_CONF_PREFIX[doc] = "Prefix to use for FIT configuration node name"
>   
>   FIT_SUPPORTED_INITRAMFS_FSTYPES ?= "cpio.lz4 cpio.lzo cpio.lzma cpio.xz cpio.zst cpio.gz ext2.gz cpio"
>   
> +# Allow user to select the default DTB for FIT image when multiple dtb's exists.
> +FIT_CONF_DEFAULT_DTB ?= ""
> +
>   # Keys used to sign individually image nodes.
>   # The keys to sign image nodes must be different from those used to sign
>   # configuration nodes, otherwise the "required" property, from
> @@ -412,6 +415,7 @@ fitimage_emit_section_config() {
>   	bootscr_line=""
>   	setup_line=""
>   	default_line=""
> +	default_dtb_image="${FIT_CONF_DEFAULT_DTB}"
>   
>   	dtb_image_sect=$(symlink_points_below $dtb_image "${EXTERNAL_KERNEL_DEVICETREE}")
>   	if [ -z "$dtb_image_sect" ]; then
> @@ -462,7 +466,13 @@ fitimage_emit_section_config() {
>   		# default node is selected based on dtb ID if it is present,
>   		# otherwise its selected based on kernel ID
>   		if [ -n "$dtb_image" ]; then
> -			default_line="default = \"${FIT_CONF_PREFIX}$dtb_image\";"
> +		        # Select default node as user specified dtb when
> +		        # multiple dtb exists.
> +		        if [ -n "$default_dtb_image" ]; then
> +			        default_line="default = \"${FIT_CONF_PREFIX}$default_dtb_image\";"

Shouldn't we error out if the requested device tree does not exist here 
so that we don't create an invalid fitimage?

Cheers,
Quentin
diff mbox series

Patch

diff --git a/meta/classes-recipe/kernel-fitimage.bbclass b/meta/classes-recipe/kernel-fitimage.bbclass
index cb6635a673..6cdb0e0174 100644
--- a/meta/classes-recipe/kernel-fitimage.bbclass
+++ b/meta/classes-recipe/kernel-fitimage.bbclass
@@ -89,6 +89,9 @@  FIT_CONF_PREFIX[doc] = "Prefix to use for FIT configuration node name"
 
 FIT_SUPPORTED_INITRAMFS_FSTYPES ?= "cpio.lz4 cpio.lzo cpio.lzma cpio.xz cpio.zst cpio.gz ext2.gz cpio"
 
+# Allow user to select the default DTB for FIT image when multiple dtb's exists.
+FIT_CONF_DEFAULT_DTB ?= ""
+
 # Keys used to sign individually image nodes.
 # The keys to sign image nodes must be different from those used to sign
 # configuration nodes, otherwise the "required" property, from
@@ -412,6 +415,7 @@  fitimage_emit_section_config() {
 	bootscr_line=""
 	setup_line=""
 	default_line=""
+	default_dtb_image="${FIT_CONF_DEFAULT_DTB}"
 
 	dtb_image_sect=$(symlink_points_below $dtb_image "${EXTERNAL_KERNEL_DEVICETREE}")
 	if [ -z "$dtb_image_sect" ]; then
@@ -462,7 +466,13 @@  fitimage_emit_section_config() {
 		# default node is selected based on dtb ID if it is present,
 		# otherwise its selected based on kernel ID
 		if [ -n "$dtb_image" ]; then
-			default_line="default = \"${FIT_CONF_PREFIX}$dtb_image\";"
+		        # Select default node as user specified dtb when
+		        # multiple dtb exists.
+		        if [ -n "$default_dtb_image" ]; then
+			        default_line="default = \"${FIT_CONF_PREFIX}$default_dtb_image\";"
+		        else
+			        default_line="default = \"${FIT_CONF_PREFIX}$dtb_image\";"
+		        fi
 		else
 			default_line="default = \"${FIT_CONF_PREFIX}$kernel_id\";"
 		fi