aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorRichard Genoud <richard.genoud@gmail.com>2014-06-25 17:33:34 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2014-06-25 17:37:01 +0200
commit8feb25956f788026099c44103f1b5c440bfe3598 (patch)
tree07d6c9745d486995f13a984984648e5bd08335ca /miscutils
parentf17fbe1d365d935b486ece2172043d3eeb8a999b (diff)
downloadbusybox-w32-8feb25956f788026099c44103f1b5c440bfe3598.tar.gz
busybox-w32-8feb25956f788026099c44103f1b5c440bfe3598.tar.bz2
busybox-w32-8feb25956f788026099c44103f1b5c440bfe3598.zip
nanddump: kill -b Omit bad block
since mtd-utils 1.4.7, the omit bad block method has been removed. (cf commit d8b8f780ec3c916f3990e9227d6bfbb22bf42ef8) Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/nandwrite.c38
1 files changed, 12 insertions, 26 deletions
diff --git a/miscutils/nandwrite.c b/miscutils/nandwrite.c
index a64b95bc5..509c06412 100644
--- a/miscutils/nandwrite.c
+++ b/miscutils/nandwrite.c
@@ -36,20 +36,16 @@
36//usage: "\n -s ADDR Start address" 36//usage: "\n -s ADDR Start address"
37 37
38//usage:#define nanddump_trivial_usage 38//usage:#define nanddump_trivial_usage
39//usage: "[-o] [-b|--bb=padbad|skipbad] [-s ADDR] [-l LEN] [-f FILE] MTD_DEVICE" 39//usage: "[-o] [--bb=padbad|skipbad] [-s ADDR] [-l LEN] [-f FILE] MTD_DEVICE"
40//usage:#define nanddump_full_usage "\n\n" 40//usage:#define nanddump_full_usage "\n\n"
41//usage: "Dump MTD_DEVICE\n" 41//usage: "Dump MTD_DEVICE\n"
42//usage: "\n -o Dump oob data" 42//usage: "\n -o Dump oob data"
43//usage: "\n -b Omit bad block from the dump"
44//usage: "\n -s ADDR Start address" 43//usage: "\n -s ADDR Start address"
45//usage: "\n -l LEN Length" 44//usage: "\n -l LEN Length"
46//usage: "\n -f FILE Dump to file ('-' for stdout)" 45//usage: "\n -f FILE Dump to file ('-' for stdout)"
47//usage: "\n --bb=METHOD:" 46//usage: "\n --bb=METHOD:"
48//usage: "\n skipbad: skip bad blocks" 47//usage: "\n skipbad: skip bad blocks"
49//usage: "\n padbad: substitute bad blocks by 0xff (default)" 48//usage: "\n padbad: substitute bad blocks by 0xff (default)"
50//usage: "\n The difference between omit and skip bad block is that in the omit"
51//usage: "\n case, the length of the bad block is counted as part of the total"
52//usage: "\n dump length, and in the skip case, it's not."
53 49
54#include "libbb.h" 50#include "libbb.h"
55#include <mtd/mtd-user.h> 51#include <mtd/mtd-user.h>
@@ -60,14 +56,12 @@
60#define OPT_p (1 << 0) /* nandwrite only */ 56#define OPT_p (1 << 0) /* nandwrite only */
61#define OPT_o (1 << 0) /* nanddump only */ 57#define OPT_o (1 << 0) /* nanddump only */
62#define OPT_s (1 << 1) 58#define OPT_s (1 << 1)
63#define OPT_b (1 << 2) 59#define OPT_f (1 << 2)
64#define OPT_f (1 << 3) 60#define OPT_l (1 << 3)
65#define OPT_l (1 << 4) 61#define OPT_bb (1 << 4) /* must be the last one in the list */
66#define OPT_bb (1 << 5) /* must be the last one in the list */
67 62
68#define BB_PADBAD (1 << 0) 63#define BB_PADBAD (1 << 0)
69#define BB_SKIPBAD (1 << 1) 64#define BB_SKIPBAD (1 << 1)
70#define BB_OMITBAD (1 << 2)
71 65
72/* helper for writing out 0xff for bad blocks pad */ 66/* helper for writing out 0xff for bad blocks pad */
73static void dump_bad(struct mtd_info_user *meminfo, unsigned len, int oob) 67static void dump_bad(struct mtd_info_user *meminfo, unsigned len, int oob)
@@ -128,7 +122,7 @@ int nandwrite_main(int argc UNUSED_PARAM, char **argv)
128 if (IS_NANDDUMP) { 122 if (IS_NANDDUMP) {
129 opt_complementary = "=1"; 123 opt_complementary = "=1";
130 applet_long_options = nanddump_longopts; 124 applet_long_options = nanddump_longopts;
131 opts = getopt32(argv, "os:bf:l:", &opt_s, &opt_f, &opt_l, &opt_bb); 125 opts = getopt32(argv, "os:f:l:", &opt_s, &opt_f, &opt_l, &opt_bb);
132 } else { /* nandwrite */ 126 } else { /* nandwrite */
133 opt_complementary = "-1:?2"; 127 opt_complementary = "-1:?2";
134 opts = getopt32(argv, "ps:", &opt_s); 128 opts = getopt32(argv, "ps:", &opt_s);
@@ -153,19 +147,13 @@ int nandwrite_main(int argc UNUSED_PARAM, char **argv)
153 if (length < meminfo.size - mtdoffset) 147 if (length < meminfo.size - mtdoffset)
154 end_addr = mtdoffset + length; 148 end_addr = mtdoffset + length;
155 } 149 }
156 if (IS_NANDDUMP) { 150 if (IS_NANDDUMP && (opts & OPT_bb)) {
157 if ((opts & OPT_b) && (opts & OPT_bb)) 151 if (strcmp("skipbad", opt_bb) == 0)
158 bb_show_usage(); 152 bb_method = BB_SKIPBAD;
159 if (opts & OPT_b) 153 else if (strcmp("padbad", opt_bb) == 0)
160 bb_method = BB_OMITBAD; 154 bb_method = BB_PADBAD;
161 if (opts & OPT_bb) { 155 else
162 if (!strcmp("skipbad", opt_bb)) 156 bb_show_usage();
163 bb_method = BB_SKIPBAD;
164 else if (!strcmp("padbad", opt_bb))
165 bb_method = BB_PADBAD;
166 else
167 bb_show_usage();
168 }
169 } 157 }
170 158
171 /* Pull it into a CPU register (hopefully) - smaller code that way */ 159 /* Pull it into a CPU register (hopefully) - smaller code that way */
@@ -200,7 +188,6 @@ int nandwrite_main(int argc UNUSED_PARAM, char **argv)
200 if (bb_method == BB_SKIPBAD) { 188 if (bb_method == BB_SKIPBAD) {
201 end_addr += (tmp - blockstart); 189 end_addr += (tmp - blockstart);
202 } 190 }
203 /* omitbad: do nothing */
204 } 191 }
205 mtdoffset = tmp; 192 mtdoffset = tmp;
206 } 193 }
@@ -231,7 +218,6 @@ int nandwrite_main(int argc UNUSED_PARAM, char **argv)
231 end_addr = ~0; 218 end_addr = ~0;
232 limit = MIN(meminfo.size, end_addr); 219 limit = MIN(meminfo.size, end_addr);
233 } 220 }
234 /* omitbad: do nothing */
235 } 221 }
236 if (mtdoffset >= limit) 222 if (mtdoffset >= limit)
237 break; 223 break;