diff mbox series

fitimage: introduce FIT_CONF_STRIP_EXT

Message ID 20260107092600.73848-1-dev@g0hl1n.net
State Changes Requested
Headers show
Series fitimage: introduce FIT_CONF_STRIP_EXT | expand

Commit Message

Richard Leitner Jan. 7, 2026, 9:26 a.m. UTC
Introduce a configuration variable named FIT_CONF_STRIP_EXT which
removes the file-type extension from the configuration node name.

This feature enables us to give configuration nodes arbritary names
(based on the dtb file names). This is in my case needed to ensure
consistent configuration names which where previously (walnascar)
generated using a fitimage_emit_section_config:append() function.

Signed-off-by: Richard Leitner <dev@g0hl1n.net>
---
 meta/classes-recipe/kernel-fit-image.bbclass | 1 +
 meta/conf/image-fitimage.conf                | 3 +++
 meta/lib/oe/fitimage.py                      | 4 ++++
 meta/lib/oeqa/selftest/cases/fitimage.py     | 3 +++
 4 files changed, 11 insertions(+)

Comments

Mathieu Dubois-Briand Jan. 9, 2026, 8:09 a.m. UTC | #1
On Wed Jan 7, 2026 at 10:26 AM CET, Richard Leitner via lists.openembedded.org wrote:
> Introduce a configuration variable named FIT_CONF_STRIP_EXT which
> removes the file-type extension from the configuration node name.
>
> This feature enables us to give configuration nodes arbritary names
> (based on the dtb file names). This is in my case needed to ensure
> consistent configuration names which where previously (walnascar)
> generated using a fitimage_emit_section_config:append() function.
>
> Signed-off-by: Richard Leitner <dev@g0hl1n.net>
> ---

Hi Richard,

Thanks for your patch.

It looks like this is making some selftest fail:

2026-01-08 18:18:47,312 - oe-selftest - INFO - fitimage.FitImagePyTests.test_fitimage_py_conf_extra_mappings_unused_error (subunit.RemotedTestCase)
2026-01-08 18:18:47,313 - oe-selftest - INFO -  ... ERROR
...
2026-01-08 18:18:47,313 - oe-selftest - INFO - testtools.testresult.real._StringException: Traceback (most recent call last):
  File "/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/openembedded-core/meta/lib/oeqa/selftest/cases/fitimage.py", line 1257, in test_fitimage_py_conf_extra_mappings_unused_error
    self._test_fitimage_py(bb_vars_overrides)
  File "/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/openembedded-core/meta/lib/oeqa/selftest/cases/fitimage.py", line 1203, in _test_fitimage_py
    root_node.fitimage_emit_section_config(bb_vars['FIT_CONF_DEFAULT_DTB'], bb_vars.get('FIT_CONF_MAPPINGS'))
  File "/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/openembedded-core/meta/lib/oe/fitimage.py", line 498, in fitimage_emit_section_config
    default_conf = self.configurations.sub_nodes[0].name
                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

...
2026-01-08 18:18:47,317 - oe-selftest - INFO - fitimage.FitImagePyTests.test_fitimage_py_conf_mappings (subunit.RemotedTestCase)
2026-01-08 18:18:47,317 - oe-selftest - INFO -  ... ERROR
...
2026-01-08 18:18:47,322 - oe-selftest - INFO - fitimage.FitImagePyTests.test_fitimage_py_conf_mappings_unused_error (subunit.RemotedTestCase)
2026-01-08 18:18:47,322 - oe-selftest - INFO -  ... ERROR
...
2026-01-08 18:18:47,327 - oe-selftest - INFO - fitimage.FitImagePyTests.test_fitimage_py_conf_mappings_with_alias (subunit.RemotedTestCase)
2026-01-08 18:18:47,327 - oe-selftest - INFO -  ... ERROR
...
2026-01-08 18:18:47,338 - oe-selftest - INFO - fitimage.FitImagePyTests.test_fitimage_py_default_dtb (subunit.RemotedTestCase)
2026-01-08 18:18:47,339 - oe-selftest - INFO -  ... ERROR

I did not copy all the errors, as they are all similar to the first one.

https://autobuilder.yoctoproject.org/valkyrie/#/builders/35/builds/2989
https://autobuilder.yoctoproject.org/valkyrie/#/builders/48/builds/2880
https://autobuilder.yoctoproject.org/valkyrie/#/builders/23/builds/3127

Can you have a look at these issues?

Note, I had merge conflicts on your patch, so maybe my resolution was
incorrect. If that's the case, can you rebase on master before sending
the new version?

Thanks,
Mathieu
Richard Leitner Jan. 9, 2026, 8:28 a.m. UTC | #2
Hi Mathieu,

thanks for your reply!

On Fri, Jan 09, 2026 at 09:09:04AM +0100, Mathieu Dubois-Briand wrote:
> On Wed Jan 7, 2026 at 10:26 AM CET, Richard Leitner via lists.openembedded.org wrote:
> > Introduce a configuration variable named FIT_CONF_STRIP_EXT which
> > removes the file-type extension from the configuration node name.
> >
> > This feature enables us to give configuration nodes arbritary names
> > (based on the dtb file names). This is in my case needed to ensure
> > consistent configuration names which where previously (walnascar)
> > generated using a fitimage_emit_section_config:append() function.
> >
> > Signed-off-by: Richard Leitner <dev@g0hl1n.net>
> > ---
> 
> Hi Richard,
> 
> Thanks for your patch.
> 
> It looks like this is making some selftest fail:
> 
> 2026-01-08 18:18:47,312 - oe-selftest - INFO - fitimage.FitImagePyTests.test_fitimage_py_conf_extra_mappings_unused_error (subunit.RemotedTestCase)
> 2026-01-08 18:18:47,313 - oe-selftest - INFO -  ... ERROR
> ...
> 2026-01-08 18:18:47,313 - oe-selftest - INFO - testtools.testresult.real._StringException: Traceback (most recent call last):
>   File "/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/openembedded-core/meta/lib/oeqa/selftest/cases/fitimage.py", line 1257, in test_fitimage_py_conf_extra_mappings_unused_error
>     self._test_fitimage_py(bb_vars_overrides)
>   File "/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/openembedded-core/meta/lib/oeqa/selftest/cases/fitimage.py", line 1203, in _test_fitimage_py
>     root_node.fitimage_emit_section_config(bb_vars['FIT_CONF_DEFAULT_DTB'], bb_vars.get('FIT_CONF_MAPPINGS'))
>   File "/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/openembedded-core/meta/lib/oe/fitimage.py", line 498, in fitimage_emit_section_config
>     default_conf = self.configurations.sub_nodes[0].name
>                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
> IndexError: list index out of range
> 
> ...
> 2026-01-08 18:18:47,317 - oe-selftest - INFO - fitimage.FitImagePyTests.test_fitimage_py_conf_mappings (subunit.RemotedTestCase)
> 2026-01-08 18:18:47,317 - oe-selftest - INFO -  ... ERROR
> ...
> 2026-01-08 18:18:47,322 - oe-selftest - INFO - fitimage.FitImagePyTests.test_fitimage_py_conf_mappings_unused_error (subunit.RemotedTestCase)
> 2026-01-08 18:18:47,322 - oe-selftest - INFO -  ... ERROR
> ...
> 2026-01-08 18:18:47,327 - oe-selftest - INFO - fitimage.FitImagePyTests.test_fitimage_py_conf_mappings_with_alias (subunit.RemotedTestCase)
> 2026-01-08 18:18:47,327 - oe-selftest - INFO -  ... ERROR
> ...
> 2026-01-08 18:18:47,338 - oe-selftest - INFO - fitimage.FitImagePyTests.test_fitimage_py_default_dtb (subunit.RemotedTestCase)
> 2026-01-08 18:18:47,339 - oe-selftest - INFO -  ... ERROR
> 
> I did not copy all the errors, as they are all similar to the first one.
> 
> https://autobuilder.yoctoproject.org/valkyrie/#/builders/35/builds/2989
> https://autobuilder.yoctoproject.org/valkyrie/#/builders/48/builds/2880
> https://autobuilder.yoctoproject.org/valkyrie/#/builders/23/builds/3127
> 
> Can you have a look at these issues?

Oh. Sorry. Sure I will have a look at those and send an updated v2.

> 
> Note, I had merge conflicts on your patch, so maybe my resolution was
> incorrect. If that's the case, can you rebase on master before sending
> the new version?

Sure. I will rebase on master for v2.

Thanks again for your feedback!

regards;rl

> 
> Thanks,
> Mathieu
> 
> -- 
> Mathieu Dubois-Briand, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
>
diff mbox series

Patch

diff --git a/meta/classes-recipe/kernel-fit-image.bbclass b/meta/classes-recipe/kernel-fit-image.bbclass
index fd0d21ceee..6f78016e14 100644
--- a/meta/classes-recipe/kernel-fit-image.bbclass
+++ b/meta/classes-recipe/kernel-fit-image.bbclass
@@ -54,6 +54,7 @@  python do_compile() {
     root_node = oe.fitimage.ItsNodeRootKernel(
         d.getVar("FIT_DESC"), d.getVar("FIT_ADDRESS_CELLS"),
         d.getVar('HOST_PREFIX'), d.getVar('UBOOT_ARCH'),  d.getVar("FIT_CONF_PREFIX"),
+        oe.types.boolean(d.getVar('FIT_CONF_STRIP_EXT')),
         oe.types.boolean(d.getVar('FIT_KERNEL_SIGN_ENABLE')), d.getVar("FIT_KERNEL_SIGN_KEYDIR"),
         d.getVar("UBOOT_MKIMAGE"), d.getVar("UBOOT_MKIMAGE_DTCOPTS"),
         d.getVar("UBOOT_MKIMAGE_SIGN"), d.getVar("UBOOT_MKIMAGE_SIGN_ARGS"),
diff --git a/meta/conf/image-fitimage.conf b/meta/conf/image-fitimage.conf
index 090ee148f4..6bf0dd1299 100644
--- a/meta/conf/image-fitimage.conf
+++ b/meta/conf/image-fitimage.conf
@@ -35,6 +35,9 @@  FIT_SIGN_INDIVIDUAL ?= "0"
 FIT_CONF_PREFIX ?= "conf-"
 FIT_CONF_PREFIX[doc] = "Prefix to use for FIT configuration node name"
 
+FIT_CONF_STRIP_EXT ?= "0"
+FIT_CONF_STRIP_EXT[doc] = "Set true to strip a possible file-type extension from a 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 support special use cases where the kernel binary is
diff --git a/meta/lib/oe/fitimage.py b/meta/lib/oe/fitimage.py
index f303799155..bbd5e1843f 100644
--- a/meta/lib/oe/fitimage.py
+++ b/meta/lib/oe/fitimage.py
@@ -154,6 +154,7 @@  class ItsNodeRootKernel(ItsNode):
     firt DTB. If there is no dtb present than the default configuation the kernel.
     """
     def __init__(self, description, address_cells, host_prefix, arch, conf_prefix,
+                 conf_strip_ext=False,
                  sign_enable=False, sign_keydir=None,
                  mkimage=None, mkimage_dtcopts=None,
                  mkimage_sign=None, mkimage_sign_args=None,
@@ -171,6 +172,7 @@  class ItsNodeRootKernel(ItsNode):
         self._host_prefix = host_prefix
         self._arch = arch
         self._conf_prefix = conf_prefix
+        self._conf_strip_ext = conf_strip_ext
 
         # Signature related properties
         self._sign_enable = sign_enable
@@ -468,6 +470,8 @@  class ItsNodeRootKernel(ItsNode):
                 dtb_name = dtb.name
                 if dtb.name.startswith("fdt-"):
                     dtb_name = dtb.name[len("fdt-"):]
+                if self._conf_strip_ext:
+                    dtb_name = dtb_name.rsplit(".", 1)[0]
                 self._fitimage_emit_one_section_config(self._conf_prefix + dtb_name, dtb)
             for dtb in self._dtb_alias:
                 self._fitimage_emit_one_section_config(self._conf_prefix + dtb.alias_name, dtb)
diff --git a/meta/lib/oeqa/selftest/cases/fitimage.py b/meta/lib/oeqa/selftest/cases/fitimage.py
index 8df5e92a34..84741f10ae 100644
--- a/meta/lib/oeqa/selftest/cases/fitimage.py
+++ b/meta/lib/oeqa/selftest/cases/fitimage.py
@@ -412,6 +412,7 @@  class KernelFitImageBase(FitImageTestCase):
             'DEPLOY_DIR_IMAGE',
             'FIT_CONF_DEFAULT_DTB',
             'FIT_CONF_PREFIX',
+            'FIT_CONF_STRIP_EXT',
             'FIT_DESC',
             'FIT_HASH_ALG',
             'FIT_KERNEL_COMP_ALG',
@@ -1070,6 +1071,7 @@  class FitImagePyTests(KernelFitImageBase):
             'FIT_ADDRESS_CELLS': "1",
             'FIT_CONF_DEFAULT_DTB': "",
             'FIT_CONF_PREFIX': "conf-",
+            'FIT_CONF_STRIP_EXT': "0",
             'FIT_DESC': "Kernel fitImage for a dummy distro",
             'FIT_GENERATE_KEYS': "0",
             'FIT_HASH_ALG': "sha256",
@@ -1115,6 +1117,7 @@  class FitImagePyTests(KernelFitImageBase):
         root_node = oe.fitimage.ItsNodeRootKernel(
             bb_vars["FIT_DESC"], bb_vars["FIT_ADDRESS_CELLS"],
             bb_vars['HOST_PREFIX'], bb_vars['UBOOT_ARCH'],  bb_vars["FIT_CONF_PREFIX"],
+            oe.types.boolean(bb_vars['FIT_CONF_STRIP_EXT']),
             oe.types.boolean(bb_vars['UBOOT_SIGN_ENABLE']), bb_vars["UBOOT_SIGN_KEYDIR"],
             bb_vars["UBOOT_MKIMAGE"], bb_vars["UBOOT_MKIMAGE_DTCOPTS"],
             bb_vars["UBOOT_MKIMAGE_SIGN"], bb_vars["UBOOT_MKIMAGE_SIGN_ARGS"],