1 // SPDX-License-Identifier: GPL-2.0+
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
10 static int do_unzip(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
12 unsigned long src, dst;
13 unsigned long src_len = ~0UL, dst_len = ~0UL;
17 dst_len = simple_strtoul(argv[3], NULL, 16);
20 src = simple_strtoul(argv[1], NULL, 16);
21 dst = simple_strtoul(argv[2], NULL, 16);
27 if (gunzip((void *) dst, dst_len, (void *) src, &src_len) != 0)
30 printf("Uncompressed size: %lu = 0x%lX\n", src_len, src_len);
31 env_set_hex("filesize", src_len);
37 unzip, 4, 1, do_unzip,
38 "unzip a memory region",
39 "srcaddr dstaddr [dstsize]"
42 static int do_gzwrite(cmd_tbl_t *cmdtp, int flag,
43 int argc, char * const argv[])
45 struct blk_desc *bdev;
49 unsigned long writebuf = 1<<20;
55 ret = blk_get_device_by_str(argv[1], argv[2], &bdev);
57 return CMD_RET_FAILURE;
59 addr = (unsigned char *)simple_strtoul(argv[3], NULL, 16);
60 length = simple_strtoul(argv[4], NULL, 16);
63 writebuf = simple_strtoul(argv[5], NULL, 16);
65 startoffs = simple_strtoull(argv[6], NULL, 16);
67 szexpected = simple_strtoull(argv[7],
72 ret = gzwrite(addr, length, bdev, writebuf, startoffs, szexpected);
74 return ret ? CMD_RET_FAILURE : CMD_RET_SUCCESS;
78 gzwrite, 8, 0, do_gzwrite,
79 "unzip and write memory to block device",
80 "<interface> <dev> <addr> length [wbuf=1M [offs=0 [outsize=0]]]\n"
81 "\twbuf is the size in bytes (hex) of write buffer\n"
82 "\t\tand should be padded to erase size for SSDs\n"
83 "\toffs is the output start offset in bytes (hex)\n"
84 "\toutsize is the size of the expected output (hex bytes)\n"
85 "\t\tand is required for files with uncompressed lengths\n"
86 "\t\t4 GiB or larger\n"