Commit 2dc3c483a9f7c8215b4523183dc74e8692253404

Authored by Boris Brezillon
Committed by Scott Wood
1 parent 29d63a59ea

cmd, nand: add an option to disable the verification when writing in raw mode

Modern NANDs do not guarantee that data written in raw mode will not
contain bitflips just after writing them. This is fine since the number
of bitflips should be rather low and thus fixable by the ECC engine,
but since we are reading data in raw mode to verify if they match the
input data we cannot prevent failures if some bits are flipped.

The option of using standard mode to verify the data is not acceptable
either, since one of the usage of raw mode is to allow flashing images
that do not respect the standard NAND page layout or the default ECC
config (this is the case on Allwinner platforms, where the ROM code
tests several hardcoded configs, which are not necessarily matching the
NAND characteristics).

Add an extension to the nand write.raw command allowing one to disable
the verification step.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

Showing 1 changed file with 10 additions and 5 deletions Side-by-side Diff

... ... @@ -306,7 +306,7 @@
306 306 }
307 307  
308 308 static int raw_access(struct mtd_info *mtd, ulong addr, loff_t off,
309   - ulong count, int read)
  309 + ulong count, int read, int no_verify)
310 310 {
311 311 int ret = 0;
312 312  
... ... @@ -324,7 +324,7 @@
324 324 ret = mtd_read_oob(mtd, off, &ops);
325 325 } else {
326 326 ret = mtd_write_oob(mtd, off, &ops);
327   - if (!ret)
  327 + if (!ret && !no_verify)
328 328 ret = nand_verify_page_oob(mtd, &ops, off);
329 329 }
330 330  
... ... @@ -546,6 +546,7 @@
546 546 ulong pagecount = 1;
547 547 int read;
548 548 int raw = 0;
  549 + int no_verify = 0;
549 550  
550 551 if (argc < 4)
551 552 goto usage;
552 553  
... ... @@ -557,9 +558,12 @@
557 558  
558 559 s = strchr(cmd, '.');
559 560  
560   - if (s && !strcmp(s, ".raw")) {
  561 + if (s && !strncmp(s, ".raw", 4)) {
561 562 raw = 1;
562 563  
  564 + if (!strcmp(s, ".raw.noverify"))
  565 + no_verify = 1;
  566 +
563 567 if (mtd_arg_off(argv[3], &dev, &off, &size, &maxsize,
564 568 MTD_DEV_TYPE_NAND,
565 569 nand_info[dev]->size))
... ... @@ -633,7 +637,8 @@
633 637 else
634 638 ret = mtd_write_oob(mtd, off, &ops);
635 639 } else if (raw) {
636   - ret = raw_access(mtd, addr, off, pagecount, read);
  640 + ret = raw_access(mtd, addr, off, pagecount, read,
  641 + no_verify);
637 642 } else {
638 643 printf("Unknown nand command suffix '%s'.\n", s);
639 644 return 1;
... ... @@ -786,7 +791,7 @@
786 791 " read/write 'size' bytes starting at offset 'off'\n"
787 792 " to/from memory address 'addr', skipping bad blocks.\n"
788 793 "nand read.raw - addr off|partition [count]\n"
789   - "nand write.raw - addr off|partition [count]\n"
  794 + "nand write.raw[.noverify] - addr off|partition [count]\n"
790 795 " Use read.raw/write.raw to avoid ECC and access the flash as-is.\n"
791 796 #ifdef CONFIG_CMD_NAND_TRIMFFS
792 797 "nand write.trimffs - addr off|partition size\n"