aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--miscutils/nandwrite.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/miscutils/nandwrite.c b/miscutils/nandwrite.c
index 6c85ea346..de30a0c1f 100644
--- a/miscutils/nandwrite.c
+++ b/miscutils/nandwrite.c
@@ -60,7 +60,6 @@
60#define OPT_f (1 << 3) 60#define OPT_f (1 << 3)
61#define OPT_l (1 << 4) 61#define OPT_l (1 << 4)
62 62
63#define NAND_MAX_OOBSIZE 256
64/* helper for writing out 0xff for bad blocks pad */ 63/* helper for writing out 0xff for bad blocks pad */
65static void dump_bad(struct mtd_info_user *meminfo, unsigned len, int oob) 64static void dump_bad(struct mtd_info_user *meminfo, unsigned len, int oob)
66{ 65{
@@ -103,7 +102,7 @@ int nandwrite_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
103int nandwrite_main(int argc UNUSED_PARAM, char **argv) 102int nandwrite_main(int argc UNUSED_PARAM, char **argv)
104{ 103{
105 /* Buffer for OOB data */ 104 /* Buffer for OOB data */
106 unsigned char oobbuf[NAND_MAX_OOBSIZE]; 105 unsigned char *oobbuf;
107 unsigned opts; 106 unsigned opts;
108 int fd; 107 int fd;
109 ssize_t cnt; 108 ssize_t cnt;
@@ -135,10 +134,6 @@ int nandwrite_main(int argc UNUSED_PARAM, char **argv)
135 fd = xopen(argv[0], O_RDWR); 134 fd = xopen(argv[0], O_RDWR);
136 xioctl(fd, MEMGETINFO, &meminfo); 135 xioctl(fd, MEMGETINFO, &meminfo);
137 136
138 oob.start = 0;
139 oob.length = meminfo.oobsize;
140 oob.ptr = oobbuf;
141
142 mtdoffset = xstrtou(opt_s, 0); 137 mtdoffset = xstrtou(opt_s, 0);
143 if (IS_NANDDUMP && (opts & OPT_l)) { 138 if (IS_NANDDUMP && (opts & OPT_l)) {
144 unsigned length = xstrtou(opt_l, 0); 139 unsigned length = xstrtou(opt_l, 0);
@@ -153,6 +148,11 @@ int nandwrite_main(int argc UNUSED_PARAM, char **argv)
153 bb_error_msg_and_die("start address is not page aligned"); 148 bb_error_msg_and_die("start address is not page aligned");
154 149
155 filebuf = xmalloc(meminfo_writesize); 150 filebuf = xmalloc(meminfo_writesize);
151 oobbuf = xmalloc(meminfo.oobsize);
152
153 oob.start = 0;
154 oob.length = meminfo.oobsize;
155 oob.ptr = oobbuf;
156 156
157 blockstart = mtdoffset & ~(meminfo.erasesize - 1); 157 blockstart = mtdoffset & ~(meminfo.erasesize - 1);
158 if (blockstart != mtdoffset) { 158 if (blockstart != mtdoffset) {