Re: [PATCH 0/2] arm64,riscv: boot: emit standard LZ4 frame for Image.lz4

From: Yann Collet

Date: Wed Nov 25 2026 - 19:20:06 EST


On Tue, Nov 24, 2026 at 02:56:48PM +0800, Ping Li wrote:
> arm64 and riscv also build Image.lz4 with the plain cmd_lz4, but a
> compressed boot image on these two architectures is not decompressed
> by the kernel itself - it is handed to the bootloader. U-Boot, which
> implements this via the 'booti' compressed-kernel path (boot/image.c
> image_decomp -> lib/lz4_wrapper.c ulz4fn), only accepts the standard
> LZ4 frame (magic 0x184D2204) and returns -EPROTONOSUPPORT for
> anything else.

U-Boot's decoder has a second requirement: independent blocks. It
rejects frames with linked blocks, and the new rules rely on
independent blocks being the default of the lz4 CLI. lz4 is considering
linked blocks by default in a future version. U-Boot can learn to
accept them, but bootloaders already deployed won't.

Passing -BI makes the output independent of that default:

cmd_lz4_std = cat $(real-prereqs) | $(LZ4) -9 -BI - - > $@

With current lz4 versions, the output is unchanged. One caveat: -BI
exists since lz4 v1.9.0 (2019). Older versions, still found on some
build hosts (lz4 1.8.3 on RHEL 8), reject it, but they produce
independent blocks by default anyway. So the rule can pass -BI only
when lz4 accepts it: 'lz4 -BI -V' fails on these older versions.

Yann