diff options
author | Dmitry Gerasimov <di.gerasimov@gmail.com> | 2024-06-02 17:25:52 +0200 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2024-06-13 16:30:47 -0600 |
commit | 822911d574089abc79f7ca141ca0fb82e891968b (patch) | |
tree | cf0e50b9d9fe842ddbe6ff74cfe11910c5747b47 /cmd | |
parent | b993bd65ec249c842afefd39010946650bec4f8e (diff) | |
download | u-boot-822911d574089abc79f7ca141ca0fb82e891968b.tar.gz u-boot-822911d574089abc79f7ca141ca0fb82e891968b.tar.bz2 u-boot-822911d574089abc79f7ca141ca0fb82e891968b.zip |
imxtract: add support for zstd-compressed images
Allow extraction of zstd-compressed images from FIT using imxtract
command. This is especially useful when one has to load an image via
some interface (e.g. SPI) rather that just to the memory.
Signed-off-by: Dmitry Gerasimov <di.gerasimov@gmail.com>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/ximg.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/cmd/ximg.c b/cmd/ximg.c index 1467484df8..c79e8a0786 100644 --- a/cmd/ximg.c +++ b/cmd/ximg.c @@ -15,6 +15,9 @@ #include <cpu_func.h> #include <env.h> #include <gzip.h> +#if IS_ENABLED(CONFIG_ZSTD) +#include <linux/zstd.h> +#endif #include <image.h> #include <malloc.h> #include <mapmem.h> @@ -237,6 +240,26 @@ do_imgextract(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) } break; #endif /* CONFIG_BZIP2 */ +#if IS_ENABLED(CONFIG_ZSTD) + case IH_COMP_ZSTD: + { + int ret; + struct abuf in, out; + + printf(" Uncompressing part %d ... ", part); + + abuf_init_set(&in, (void *)data, len); + abuf_init_set(&out, (void *)dest, unc_len); + ret = zstd_decompress(&in, &out); + if (ret < 0) { + printf("ZSTD ERROR %d - " + "image not loaded\n", ret); + return 1; + } + len = ret; + } + break; +#endif default: printf("Unimplemented compression type %d\n", comp); return 1; |