]> 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 65ba41320a02350234e96b1f0769ea2a9e128c48..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 CONFIG_SYS_XIMG_LEN
-/* use 8MByte as default max gunzip size */
-#define CONFIG_SYS_XIMG_LEN    0x800000
-#endif
-
 static int
 do_imgextract(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
@@ -42,7 +38,7 @@ do_imgextract(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
        int             part = 0;
 #if defined(CONFIG_LEGACY_IMAGE_FORMAT)
        ulong           count;
-       image_header_t  *hdr = NULL;
+       struct legacy_img_hdr   *hdr = NULL;
 #endif
 #if defined(CONFIG_FIT)
        const char      *uname = NULL;
@@ -78,7 +74,7 @@ do_imgextract(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
                printf("## Copying part %d from legacy image "
                        "at %08lx ...\n", part, addr);
 
-               hdr = (image_header_t *)addr;
+               hdr = (struct legacy_img_hdr *)addr;
                if (!image_check_magic(hdr)) {
                        printf("Bad Magic Number\n");
                        return 1;
@@ -171,11 +167,8 @@ do_imgextract(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
                        return 1;
                }
 
-               if (fit_image_get_comp(fit_hdr, noffset, &comp)) {
-                       puts("Could not find script subimage "
-                               "compression type\n");
-                       return 1;
-               }
+               if (fit_image_get_comp(fit_hdr, noffset, &comp))
+                       comp = IH_COMP_NONE;
 
                data = (ulong)fit_data;
                len = (ulong)fit_len;
@@ -200,7 +193,7 @@ do_imgextract(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 
                                while (l > 0) {
                                        tail = (l > CHUNKSZ) ? CHUNKSZ : l;
-                                       WATCHDOG_RESET();
+                                       schedule();
                                        memmove(to, from, tail);
                                        to += tail;
                                        from += tail;
@@ -246,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;
@@ -261,8 +274,7 @@ do_imgextract(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
        return 0;
 }
 
-#ifdef CONFIG_SYS_LONGHELP
-static char imgextract_help_text[] =
+U_BOOT_LONGHELP(imgextract,
        "addr part [dest]\n"
        "    - extract <part> from legacy image at <addr> and copy to <dest>"
 #if defined(CONFIG_FIT)
@@ -270,8 +282,7 @@ static char imgextract_help_text[] =
        "addr uname [dest]\n"
        "    - extract <uname> subimage from FIT image at <addr> and copy to <dest>"
 #endif
-       "";
-#endif
+       );
 
 U_BOOT_CMD(
        imxtract, 4, 1, do_imgextract,
This page took 0.024318 seconds and 4 git commands to generate.