diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/Kconfig | 33 | ||||
-rw-r--r-- | cmd/arm/exception.c | 1 | ||||
-rw-r--r-- | cmd/elf.c | 39 | ||||
-rw-r--r-- | cmd/md5sum.c | 150 | ||||
-rw-r--r-- | cmd/pmic.c | 4 | ||||
-rw-r--r-- | cmd/reiser.c | 171 | ||||
-rw-r--r-- | cmd/riscv/exception.c | 1 | ||||
-rw-r--r-- | cmd/rng.c | 23 | ||||
-rw-r--r-- | cmd/sandbox/exception.c | 1 | ||||
-rw-r--r-- | cmd/setexpr.c | 9 | ||||
-rw-r--r-- | cmd/x86/exception.c | 1 |
11 files changed, 94 insertions, 339 deletions
diff --git a/cmd/Kconfig b/cmd/Kconfig index a86b5705174..61e280fb1a4 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -189,6 +189,17 @@ config CMD_HISTORY Show the command-line history, i.e. a list of commands that are in the history buffer. +config CMD_HISTORY_USE_CALLOC + bool "dynamically allocate memory" + default y + depends on CMD_HISTORY + help + Saying Y to this will use calloc to get the space for history + storing. Otherwise the history buffer will be an uninitialized + static array directly, without the memory allocation, and it is + writable after relocation to RAM. If u-boot is running from ROM + all the time or unsure, say Y to this. + config CMD_LICENSE bool "license" select BUILD_BIN2C @@ -479,6 +490,17 @@ config CMD_ELF help Boot an ELF/vxWorks image from the memory. +config CMD_ELF_FDT_SETUP + bool "Flattened Device Tree setup in bootelf cmd" + default n + depends on CMD_ELF + select LIB_LIBFDT + select LMB + help + Do FDT setup in bootelf command optionally by param -d, which + allows to bring additional system info (e.g. /memory node) to + the Operating System or application. + config CMD_FDT bool "Flattened Device Tree utility commands" default y @@ -740,6 +762,7 @@ config CRC32_VERIFY config CMD_EEPROM bool "eeprom - EEPROM subsystem" + depends on DM_I2C || SYS_I2C_LEGACY help (deprecated, needs conversion to driver model) Provides commands to read and write EEPROM (Electrically Erasable @@ -825,6 +848,7 @@ config LOOPW config CMD_MD5SUM bool "md5sum" select MD5 + select HASH help Compute MD5 checksum. @@ -2750,15 +2774,6 @@ config MTDPARTS_DEFAULT Defines a default MTD partitioning scheme in the Linux MTD command line partitions format -config CMD_REISER - bool "reiser - Access to reiserfs filesystems" - help - This provides two commands which operate on a resierfs filesystem, - commonly used some years ago: - - reiserls - list files - reiserload - load a file - config CMD_YAFFS2 bool "yaffs2 - Access of YAFFS2 filesystem" depends on YAFFS2 diff --git a/cmd/arm/exception.c b/cmd/arm/exception.c index 522f6dff53f..98a9795b68c 100644 --- a/cmd/arm/exception.c +++ b/cmd/arm/exception.c @@ -5,7 +5,6 @@ * Copyright (c) 2018, Heinrich Schuchardt <xypron.glpk@gmx.de> */ -#include <common.h> #include <command.h> static int do_unaligned(struct cmd_tbl *cmdtp, int flag, int argc, diff --git a/cmd/elf.c b/cmd/elf.c index b7b9f506a52..df4354d3742 100644 --- a/cmd/elf.c +++ b/cmd/elf.c @@ -38,6 +38,10 @@ static unsigned long do_bootelf_exec(ulong (*entry)(int, char * const[]), /* Interpreter command to boot an arbitrary ELF image from memory */ int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { +#if CONFIG_IS_ENABLED(CMD_ELF_FDT_SETUP) + struct bootm_headers img = {0}; + unsigned long fdt_addr = 0; /* Address of the FDT */ +#endif unsigned long addr; /* Address of the ELF image */ unsigned long rc; /* Return value from user code */ char *sload = NULL; @@ -46,13 +50,25 @@ int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) /* Consume 'bootelf' */ argc--; argv++; - /* Check for flag. */ + /* Check for [-p|-s] flag. */ if (argc >= 1 && (argv[0][0] == '-' && \ (argv[0][1] == 'p' || argv[0][1] == 's'))) { sload = argv[0]; /* Consume flag. */ argc--; argv++; } + +#if CONFIG_IS_ENABLED(CMD_ELF_FDT_SETUP) + /* Check for [-d fdt_addr_r] option. */ + if ((argc >= 2) && (argv[0][0] == '-') && (argv[0][1] == 'd')) { + if (strict_strtoul(argv[1], 16, &fdt_addr) != 0) + return CMD_RET_USAGE; + /* Consume option. */ + argc -= 2; + argv += 2; + } +#endif + /* Check for address. */ if (argc >= 1 && strict_strtoul(argv[0], 16, &addr) != -EINVAL) { /* Consume address */ @@ -68,6 +84,16 @@ int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) else addr = load_elf_image_shdr(addr); +#if CONFIG_IS_ENABLED(CMD_ELF_FDT_SETUP) + if (fdt_addr) { + printf("## Setting up FDT at 0x%08lx ...\n", fdt_addr); + flush(); + + if (image_setup_libfdt(&img, (void *)fdt_addr, NULL)) + return 1; + } +#endif + if (!env_get_autostart()) return rcode; @@ -298,9 +324,16 @@ int do_bootvx(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) U_BOOT_CMD( bootelf, CONFIG_SYS_MAXARGS, 0, do_bootelf, "Boot from an ELF image in memory", - "[-p|-s] [address]\n" + "[-p|-s] " +#if CONFIG_IS_ENABLED(CMD_ELF_FDT_SETUP) + "[-d fdt_addr_r] " +#endif + "[address]\n" "\t- load ELF image at [address] via program headers (-p)\n" - "\t or via section headers (-s)" + "\t or via section headers (-s)\n" +#if CONFIG_IS_ENABLED(CMD_ELF_FDT_SETUP) + "\t- setup FDT image at [fdt_addr_r] (-d)" +#endif ); U_BOOT_CMD( diff --git a/cmd/md5sum.c b/cmd/md5sum.c index 0f0e1d3dd68..ded3f9e1831 100644 --- a/cmd/md5sum.c +++ b/cmd/md5sum.c @@ -7,166 +7,36 @@ * Wolfgang Denk, DENX Software Engineering, wd@denx.de. */ -#include <common.h> #include <command.h> #include <env.h> #include <image.h> +#include <hash.h> #include <mapmem.h> #include <u-boot/md5.h> #include <asm/io.h> -/* - * Store the resulting sum to an address or variable - */ -static void store_result(const u8 *sum, const char *dest) -{ - unsigned int i; - - if (*dest == '*') { - u8 *ptr; - - ptr = (u8 *)hextoul(dest + 1, NULL); - for (i = 0; i < 16; i++) - *ptr++ = sum[i]; - } else { - char str_output[33]; - char *str_ptr = str_output; - - for (i = 0; i < 16; i++) { - sprintf(str_ptr, "%02x", sum[i]); - str_ptr += 2; - } - env_set(dest, str_output); - } -} - -#ifdef CONFIG_MD5SUM_VERIFY -static int parse_verify_sum(char *verify_str, u8 *vsum) -{ - if (*verify_str == '*') { - u8 *ptr; - - ptr = (u8 *)hextoul(verify_str + 1, NULL); - memcpy(vsum, ptr, 16); - } else { - unsigned int i; - char *vsum_str; - - if (strlen(verify_str) == 32) - vsum_str = verify_str; - else { - vsum_str = env_get(verify_str); - if (vsum_str == NULL || strlen(vsum_str) != 32) - return 1; - } - - for (i = 0; i < 16; i++) { - char *nullp = vsum_str + (i + 1) * 2; - char end = *nullp; - - *nullp = '\0'; - *(u8 *)(vsum + i) = - hextoul(vsum_str + (i * 2), NULL); - *nullp = end; - } - } - return 0; -} - -int do_md5sum(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) +static int do_md5sum(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) { - ulong addr, len; - unsigned int i; - u8 output[16]; - u8 vsum[16]; - int verify = 0; + int flags = HASH_FLAG_ENV; int ac; - char * const *av; - void *buf; + char *const *av; if (argc < 3) return CMD_RET_USAGE; av = argv + 1; ac = argc - 1; - if (strcmp(*av, "-v") == 0) { - verify = 1; + if (IS_ENABLED(CONFIG_MD5SUM_VERIFY) && strcmp(*av, "-v") == 0) { + flags |= HASH_FLAG_VERIFY; av++; ac--; - if (ac < 3) - return CMD_RET_USAGE; } - addr = hextoul(*av++, NULL); - len = hextoul(*av++, NULL); - - buf = map_sysmem(addr, len); - md5_wd(buf, len, output, CHUNKSZ_MD5); - unmap_sysmem(buf); - - if (!verify) { - printf("md5 for %08lx ... %08lx ==> ", addr, addr + len - 1); - for (i = 0; i < 16; i++) - printf("%02x", output[i]); - printf("\n"); - - if (ac > 2) - store_result(output, *av); - } else { - char *verify_str = *av++; - - if (parse_verify_sum(verify_str, vsum)) { - printf("ERROR: %s does not contain a valid md5 sum\n", - verify_str); - return 1; - } - if (memcmp(output, vsum, 16) != 0) { - printf("md5 for %08lx ... %08lx ==> ", addr, - addr + len - 1); - for (i = 0; i < 16; i++) - printf("%02x", output[i]); - printf(" != "); - for (i = 0; i < 16; i++) - printf("%02x", vsum[i]); - printf(" ** ERROR **\n"); - return 1; - } - } - - return 0; -} -#else -static int do_md5sum(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[]) -{ - unsigned long addr, len; - unsigned int i; - u8 output[16]; - void *buf; - - if (argc < 3) - return CMD_RET_USAGE; - - addr = hextoul(argv[1], NULL); - len = hextoul(argv[2], NULL); - - buf = map_sysmem(addr, len); - md5_wd(buf, len, output, CHUNKSZ_MD5); - unmap_sysmem(buf); - - printf("md5 for %08lx ... %08lx ==> ", addr, addr + len - 1); - for (i = 0; i < 16; i++) - printf("%02x", output[i]); - printf("\n"); - - if (argc > 3) - store_result(output, argv[3]); - - return 0; + return hash_command("md5", flags, cmdtp, flag, ac, av); } -#endif -#ifdef CONFIG_MD5SUM_VERIFY +#if IS_ENABLED(CONFIG_MD5SUM_VERIFY) U_BOOT_CMD( md5sum, 5, 1, do_md5sum, "compute MD5 message digest", @@ -182,4 +52,4 @@ U_BOOT_CMD( "address count [[*]sum]\n" " - compute MD5 message digest [save to sum]" ); -#endif +#endif /* IS_ENABLED(CONFIG_MD5SUM_VERIFY) */ diff --git a/cmd/pmic.c b/cmd/pmic.c index 49a405fa297..c9e9730adf9 100644 --- a/cmd/pmic.c +++ b/cmd/pmic.c @@ -225,6 +225,6 @@ U_BOOT_CMD(pmic, CONFIG_SYS_MAXARGS, 1, do_pmic, "list - list pmic devices\n" "pmic dev [name] - show or [set] operating PMIC device\n" "pmic dump - dump registers\n" - "pmic read address - read byte of register at address\n" - "pmic write address - write byte to register at address\n" + "pmic read <reg> - read byte of 'reg' register\n" + "pmic write <reg> <byte> - write 'byte' byte to 'reg' register\n" ); diff --git a/cmd/reiser.c b/cmd/reiser.c deleted file mode 100644 index 707167fcd59..00000000000 --- a/cmd/reiser.c +++ /dev/null @@ -1,171 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * (C) Copyright 2003 - 2004 - * Sysgo Real-Time Solutions, AG <www.elinos.com> - * Pavel Bartusek <pba@sysgo.com> - */ - -/* - * Reiserfs support - */ -#include <common.h> -#include <config.h> -#include <command.h> -#include <env.h> -#include <image.h> -#include <linux/ctype.h> -#include <asm/byteorder.h> -#include <reiserfs.h> -#include <part.h> - -#if !CONFIG_IS_ENABLED(DOS_PARTITION) -#error DOS partition support must be selected -#endif - -/* #define REISER_DEBUG */ - -#ifdef REISER_DEBUG -#define PRINTF(fmt,args...) printf (fmt ,##args) -#else -#define PRINTF(fmt,args...) -#endif - -int do_reiserls(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) -{ - char *filename = "/"; - int dev, part; - struct blk_desc *dev_desc = NULL; - struct disk_partition info; - - if (argc < 3) - return CMD_RET_USAGE; - - part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1); - if (part < 0) - return 1; - - if (argc == 4) { - filename = argv[3]; - } - - dev = dev_desc->devnum; - PRINTF("Using device %s %d:%d, directory: %s\n", argv[1], dev, part, filename); - - reiserfs_set_blk_dev(dev_desc, &info); - - if (!reiserfs_mount(info.size)) { - printf ("** Bad Reiserfs partition or disk - %s %d:%d **\n", argv[1], dev, part); - return 1; - } - - if (reiserfs_ls (filename)) { - printf ("** Error reiserfs_ls() **\n"); - return 1; - }; - - return 0; -} - -U_BOOT_CMD( - reiserls, 4, 1, do_reiserls, - "list files in a directory (default /)", - "<interface> <dev[:part]> [directory]\n" - " - list files from 'dev' on 'interface' in a 'directory'" -); - -/****************************************************************************** - * Reiserfs boot command intepreter. Derived from diskboot - */ -int do_reiserload(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) -{ - char *filename = NULL; - int dev, part; - ulong addr = 0, filelen; - struct disk_partition info; - struct blk_desc *dev_desc = NULL; - unsigned long count; - char *addr_str; - - switch (argc) { - case 3: - addr_str = env_get("loadaddr"); - if (addr_str != NULL) { - addr = hextoul(addr_str, NULL); - } else { - addr = CONFIG_SYS_LOAD_ADDR; - } - filename = env_get("bootfile"); - count = 0; - break; - case 4: - addr = hextoul(argv[3], NULL); - filename = env_get("bootfile"); - count = 0; - break; - case 5: - addr = hextoul(argv[3], NULL); - filename = argv[4]; - count = 0; - break; - case 6: - addr = hextoul(argv[3], NULL); - filename = argv[4]; - count = hextoul(argv[5], NULL); - break; - - default: - return CMD_RET_USAGE; - } - - if (!filename) { - puts ("\n** No boot file defined **\n"); - return 1; - } - - part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1); - if (part < 0) - return 1; - - dev = dev_desc->devnum; - - printf("Loading file \"%s\" from %s device %d%c%c\n", - filename, argv[1], dev, - part ? ':' : ' ', part ? part + '0' : ' '); - - reiserfs_set_blk_dev(dev_desc, &info); - - if (!reiserfs_mount(info.size)) { - printf ("** Bad Reiserfs partition or disk - %s %d:%d **\n", argv[1], dev, part); - return 1; - } - - filelen = reiserfs_open(filename); - if (filelen < 0) { - printf("** File not found %s **\n", filename); - return 1; - } - if ((count < filelen) && (count != 0)) { - filelen = count; - } - - if (reiserfs_read((char *)addr, filelen) != filelen) { - printf("\n** Unable to read \"%s\" from %s %d:%d **\n", filename, argv[1], dev, part); - return 1; - } - - /* Loading ok, update default load address */ - image_load_addr = addr; - - printf ("\n%ld bytes read\n", filelen); - env_set_hex("filesize", filelen); - - return filelen; -} - -U_BOOT_CMD( - reiserload, 6, 0, do_reiserload, - "load binary file from a Reiser filesystem", - "<interface> <dev[:part]> [addr] [filename] [bytes]\n" - " - load binary file 'filename' from 'dev' on 'interface'\n" - " to address 'addr' from dos filesystem" -); diff --git a/cmd/riscv/exception.c b/cmd/riscv/exception.c index f38f454a0b1..14ad6c440a5 100644 --- a/cmd/riscv/exception.c +++ b/cmd/riscv/exception.c @@ -5,7 +5,6 @@ * Copyright (c) 2018, Heinrich Schuchardt <xypron.glpk@gmx.de> */ -#include <common.h> #include <command.h> static int do_compressed(struct cmd_tbl *cmdtp, int flag, int argc, diff --git a/cmd/rng.c b/cmd/rng.c index 52f722c7af8..b073a6c8492 100644 --- a/cmd/rng.c +++ b/cmd/rng.c @@ -19,6 +19,22 @@ static int do_rng(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) struct udevice *dev; int ret = CMD_RET_SUCCESS; + if (argc == 2 && !strcmp(argv[1], "list")) { + int idx = 0; + + uclass_foreach_dev_probe(UCLASS_RNG, dev) { + idx++; + printf("RNG #%d - %s\n", dev->seq_, dev->name); + } + + if (!idx) { + log_err("No RNG device\n"); + return CMD_RET_FAILURE; + } + + return CMD_RET_SUCCESS; + } + switch (argc) { case 1: devnum = 0; @@ -56,12 +72,9 @@ static int do_rng(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return ret; } -U_BOOT_LONGHELP(rng, - "[dev [n]]\n" - " - print n random bytes(max 64) read from dev\n"); - U_BOOT_CMD( rng, 3, 0, do_rng, "print bytes from the hardware random number generator", - rng_help_text + "list - list all the probed rng devices\n" + "rng [dev] [n] - print n random bytes(max 64) read from dev\n" ); diff --git a/cmd/sandbox/exception.c b/cmd/sandbox/exception.c index c082401ce6b..cfa153da260 100644 --- a/cmd/sandbox/exception.c +++ b/cmd/sandbox/exception.c @@ -5,7 +5,6 @@ * Copyright (c) 2020, Heinrich Schuchardt <xypron.glpk@gmx.de> */ -#include <common.h> #include <command.h> static int do_sigsegv(struct cmd_tbl *cmdtp, int flag, int argc, diff --git a/cmd/setexpr.c b/cmd/setexpr.c index 233471f6cb7..ab76824a32b 100644 --- a/cmd/setexpr.c +++ b/cmd/setexpr.c @@ -216,14 +216,12 @@ int setexpr_regex_sub(char *data, uint data_size, char *nbuf, uint nbuf_size, if (res == 0) { if (loop == 0) { debug("%s: No match\n", data); - return 1; } else { - break; + debug("## MATCH ## %s\n", data); } + break; } - debug("## MATCH ## %s\n", data); - if (!s) return 1; @@ -540,7 +538,8 @@ U_BOOT_CMD( " - For each substring matching the regular expression <r> in the\n" " string <t>, substitute the string <s>. The result is\n" " assigned to <name>. If <t> is not supplied, use the old\n" - " value of <name>\n" + " value of <name>. If no substring matching <r> is found in <t>,\n" + " assign <t> to <name>.\n" "setexpr name sub r s [t]\n" " - Just like gsub(), but replace only the first matching substring" #endif diff --git a/cmd/x86/exception.c b/cmd/x86/exception.c index 82faaa913e5..14b6bd6f493 100644 --- a/cmd/x86/exception.c +++ b/cmd/x86/exception.c @@ -5,7 +5,6 @@ * Copyright (c) 2018, Heinrich Schuchardt <xypron.glpk@gmx.de> */ -#include <common.h> #include <command.h> static int do_undefined(struct cmd_tbl *cmdtp, int flag, int argc, |