Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH v2 0/1] Add support for custom compatible string via optional parameter
@ 2025-09-29 14:47 Kavinaya S
  2025-09-29 14:47 ` [PATCH v1 1/1] fitimage: " Kavinaya S
  0 siblings, 1 reply; 4+ messages in thread
From: Kavinaya S @ 2025-09-29 14:47 UTC (permalink / raw)
  To: openembedded-core; +Cc: Kavinaya S

This update adds flexibility to FIT image generation by introducing 
an optional mechanism to override the DTB compatible string. 
Instead of always extracting the value from the DTB, the generator 
can now use a custom string defined in build metadata. This is 
particularly useful when the FIT configuration requires a different 
compatible value than what is embedded in the DTB.

Key changes:
Adds a custom_compatible parameter to fitimage_emit_section_dtb().
Preserves existing behavior when no override is specified.

Usage:
To override the default behavior, define in machine configuration 
or local.conf:
COMPATIBLE:<dtb-filename.dtb> = "custom-compatible-string"

This method avoids using custom ITS files, keeps the build process 
consistent, and makes it easy to understand and track changes.

Kavinaya S (1):
  fitimage: Add support for custom compatible string via optional
    parameter

 meta/classes-recipe/kernel-fit-image.bbclass |  3 ++-
 meta/conf/image-fitimage.conf                |  6 ++++++
 meta/lib/oe/fitimage.py                      | 12 ++++++++++--
 3 files changed, 18 insertions(+), 3 deletions(-)

-- 
2.34.1



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v1 1/1] fitimage: Add support for custom compatible string via optional parameter
  2025-09-29 14:47 [PATCH v2 0/1] Add support for custom compatible string via optional parameter Kavinaya S
@ 2025-09-29 14:47 ` Kavinaya S
  2025-09-29 14:56   ` [OE-core] " Alexander Kanavin
  0 siblings, 1 reply; 4+ messages in thread
From: Kavinaya S @ 2025-09-29 14:47 UTC (permalink / raw)
  To: openembedded-core; +Cc: Kavinaya S

Currently, fitimage_emit_section_dtb() always derives the 'compatible'
property from the DTB using fdtget when add_compatible=True. In some
cases, it is desirable to override this with a custom compatible string
defined in the build metadata.

This patch introduces an optional 'custom_compatible' parameter to
fitimage_emit_section_dtb(). When provided, this value is used instead
of extracting from the DTB. The parameter accepts either a space-
separated string or a list of strings, which are split into the
compatible array for the ITS node.

Signed-off-by: Kavinaya S <kavinaya@qti.qualcomm.com>
---
 meta/classes-recipe/kernel-fit-image.bbclass |  3 ++-
 meta/conf/image-fitimage.conf                |  6 ++++++
 meta/lib/oe/fitimage.py                      | 12 ++++++++++--
 3 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/meta/classes-recipe/kernel-fit-image.bbclass b/meta/classes-recipe/kernel-fit-image.bbclass
index f04aee1807..08b05f7aed 100644
--- a/meta/classes-recipe/kernel-fit-image.bbclass
+++ b/meta/classes-recipe/kernel-fit-image.bbclass
@@ -84,8 +84,9 @@ python do_compile() {
 
             # Copy the dtb or dtbo file into the FIT image assembly directory
             shutil.copyfile(os.path.join(kernel_deploydir, dtb_name), dtb_name)
+            custom_compatible_str = d.getVar(f"COMPATIBLE:{dtb_name}")
             root_node.fitimage_emit_section_dtb(dtb_name, dtb_name,
-                d.getVar("UBOOT_DTB_LOADADDRESS"), d.getVar("UBOOT_DTBO_LOADADDRESS"))
+                d.getVar("UBOOT_DTB_LOADADDRESS"), d.getVar("UBOOT_DTBO_LOADADDRESS"), True, custom_compatible=custom_compatible_str)
 
     if external_kernel_devicetree:
         # iterate over all .dtb and .dtbo files in the external kernel devicetree directory
diff --git a/meta/conf/image-fitimage.conf b/meta/conf/image-fitimage.conf
index 090ee148f4..16fa0de9fa 100644
--- a/meta/conf/image-fitimage.conf
+++ b/meta/conf/image-fitimage.conf
@@ -65,3 +65,9 @@ FIT_ADDRESS_CELLS ?= "1"
 # Machine configurations needing such a script file should include it in the
 # SRC_URI of the kernel recipe and set the FIT_UBOOT_ENV parameter.
 FIT_UBOOT_ENV ?= ""
+
+
+# To override the DTB 'compatible' string in the FIT image, add in your
+# machine.conf or local.conf:
+#
+#   COMPATIBLE:<dtb-filename.dtb> = "custom-compatible-string"
diff --git a/meta/lib/oe/fitimage.py b/meta/lib/oe/fitimage.py
index f303799155..2ff39e9e62 100644
--- a/meta/lib/oe/fitimage.py
+++ b/meta/lib/oe/fitimage.py
@@ -289,7 +289,7 @@ class ItsNodeRootKernel(ItsNode):
         self._kernel = kernel_node
 
     def fitimage_emit_section_dtb(self, dtb_id, dtb_path, dtb_loadaddress=None,
-                                  dtbo_loadaddress=None, add_compatible=False):
+                                  dtbo_loadaddress=None, add_compatible=False, custom_compatible=False):
         """Emit the fitImage ITS DTB section"""
         load=None
         dtb_ext = os.path.splitext(dtb_path)[1]
@@ -309,7 +309,15 @@ class ItsNodeRootKernel(ItsNode):
         # Preserve the DTB's compatible string to be added to the configuration node
         compatible = None
         if add_compatible:
-            compatible = get_compatible_from_dtb(dtb_path)
+            if custom_compatible:
+            # Accept either a string (space-separated) or an iterable of strings
+                if isinstance(custom_compatible, (list, tuple)):
+                    compatible = list(custom_compatible)
+                else:
+                    compatible = str(custom_compatible).split()
+            else:
+                compatible = get_compatible_from_dtb(dtb_path)
+
 
         dtb_node = self.its_add_node_dtb(
             "fdt-" + dtb_id,
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [OE-core] [PATCH v1 1/1] fitimage: Add support for custom compatible string via optional parameter
  2025-09-29 14:47 ` [PATCH v1 1/1] fitimage: " Kavinaya S
@ 2025-09-29 14:56   ` Alexander Kanavin
  2025-09-29 16:02     ` Kavinaya S
  0 siblings, 1 reply; 4+ messages in thread
From: Alexander Kanavin @ 2025-09-29 14:56 UTC (permalink / raw)
  To: kavinaya; +Cc: openembedded-core

On Mon, 29 Sept 2025 at 16:47, Kavinaya S via lists.openembedded.org
<kavinaya=qti.qualcomm.com@lists.openembedded.org> wrote:
>
> Currently, fitimage_emit_section_dtb() always derives the 'compatible'
> property from the DTB using fdtget when add_compatible=True. In some
> cases, it is desirable to override this with a custom compatible string
> defined in the build metadata.
>
> This patch introduces an optional 'custom_compatible' parameter to
> fitimage_emit_section_dtb(). When provided, this value is used instead
> of extracting from the DTB. The parameter accepts either a space-
> separated string or a list of strings, which are split into the
> compatible array for the ITS node.

This looks much better, thanks! But it still needs a bit of work.

>              # Copy the dtb or dtbo file into the FIT image assembly directory
>              shutil.copyfile(os.path.join(kernel_deploydir, dtb_name), dtb_name)
> +            custom_compatible_str = d.getVar(f"COMPATIBLE:{dtb_name}")

COMPATIBLE is really not an appropriate name. It should be much more
specific, e.g. DTB_CUSTOM_COMPATIBLE, or something even more detailed.

> -                                  dtbo_loadaddress=None, add_compatible=False):
> +                                  dtbo_loadaddress=None, add_compatible=False, custom_compatible=False):

custom_compatible is not a boolean parameter, it's a string. If it
isn't supplied, set the default to None.

>          if add_compatible:
> -            compatible = get_compatible_from_dtb(dtb_path)
> +            if custom_compatible:
> +            # Accept either a string (space-separated) or an iterable of strings
> +                if isinstance(custom_compatible, (list, tuple)):
> +                    compatible = list(custom_compatible)
> +                else:
> +                    compatible = str(custom_compatible).split()

I don't understand. d.getVar() returns a string. At which point
custom_compatible turns into a list or a tuple?

That's why I had asked you to also make tests for this feature.

Alex


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1 1/1] fitimage: Add support for custom compatible string via optional parameter
  2025-09-29 14:56   ` [OE-core] " Alexander Kanavin
@ 2025-09-29 16:02     ` Kavinaya S
  0 siblings, 0 replies; 4+ messages in thread
From: Kavinaya S @ 2025-09-29 16:02 UTC (permalink / raw)
  To: openembedded-core

On Mon, Sep 29, 2025 at 08:26 PM, Alexander Kanavin wrote:

>
> COMPATIBLE is really not an appropriate name. It should be much more
> specific, e.g. DTB_CUSTOM_COMPATIBLE, or something even more detailed.
> 
Hi Alex, Sure. I will update COMPATIBLE to DTB_CUSTOM_COMPATIBLE
> > 
> > - dtbo_loadaddress=None, add_compatible=False):
> > + dtbo_loadaddress=None, add_compatible=False, custom_compatible=False):
> 
> custom_compatible is not a boolean parameter, it's a string. If it
> isn't supplied, set the default to None.
> 
Sure
> > 
> > if add_compatible:
> > - compatible = get_compatible_from_dtb(dtb_path)
> > + if custom_compatible:
> > + # Accept either a string (space-separated) or an iterable of strings
> > + if isinstance(custom_compatible, (list, tuple)):
> > + compatible = list(custom_compatible)
> > + else:
> > + compatible = str(custom_compatible).split()
> 
> I don't understand. d.getVar() returns a string. At which point
> custom_compatible turns into a list or a tuple?
> 
I will update this logic as well.
> That's why I had asked you to also make tests for this feature.
>
I will add tests as well.
Thanks 
Alex


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-09-29 16:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-29 14:47 [PATCH v2 0/1] Add support for custom compatible string via optional parameter Kavinaya S
2025-09-29 14:47 ` [PATCH v1 1/1] fitimage: " Kavinaya S
2025-09-29 14:56   ` [OE-core] " Alexander Kanavin
2025-09-29 16:02     ` Kavinaya S

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox