]> Git Repo - J-u-boot.git/blobdiff - cmd/ximg.c
Merge patch series "Add OPP_LOW support for J7200"
[J-u-boot.git] / cmd / ximg.c
index a50dd20b19aafcab44cbd15c9d357b40eaf05985..1c96f5a0a1f680a9d7b98a039287a19ba48be2a6 100644 (file)
@@ -7,15 +7,16 @@
  * Kai-Uwe Bloem, Auerswald GmbH & Co KG, <[email protected]>
  */
 
-
 /*
  * Multi Image extract
  */
-#include <common.h>
 #include <command.h>
 #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>
 #include <asm/cache.h>
 #include <asm/io.h>
 
-#ifndef CFG_SYS_XIMG_LEN
-/* use 8MByte as default max gunzip size */
-#define CFG_SYS_XIMG_LEN       0x800000
-#endif
-
 static int
 do_imgextract(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
@@ -52,7 +48,7 @@ do_imgextract(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
        size_t          fit_len;
 #endif
 #ifdef CONFIG_GZIP
-       uint            unc_len = CFG_SYS_XIMG_LEN;
+       uint            unc_len = CONFIG_SYS_XIMG_LEN;
 #endif
        uint8_t         comp;
 
@@ -243,6 +239,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;
This page took 0.027769 seconds and 4 git commands to generate.