diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/cmd_bdinfo.c | 28 | ||||
-rw-r--r-- | common/cmd_nand.c | 95 | ||||
-rw-r--r-- | common/cmd_nvedit.c | 16 | ||||
-rw-r--r-- | common/cmd_sata.c | 9 | ||||
-rw-r--r-- | common/main.c | 1 |
5 files changed, 92 insertions, 57 deletions
diff --git a/common/cmd_bdinfo.c b/common/cmd_bdinfo.c index 3ab285b..42f08fd 100644 --- a/common/cmd_bdinfo.c +++ b/common/cmd_bdinfo.c @@ -147,7 +147,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) #ifdef CONFIG_HERMES print_mhz("ethspeed", bd->bi_ethspeed); #endif - printf("IP addr = %pI4\n", &bd->bi_ip_addr); + printf("IP addr = %s\n", getenv("ipaddr")); printf("baudrate = %6ld bps\n", bd->bi_baudrate); print_num("relocaddr", gd->relocaddr); return 0; @@ -172,7 +172,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) #if defined(CONFIG_CMD_NET) print_eth(0); - printf("ip_addr = %pI4\n", &bd->bi_ip_addr); + printf("ip_addr = %s\n", getenv("ipaddr")); #endif printf("baudrate = %ld bps\n", bd->bi_baudrate); @@ -196,7 +196,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) #endif #if defined(CONFIG_CMD_NET) print_eth(0); - printf("ip_addr = %pI4\n", &bd->bi_ip_addr); + printf("ip_addr = %s\n", getenv("ipaddr")); #endif printf("baudrate = %ld bps\n", (ulong)bd->bi_baudrate); return 0; @@ -229,7 +229,7 @@ int do_bdinfo(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) #if defined(CONFIG_CMD_NET) print_eth(0); - printf("ip_addr = %pI4\n", &bd->bi_ip_addr); + printf("ip_addr = %s\n", getenv("ipaddr")); #endif printf("baudrate = %6ld bps\n", bd->bi_baudrate); return 0; @@ -275,7 +275,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) print_eth(3); #endif - printf("ip_addr = %pI4\n", &bd->bi_ip_addr); + printf("ip_addr = %s\n", getenv("ipaddr")); #endif printf("baudrate = %ld bps\n", bd->bi_baudrate); @@ -303,7 +303,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) print_num("flashoffset", (ulong)bd->bi_flashoffset); print_eth(0); - printf("ip_addr = %pI4\n", &bd->bi_ip_addr); + printf("ip_addr = %s\n", getenv("ipaddr")); printf("baudrate = %d bps\n", bd->bi_baudrate); return 0; @@ -323,7 +323,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) print_num("flashoffset", (ulong)bd->bi_flashoffset); print_eth(0); - printf("ip_addr = %pI4\n", &bd->bi_ip_addr); + printf("ip_addr = %s\n", getenv("ipaddr")); printf("baudrate = %d bps\n", bd->bi_baudrate); return 0; @@ -343,7 +343,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) print_num("flashoffset", (ulong)bd->bi_flashoffset); print_eth(0); - printf("ip_addr = %pI4\n", &bd->bi_ip_addr); + printf("ip_addr = %s\n", getenv("ipaddr")); printf("baudrate = %lu bps\n", bd->bi_baudrate); return 0; @@ -367,7 +367,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) #if defined(CONFIG_CMD_NET) print_eth(0); - printf("ip_addr = %pI4\n", &bd->bi_ip_addr); + printf("ip_addr = %s\n", getenv("ipaddr")); #endif printf("baudrate = %d bps\n", bd->bi_baudrate); #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF)) @@ -403,7 +403,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) #if defined(CONFIG_CMD_NET) print_eth(0); - printf("ip_addr = %pI4\n", &bd->bi_ip_addr); + printf("ip_addr = %s\n", getenv("ipaddr")); #endif printf("baudrate = %ld bps\n", (ulong)bd->bi_baudrate); return 0; @@ -436,7 +436,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) #if defined(CONFIG_CMD_NET) print_eth(0); - printf("ip_addr = %pI4\n", &bd->bi_ip_addr); + printf("ip_addr = %s\n", getenv("ipaddr")); print_mhz("ethspeed", bd->bi_ethspeed); #endif printf("baudrate = %d bps\n", bd->bi_baudrate); @@ -461,7 +461,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) #if defined(CONFIG_CMD_NET) print_eth(0); - printf("ip_addr = %pI4\n", &bd->bi_ip_addr); + printf("ip_addr = %s\n", getenv("ipaddr")); #endif print_num("FB base ", gd->fb_base); return 0; @@ -485,7 +485,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) #if defined(CONFIG_CMD_NET) print_eth(0); - printf("ip_addr = %pI4\n", &bd->bi_ip_addr); + printf("ip_addr = %s\n", getenv("ipaddr")); #endif printf("baudrate = %d bps\n", bd->bi_baudrate); @@ -506,7 +506,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) #if defined(CONFIG_CMD_NET) print_eth(0); - printf("ip_addr = %pI4\n", &bd->bi_ip_addr); + printf("ip_addr = %s\n", getenv("ipaddr")); #endif printf("baudrate = %ld bps\n", bd->bi_baudrate); diff --git a/common/cmd_nand.c b/common/cmd_nand.c index 0fd3a6c..f060a31 100644 --- a/common/cmd_nand.c +++ b/common/cmd_nand.c @@ -11,7 +11,7 @@ * Added 16-bit nand support * (C) 2004 Texas Instruments * - * Copyright 2010 Freescale Semiconductor + * Copyright 2010, 2012 Freescale Semiconductor * The portions of this file whose copyright is held by Freescale and which * are not considered a derived work of GPL v2-only code may be distributed * and/or modified under the terms of the GNU General Public License as @@ -390,6 +390,41 @@ static void nand_print_and_set_info(int idx) setenv("nand_erasesize", buf); } +static int raw_access(nand_info_t *nand, ulong addr, loff_t off, ulong count, + int read) +{ + int ret = 0; + size_t rwsize; + + while (count--) { + /* Raw access */ + mtd_oob_ops_t ops = { + .datbuf = (u8 *)addr, + .oobbuf = ((u8 *)addr) + nand->writesize, + .len = nand->writesize, + .ooblen = nand->oobsize, + .mode = MTD_OOB_RAW + }; + + rwsize = nand->writesize + nand->oobsize; + if (read) + ret = nand->read_oob(nand, off, &ops); + else + ret = nand->write_oob(nand, off, &ops); + + if (ret) { + printf("%s: error at offset %llx, ret %d\n", + __func__, (long long)off, ret); + break; + } + + addr += nand->writesize + nand->oobsize; + off += nand->writesize; + } + + return ret; +} + int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) { int i, ret = 0; @@ -568,7 +603,9 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) if (strncmp(cmd, "read", 4) == 0 || strncmp(cmd, "write", 5) == 0) { size_t rwsize; + ulong pagecount = 1; int read; + int raw; if (argc < 4) goto usage; @@ -577,13 +614,36 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) read = strncmp(cmd, "read", 4) == 0; /* 1 = read, 0 = write */ printf("\nNAND %s: ", read ? "read" : "write"); - if (arg_off_size(argc - 3, argv + 3, &dev, &off, &size) != 0) - return 1; nand = &nand_info[dev]; - rwsize = size; s = strchr(cmd, '.'); + + if (!strcmp(s, ".raw")) { + raw = 1; + + if (arg_off(argv[3], &dev, &off, &size)) + return 1; + + if (argc > 4 && !str2long(argv[4], &pagecount)) { + printf("'%s' is not a number\n", argv[4]); + return 1; + } + + if (pagecount * nand->writesize > size) { + puts("Size exceeds partition or device limit\n"); + return -1; + } + + rwsize = pagecount * (nand->writesize + nand->oobsize); + } else { + if (arg_off_size(argc - 3, argv + 3, &dev, + &off, &size) != 0) + return 1; + + rwsize = size; + } + if (!s || !strcmp(s, ".jffs2") || !strcmp(s, ".e") || !strcmp(s, ".i")) { if (read) @@ -609,7 +669,8 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) return 1; } ret = nand_write_skip_bad(nand, off, &rwsize, - (u_char *)addr, WITH_YAFFS_OOB); + (u_char *)addr, + WITH_INLINE_OOB); #endif } else if (!strcmp(s, ".oob")) { /* out-of-band data */ @@ -623,22 +684,8 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) ret = nand->read_oob(nand, off, &ops); else ret = nand->write_oob(nand, off, &ops); - } else if (!strcmp(s, ".raw")) { - /* Raw access */ - mtd_oob_ops_t ops = { - .datbuf = (u8 *)addr, - .oobbuf = ((u8 *)addr) + nand->writesize, - .len = nand->writesize, - .ooblen = nand->oobsize, - .mode = MTD_OOB_RAW - }; - - rwsize = nand->writesize + nand->oobsize; - - if (read) - ret = nand->read_oob(nand, off, &ops); - else - ret = nand->write_oob(nand, off, &ops); + } else if (raw) { + ret = raw_access(nand, addr, off, pagecount, read); } else { printf("Unknown nand command suffix '%s'.\n", s); return 1; @@ -732,9 +779,9 @@ U_BOOT_CMD( "nand write - addr off|partition size\n" " read/write 'size' bytes starting at offset 'off'\n" " to/from memory address 'addr', skipping bad blocks.\n" - "nand read.raw - addr off|partition\n" - "nand write.raw - addr off|partition\n" - " Use read.raw/write.raw to avoid ECC and access the page as-is.\n" + "nand read.raw - addr off|partition [count]\n" + "nand write.raw - 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" " write 'size' bytes starting at offset 'off' from memory address\n" diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index e1ccdd8..5999cb8 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -343,21 +343,7 @@ int _do_env_set(int flag, int argc, char * const argv[]) * Some variables should be updated when the corresponding * entry in the environment is changed */ - if (strcmp(name, "ipaddr") == 0) { - char *s = argv[2]; /* always use only one arg */ - char *e; - unsigned long addr; - bd->bi_ip_addr = 0; - for (addr = 0, i = 0; i < 4; ++i) { - ulong val = s ? simple_strtoul(s, &e, 10) : 0; - addr <<= 8; - addr |= val & 0xFF; - if (s) - s = *e ? e + 1 : e; - } - bd->bi_ip_addr = htonl(addr); - return 0; - } else if (strcmp(argv[1], "loadaddr") == 0) { + if (strcmp(argv[1], "loadaddr") == 0) { load_addr = simple_strtoul(argv[2], NULL, 16); return 0; } diff --git a/common/cmd_sata.c b/common/cmd_sata.c index 7b1703f..3f98235 100644 --- a/common/cmd_sata.c +++ b/common/cmd_sata.c @@ -48,9 +48,12 @@ int __sata_initialize(void) sata_dev_desc[i].block_write = sata_write; rc = init_sata(i); - rc = scan_sata(i); - if ((sata_dev_desc[i].lba > 0) && (sata_dev_desc[i].blksz > 0)) - init_part(&sata_dev_desc[i]); + if (!rc) { + rc = scan_sata(i); + if (!rc && (sata_dev_desc[i].lba > 0) && + (sata_dev_desc[i].blksz > 0)) + init_part(&sata_dev_desc[i]); + } } sata_curr_device = 0; return rc; diff --git a/common/main.c b/common/main.c index 3b9e39a..a933357 100644 --- a/common/main.c +++ b/common/main.c @@ -973,7 +973,6 @@ int readline_into_buffer(const char *const prompt, char *buffer, int timeout) #ifdef CONFIG_SHOW_ACTIVITY while (!tstc()) { - extern void show_activity(int arg); show_activity(0); WATCHDOG_RESET(); } |