"Das U-Boot" Source Tree
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

cmd: nand: nand dump with ecc option

option to show nand dump data ecc corrected as opposed to just raw

Signed-off-by: david regan <dregan@broadcom.com>
Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>

authored by

david regan and committed by
Michael Trimarchi
bb5d3a7a b5ce63e1

+18 -7
+18 -7
cmd/nand.c
··· 160 160 } 161 161 162 162 static int nand_dump(struct mtd_info *mtd, ulong off, int only_oob, 163 - int repeat) 163 + int ecc, int repeat) 164 164 { 165 165 int i; 166 166 u_char *datbuf, *oobbuf, *p; ··· 192 192 ops.oobbuf = oobbuf; 193 193 ops.len = mtd->writesize; 194 194 ops.ooblen = mtd->oobsize; 195 - ops.mode = MTD_OPS_RAW; 195 + if (ecc) 196 + ops.mode = MTD_OPS_PLACE_OOB; 197 + else 198 + ops.mode = MTD_OPS_RAW; 196 199 i = mtd_read_oob(mtd, addr, &ops); 197 200 if (i < 0) { 198 - printf("Error (%d) reading page %08lx\n", i, off); 201 + printf("Error reading page at offset %08lx, %d %s\n", 202 + off, i, i == -EUCLEAN ? "correctable" : 203 + "uncorrectable, dumping raw data"); 199 204 ret = 1; 200 - goto free_all; 201 205 } 202 206 printf("\nPage at offset %08lx dump:\n", off); 203 207 ··· 212 216 p = oobbuf; 213 217 print_buffer(0, p, 1, i, 8); 214 218 215 - free_all: 216 219 free(oobbuf); 217 220 free_dat: 218 221 free(datbuf); ··· 697 700 } 698 701 699 702 if (strncmp(cmd, "dump", 4) == 0) { 703 + int only_oob, ecc; 704 + 700 705 if (argc < 3) 701 706 goto usage; 702 707 708 + only_oob = !strcmp(&cmd[4], ".oob") || !strcmp(&cmd[4], ".ecc.oob") || 709 + !strcmp(&cmd[4], ".oob.ecc"); 710 + 711 + ecc = !strcmp(&cmd[4], ".ecc") || !strcmp(&cmd[4], ".ecc.oob") || 712 + !strcmp(&cmd[4], ".oob.ecc"); 713 + 703 714 off = (int)hextoul(argv[2], NULL); 704 - ret = nand_dump(mtd, off, !strcmp(&cmd[4], ".oob"), repeat); 715 + ret = nand_dump(mtd, off, only_oob, ecc, repeat); 705 716 706 717 return ret == 0 ? 1 : 0; 707 718 } ··· 1031 1042 "nand erase.part [clean] partition - erase entire mtd partition'\n" 1032 1043 "nand erase.chip [clean] - erase entire chip'\n" 1033 1044 "nand bad - show bad blocks\n" 1034 - "nand dump[.oob] off - dump page\n" 1045 + "nand dump[.oob][.ecc] off - dump raw (default) or ecc corrected page at offset\n" 1035 1046 #ifdef CONFIG_CMD_NAND_WATCH 1036 1047 "nand watch <off> <size> - check an area for bitflips\n" 1037 1048 "nand watch.part <part> - check a partition for bitflips\n"