]> www.infradead.org Git - mtd-utils.git/commitdiff
nandwrite: add only write oob option
authorLei Wen <leiwen@marvell.com>
Mon, 7 Mar 2011 09:44:46 +0000 (01:44 -0800)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Tue, 8 Mar 2011 12:09:30 +0000 (14:09 +0200)
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>
nandwrite.c

index 7f459cb948232763ff04a12d9fb0cd7ae61a4c05..6e986c5d7741667623a5ee810da9f826797e183a 100644 (file)
@@ -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) {