summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2020-11-10 15:07:38 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2020-11-10 15:07:38 +0100
commit7b1d8b4b3561c043a79d5933a7c1eb9266dc328d (patch)
tree9c398aa20e22763a239d11eecf6fb4c1d06d4c97 /commands
parent0b0eada569b198aa3882cfec5874bc35a8a0fa14 (diff)
parent4db0f1c3dbe6173fdf91cbeb83e250719332c6a3 (diff)
downloadbarebox-7b1d8b4b3561c043a79d5933a7c1eb9266dc328d.tar.gz
barebox-7b1d8b4b3561c043a79d5933a7c1eb9266dc328d.tar.xz
Merge branch 'for-next/mtd-nand'
Diffstat (limited to 'commands')
-rw-r--r--commands/nand-bitflip.c23
-rw-r--r--commands/nand.c5
2 files changed, 26 insertions, 2 deletions
diff --git a/commands/nand-bitflip.c b/commands/nand-bitflip.c
index 7335f77379..1395021ec0 100644
--- a/commands/nand-bitflip.c
+++ b/commands/nand-bitflip.c
@@ -10,6 +10,25 @@
#include <linux/mtd/mtd.h>
#include <mtd/mtd-peb.h>
+static int bitflip_mtd_read(struct mtd_info *mtd, loff_t from, size_t len,
+ size_t *retlen, void *buf)
+{
+ int ret_code;
+
+ if (mtd->_read_oob) {
+ struct mtd_oob_ops ops = {
+ .len = len,
+ .datbuf = buf,
+ };
+
+ ret_code = mtd->_read_oob(mtd, from, &ops);
+ } else {
+ ret_code = mtd->_read(mtd, from, len, retlen, buf);
+ }
+
+ return ret_code;
+}
+
static int do_nand_bitflip(int argc, char *argv[])
{
int opt, ret, fd;
@@ -34,7 +53,7 @@ static int do_nand_bitflip(int argc, char *argv[])
block = simple_strtoul(optarg, NULL, 0);
break;
case 'o':
- offset = simple_strtoull(optarg, NULL, 0);
+ offset = strtoull_suffix(optarg, NULL, 0);
break;
case 'c':
check = 1;
@@ -77,7 +96,7 @@ static int do_nand_bitflip(int argc, char *argv[])
buf = xzalloc(meminfo.writesize);
roffset = (loff_t)block * meminfo.mtd->erasesize + offset;
- ret = meminfo.mtd->read(meminfo.mtd, roffset, meminfo.writesize, &r, buf);
+ ret = bitflip_mtd_read(meminfo.mtd, roffset, meminfo.writesize, &r, buf);
if (ret > 0) {
printf("page at block %d, offset 0x%08llx has %d bitflips%s\n",
block, offset, ret,
diff --git a/commands/nand.c b/commands/nand.c
index ed2864fb7b..67e43eba30 100644
--- a/commands/nand.c
+++ b/commands/nand.c
@@ -13,6 +13,7 @@
#include <ioctl.h>
#include <nand.h>
#include <linux/mtd/mtd-abi.h>
+#include <linux/mtd/mtd.h>
#include <fcntl.h>
#include <libgen.h>
@@ -130,6 +131,8 @@ static int do_nand(int argc, char *argv[])
loff_t ofs;
int bad = 0;
+ printf("---- bad blocks ----\n");
+
for (ofs = 0; ofs < mtdinfo.size; ofs += mtdinfo.erasesize) {
if (ioctl(fd, MEMGETBADBLOCK, &ofs)) {
printf("Block at 0x%08llx is bad\n", ofs);
@@ -139,6 +142,8 @@ static int do_nand(int argc, char *argv[])
if (!bad)
printf("No bad blocks\n");
+
+ mtd_print_oob_info(mtdinfo.mtd);
}
out: