SPL knows about multiple compression algorithms, but only two are
hand-rolled into the simple FIT loading code, in spite of a nice ready
made helper already being available right there.

Generalize the compressed FIT handling code to accept any compression
algorithm compiled into the SPL, and fix up the SPL_ZSTD linkage which
requires xxhash in the SPL but which was absent to date.

While here, also extend binman to support passing a compression level via
its image templates, which helps squeeze additional ~15% size savings in
my testing with Zstd level 19 without impacting decompression speed.

This is done with Rockchip RK3576 in mind, so a small Rockchip image
template refactor is included.

CI passes all green: 
https://git.u-boot-project.org/u-boot/contributors/alchark/u-boot/-/pipelines/1319

Signed-off-by: Alexey Charkov <[email protected]>
---
Changes in v2:
- Dropped redundant help text passage about SPL heap free() being noop (thanks 
Tom)
- Dropped redundant indirection via spl_decompression_enabled() now that it's 
directly
  queryable via the new Kconfig symbol (thanks Tom)
- Link to v1: 
https://patch.msgid.link/[email protected]

To: [email protected]
Cc: Tom Rini <[email protected]>
Cc: Alexey Charkov <[email protected]>
Cc: Quentin Schulz <[email protected]>
Cc: Ilias Apalodimas <[email protected]>
Cc: Vincent Jardin <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: Casey Connolly <[email protected]>
Cc: Michael Srba <[email protected]>
Cc: Cole Munz <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Francesco Valla <[email protected]>
Cc: Anton Ivanov <[email protected]>
Cc: Aristo Chen <[email protected]>
Cc: João Marcos Costa <[email protected]>
Cc: Richard Genoud <[email protected]>
Cc: Daniel Golle <[email protected]>
Cc: Heinrich Schuchardt <[email protected]>
Cc: Alper Nebi Yasak <[email protected]>
Cc: James Hilliard <[email protected]>
Cc: Quentin Schulz <[email protected]>
Cc: Kever Yang <[email protected]>
Cc: Johan Jonker <[email protected]>

---
Alexey Charkov (11):
      boot: image: Keep the image-type table out of xPL
      lib: Build xxhash in the SPL phase
      lib: Let SPL minify zstd on its own
      lib: Track whether a phase has a decompressor
      spl: fit: Decompress any supported algorithm
      test: spl: Keep the payload create_fit() is handed
      test: spl: Size the FIT properties for the image name
      test: spl: Cover FIT image decompression
      sandbox: spl: Enable zstd
      binman: Allow choosing the compression level
      rockchip: Choose FIT payload compression via Kconfig

 arch/arm/dts/rockchip-u-boot.dtsi                  | 16 ++---
 arch/arm/mach-rockchip/Kconfig                     | 78 ++++++++++++++++++++
 boot/image.c                                       |  7 +-
 common/spl/spl_fit.c                               | 33 ++++-----
 configs/sandbox_spl_defconfig                      |  3 +-
 include/spl.h                                      | 10 ---
 include/test/spl.h                                 |  8 +++
 lib/Kconfig                                        | 52 +++++++++++++-
 lib/Makefile                                       |  3 +-
 lib/zstd/Makefile                                  |  2 +-
 test/image/spl_load.c                              | 84 +++++++++++++++++-----
 test/image/spl_load_nor.c                          |  2 +
 tools/binman/binman.rst                            | 21 ++++++
 tools/binman/bintool.py                            | 10 ++-
 tools/binman/btool/lz4.py                          |  6 +-
 tools/binman/btool/lzma_alone.py                   |  6 +-
 tools/binman/entry.py                              |  6 +-
 tools/binman/ftest.py                              | 34 +++++++++
 tools/binman/test/entry/compress_level.dts         | 12 ++++
 tools/binman/test/entry/compress_level_gzip.dts    | 12 ++++
 tools/binman/test/entry/compress_level_lzma.dts    | 12 ++++
 .../test/entry/compress_level_no_compress.dts      | 11 +++
 22 files changed, 359 insertions(+), 69 deletions(-)
---
base-commit: b8e0086b585791a771416ce51b58ce0097bc0b28
change-id: 20260915-spl-fit-compression-62108358dc6f

Best regards,
--  
Alexey Charkov <[email protected]>

Reply via email to