summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Wen <leiwen@marvell.com>2011-03-07 01:44:46 -0800
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2011-03-08 14:09:30 +0200
commita74619f416f89127138eb7e8168a0b67fb419c64 (patch)
tree09a85c8f8899fa7b9526cd3562127c7e3f530406
parent1b083e0c9011f32028a79d4ad707deaa17ad1b5e (diff)
nandwrite: add only write oob option
Write only oob part goes different path in nand_base.c, it is better to have userland program so that we could easy debug this path when the write only oob fail like the mtd_oobtest in mtd_test suit. Signed-off-by: Lei Wen <leiwen@marvell.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
-rw-r--r--nandwrite.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/nandwrite.c b/nandwrite.c
index 7f459cb..6e986c5 100644
--- a/nandwrite.c
+++ b/nandwrite.c
@@ -80,6 +80,7 @@ static void display_help(void)
" -n, --noecc Write without ecc\n"
" -N, --noskipbad Write without bad block skipping\n"
" -o, --oob Image contains oob data\n"
+" -O, --onlyoob Image contains oob data and only write the oob part\n"
" -r, --raw Image contains the raw oob data dumped by nanddump\n"
" -s addr, --start=addr Set start address (default is 0)\n"
" -p, --pad Pad to page size\n"
@@ -113,6 +114,7 @@ static long long mtdoffset = 0;
static bool quiet = false;
static bool writeoob = false;
static bool rawoob = false;
+static bool onlyoob = false;
static bool autoplace = false;
static bool markbad = false;
static bool forcejffs2 = false;
@@ -129,7 +131,7 @@ static void process_options(int argc, char * const argv[])
for (;;) {
int option_index = 0;
- static const char *short_options = "ab:fjmnNopqrs:y";
+ static const char *short_options = "ab:fjmnNoOpqrs:y";
static const struct option long_options[] = {
{"help", no_argument, 0, 0},
{"version", no_argument, 0, 0},
@@ -141,6 +143,7 @@ static void process_options(int argc, char * const argv[])
{"noecc", no_argument, 0, 'n'},
{"noskipbad", no_argument, 0, 'N'},
{"oob", no_argument, 0, 'o'},
+ {"onlyoob", no_argument, 0, 'O'},
{"pad", no_argument, 0, 'p'},
{"quiet", no_argument, 0, 'q'},
{"raw", no_argument, 0, 'r'},
@@ -193,6 +196,10 @@ static void process_options(int argc, char * const argv[])
case 'o':
writeoob = true;
break;
+ case 'O':
+ writeoob = true;
+ onlyoob = true;
+ break;
case 'p':
pad = true;
break;
@@ -282,7 +289,7 @@ int main(int argc, char * const argv[])
process_options(argc, argv);
- if (pad && writeoob) {
+ if (!onlyoob && (pad && writeoob)) {
fprintf(stderr, "Can't pad when oob data is present.\n");
exit(EXIT_FAILURE);
}
@@ -639,7 +646,7 @@ int main(int argc, char * const argv[])
}
/* Write out the Page data */
- if (mtd_write(&mtd, fd, mtdoffset / mtd.eb_size, mtdoffset % mtd.eb_size,
+ if (!onlyoob && mtd_write(&mtd, fd, mtdoffset / mtd.eb_size, mtdoffset % mtd.eb_size,
writebuf, mtd.min_io_size)) {
int i;
if (errno != EIO) {