From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.windriver.com ([147.11.1.11]) by bombadil.infradead.org with esmtps (Exim 4.69 #1 (Red Hat Linux)) id 1OEvAE-0005xZ-FJ for linux-mtd@lists.infradead.org; Thu, 20 May 2010 02:07:11 +0000 Message-ID: <4BF49BB4.30306@windriver.com> Date: Thu, 20 May 2010 10:17:24 +0800 From: "stanley.miao" MIME-Version: 1.0 To: Artem.Bityutskiy@nokia.com Subject: Re: [Yaffs] [PATCH 1/2] Fix the bug of writing a yaffs2 image to NAND References: <1274185390-3066-1-git-send-email-stanley.miao@windriver.com> <1274185390-3066-2-git-send-email-stanley.miao@windriver.com> In-Reply-To: <1274185390-3066-2-git-send-email-stanley.miao@windriver.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: linux-mtd@lists.infradead.org, yaffs@lists.aleph1.co.uk List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Hi, Artem, Any comments ? Stanley. Stanley.Miao wrote: > The tool mkyaffs2image doesn't know the oob layout of a NAND flash, so it > puts the yaffs2 tags at the offset 0 of oob area, as a result, the image > generated by mkyaffs2image is different with the image dumped by nanddump. > Now adding a parameter "-r" for nandwrite to differentiate these images. > > Write a image generated by mkyaffs2image: > $> nandwrite -a -o /dev/mtd3 yaffs2.bin > > Write a image dumped by nanddump: > $> nandwrite -a -r /dev/mtd3 image.bin > > Signed-off-by: Stanley.Miao > --- > nandwrite.c | 20 ++++++++++++++++---- > 1 files changed, 16 insertions(+), 4 deletions(-) > > diff --git a/nandwrite.c b/nandwrite.c > index b77edd6..1e30ad1 100644 > --- a/nandwrite.c > +++ b/nandwrite.c > @@ -80,6 +80,7 @@ static void display_help (void) > " -m, --markbad Mark blocks bad if write fails\n" > " -n, --noecc Write without ecc\n" > " -o, --oob Image contains oob data\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" > " -b, --blockalign=1|2|4 Set multiple of eraseblocks to align to\n" > @@ -110,6 +111,7 @@ static const char *mtd_device, *img; > static int mtdoffset = 0; > static bool quiet = false; > static bool writeoob = false; > +static bool rawoob = false; > static bool autoplace = false; > static bool markbad = false; > static bool forcejffs2 = false; > @@ -125,7 +127,7 @@ static void process_options (int argc, char * const argv[]) > > for (;;) { > int option_index = 0; > - static const char *short_options = "ab:fjmnopqs:y"; > + static const char *short_options = "ab:fjmnopqrs:y"; > static const struct option long_options[] = { > {"help", no_argument, 0, 0}, > {"version", no_argument, 0, 0}, > @@ -138,6 +140,7 @@ static void process_options (int argc, char * const argv[]) > {"oob", no_argument, 0, 'o'}, > {"pad", no_argument, 0, 'p'}, > {"quiet", no_argument, 0, 'q'}, > + {"raw", no_argument, 0, 'r'}, > {"start", required_argument, 0, 's'}, > {"yaffs", no_argument, 0, 'y'}, > {0, 0, 0, 0}, > @@ -187,6 +190,10 @@ static void process_options (int argc, char * const argv[]) > case 'p': > pad = true; > break; > + case 'r': > + rawoob = true; > + writeoob = true; > + break; > case 's': > mtdoffset = strtol (optarg, NULL, 0); > break; > @@ -583,6 +590,7 @@ int main(int argc, char * const argv[]) > oob.ptr = oobreadbuf; > } else { > int i, start, len; > + int tags_pos = 0; > /* > * We use autoplacement and have the oobinfo with the autoplacement > * information from the kernel available > @@ -595,9 +603,13 @@ int main(int argc, char * const argv[]) > /* Set the reserved bytes to 0xff */ > start = old_oobinfo.oobfree[i][0]; > len = old_oobinfo.oobfree[i][1]; > - memcpy(oobbuf + start, > - oobreadbuf + start, > - len); > + if (rawoob) > + memcpy(oobbuf + start, > + oobreadbuf + start, len); > + else > + memcpy(oobbuf + start, > + oobreadbuf + tags_pos, len); > + tags_pos += len; > } > } else { > /* Set at least the ecc byte positions to 0xff */ >