Skip to content

meta-aspeed: Compress raw arm64 kernels in the FIT - #316

Open
louis-nexthop wants to merge 1 commit into
meta:heliumfrom
nexthop-ai:fit-compress-arm64-kernel
Open

louis-nexthop wants to merge 1 commit into
meta:heliumfrom
nexthop-ai:fit-compress-arm64-kernel

Conversation

@louis-nexthop

@louis-nexthop louis-nexthop commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Description

kernel_fitimage.bbclass always puts the kernel in the FIT uncompressed. That suits the AST2400-AST2600 zImage, which decompresses itself, but AST2700 machines boot a raw arm64 Image of about 23 MiB.

A raw Image is now compressed with FIT_KERNEL_COMP_ALG (default none; lzma from ast2700.inc; gzip also accepted), as oe-core's kernel-fitimage does, and U-Boot decompresses it. Self-decompressing kernels are unchanged.

Motivation

ast2700.inc already sets FIT_KERNEL_COMP_ALG ?= "lzma", but the class never reads it, so AST2700 FITs carry the kernel uncompressed. With this change the FIT shrinks by 15.6 MiB on AST2700. Boot time is about the same: lzma decompression takes 1.6 s on the A35, about what reading the saved 15.6 MiB from SPI costs.

Test Plan

The same tree built for the AST2720 variant of Nexthop's BMC without and with this change (only kernel_fitimage.bbclass differs):

before after
flash image 60,364,522 B (57.6 MiB) 43,955,210 B (41.9 MiB)
FIT (os-fit) 56,039,146 B (53.4 MiB) 39,629,834 B (37.8 MiB)
kernel node 23,951,368 B, none 7,544,252 B, lzma

FIT headers read from the two flash images:

before/flash.bin: 60364522 bytes (57.6 MiB)
  FIT at 0x420000: totalsize 56039146 bytes (53.4 MiB)
  kernel@1     type=kernel     compression=none   data=23951368 bytes (22.8 MiB)
  ramdisk@1    type=ramdisk    compression=lzma   data=32035456 bytes (30.6 MiB)
  fdt@1        type=flat_dt    compression=none   data=50798 bytes (0.0 MiB)
after/flash.bin: 43955210 bytes (41.9 MiB)
  FIT at 0x420000: totalsize 39629834 bytes (37.8 MiB)
  kernel@1     type=kernel     compression=lzma   data=7544252 bytes (7.2 MiB)
  ramdisk@1    type=ramdisk    compression=lzma   data=32033260 bytes (30.5 MiB)
  fdt@1        type=flat_dt    compression=none   data=50798 bytes (0.0 MiB)

U-Boot booting a compressed kernel on the board:

## Loading kernel from FIT Image at 403000000 ...
   Using 'conf@1' configuration
   Trying 'kernel@1' kernel subimage
     Description:  Linux kernel
     Type:         Kernel Image
     Compression:  lzma compressed
     Data Start:   0x4030000e8
     Data Size:    7532961 Bytes = 7.2 MiB
     Architecture: AArch64
     OS:           Linux
     Load Address: 0x400000000
     Entry Point:  0x400000000
     Hash algo:    sha256
     Hash value:   d69a8235c37db7cb67584bdbfed074c12682ad98b37259f3088a6d1e9ea6f1bd
## Loading ramdisk from FIT Image at 403000000 ...
   Using 'conf@1' configuration
   Trying 'ramdisk@1' ramdisk subimage
     Description:  RAMDISK
     Type:         RAMDisk Image
     Compression:  lzma compressed
     Data Start:   0x40372f388
     Data Size:    32020037 Bytes = 30.5 MiB
     Architecture: AArch64
     OS:           Linux
     Load Address: unavailable
     Entry Point:  unavailable
     Hash algo:    sha256
     Hash value:   75961b5011d35ecd2d27c648908be2e865eae90102828a01808b3cc4b3423c48
WARNING: 'compression' nodes for ramdisks are deprecated, please fix your .its file!
## Loading fdt from FIT Image at 403000000 ...
   Using 'conf@1' configuration
   Trying 'fdt@1' fdt subimage
     Description:  Flattened Device Tree blob
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x4055b8ab4
     Data Size:    55694 Bytes = 54.4 KiB
     Architecture: AArch64
     Hash algo:    sha256
     Hash value:   e873a0eac939d4d8e14669a8eb72542c75523bc53609299ec0c671b4c21d670a
   Booting using the fdt blob at 0x4055b8ab4
Working FDT set to 4055b8ab4
   Uncompressing Kernel Image
   Loading Ramdisk to 4eaf5d000, end 4ecde6645 ... OK
   Loading Device Tree to 00000004eaf4c000, end 00000004eaf5c98d ... OK
Working FDT set to 4eaf4c000

Starting kernel ...

@meta-cla meta-cla Bot added the CLA Signed label Nov 14, 2026
kernel_fitimage.bbclass always puts the kernel in the FIT uncompressed.
That suits the AST2400-AST2600 zImage, which decompresses itself, but
AST2700 machines boot a raw arm64 Image of about 23 MiB.

Compress a raw Image with FIT_KERNEL_COMP_ALG (default "none"; "lzma"
from ast2700.inc; "gzip" also accepted), as oe-core's kernel-fitimage
does, and let U-Boot decompress it. Self-decompressing kernels are
unchanged.

Signed-off-by: Louis Maliyam <louis@nexthop.ai>
@louis-nexthop
louis-nexthop force-pushed the fit-compress-arm64-kernel branch from 71932e9 to 08a963c Compare November 14, 2026 02:16
@williamspatrick

Copy link
Copy Markdown
Contributor

Did you look at zstd compression? Usually we prefer that over lzma because it is significantly faster at decompression.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants