1

I've successfully used buildroot (v. 2019.05) to built u-boot and Kernel and was able to boot it together.

The problem is that, even though I selected Kernel compression mode to gzip, all I get is the uncompressed Image file.

In the output directory (and Linux as well) there is only Image file, while there should be Image.gz.

How to generate Image.gz from / instead of Image?

zupazt3
  • 966
  • 9
  • 30

3 Answers3

6

On arm64, Linux does not support self-extracting compression. It relies on the boot loader to do that.

The Linux build system does have an Image.gz (and Image.bz2 etc.) target, but it does nothing more than calling gzip on Image (compare this with zImage, which adds a self-extractor).

Since it is easy to do the compression outside of the kernel build system, and since there are so many different compressors possible, Buildroot doesn't provide options for them. However, it is possible to select a custom image name (BR2_LINUX_KERNEL_IMAGE_TARGET_CUSTOM) and then set BR2_LINUX_KERNEL_IMAGE_TARGET_NAME to Image.gz. Alternatively, you can do the compression in a post-build script.

Remember to make sure that the bootloader is able to decompress with that algorithm.

Arnout
  • 2,927
  • 16
  • 24
  • Thanks that was exactly this. I took the `Image` file generated by the buildroot (well Kernel to be precise) and used a command `gzip Image` to get the `Image.gz` and simply set `compression = "gzip"` in my *.its file. Was much simpler than I thought, thanks. – zupazt3 May 21 '19 at 12:43
1

According to the Linux package configuration tool:

This selection will just ensure that the correct host tools are built. The actual compression for the kernel should be selected in the kernel configuration menu.

Make sure you select the compression option using make linux-menuconfig too.

Bora
  • 451
  • 2
  • 5
  • Thanks, but for some reason "Kernel compression mode" is not visible in "General setup" in my kernel config. – zupazt3 May 20 '19 at 07:57
1

In buildroot, besides selecting the compression mechanism you can also select the output format for the kernel image (uImage, zImage, vmlinux ...).

You should find on of those in your output/images/ or in the build directory of your kernel.

When using U-boot you probably want to use the uImage or the zImage. See this question. Both of them will be compressed if selected in the kernel configuration (CONFIG_KERNEL_GZIP).

During boot the uncompressed size of the kernel is logged in the beginning. You can compare it to the size on your filesystem.

## Booting kernel from Legacy Image at 10000000 ...
   Image Name:   Linux-4.14.73-ltsi
   Created:      2019-05-14  11:55:16 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    4684016 Bytes = 4.5 MiB
   Load Address: 00008000
   Entry Point:  00008000
...
Toto
  • 79
  • 10
  • Thanks, I search for `CONFIG_KERNEL_GZIP` and it's an option for "Kernel compression mode" - but this choice is not visible in my kernel config. I have enabled `gzip` in buildroot `menuconfig` and then in the buildroot directory I do `make linux-menuconfig` and I don't see "Kernel compression mode" under "General setup". This option depends on `HAVE_KERNEL_GZIP`, but I don't know how / why it's not set. Do you know why I don't see "Kernel compression mode"? – zupazt3 May 20 '19 at 08:01