* [PATCH v2 0/3] kernel-fit-image: allow replacing kernel, handle compression in FIT recipe
@ 2026-07-27 9:05 Nora Schiffer
2026-07-27 9:05 ` [PATCH v2 1/3] kernel-uboot: move FIT_KERNEL_COMP_ALG to image-fitimage.conf Nora Schiffer
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Nora Schiffer @ 2026-07-27 9:05 UTC (permalink / raw)
To: openembedded-core; +Cc: oss, Nora Schiffer
Add support for building alternative kernel images into a FIT image instead of
using linux.bin. An incomplete solution with a similar goal was added in in
commit 9c8ef2119949 ("kernel-fit-image: control kernel section with
FIT_LINUX_BIN") and subsequently reverted in commit 6eae261b6f52 ("Revert
"kernel-fit-image: control kernel section with FIT_LINUX_BIN"") due to missing
features, lack of tests and the submitter having abandoned their approach.
With the new approach, compression is now either handled as part of the
FIT image (KERNEL_FILENAME) or the image is considered to be compressed already
(KERNEL_FILENAME_COMPRESSED). The option to let the kernel recipe do the
compression and store the result in the image deploydir as linux.bin is
preserved for backwards compatibility, but will result in a deprecation warning.
Our main use case for this is to support building a FIT image with an EFI
application as kernel (with FIT_OS = "efi").
v2: do not hardcode kernel filename to bzImage in
fitimage.KernelFitImageRecipeTests.test_fit_image_kernel_filename selftest
to fix build on non-x86 machines in PATCH 2/3
Nora Schiffer (3):
kernel-uboot: move FIT_KERNEL_COMP_ALG to image-fitimage.conf
kernel-fit-image: reintroduce option to replace kernel image
kernel-fit-extra-artifacts: skip building linux.bin if unneeded
.../kernel-fit-extra-artifacts.bbclass | 4 +-
meta/classes-recipe/kernel-fit-image.bbclass | 53 ++++++++--
meta/classes-recipe/kernel-uboot.bbclass | 3 +-
meta/conf/image-fitimage.conf | 27 +++++-
meta/lib/oeqa/selftest/cases/fitimage.py | 96 ++++++++++++++++++-
5 files changed, 166 insertions(+), 17 deletions(-)
--
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
https://www.tq-group.com/
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH v2 1/3] kernel-uboot: move FIT_KERNEL_COMP_ALG to image-fitimage.conf 2026-07-27 9:05 [PATCH v2 0/3] kernel-fit-image: allow replacing kernel, handle compression in FIT recipe Nora Schiffer @ 2026-07-27 9:05 ` Nora Schiffer 2026-07-30 10:43 ` [OE-core] " Richard Purdie 2026-07-27 9:06 ` [PATCH v2 2/3] kernel-fit-image: reintroduce option to replace kernel image Nora Schiffer 2026-07-27 9:06 ` [PATCH v2 3/3] kernel-fit-extra-artifacts: skip building linux.bin if unneeded Nora Schiffer 2 siblings, 1 reply; 10+ messages in thread From: Nora Schiffer @ 2026-07-27 9:05 UTC (permalink / raw) To: openembedded-core; +Cc: oss, Nora Schiffer It is a bit weird that FIT_KERNEL_COMP_ALG also affects uImage creation, as kernel-uboot.bbclass is used for both, but fixing that would unnecessarily break backwards compatibility. Signed-off-by: Nora Schiffer <nora.schiffer@ew.tq-group.com> --- meta/classes-recipe/kernel-uboot.bbclass | 3 +-- meta/conf/image-fitimage.conf | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/meta/classes-recipe/kernel-uboot.bbclass b/meta/classes-recipe/kernel-uboot.bbclass index fa28be1715..9beccc2dff 100644 --- a/meta/classes-recipe/kernel-uboot.bbclass +++ b/meta/classes-recipe/kernel-uboot.bbclass @@ -4,8 +4,7 @@ # SPDX-License-Identifier: MIT # -# fitImage kernel compression algorithm -FIT_KERNEL_COMP_ALG ?= "gzip" +require conf/image-fitimage.conf # Kernel image type passed to mkimage (i.e. kernel kernel_noload...) UBOOT_MKIMAGE_KERNEL_TYPE ?= "kernel" diff --git a/meta/conf/image-fitimage.conf b/meta/conf/image-fitimage.conf index a06d30e494..abb17186a5 100644 --- a/meta/conf/image-fitimage.conf +++ b/meta/conf/image-fitimage.conf @@ -48,6 +48,9 @@ FIT_OS ?= "linux" # DTBs are provided separately in a FIT image. FIT_LINUX_BIN ?= "linux.bin" +# fitImage kernel compression algorithm +FIT_KERNEL_COMP_ALG ?= "gzip" + # Additional mkimage options for FIT image creation FIT_MKIMAGE_EXTRA_OPTS ?= "" -- TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany Amtsgericht München, HRB 105018 Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider https://www.tq-group.com/ ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [OE-core] [PATCH v2 1/3] kernel-uboot: move FIT_KERNEL_COMP_ALG to image-fitimage.conf 2026-07-27 9:05 ` [PATCH v2 1/3] kernel-uboot: move FIT_KERNEL_COMP_ALG to image-fitimage.conf Nora Schiffer @ 2026-07-30 10:43 ` Richard Purdie 2026-07-30 11:15 ` Nora Schiffer 0 siblings, 1 reply; 10+ messages in thread From: Richard Purdie @ 2026-07-30 10:43 UTC (permalink / raw) To: nora.schiffer, openembedded-core; +Cc: oss On Mon, 2026-07-27 at 11:05 +0200, Nora Schiffer via lists.openembedded.org wrote: > It is a bit weird that FIT_KERNEL_COMP_ALG also affects uImage creation, > as kernel-uboot.bbclass is used for both, but fixing that would > unnecessarily break backwards compatibility. > > Signed-off-by: Nora Schiffer <nora.schiffer@ew.tq-group.com> > --- > meta/classes-recipe/kernel-uboot.bbclass | 3 +-- > meta/conf/image-fitimage.conf | 3 +++ > 2 files changed, 4 insertions(+), 2 deletions(-) > > diff --git a/meta/classes-recipe/kernel-uboot.bbclass b/meta/classes-recipe/kernel-uboot.bbclass > index fa28be1715..9beccc2dff 100644 > --- a/meta/classes-recipe/kernel-uboot.bbclass > +++ b/meta/classes-recipe/kernel-uboot.bbclass > @@ -4,8 +4,7 @@ > # SPDX-License-Identifier: MIT > # > > -# fitImage kernel compression algorithm > -FIT_KERNEL_COMP_ALG ?= "gzip" > +require conf/image-fitimage.conf > > # Kernel image type passed to mkimage (i.e. kernel kernel_noload...) > UBOOT_MKIMAGE_KERNEL_TYPE ?= "kernel" > diff --git a/meta/conf/image-fitimage.conf b/meta/conf/image-fitimage.conf > index a06d30e494..abb17186a5 100644 > --- a/meta/conf/image-fitimage.conf > +++ b/meta/conf/image-fitimage.conf > @@ -48,6 +48,9 @@ FIT_OS ?= "linux" > # DTBs are provided separately in a FIT image. > FIT_LINUX_BIN ?= "linux.bin" > > +# fitImage kernel compression algorithm > +FIT_KERNEL_COMP_ALG ?= "gzip" > + > # Additional mkimage options for FIT image creation > FIT_MKIMAGE_EXTRA_OPTS ?= "" > We're realising that the kernel classes are a bit of a tangled spiders web and we want to improve things and clean things up. Adding a dependency on "fit" from the "uboot" class does therefore feed a bit backward as you note. You mention not breaking backwards compatibility. I think given the other work we're thinking about, it might be worth considering that and seeing if we can avoid tangling things up even further. Cheers, Richard ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [OE-core] [PATCH v2 1/3] kernel-uboot: move FIT_KERNEL_COMP_ALG to image-fitimage.conf 2026-07-30 10:43 ` [OE-core] " Richard Purdie @ 2026-07-30 11:15 ` Nora Schiffer 2026-07-30 13:09 ` Richard Purdie 0 siblings, 1 reply; 10+ messages in thread From: Nora Schiffer @ 2026-07-30 11:15 UTC (permalink / raw) To: Richard Purdie, openembedded-core; +Cc: oss On Thu, 2026-07-30 at 11:43 +0100, Richard Purdie wrote: > On Mon, 2026-07-27 at 11:05 +0200, Nora Schiffer via lists.openembedded.org wrote: > > It is a bit weird that FIT_KERNEL_COMP_ALG also affects uImage creation, > > as kernel-uboot.bbclass is used for both, but fixing that would > > unnecessarily break backwards compatibility. > > > > Signed-off-by: Nora Schiffer <nora.schiffer@ew.tq-group.com> > > --- > > meta/classes-recipe/kernel-uboot.bbclass | 3 +-- > > meta/conf/image-fitimage.conf | 3 +++ > > 2 files changed, 4 insertions(+), 2 deletions(-) > > > > diff --git a/meta/classes-recipe/kernel-uboot.bbclass b/meta/classes-recipe/kernel-uboot.bbclass > > index fa28be1715..9beccc2dff 100644 > > --- a/meta/classes-recipe/kernel-uboot.bbclass > > +++ b/meta/classes-recipe/kernel-uboot.bbclass > > @@ -4,8 +4,7 @@ > > # SPDX-License-Identifier: MIT > > # > > > > -# fitImage kernel compression algorithm > > -FIT_KERNEL_COMP_ALG ?= "gzip" > > +require conf/image-fitimage.conf > > > > # Kernel image type passed to mkimage (i.e. kernel kernel_noload...) > > UBOOT_MKIMAGE_KERNEL_TYPE ?= "kernel" > > diff --git a/meta/conf/image-fitimage.conf b/meta/conf/image-fitimage.conf > > index a06d30e494..abb17186a5 100644 > > --- a/meta/conf/image-fitimage.conf > > +++ b/meta/conf/image-fitimage.conf > > @@ -48,6 +48,9 @@ FIT_OS ?= "linux" > > # DTBs are provided separately in a FIT image. > > FIT_LINUX_BIN ?= "linux.bin" > > > > +# fitImage kernel compression algorithm > > +FIT_KERNEL_COMP_ALG ?= "gzip" > > + > > # Additional mkimage options for FIT image creation > > FIT_MKIMAGE_EXTRA_OPTS ?= "" > > > > We're realising that the kernel classes are a bit of a tangled spiders > web and we want to improve things and clean things up. > > Adding a dependency on "fit" from the "uboot" class does therefore feed > a bit backward as you note. > > You mention not breaking backwards compatibility. I think given the > other work we're thinking about, it might be worth considering that and > seeing if we can avoid tangling things up even further. > > Cheers, > > Richard Okay, new plan: Change uboot_prep_kimage to accept the compression algorithm as an argument, so we can use different variables when calling it from kernel- uimage.bbclass and kernel-fit-extra-artifacts.bbclass. kernel-uimage.bbclass could then use a separate variable UBOOT_MKIMAGE_KERNEL_COMP_ALG instead of reusing the FIT one. A more radical approach would be to skip the deprecation of using a linux.bin generated by the kernel recipe as a FIT image's kernel and drop support immediately. This would result in kernel-fit-extra-artifacts.bbclass not needing kernel-uboot.bbclass anymore, and maybe kernel-fit-extra-artifacts.bbclass could then be dropped in favor of listing setup.bin in KERNEL_IMAGETYPES if it is needed. I'm a bit worried doing all that at once might cause too much breakage, and I think an incremental approach with deprecation warnings works fine here, but of course that also depends on the other work you want to do. Let me know which direction you prefer for the next iteration of these patches. Best, Nora > > -- TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany Amtsgericht München, HRB 105018 Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider https://www.tq-group.com/ ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [OE-core] [PATCH v2 1/3] kernel-uboot: move FIT_KERNEL_COMP_ALG to image-fitimage.conf 2026-07-30 11:15 ` Nora Schiffer @ 2026-07-30 13:09 ` Richard Purdie 2026-07-30 13:35 ` Nora Schiffer 0 siblings, 1 reply; 10+ messages in thread From: Richard Purdie @ 2026-07-30 13:09 UTC (permalink / raw) To: Nora Schiffer, openembedded-core; +Cc: oss On Thu, 2026-07-30 at 13:15 +0200, Nora Schiffer wrote: > On Thu, 2026-07-30 at 11:43 +0100, Richard Purdie wrote: > > Okay, new plan: Change uboot_prep_kimage to accept the compression algorithm as > an argument, so we can use different variables when calling it from kernel- > uimage.bbclass and kernel-fit-extra-artifacts.bbclass. kernel-uimage.bbclass > could then use a separate variable UBOOT_MKIMAGE_KERNEL_COMP_ALG instead of > reusing the FIT one. > > A more radical approach would be to skip the deprecation of using a linux.bin > generated by the kernel recipe as a FIT image's kernel and drop support > immediately. Can you see from the commit history who might have been using that? Do you think there are many people relying upon it? If that functionality doesn't make much sense and wouldn't or shouldn't be used by people, I'm fine with actually removing it, as long as we're clear about why it likely isn't needed or is inefficient (or whatever) and what the alternative is. A lot of the time I think we support too many code paths when we should try and encourage people to do the "best" known things. Cheers, Richard ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [OE-core] [PATCH v2 1/3] kernel-uboot: move FIT_KERNEL_COMP_ALG to image-fitimage.conf 2026-07-30 13:09 ` Richard Purdie @ 2026-07-30 13:35 ` Nora Schiffer 2026-07-30 13:50 ` Richard Purdie 0 siblings, 1 reply; 10+ messages in thread From: Nora Schiffer @ 2026-07-30 13:35 UTC (permalink / raw) To: Richard Purdie, openembedded-core; +Cc: oss On Thu, 2026-07-30 at 14:09 +0100, Richard Purdie wrote: > On Thu, 2026-07-30 at 13:15 +0200, Nora Schiffer wrote: > > On Thu, 2026-07-30 at 11:43 +0100, Richard Purdie wrote: > > > > Okay, new plan: Change uboot_prep_kimage to accept the compression algorithm as > > an argument, so we can use different variables when calling it from kernel- > > uimage.bbclass and kernel-fit-extra-artifacts.bbclass. kernel-uimage.bbclass > > could then use a separate variable UBOOT_MKIMAGE_KERNEL_COMP_ALG instead of > > reusing the FIT one. > > > > A more radical approach would be to skip the deprecation of using a linux.bin > > generated by the kernel recipe as a FIT image's kernel and drop support > > immediately. > > Can you see from the commit history who might have been using that? Do > you think there are many people relying upon it? If that functionality > doesn't make much sense and wouldn't or shouldn't be used by people, > I'm fine with actually removing it, as long as we're clear about why it > likely isn't needed or is inefficient (or whatever) and what the > alternative is. > > A lot of the time I think we support too many code paths when we should > try and encourage people to do the "best" known things. Right now using linux.bin is the only way to build a FIT image using kernel-fit- image.bbclass - my patch 2/3 introduces the option to use something different instead of linux.bin. As currently implemented, the patch results in a deprecation warning for *all* BSPs that build FIT images, but that seems preferable to breaking such BSPs. Making FIT_KERNEL_FILENAME default to KERNEL_IMAGETYPE would keep the FIT image working where KERNEL_IMAGETYPE is the correct image to include in the FIT, but it would differ from the current generation of linux.bin in kernel-uboot.bbclass in most cases. As far as I can tell this should work as intended on platforms that set KERNEL_IMAGETYPE to "Image"; types like zImage and bzImage would result in double compression with the default settings, and most other types would just be unbootable. I don't think we should go with this solution. Best, Nora -- TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany Amtsgericht München, HRB 105018 Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider https://www.tq-group.com/ ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [OE-core] [PATCH v2 1/3] kernel-uboot: move FIT_KERNEL_COMP_ALG to image-fitimage.conf 2026-07-30 13:35 ` Nora Schiffer @ 2026-07-30 13:50 ` Richard Purdie 2026-07-30 14:05 ` Nora Schiffer 0 siblings, 1 reply; 10+ messages in thread From: Richard Purdie @ 2026-07-30 13:50 UTC (permalink / raw) To: Nora Schiffer, openembedded-core; +Cc: oss On Thu, 2026-07-30 at 15:35 +0200, Nora Schiffer wrote: > On Thu, 2026-07-30 at 14:09 +0100, Richard Purdie wrote: > > On Thu, 2026-07-30 at 13:15 +0200, Nora Schiffer wrote: > > > On Thu, 2026-07-30 at 11:43 +0100, Richard Purdie wrote: > > > > > > Okay, new plan: Change uboot_prep_kimage to accept the compression algorithm as > > > an argument, so we can use different variables when calling it from kernel- > > > uimage.bbclass and kernel-fit-extra-artifacts.bbclass. kernel-uimage.bbclass > > > could then use a separate variable UBOOT_MKIMAGE_KERNEL_COMP_ALG instead of > > > reusing the FIT one. > > > > > > A more radical approach would be to skip the deprecation of using a linux.bin > > > generated by the kernel recipe as a FIT image's kernel and drop support > > > immediately. > > > > Can you see from the commit history who might have been using that? Do > > you think there are many people relying upon it? If that functionality > > doesn't make much sense and wouldn't or shouldn't be used by people, > > I'm fine with actually removing it, as long as we're clear about why it > > likely isn't needed or is inefficient (or whatever) and what the > > alternative is. > > > > A lot of the time I think we support too many code paths when we should > > try and encourage people to do the "best" known things. > > Right now using linux.bin is the only way to build a FIT image using kernel-fit- > image.bbclass - my patch 2/3 introduces the option to use something different > instead of linux.bin. As currently implemented, the patch results in a > deprecation warning for *all* BSPs that build FIT images, but that seems > preferable to breaking such BSPs. > > Making FIT_KERNEL_FILENAME default to KERNEL_IMAGETYPE would keep the FIT image > working where KERNEL_IMAGETYPE is the correct image to include in the FIT, but > it would differ from the current generation of linux.bin in kernel-uboot.bbclass > in most cases. As far as I can tell this should work as intended on platforms > that set KERNEL_IMAGETYPE to "Image"; types like zImage and bzImage would result > in double compression with the default settings, and most other types would just > be unbootable. I don't think we should go with this solution. Right, that does not sound like a good outcome. It also means that linux.bin isn't really deprecated though as the commit messages hinted at :/. This is why I'm asking questions since I really haven't looked into this in detail. I'm just very worried about the spaghetti nature of our classes and really don't want to make it worse. Cheers, Richard ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [OE-core] [PATCH v2 1/3] kernel-uboot: move FIT_KERNEL_COMP_ALG to image-fitimage.conf 2026-07-30 13:50 ` Richard Purdie @ 2026-07-30 14:05 ` Nora Schiffer 0 siblings, 0 replies; 10+ messages in thread From: Nora Schiffer @ 2026-07-30 14:05 UTC (permalink / raw) To: Richard Purdie, openembedded-core; +Cc: oss On Thu, 2026-07-30 at 14:50 +0100, Richard Purdie wrote: > On Thu, 2026-07-30 at 15:35 +0200, Nora Schiffer wrote: > > On Thu, 2026-07-30 at 14:09 +0100, Richard Purdie wrote: > > > On Thu, 2026-07-30 at 13:15 +0200, Nora Schiffer wrote: > > > > On Thu, 2026-07-30 at 11:43 +0100, Richard Purdie wrote: > > > > > > > > Okay, new plan: Change uboot_prep_kimage to accept the compression algorithm as > > > > an argument, so we can use different variables when calling it from kernel- > > > > uimage.bbclass and kernel-fit-extra-artifacts.bbclass. kernel-uimage.bbclass > > > > could then use a separate variable UBOOT_MKIMAGE_KERNEL_COMP_ALG instead of > > > > reusing the FIT one. > > > > > > > > A more radical approach would be to skip the deprecation of using a linux.bin > > > > generated by the kernel recipe as a FIT image's kernel and drop support > > > > immediately. > > > > > > Can you see from the commit history who might have been using that? Do > > > you think there are many people relying upon it? If that functionality > > > doesn't make much sense and wouldn't or shouldn't be used by people, > > > I'm fine with actually removing it, as long as we're clear about why it > > > likely isn't needed or is inefficient (or whatever) and what the > > > alternative is. > > > > > > A lot of the time I think we support too many code paths when we should > > > try and encourage people to do the "best" known things. > > > > Right now using linux.bin is the only way to build a FIT image using kernel-fit- > > image.bbclass - my patch 2/3 introduces the option to use something different > > instead of linux.bin. As currently implemented, the patch results in a > > deprecation warning for *all* BSPs that build FIT images, but that seems > > preferable to breaking such BSPs. > > > > Making FIT_KERNEL_FILENAME default to KERNEL_IMAGETYPE would keep the FIT image > > working where KERNEL_IMAGETYPE is the correct image to include in the FIT, but > > it would differ from the current generation of linux.bin in kernel-uboot.bbclass > > in most cases. As far as I can tell this should work as intended on platforms > > that set KERNEL_IMAGETYPE to "Image"; types like zImage and bzImage would result > > in double compression with the default settings, and most other types would just > > be unbootable. I don't think we should go with this solution. > > Right, that does not sound like a good outcome. It also means that > linux.bin isn't really deprecated though as the commit messages hinted > at :/. My goal is to deprecate it though - linux.bin generation has some weirdness that we should get rid of in my opinion, at least for FIT images (I don't have an opinion about uImage build). Thus patch 2 - implements an alternative approach that avoids the weirdness - warns users to switch to the new approach (to set KERNEL_IMAGETYPE(S) and FIT_KERNEL_FILENAME appropriately), without immediately breaking existing BSPs. I feel like implementing the new way without the deprecation warning would just result in users keeping the old solution longer, thus requiring us to preserve support for using linux.bin. Best, Nora -- TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany Amtsgericht München, HRB 105018 Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider https://www.tq-group.com/ ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 2/3] kernel-fit-image: reintroduce option to replace kernel image 2026-07-27 9:05 [PATCH v2 0/3] kernel-fit-image: allow replacing kernel, handle compression in FIT recipe Nora Schiffer 2026-07-27 9:05 ` [PATCH v2 1/3] kernel-uboot: move FIT_KERNEL_COMP_ALG to image-fitimage.conf Nora Schiffer @ 2026-07-27 9:06 ` Nora Schiffer 2026-07-27 9:06 ` [PATCH v2 3/3] kernel-fit-extra-artifacts: skip building linux.bin if unneeded Nora Schiffer 2 siblings, 0 replies; 10+ messages in thread From: Nora Schiffer @ 2026-07-27 9:06 UTC (permalink / raw) To: openembedded-core; +Cc: oss, Nora Schiffer A similar feature was added in commit 9c8ef2119949 ("kernel-fit-image: control kernel section with FIT_LINUX_BIN") and subsequently reverted in commit 6eae261b6f52 ("Revert "kernel-fit-image: control kernel section with FIT_LINUX_BIN"") due to its incomplete implementation and lack of tests. Reintroduce an improved version: - The FIT_LINUX_BIN variable (which had been left unused) is renamed to FIT_KERNEL_FILENAME. It can now actually be used to select a different file from DEPLOY_DIR_IMAGE. The file will be compressed using FIT_KERNEL_COMP_ALG, rather than than letting the kernel recipe handle this through kernel-fit-extra-artifacts.bbclass. - Alternatively, FIT_KERNEL_FILENAME_COMPRESSED can be used to select a pre-compressed file from DEPLOY_DIR_IMAGE. In this case, FIT_KERNEL_COMP_ALG only controls the "compression" field of the generated FIT image. - To avoid breaking backwards compatibility, FIT_KERNEL_FILENAME_COMPRESSED defaults to "linux.bin". As a special case, the compression algorithm will be read from "linux_comp" for linux.bin. - Add tests. Signed-off-by: Nora Schiffer <nora.schiffer@ew.tq-group.com> --- meta/classes-recipe/kernel-fit-image.bbclass | 53 +++++++++-- meta/conf/image-fitimage.conf | 24 ++++- meta/lib/oeqa/selftest/cases/fitimage.py | 96 +++++++++++++++++++- 3 files changed, 159 insertions(+), 14 deletions(-) diff --git a/meta/classes-recipe/kernel-fit-image.bbclass b/meta/classes-recipe/kernel-fit-image.bbclass index 3ace09ef5c..4ace6871f8 100644 --- a/meta/classes-recipe/kernel-fit-image.bbclass +++ b/meta/classes-recipe/kernel-fit-image.bbclass @@ -64,6 +64,7 @@ def apply_dtbvendored(d,dtb): python do_compile() { import shutil + import subprocess import oe.fitimage itsfile = "fit-image.its" @@ -88,12 +89,52 @@ python do_compile() { ) # Prepare a kernel image section. - shutil.copyfile(os.path.join(kernel_deploydir, "linux.bin"), "linux.bin") - with open(os.path.join(kernel_deploydir, "linux_comp")) as linux_comp_f: - linux_comp = linux_comp_f.read() - root_node.fitimage_emit_section_kernel("kernel-1", "linux.bin", linux_comp, - d.getVar('UBOOT_LOADADDRESS'), d.getVar('UBOOT_ENTRYPOINT'), - d.getVar('UBOOT_MKIMAGE_KERNEL_TYPE'), d.getVar("UBOOT_ENTRYSYMBOL")) + kernel = d.getVar('FIT_KERNEL_FILENAME') + kernel_compressed = d.getVar('FIT_KERNEL_FILENAME_COMPRESSED') + kernel_comp_alg = d.getVar('FIT_KERNEL_COMP_ALG') + + COMP_ALGS = { + 'gzip': ['gzip', '-9', '--stdout'], + 'lzo': ['lzop', '-9', '--stdout'], + 'lzma': ['xz', '--format=lzma', '-f', '-6', '--stdout'], + } + + if kernel and kernel_comp_alg == 'none': + kernel_compressed = kernel + kernel = None + elif not kernel and kernel_compressed == 'linux.bin': + # Backwards compatibility + bb.warn('FIT_KERNEL_FILENAME_COMPRESSED = "linux.bin" is deprecated. Set FIT_KERNEL_FILENAME or FIT_KERNEL_FILENAME_COMPRESSED explicitly.') + with open(os.path.join(kernel_deploydir, "linux_comp")) as linux_comp_f: + kernel_comp_alg = linux_comp_f.read() + + if kernel: + kernel_path = os.path.join(kernel_deploydir, kernel) + kernel_name = os.path.basename(kernel) + '.compressed' + + try: + cmd = COMP_ALGS[kernel_comp_alg] + [kernel_path] + except KeyError: + bb.fatal(f"Unknown algorithm {kernel_comp_alg} in FIT_KERNEL_COMP_ALG.") + + with open(kernel_name, 'wb') as f: + try: + subprocess.run(cmd, check=True, stdout=f, stderr=subprocess.PIPE) + except subprocess.CalledProcessError as e: + bb.fatal(f"Command '{' '.join(cmd)}' failed with return code {e.returncode}\nstderr: {e.stderr.decode()}") + + elif kernel_compressed: + kernel_path = os.path.join(kernel_deploydir, kernel_compressed) + kernel_name = os.path.basename(kernel_compressed) + shutil.copyfile(kernel_path, kernel_name) + + # FIT_KERNEL_FILENAME or FIT_KERNEL_FILENAME_COMPRESSED was set + if kernel_name: + root_node.fitimage_emit_section_kernel("kernel-1", kernel_name, kernel_comp_alg, + d.getVar('UBOOT_LOADADDRESS'), + d.getVar('UBOOT_ENTRYPOINT'), + d.getVar('UBOOT_MKIMAGE_KERNEL_TYPE'), + d.getVar("UBOOT_ENTRYSYMBOL")) # Prepare a DTB image section kernel_devicetree = d.getVar('KERNEL_DEVICETREE') diff --git a/meta/conf/image-fitimage.conf b/meta/conf/image-fitimage.conf index abb17186a5..f7b1ffdfd5 100644 --- a/meta/conf/image-fitimage.conf +++ b/meta/conf/image-fitimage.conf @@ -41,12 +41,28 @@ FIT_SUPPORTED_INITRAMFS_FSTYPES ?= "cpio.lz4 cpio.lzo cpio.lzma cpio.xz cpio.zst # to load a kernel with EFI stub as an EFI application. FIT_OS ?= "linux" -# Allow user to support special use cases where the kernel binary is -# not included in the FIT image itself. +# Select the binary included as kernel image in the FIT image. +# This allows the user to support special use cases where the kernel binary is +# not included in the FIT image itself or a different image is used as kernel. # This is particularly useful for UKI-based setups, where the kernel # and initramfs are bundled into a Unified Kernel Image (UKI), and -# DTBs are provided separately in a FIT image. -FIT_LINUX_BIN ?= "linux.bin" +# DTBs are provided separately in a FIT image, as well as providing the option +# to include an EFI application as the kernel. +# +# Will be compressed using FIT_KERNEL_COMP_ALG. See also +# FIT_KERNEL_FILENAME_COMPRESSED. +FIT_KERNEL_FILENAME ?= "" + +# Precompressed kernel image. FIT_KERNEL_COMP_ALG is used to fill the +# "compression" property in the FIT image, so it must match the used +# compression algorithm. As a special case, if FIT_KERNEL_FILENAME_COMPRESSED +# is set to "linux.bin", the compression algorithm is read from the "linux_comp" +# file instead for backwards compatiblity; this behavior is deprecated. +# +# If both FIT_KERNEL_FILENAME and FIT_KERNEL_FILENAME_COMPRESSED are set, +# FIT_KERNEL_FILENAME takes precedence. Unset both to generate a FIT image +# without kernel section. +FIT_KERNEL_FILENAME_COMPRESSED ?= "linux.bin" # fitImage kernel compression algorithm FIT_KERNEL_COMP_ALG ?= "gzip" diff --git a/meta/lib/oeqa/selftest/cases/fitimage.py b/meta/lib/oeqa/selftest/cases/fitimage.py index 451878aafd..5d54059b54 100644 --- a/meta/lib/oeqa/selftest/cases/fitimage.py +++ b/meta/lib/oeqa/selftest/cases/fitimage.py @@ -677,6 +677,8 @@ class KernelFitImageBase(FitImageTestCase): 'FIT_DESC', 'FIT_HASH_ALG', 'FIT_KERNEL_COMP_ALG', + 'FIT_KERNEL_FILENAME', + 'FIT_KERNEL_FILENAME_COMPRESSED', 'FIT_LOADABLES', 'FIT_LOADABLE_ENTRYPOINT', 'FIT_LOADABLE_LOADADDRESS', @@ -909,17 +911,39 @@ class KernelFitImageBase(FitImageTestCase): uboot_rd_loadaddress = bb_vars.get('UBOOT_RD_LOADADDRESS') uboot_rd_entrypoint = bb_vars.get('UBOOT_RD_ENTRYPOINT') + kernel_filename = bb_vars.get('FIT_KERNEL_FILENAME') + kernel_filename_compressed = bb_vars.get('FIT_KERNEL_FILENAME_COMPRESSED') + kernel_comp_alg = bb_vars['FIT_KERNEL_COMP_ALG'] + + if kernel_filename: + kernel_name = os.path.basename(kernel_filename) + if kernel_comp_alg != 'none': + kernel_name += '.compressed' + elif kernel_filename_compressed: + kernel_name = os.path.basename(kernel_filename_compressed) + its_field_check = [ 'description = "%s";' % bb_vars['FIT_DESC'], 'description = "Linux kernel";', 'type = "' + str(bb_vars['UBOOT_MKIMAGE_KERNEL_TYPE']) + '";', - # 'compression = "' + str(bb_vars['FIT_KERNEL_COMP_ALG']) + '";', defined based on files in TMPDIR, not ideal... - 'data = /incbin/("linux.bin");', + ] + + # Compression test skipped for deprecated linux.bin handling, as that + # would be based on files in TMPDIR + if kernel_filename or kernel_filename_compressed != 'linux.bin': + its_field_check.append('compression = "%s";' % kernel_comp_alg) + + if kernel_name: + its_field_check.append('data = /incbin/("%s");' % kernel_name) + + # Field order of its_field_check and the generated ITS must match + its_field_check += [ 'arch = "' + str(bb_vars['UBOOT_ARCH']) + '";', 'os = "%s";' % bb_vars['FIT_OS'], 'load = <' + str(bb_vars['UBOOT_LOADADDRESS']) + '>;', 'entry = <' + str(bb_vars['UBOOT_ENTRYPOINT']) + '>;', ] + if initramfs_image and initramfs_image_bundle != "1": its_field_check.append('type = "ramdisk";') if uboot_rd_loadaddress: @@ -1272,6 +1296,23 @@ PREFERRED_PROVIDER_virtual/dtb = "test-dtbs-as-ext" self._gen_atf_tee_dummy_images(bb_vars) self._test_fitimage(bb_vars) + def test_fit_image_kernel_filename(self): + """ + Summary: Check if FIT image and Image Tree Source (its) are built + and the Image Tree Source has the correct fields. + Expected: 1. fitImage and Image Tree Source can be built + 2. Filename and compression are as expected in the ITS + 3. Filename is as expected in the fitImage + """ + config = """ +FIT_KERNEL_FILENAME = "${KERNEL_IMAGETYPE}" +FIT_KERNEL_COMP_ALG = "none" +""" + config = self._config_add_kernel_classes(config) + self.write_config(config) + bb_vars = self._fit_get_bb_vars() + self._test_fitimage(bb_vars) + def test_sign_fit_image_configurations(self): """ @@ -1506,11 +1547,12 @@ class FitImagePyTests(KernelFitImageBase): 'FIT_DESC': "Kernel fitImage for a dummy distro", 'FIT_GENERATE_KEYS': "0", 'FIT_HASH_ALG': "sha256", + 'FIT_KERNEL_COMP_ALG': "gzip", + 'FIT_KERNEL_FILENAME_COMPRESSED': "linux.bin", 'FIT_KEY_GENRSA_ARGS': "-F4", 'FIT_KEY_REQ_ARGS': "-batch -new", 'FIT_KEY_SIGN_PKCS': "-x509", 'FIT_LOADABLES': "", - 'FIT_LINUX_BIN': "linux.bin", 'FIT_OS': "linux", 'FIT_PAD_ALG': "pkcs-1.5", 'FIT_SIGN_ALG': "rsa2048", @@ -1549,6 +1591,19 @@ class FitImagePyTests(KernelFitImageBase): debug_output = "\n".join([f"{key} = {value}" for key, value in bb_vars_overrides.items()]) self.logger.debug("bb_vars overrides:\n%s" % debug_output) + kernel = bb_vars.get('FIT_KERNEL_FILENAME') + kernel_compressed = bb_vars.get('FIT_KERNEL_FILENAME_COMPRESSED') + kernel_comp_alg = bb_vars.get('FIT_KERNEL_COMP_ALG') + + if kernel and kernel_comp_alg == 'none': + kernel_compressed = kernel + kernel = None + + if kernel: + kernel_name = os.path.basename(kernel) + '.compressed' + elif kernel_compressed: + kernel_name = os.path.basename(kernel_compressed) + 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_OS'], @@ -1561,7 +1616,8 @@ class FitImagePyTests(KernelFitImageBase): oe.types.boolean(bb_vars['FIT_SIGN_INDIVIDUAL']), bb_vars['UBOOT_SIGN_IMG_KEYNAME'] ) - root_node.fitimage_emit_section_kernel("kernel-1", "linux.bin", "none", + root_node.fitimage_emit_section_kernel("kernel-1", + kernel_name, kernel_comp_alg, bb_vars.get('UBOOT_LOADADDRESS'), bb_vars.get('UBOOT_ENTRYPOINT'), bb_vars.get('UBOOT_MKIMAGE_KERNEL_TYPE'), bb_vars.get("UBOOT_ENTRYSYMBOL") ) @@ -1651,6 +1707,38 @@ class FitImagePyTests(KernelFitImageBase): with self.assertRaises(BBHandledException): self._test_fitimage_py(bb_vars_overrides) + def test_fitimage_py_conf_kernel_filename_compression(self): + """Test FIT_KERNEL_FILENAME and FIT_KERNEL_COMP_ALG functionality""" + bb_vars_overrides = { + 'FIT_KERNEL_FILENAME': "path/to/my/Image", + 'FIT_KERNEL_COMP_ALG': "gzip", + } + self._test_fitimage_py(bb_vars_overrides) + + def test_fitimage_py_conf_kernel_filename_compression_none(self): + """Test FIT_KERNEL_FILENAME and FIT_KERNEL_COMP_ALG functionality""" + bb_vars_overrides = { + 'FIT_KERNEL_FILENAME': "path/to/my/Image", + 'FIT_KERNEL_COMP_ALG': "none", + } + self._test_fitimage_py(bb_vars_overrides) + + def test_fitimage_py_conf_kernel_filename_compressed(self): + """Test FIT_KERNEL_FILENAME_COMPRESSED functionality""" + bb_vars_overrides = { + 'FIT_KERNEL_FILENAME_COMPRESSED': "path/to/my/Image", + 'FIT_KERNEL_COMP_ALG': "gzip", + } + self._test_fitimage_py(bb_vars_overrides) + + def test_fitimage_py_conf_kernel_filename_compressed_none(self): + """Test FIT_KERNEL_FILENAME_COMPRESSED functionality""" + bb_vars_overrides = { + 'FIT_KERNEL_FILENAME_COMPRESSED': "path/to/my/Image", + 'FIT_KERNEL_COMP_ALG': "none", + } + self._test_fitimage_py(bb_vars_overrides) + def test_fitimage_py_conf_loadables(self): """Test FIT_LOADABLES basic functionality""" bb_vars_overrides = { -- TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany Amtsgericht München, HRB 105018 Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider https://www.tq-group.com/ ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 3/3] kernel-fit-extra-artifacts: skip building linux.bin if unneeded 2026-07-27 9:05 [PATCH v2 0/3] kernel-fit-image: allow replacing kernel, handle compression in FIT recipe Nora Schiffer 2026-07-27 9:05 ` [PATCH v2 1/3] kernel-uboot: move FIT_KERNEL_COMP_ALG to image-fitimage.conf Nora Schiffer 2026-07-27 9:06 ` [PATCH v2 2/3] kernel-fit-image: reintroduce option to replace kernel image Nora Schiffer @ 2026-07-27 9:06 ` Nora Schiffer 2 siblings, 0 replies; 10+ messages in thread From: Nora Schiffer @ 2026-07-27 9:06 UTC (permalink / raw) To: openembedded-core; +Cc: oss, Nora Schiffer The linux.bin generation logic is both complex and inflexible. With the introduction of FIT_KERNEL_FILENAME[_COMPRESSED], building linux.bin can be skipped if any of the two variables is set to a non-default value, as kernel-fit-image.bbclass will handle the compression itself. Signed-off-by: Nora Schiffer <nora.schiffer@ew.tq-group.com> --- meta/classes-recipe/kernel-fit-extra-artifacts.bbclass | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/meta/classes-recipe/kernel-fit-extra-artifacts.bbclass b/meta/classes-recipe/kernel-fit-extra-artifacts.bbclass index 385fe9895a..02e7d1273f 100644 --- a/meta/classes-recipe/kernel-fit-extra-artifacts.bbclass +++ b/meta/classes-recipe/kernel-fit-extra-artifacts.bbclass @@ -11,7 +11,9 @@ inherit kernel-uboot kernel_do_deploy:append() { # Provide the kernel artifacts to post processing recipes e.g. for creating a FIT image - uboot_prep_kimage "$deployDir" + if [ -z "${FIT_KERNEL_FILENAME}" ] && [ "${FIT_KERNEL_FILENAME_COMPRESSED}" = 'linux.bin' ]; then + uboot_prep_kimage "$deployDir" + fi # For x86 a setup.bin needs to be include"d in a fitImage as well if [ -e ${KERNEL_OUTPUT_DIR}/setup.bin ]; then install -D "${B}/${KERNEL_OUTPUT_DIR}/setup.bin" "$deployDir/" -- TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany Amtsgericht München, HRB 105018 Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider https://www.tq-group.com/ ^ permalink raw reply related [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-07-30 14:05 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-07-27 9:05 [PATCH v2 0/3] kernel-fit-image: allow replacing kernel, handle compression in FIT recipe Nora Schiffer 2026-07-27 9:05 ` [PATCH v2 1/3] kernel-uboot: move FIT_KERNEL_COMP_ALG to image-fitimage.conf Nora Schiffer 2026-07-30 10:43 ` [OE-core] " Richard Purdie 2026-07-30 11:15 ` Nora Schiffer 2026-07-30 13:09 ` Richard Purdie 2026-07-30 13:35 ` Nora Schiffer 2026-07-30 13:50 ` Richard Purdie 2026-07-30 14:05 ` Nora Schiffer 2026-07-27 9:06 ` [PATCH v2 2/3] kernel-fit-image: reintroduce option to replace kernel image Nora Schiffer 2026-07-27 9:06 ` [PATCH v2 3/3] kernel-fit-extra-artifacts: skip building linux.bin if unneeded Nora Schiffer
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox