Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] linux: Use the choosen rootfs compression type when rootfs is builtin
@ 2023-11-06 12:37 Corentin Labbe
  2023-11-27 11:42 ` Corentin LABBE
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Corentin Labbe @ 2023-11-06 12:37 UTC (permalink / raw)
  To: buildroot; +Cc: Corentin Labbe

I have built a buildroot with:
BR2_TARGET_ROOTFS_CPIO_XZ=y
BR2_TARGET_ROOTFS_INITRAMFS=y
With this buildroot produces an images/rootfs.cpio.xz but the kernel still use gzip (CONFIG_INITRAMFS_COMPRESSION_GZIP)
as compression for a plain rootfs.cpio

Setting CONFIG_INITRAMFS_COMPRESSION_XZ in a linux.fragment does not
work as it seems the fragment is setup before buildroot set
CONFIG_INITRAMFS_SOURCE which reset the CONFIG_INITRAMFS_COMPRESSION
choice.

So buildroot have to change CONFIG_INITRAMFS_COMPRESSION after setup
CONFIG_INITRAMFS_SOURCE.

Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
---
 linux/linux.mk | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/linux/linux.mk b/linux/linux.mk
index 1db5c6046d..d64ebb5119 100644
--- a/linux/linux.mk
+++ b/linux/linux.mk
@@ -116,6 +116,14 @@ LINUX_COMPRESSION_OPT_$(BR2_LINUX_KERNEL_XZ) += CONFIG_KERNEL_XZ
 LINUX_COMPRESSION_OPT_$(BR2_LINUX_KERNEL_ZSTD) += CONFIG_KERNEL_ZSTD
 LINUX_COMPRESSION_OPT_$(BR2_LINUX_KERNEL_UNCOMPRESSED) += CONFIG_KERNEL_UNCOMPRESSED
 
+LINUX_ROOTFS_COMPRESSION_OPT_$(BR2_TARGET_ROOTFS_CPIO_GZIP) += CONFIG_INITRAMFS_COMPRESSION_GZIP
+LINUX_ROOTFS_COMPRESSION_OPT_$(BR2_TARGET_ROOTFS_CPIO_LZ4) += CONFIG_INITRAMFS_COMPRESSION_LZ4
+LINUX_ROOTFS_COMPRESSION_OPT_$(BR2_TARGET_ROOTFS_CPIO_LZMA) += CONFIG_INITRAMFS_COMPRESSION_LZMA
+LINUX_ROOTFS_COMPRESSION_OPT_$(BR2_TARGET_ROOTFS_CPIO_LZO) += CONFIG_INITRAMFS_COMPRESSION_LZO
+LINUX_ROOTFS_COMPRESSION_OPT_$(BR2_TARGET_ROOTFS_CPIO_XZ) += CONFIG_INITRAMFS_COMPRESSION_XZ
+LINUX_ROOTFS_COMPRESSION_OPT_$(BR2_TARGET_ROOTFS_CPIO_ZSTD) += CONFIG_INITRAMFS_COMPRESSION_ZSTD
+LINUX_ROOTFS_COMPRESSION_OPT_$(BR2_TARGET_ROOTFS_CPIO_NONE) += CONFIG_INITRAMFS_COMPRESSION_NONE
+
 ifeq ($(BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL),y)
 LINUX_DEPENDENCIES += host-openssl
 endif
@@ -378,6 +386,10 @@ define LINUX_KCONFIG_FIXUP_CMDS_ROOTFS_CPIO
 	$(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_SOURCE,"$${BR_BINARIES_DIR}/rootfs.cpio")
 	$(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_ROOT_UID,0)
 	$(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_ROOT_GID,0)
+	$(call KCONFIG_ENABLE_OPT,$(strip $(LINUX_ROOTFS_COMPRESSION_OPT_y)))
+	$(foreach opt, $(LINUX_ROOTFS_COMPRESSION_OPT_),
+		$(call KCONFIG_DISABLE_OPT,$(opt))
+	)
 endef
 endif
 
-- 
2.25.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* Re: [Buildroot] [PATCH 1/1] linux: Use the choosen rootfs compression type when rootfs is builtin
  2023-11-06 12:37 [Buildroot] [PATCH 1/1] linux: Use the choosen rootfs compression type when rootfs is builtin Corentin Labbe
@ 2023-11-27 11:42 ` Corentin LABBE
  2026-10-11 13:11 ` Arnout Vandecappelle via buildroot
  2026-11-23 17:47 ` [Buildroot] [PATCH v2] " Angelo Compagnucci
  2 siblings, 0 replies; 4+ messages in thread
From: Corentin LABBE @ 2023-11-27 11:42 UTC (permalink / raw)
  To: buildroot

Le Mon, Nov 06, 2023 at 12:37:05PM +0000, Corentin Labbe a écrit :
> I have built a buildroot with:
> BR2_TARGET_ROOTFS_CPIO_XZ=y
> BR2_TARGET_ROOTFS_INITRAMFS=y
> With this buildroot produces an images/rootfs.cpio.xz but the kernel still use gzip (CONFIG_INITRAMFS_COMPRESSION_GZIP)
> as compression for a plain rootfs.cpio
> 
> Setting CONFIG_INITRAMFS_COMPRESSION_XZ in a linux.fragment does not
> work as it seems the fragment is setup before buildroot set
> CONFIG_INITRAMFS_SOURCE which reset the CONFIG_INITRAMFS_COMPRESSION
> choice.
> 
> So buildroot have to change CONFIG_INITRAMFS_COMPRESSION after setup
> CONFIG_INITRAMFS_SOURCE.
> 
> Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
> ---

Hello

Ping

Regards
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* Re: [Buildroot] [PATCH 1/1] linux: Use the choosen rootfs compression type when rootfs is builtin
  2023-11-06 12:37 [Buildroot] [PATCH 1/1] linux: Use the choosen rootfs compression type when rootfs is builtin Corentin Labbe
  2023-11-27 11:42 ` Corentin LABBE
@ 2026-10-11 13:11 ` Arnout Vandecappelle via buildroot
  2026-11-23 17:47 ` [Buildroot] [PATCH v2] " Angelo Compagnucci
  2 siblings, 0 replies; 4+ messages in thread
From: Arnout Vandecappelle via buildroot @ 2026-10-11 13:11 UTC (permalink / raw)
  To: Corentin Labbe, buildroot

  Hi Corentin,

  Sorry to come back to this only three years later... You probably don't 
remember anything about this, but I'm replying anyway in case anybody comes back 
on this.

On 06/11/2023 13:37, Corentin Labbe wrote:
> I have built a buildroot with:
> BR2_TARGET_ROOTFS_CPIO_XZ=y
> BR2_TARGET_ROOTFS_INITRAMFS=y
> With this buildroot produces an images/rootfs.cpio.xz but the kernel still use gzip (CONFIG_INITRAMFS_COMPRESSION_GZIP)
> as compression for a plain rootfs.cpio
> 
> Setting CONFIG_INITRAMFS_COMPRESSION_XZ in a linux.fragment does not
> work as it seems the fragment is setup before buildroot set
> CONFIG_INITRAMFS_SOURCE which reset the CONFIG_INITRAMFS_COMPRESSION
> choice.
> 
> So buildroot have to change CONFIG_INITRAMFS_COMPRESSION after setup
> CONFIG_INITRAMFS_SOURCE.
> 
> Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
> ---
>   linux/linux.mk | 12 ++++++++++++
>   1 file changed, 12 insertions(+)
> 
> diff --git a/linux/linux.mk b/linux/linux.mk
> index 1db5c6046d..d64ebb5119 100644
> --- a/linux/linux.mk
> +++ b/linux/linux.mk
> @@ -116,6 +116,14 @@ LINUX_COMPRESSION_OPT_$(BR2_LINUX_KERNEL_XZ) += CONFIG_KERNEL_XZ
>   LINUX_COMPRESSION_OPT_$(BR2_LINUX_KERNEL_ZSTD) += CONFIG_KERNEL_ZSTD
>   LINUX_COMPRESSION_OPT_$(BR2_LINUX_KERNEL_UNCOMPRESSED) += CONFIG_KERNEL_UNCOMPRESSED
>   
> +LINUX_ROOTFS_COMPRESSION_OPT_$(BR2_TARGET_ROOTFS_CPIO_GZIP) += CONFIG_INITRAMFS_COMPRESSION_GZIP
> +LINUX_ROOTFS_COMPRESSION_OPT_$(BR2_TARGET_ROOTFS_CPIO_LZ4) += CONFIG_INITRAMFS_COMPRESSION_LZ4
> +LINUX_ROOTFS_COMPRESSION_OPT_$(BR2_TARGET_ROOTFS_CPIO_LZMA) += CONFIG_INITRAMFS_COMPRESSION_LZMA
> +LINUX_ROOTFS_COMPRESSION_OPT_$(BR2_TARGET_ROOTFS_CPIO_LZO) += CONFIG_INITRAMFS_COMPRESSION_LZO
> +LINUX_ROOTFS_COMPRESSION_OPT_$(BR2_TARGET_ROOTFS_CPIO_XZ) += CONFIG_INITRAMFS_COMPRESSION_XZ
> +LINUX_ROOTFS_COMPRESSION_OPT_$(BR2_TARGET_ROOTFS_CPIO_ZSTD) += CONFIG_INITRAMFS_COMPRESSION_ZSTD
> +LINUX_ROOTFS_COMPRESSION_OPT_$(BR2_TARGET_ROOTFS_CPIO_NONE) += CONFIG_INITRAMFS_COMPRESSION_NONE
> +
>   ifeq ($(BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL),y)
>   LINUX_DEPENDENCIES += host-openssl
>   endif
> @@ -378,6 +386,10 @@ define LINUX_KCONFIG_FIXUP_CMDS_ROOTFS_CPIO
>   	$(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_SOURCE,"$${BR_BINARIES_DIR}/rootfs.cpio")

  We still use the uncompressed cpio, so shouldn't we simply set 
CONFIG_INITRAMFS_COMPRESSION_NONE ?

  We could use the compressed image here, but I think it's intentional to use 
the uncompressed one, because normally you still compress your kernel afterwards 
(either as a zImage or in the U-Boot wrapper). This will also compress the cpio, 
so compressing it separately just adds overhead.

>   	$(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_ROOT_UID,0)
>   	$(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_ROOT_GID,0)
> +	$(call KCONFIG_ENABLE_OPT,$(strip $(LINUX_ROOTFS_COMPRESSION_OPT_y)))
> +	$(foreach opt, $(LINUX_ROOTFS_COMPRESSION_OPT_),
> +		$(call KCONFIG_DISABLE_OPT,$(opt))

  AFAIK for a choice it's not needed to disable all the other options; the last 
=y option wins anyway (if it is not forbidden by other options).

  I've marked the patch as Changes Requested in patchwork.

  Regards,
  Arnout

> +	)
>   endef
>   endif
>   

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* [Buildroot] [PATCH v2] linux: Use the choosen rootfs compression type when rootfs is builtin
  2023-11-06 12:37 [Buildroot] [PATCH 1/1] linux: Use the choosen rootfs compression type when rootfs is builtin Corentin Labbe
  2023-11-27 11:42 ` Corentin LABBE
  2026-10-11 13:11 ` Arnout Vandecappelle via buildroot
@ 2026-11-23 17:47 ` Angelo Compagnucci
  2 siblings, 0 replies; 4+ messages in thread
From: Angelo Compagnucci @ 2026-11-23 17:47 UTC (permalink / raw)
  To: buildroot; +Cc: Corentin Labbe, Arnout Vandecappelle

From: Corentin Labbe <clabbe@baylibre.com>

I have built a buildroot with:
BR2_TARGET_ROOTFS_CPIO_XZ=y
BR2_TARGET_ROOTFS_INITRAMFS=y
With this buildroot produces an images/rootfs.cpio.xz but the kernel still use gzip (CONFIG_INITRAMFS_COMPRESSION_GZIP)
as compression for a plain rootfs.cpio

Setting CONFIG_INITRAMFS_COMPRESSION_XZ in a linux.fragment does not
work as it seems the fragment is setup before buildroot set
CONFIG_INITRAMFS_SOURCE which reset the CONFIG_INITRAMFS_COMPRESSION
choice.

So buildroot have to change CONFIG_INITRAMFS_COMPRESSION after setup
CONFIG_INITRAMFS_SOURCE.

Without cpio compression, the kernel keeps its own default, as before.
So the defconfigs with a built-in initramfs, which use no cpio
compression and often boot an uncompressed kernel image, don't change.

Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
Co-authored-by: Angelo Compagnucci <angelo.compagnucci@gmail.com>
Tested-by: Angelo Compagnucci <angelo.compagnucci@gmail.com>
Signed-off-by: Angelo Compagnucci <angelo.compagnucci@gmail.com>
---
Changes v1 -> v2:
  - keep the kernel default when the cpio image is not compressed,
    instead of CONFIG_INITRAMFS_COMPRESSION_NONE: the 20 defconfigs
    with a built-in initramfs use no cpio compression, and most of them
    boot an uncompressed kernel (vmlinux, linux.bin, XIP), so their
    images would grow [Arnout Vandecappelle]
  - only enable the chosen option, don't disable the others
    [Arnout Vandecappelle]
  - also enable the CONFIG_RD_* option the choice depends on
  - add bzip2
  - rebase on master

Supersedes v1: https://patchwork.buildroot.org/project/buildroot/patch/20231106123705.311899-1-clabbe@baylibre.com/

 linux/linux.mk | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/linux/linux.mk b/linux/linux.mk
index 49325a3a07..72624fff59 100644
--- a/linux/linux.mk
+++ b/linux/linux.mk
@@ -420,7 +420,26 @@ define LINUX_KCONFIG_FIXUP_CMDS_ROOTFS_CPIO
 	$(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_SOURCE,"$${BR_BINARIES_DIR}/rootfs.cpio")
 	$(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_ROOT_UID,0)
 	$(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_ROOT_GID,0)
+	$(LINUX_KCONFIG_FIXUP_CMDS_INITRAMFS_COMPRESSION)
 endef
+
+# Compress the built-in initramfs like the cpio image. Setting
+# CONFIG_INITRAMFS_SOURCE above resets this choice, so a kernel
+# configuration fragment can't set it. Without cpio compression, the
+# kernel keeps its own default.
+LINUX_INITRAMFS_COMPRESSION_$(BR2_TARGET_ROOTFS_CPIO_BZIP2) = BZIP2
+LINUX_INITRAMFS_COMPRESSION_$(BR2_TARGET_ROOTFS_CPIO_GZIP) = GZIP
+LINUX_INITRAMFS_COMPRESSION_$(BR2_TARGET_ROOTFS_CPIO_LZ4) = LZ4
+LINUX_INITRAMFS_COMPRESSION_$(BR2_TARGET_ROOTFS_CPIO_LZMA) = LZMA
+LINUX_INITRAMFS_COMPRESSION_$(BR2_TARGET_ROOTFS_CPIO_LZO) = LZO
+LINUX_INITRAMFS_COMPRESSION_$(BR2_TARGET_ROOTFS_CPIO_XZ) = XZ
+LINUX_INITRAMFS_COMPRESSION_$(BR2_TARGET_ROOTFS_CPIO_ZSTD) = ZSTD
+ifneq ($(LINUX_INITRAMFS_COMPRESSION_y),)
+define LINUX_KCONFIG_FIXUP_CMDS_INITRAMFS_COMPRESSION
+	$(call KCONFIG_ENABLE_OPT,CONFIG_RD_$(LINUX_INITRAMFS_COMPRESSION_y))
+	$(call KCONFIG_ENABLE_OPT,CONFIG_INITRAMFS_COMPRESSION_$(LINUX_INITRAMFS_COMPRESSION_y))
+endef
+endif
 endif
 
 # Since kernel >= 6.15.y, x86 and x86_64 kernels requires a toolchain
-- 
2.53.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

end of thread, other threads:[~2026-11-23 17:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-06 12:37 [Buildroot] [PATCH 1/1] linux: Use the choosen rootfs compression type when rootfs is builtin Corentin Labbe
2023-11-27 11:42 ` Corentin LABBE
2026-10-11 13:11 ` Arnout Vandecappelle via buildroot
2026-11-23 17:47 ` [Buildroot] [PATCH v2] " Angelo Compagnucci

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