diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/bdinfo.c | 4 | ||||
-rw-r--r-- | cmd/bootefi.c | 7 | ||||
-rw-r--r-- | cmd/i2c.c | 2 | ||||
-rw-r--r-- | cmd/lzmadec.c | 5 | ||||
-rw-r--r-- | cmd/misc.c | 21 | ||||
-rw-r--r-- | cmd/mtdparts.c | 96 | ||||
-rw-r--r-- | cmd/nand.c | 15 | ||||
-rw-r--r-- | cmd/sf.c | 2 |
8 files changed, 100 insertions, 52 deletions
diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c index 1c4bed96b5..f2435ab7e5 100644 --- a/cmd/bdinfo.c +++ b/cmd/bdinfo.c @@ -385,9 +385,9 @@ static int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, } #ifdef CONFIG_SYS_MEM_RESERVE_SECURE - if (gd->secure_ram & MEM_RESERVE_SECURE_SECURED) { + if (gd->arch.secure_ram & MEM_RESERVE_SECURE_SECURED) { print_num("Secure ram", - gd->secure_ram & MEM_RESERVE_SECURE_ADDR_MASK); + gd->arch.secure_ram & MEM_RESERVE_SECURE_ADDR_MASK); } #endif #if defined(CONFIG_CMD_NET) && !defined(CONFIG_DM_ETH) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 011f62c5b1..d66892e69e 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -290,6 +290,11 @@ void efi_set_bootdev(const char *dev, const char *devnr, const char *path) /* Patch bootefi_image_path to the target file path */ memset(bootefi_image_path[0].str, 0, sizeof(bootefi_image_path[0].str)); - snprintf(devname, sizeof(devname), "%s", path); + if (strcmp(dev, "Net")) { + /* Add leading / to fs paths, because they're absolute */ + snprintf(devname, sizeof(devname), "/%s", path); + } else { + snprintf(devname, sizeof(devname), "%s", path); + } ascii2unicode(bootefi_image_path[0].str, devname); } @@ -178,7 +178,7 @@ static int i2c_get_cur_bus_chip(uint chip_addr, struct udevice **devp) * i2c_init_board() - Board-specific I2C bus init * * This function is the default no-op implementation of I2C bus - * initialization. This function can be overriden by board-specific + * initialization. This function can be overridden by board-specific * implementation if needed. */ __weak diff --git a/cmd/lzmadec.c b/cmd/lzmadec.c index 1ad9ed6ce9..c78df825e8 100644 --- a/cmd/lzmadec.c +++ b/cmd/lzmadec.c @@ -20,7 +20,7 @@ static int do_lzmadec(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) { unsigned long src, dst; - unsigned long src_len = ~0UL, dst_len = ~0UL; + SizeT src_len = ~0UL, dst_len = ~0UL; int ret; switch (argc) { @@ -40,7 +40,8 @@ static int do_lzmadec(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) if (ret != SZ_OK) return 1; - printf("Uncompressed size: %ld = 0x%lX\n", src_len, src_len); + printf("Uncompressed size: %ld = %#lX\n", (ulong)src_len, + (ulong)src_len); setenv_hex("filesize", src_len); return 0; diff --git a/cmd/misc.c b/cmd/misc.c index 39d86835cf..efcbb90d18 100644 --- a/cmd/misc.c +++ b/cmd/misc.c @@ -15,13 +15,31 @@ static int do_sleep(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { ulong start = get_timer(0); + ulong mdelay = 0; ulong delay; + char *frpart; if (argc != 2) return CMD_RET_USAGE; delay = simple_strtoul(argv[1], NULL, 10) * CONFIG_SYS_HZ; + frpart = strchr(argv[1], '.'); + + if (frpart) { + uint mult = CONFIG_SYS_HZ / 10; + for (frpart++; *frpart != '\0' && mult > 0; frpart++) { + if (*frpart < '0' || *frpart > '9') { + mdelay = 0; + break; + } + mdelay += (*frpart - '0') * mult; + mult /= 10; + } + } + + delay += mdelay; + while (get_timer(start) < delay) { if (ctrlc()) return (-1); @@ -36,7 +54,8 @@ U_BOOT_CMD( sleep , 2, 1, do_sleep, "delay execution for some time", "N\n" - " - delay execution for N seconds (N is _decimal_ !!!)" + " - delay execution for N seconds (N is _decimal_ and can be\n" + " fractional)" ); #ifdef CONFIG_CMD_TIMER diff --git a/cmd/mtdparts.c b/cmd/mtdparts.c index 44b2c3a5a9..b9b160dc1e 100644 --- a/cmd/mtdparts.c +++ b/cmd/mtdparts.c @@ -109,17 +109,17 @@ DECLARE_GLOBAL_DATA_PTR; #define MTD_WRITEABLE_CMD 1 /* default values for mtdids and mtdparts variables */ -#if defined(MTDIDS_DEFAULT) -static const char *const mtdids_default = MTDIDS_DEFAULT; -#else -static const char *const mtdids_default = NULL; +#if !defined(MTDIDS_DEFAULT) +#define MTDIDS_DEFAULT NULL #endif - -#if defined(MTDPARTS_DEFAULT) -static const char *const mtdparts_default = MTDPARTS_DEFAULT; -#else -static const char *const mtdparts_default = NULL; +#if !defined(MTDPARTS_DEFAULT) +#define MTDPARTS_DEFAULT NULL +#endif +#if defined(CONFIG_SYS_MTDPARTS_RUNTIME) +extern void board_mtdparts_default(const char **mtdids, const char **mtdparts); #endif +static const char *mtdids_default = MTDIDS_DEFAULT; +static const char *mtdparts_default = MTDPARTS_DEFAULT; /* copies of last seen 'mtdids', 'mtdparts' and 'partition' env variables */ #define MTDIDS_MAXLEN 128 @@ -142,6 +142,8 @@ static struct list_head devices; struct mtd_device *current_mtd_dev = NULL; u8 current_mtd_partnum = 0; +u8 use_defaults; + static struct part_info* mtd_part_info(struct mtd_device *dev, unsigned int part_num); /* command line only routines */ @@ -1491,7 +1493,7 @@ static int spread_partitions(void) part = list_entry(pentry, struct part_info, link); debug("spread_partitions: device = %s%d, partition %d =" - " (%s) 0x%08x@0x%08x\n", + " (%s) 0x%08llx@0x%08llx\n", MTD_DEV_TYPE(dev->id->type), dev->id->num, part_num, part->name, part->size, part->offset); @@ -1516,6 +1518,23 @@ static int spread_partitions(void) #endif /* CONFIG_CMD_MTDPARTS_SPREAD */ /** + * The mtdparts variable tends to be long. If we need to access it + * before the env is relocated, then we need to use our own stack + * buffer. gd->env_buf will be too small. + * + * @param buf temporary buffer pointer MTDPARTS_MAXLEN long + * @return mtdparts variable string, NULL if not found + */ +static const char *getenv_mtdparts(char *buf) +{ + if (gd->flags & GD_FLG_ENV_READY) + return getenv("mtdparts"); + if (getenv_f("mtdparts", buf, MTDPARTS_MAXLEN) != -1) + return buf; + return NULL; +} + +/** * Accept character string describing mtd partitions and call device_parse() * for each entry. Add created devices to the global devices list. * @@ -1524,7 +1543,7 @@ static int spread_partitions(void) */ static int parse_mtdparts(const char *const mtdparts) { - const char *p = mtdparts; + const char *p; struct mtd_device *dev; int err = 1; char tmp_parts[MTDPARTS_MAXLEN]; @@ -1538,12 +1557,9 @@ static int parse_mtdparts(const char *const mtdparts) } /* re-read 'mtdparts' variable, mtd_devices_init may be updating env */ - if (gd->flags & GD_FLG_ENV_READY) { - p = getenv("mtdparts"); - } else { - p = tmp_parts; - getenv_f("mtdparts", tmp_parts, MTDPARTS_MAXLEN); - } + p = getenv_mtdparts(tmp_parts); + if (!p) + p = mtdparts; if (strncmp(p, "mtdparts=", 9) != 0) { printf("mtdparts variable doesn't start with 'mtdparts='\n"); @@ -1551,7 +1567,7 @@ static int parse_mtdparts(const char *const mtdparts) } p += 9; - while (p && (*p != '\0')) { + while (*p != '\0') { err = 1; if ((device_parse(p, &p, &dev) != 0) || (!dev)) break; @@ -1569,12 +1585,10 @@ static int parse_mtdparts(const char *const mtdparts) list_add_tail(&dev->link, &devices); err = 0; } - if (err == 1) { + if (err == 1) device_delall(&devices); - return 1; - } - return 0; + return err; } /** @@ -1688,6 +1702,7 @@ static int parse_mtdids(const char *const ids) return 0; } + /** * Parse and initialize global mtdids mapping and create global * device/partition list. @@ -1710,22 +1725,16 @@ int mtdparts_init(void) memset(last_ids, 0, MTDIDS_MAXLEN); memset(last_parts, 0, MTDPARTS_MAXLEN); memset(last_partition, 0, PARTITION_MAXLEN); +#if defined(CONFIG_SYS_MTDPARTS_RUNTIME) + board_mtdparts_default(&mtdids_default, &mtdparts_default); +#endif + use_defaults = 1; initialized = 1; } /* get variables */ ids = getenv("mtdids"); - /* - * The mtdparts variable tends to be long. If we need to access it - * before the env is relocated, then we need to use our own stack - * buffer. gd->env_buf will be too small. - */ - if (gd->flags & GD_FLG_ENV_READY) { - parts = getenv("mtdparts"); - } else { - parts = tmp_parts; - getenv_f("mtdparts", tmp_parts, MTDPARTS_MAXLEN); - } + parts = getenv_mtdparts(tmp_parts); current_partition = getenv("partition"); /* save it for later parsing, cannot rely on current partition pointer @@ -1758,10 +1767,16 @@ int mtdparts_init(void) return 1; } - /* do no try to use defaults when mtdparts variable is not defined, - * just check the length */ - if (!parts) - printf("mtdparts variable not set, see 'help mtdparts'\n"); + /* use defaults when mtdparts variable is not defined + * once mtdparts is saved environment, drop use_defaults flag */ + if (!parts) { + if (mtdparts_default && use_defaults) { + parts = mtdparts_default; + if (setenv("mtdparts", (char *)parts) == 0) + use_defaults = 0; + } else + printf("mtdparts variable not set, see 'help mtdparts'\n"); + } if (parts && (strlen(parts) > MTDPARTS_MAXLEN - 1)) { printf("mtdparts too long (> %d)\n", MTDPARTS_MAXLEN); @@ -1933,9 +1948,10 @@ static int do_mtdparts(cmd_tbl_t *cmdtp, int flag, int argc, { if (argc == 2) { if (strcmp(argv[1], "default") == 0) { - setenv("mtdids", (char *)mtdids_default); - setenv("mtdparts", (char *)mtdparts_default); + setenv("mtdids", NULL); + setenv("mtdparts", NULL); setenv("partition", NULL); + use_defaults = 1; mtdparts_init(); return 0; @@ -2009,7 +2025,7 @@ static int do_mtdparts(cmd_tbl_t *cmdtp, int flag, int argc, if (!strcmp(&argv[1][3], ".spread")) { spread_partition(mtd, p, &next_offset); - debug("increased %s to %d bytes\n", p->name, p->size); + debug("increased %s to %llu bytes\n", p->name, p->size); } #endif diff --git a/cmd/nand.c b/cmd/nand.c index ffdeea41a5..e10349ac2b 100644 --- a/cmd/nand.c +++ b/cmd/nand.c @@ -306,7 +306,7 @@ static void nand_print_and_set_info(int idx) } static int raw_access(struct mtd_info *mtd, ulong addr, loff_t off, - ulong count, int read) + ulong count, int read, int no_verify) { int ret = 0; @@ -324,7 +324,7 @@ static int raw_access(struct mtd_info *mtd, ulong addr, loff_t off, ret = mtd_read_oob(mtd, off, &ops); } else { ret = mtd_write_oob(mtd, off, &ops); - if (!ret) + if (!ret && !no_verify) ret = nand_verify_page_oob(mtd, &ops, off); } @@ -546,6 +546,7 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) ulong pagecount = 1; int read; int raw = 0; + int no_verify = 0; if (argc < 4) goto usage; @@ -557,9 +558,12 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) s = strchr(cmd, '.'); - if (s && !strcmp(s, ".raw")) { + if (s && !strncmp(s, ".raw", 4)) { raw = 1; + if (!strcmp(s, ".raw.noverify")) + no_verify = 1; + if (mtd_arg_off(argv[3], &dev, &off, &size, &maxsize, MTD_DEV_TYPE_NAND, nand_info[dev]->size)) @@ -633,7 +637,8 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) else ret = mtd_write_oob(mtd, off, &ops); } else if (raw) { - ret = raw_access(mtd, addr, off, pagecount, read); + ret = raw_access(mtd, addr, off, pagecount, read, + no_verify); } else { printf("Unknown nand command suffix '%s'.\n", s); return 1; @@ -786,7 +791,7 @@ static char nand_help_text[] = " read/write 'size' bytes starting at offset 'off'\n" " to/from memory address 'addr', skipping bad blocks.\n" "nand read.raw - addr off|partition [count]\n" - "nand write.raw - addr off|partition [count]\n" + "nand write.raw[.noverify] - addr off|partition [count]\n" " Use read.raw/write.raw to avoid ECC and access the flash as-is.\n" #ifdef CONFIG_CMD_NAND_TRIMFFS "nand write.trimffs - addr off|partition size\n" @@ -88,6 +88,8 @@ static int do_spi_flash_probe(int argc, char * const argv[]) #ifdef CONFIG_DM_SPI_FLASH struct udevice *new, *bus_dev; int ret; + /* In DM mode defaults will be taken from DT */ + speed = 0, mode = 0; #else struct spi_flash *new; #endif |