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 and gzip 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. Honoring it shrinks the FIT by 15.6 MiB. Boot time stays about the same: U-Boot unpacks the lzma kernel in about 1.6 s, roughly what reading the saved 15.6 MiB from SPI costs.

lzma stays the AST2700 default: a zstd kernel was 1.1 MiB larger and no faster to boot (measurements).

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 57.6 MiB 41.9 MiB
FIT (os-fit) 53.4 MiB 37.8 MiB
kernel node 22.8 MiB, none 7.2 MiB, 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 the compressed kernel on the board (ramdisk and fdt sections elided):

## 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
...
   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
@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.

@louis-nexthop

louis-nexthop commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for the pointer, @williamspatrick! I measured zstd on our AST2720 board. Three images, each the average of 3 reboots:

lzma kernel + lzma initramfs lzma kernel + zstd initramfs zstd kernel + zstd initramfs
total flash image 41.9 MiB 47.2 MiB 48.3 MiB
kernel in FIT 7.2 MiB 7.2 MiB 8.3 MiB
initramfs in FIT 30.5 MiB 35.9 MiB 35.9 MiB
U-Boot Uncompressing Kernel Image → Starting kernel 1.84 s 1.84 s 1.93 s
kernel initramfs unpack (dmesg) 24.64 s 2.24 s 2.23 s
U-Boot banner → login: 72.47 s 63.69 s 63.87 s

You were right about the decompression speed: with a zstd initramfs the kernel unpacks it 11x faster (24.6 → 2.2 s), and the BMC reaches login: 8.8 s sooner.

The kernel turned out differently. It is small enough that U-Boot unpacks the lzma one in under 2 s, and with zstd it came out 1.1 MiB larger and slightly slower (1.93 vs 1.84 s), with no gain in time to login. So for this PR I'd keep the existing FIT_KERNEL_COMP_ALG ?= "lzma" default from ast2700.inc, if that works for you. We'll use zstd for the initramfs: it is a per-machine choice through fb-zstd-rootfs.inc, so I'll enable it in a separate PR when we add Nexthop's AST2720 machine.

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 08a963c to fbc1d84 Compare November 18, 2026 00:44
@williamspatrick

Copy link
Copy Markdown
Contributor

SGTM

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