From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28175 invoked by alias); 23 Jan 2007 19:34:30 -0000 Received: (qmail 28151 invoked by uid 22791); 23 Jan 2007 19:34:28 -0000 X-Spam-Check-By: sourceware.org Received: from web30410.mail.mud.yahoo.com (HELO web30410.mail.mud.yahoo.com) (68.142.200.113) by sourceware.org (qpsmtpd/0.31) with SMTP; Tue, 23 Jan 2007 19:34:21 +0000 Received: (qmail 64101 invoked by uid 60001); 23 Jan 2007 19:34:16 -0000 X-YMail-OSG: bOUa7qMVM1mEhSMZ5Rbk3eSkjF.Kie8vUMHUOS4PJ9hF1YEcXoqTfKXzitd9xHGbF1gv9RzvAyUINw8105XnLXAK3Q-- Received: from [75.37.189.210] by web30410.mail.mud.yahoo.com via HTTP; Tue, 23 Jan 2007 11:34:16 PST Date: Tue, 23 Jan 2007 19:34:00 -0000 From: Weiguang Shi To: Gary Thomas Cc: ecos-discuss In-Reply-To: <45B5CA65.1060604@mlbassoc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <804814.62549.qm@web30410.mail.mud.yahoo.com> X-IsSubscribed: yes Mailing-List: contact ecos-discuss-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@ecos.sourceware.org Subject: Re: AW: [ECOS] cat zImage >/dev/mtd1 does not work X-SW-Source: 2007-01/txt/msg00137.txt.bz2 I have to make it work, old or new ;-) So I've been trying to apply your patch to 2.6.18 in a way that makes sense in uClinux-2.4.x. The patch consists three parts and, besides the one I tried, there are (I patched and diff'ed them) 87a88,91 > if (buf[i].name[0] == 0xff) { > i = numslots; > break; > } and 127c131 < continue; --- > break; It appears to me that 0xff is significant in both parts. What does it mean? I haven't been able to figure out how either will enable writing. As my node starts up, I saw in the sequence 0x003e0000-0x003ff000 : "FIS directory" mtd: partition "FIS directory" doesn't end on an erase block -- force read-only 0x003ff000-0x00400000 : "RedBoot config" mtd: partition "RedBoot config" doesn't start on an erase block boundary -- force read-only can I remove the code that forced read-only (in mtdpart.c) at start up as an alternative to applying your patch? Thanks! Wei In addition, I found this piece of code in redboot.c confusing. #ifdef CONFIG_MTD_REDBOOT_PARTS_READONLY if (!memcmp(names, "RedBoot", 8) || !memcmp(names, "RedBoot config", 15) || !memcmp(names, "FIS directory", 14)) { parts[i].mask_flags = MTD_WRITEABLE; } That is, if CONFIG_MTD_REDBOOT_PARTS_READONLY is defined, the partitions, "RedBoot", "RedBoot config", and "FIS directory", are set writeable! Can you shed some light? > image for the FIS partition back to /dev/mtd4 > > I still get > > > > cat: Write Error: Read-only file system > > You missed the part of the patch that allows the FIS directory to be > writable even if you have combined FIS & FCONFIG. I don't have such an > old system, so you'll need to figure out how to get that code in. > > > --- Gary Thomas wrote: > > > >> Weiguang Shi wrote: > >>> Gary, > >>> > >>> I'm at the point to flash the modified partition back but can't erase the > >>> FIS partition /dev/mtd4 > >>> > >>> # cat /proc/mtd > >>> dev: size erasesize name > >>> mtd0: 00080000 00020000 "RedBoot" > >>> mtd1: 00100000 00020000 "kernel" > >>> mtd2: 00200000 00020000 "ramdisk" > >>> mtd3: 00020000 00020000 "kiyon_config" > >>> mtd4: 0001f000 00020000 "FIS directory" > >>> mtd5: 00001000 00020000 "RedBoot config" > >>> # eraseall /dev/mtd4 > >>> eraseall: /dev/mtd4: Permission denied > >>> > >>> I realized that I may need to "unlock" it but both my attempts to do that > >>> in RedBoot and Linux failed. In the former, "fis unlock" worked fine in > >>> Redboot but after Linux boots up I still get the same "Permission denied" > >>> error. In linux, my unlock resulted in > >>> # unlock /dev/mtd4 > >>> Could not open mtd device: /dev/mtd4 > >>> # unlock /dev/mtd5 > >>> Could not open mtd device: /dev/mtd5 > >>> > >>> Any ideas on how shall I proceed? > >> The problem is that if you use combined FIS directory and FCONFIG data > >> (which you are based on the map above), then the MTD layer makes both of > >> those images read only. The attached patch can let you override this. > >> It's based on the public 2.6.18 kernel. > >> > >> Note: you need to be careful doing these changes to your FLASH. If you > >> simply erase the partition, RedBoot will lose everything. MTD is pretty > >> cool and if you simply open /dev/mtd4 read/write, read the current contents, > >> update them and then rewrite them, the MTD layer will take care of erasing > >> and updating the appropriate portions. > >> > >>> --- Gary Thomas wrote: > >>> > >>>> Weiguang Shi wrote: > >>>>> That's even better and was the solution that I was looking for. > >>>>> The question is how, from the OS, can I update the FIS. Obviously > >>>>> I need to know the structure of the "FIS directory" partition and > >>>>> find the offset of that checksum and insert a '0' there by > >>>>> - reading the whole partition into ram, > >>>>> - changing the bit, erasing the partition on the flash, > >>>>> - and finally flashing the modified partition in the ram back. > >>>>> > >>>>> Any suggestions as to where to start? > >>>> > >>>> > >>>> Also, drivers/mtd has some RedBoot FIS parsing code in it. You could > >>>> look at it for pointers. > >>>> > >>>>> --- Gary Thomas wrote: > >>>>> > >>>>>> Note: you don't really need to change RedBoot. Just update the > >>>>>> FIS [directory] entry for the image you are changing, either with > >>>>>> the corrected checksum, or the value 0. RedBoot ignores the checksum > >>>>>> when the stored value is 0. > >> -- > >> ------------------------------------------------------------ > >> Gary Thomas | Consulting for the > >> MLB Associates | Embedded world > >> ------------------------------------------------------------ > >>> diff -ubNr --exclude=.gitignore linux-2.6.18/drivers/mtd/redboot.c > >> /tmp/fc_base/opt/amltd/develop/linuxppc-2.6/drivers/mtd/redboot.c > >> --- linux-2.6.18/drivers/mtd/redboot.c 2006-09-19 21:42:06.000000000 -0600 > >> +++ /tmp/fc_base/opt/amltd/develop/linuxppc-2.6/drivers/mtd/redboot.c 2006-10-24 > >> 11:59:32.000000000 -0600 > >> @@ -85,6 +85,10 @@ > >> > >> numslots = (master->erasesize / sizeof(struct fis_image_desc)); > >> for (i = 0; i < numslots; i++) { > >> + if (buf[i].name[0] == 0xff) { > >> + i = numslots; > >> + break; > >> + } > >> if (!memcmp(buf[i].name, "FIS directory", 14)) { > >> /* This is apparently the FIS directory entry for the > >> * FIS directory itself. The FIS directory size is > >> @@ -124,7 +128,7 @@ > >> struct fis_list *new_fl, **prev; > >> > >> if (buf[i].name[0] == 0xff) > >> - continue; > >> + break; > >> if (!redboot_checksum(&buf[i])) > >> break; > >> > >> @@ -196,14 +200,22 @@ > >> parts[i].size = fl->img->size; > >> parts[i].offset = fl->img->flash_base; > >> parts[i].name = names; > >> - > >> strcpy(names, fl->img->name); > >> + > >> #ifdef CONFIG_MTD_REDBOOT_PARTS_READONLY > >> if (!memcmp(names, "RedBoot", 8) || > >> !memcmp(names, "RedBoot config", 15) || > >> !memcmp(names, "FIS directory", 14)) { > >> parts[i].mask_flags = MTD_WRITEABLE; > >> } > >> +#else > >> + if (!memcmp(names, "FIS directory", 14)) { > >> + // Special hack to let directory be read/write > >> + if ((fl->img->size & (master->erasesize - 1)) != 0) { > >> + parts[i].size = (fl->img->size + (master->erasesize - 1)) & > >> ~(master->erasesize - 1); > >> + } > >> + } > >> + > >> #endif > >> names += strlen(names)+1; > >> > >> > >>> -- > >> Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos > >> and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss > > > > > > > > > > ____________________________________________________________________________________ > > It's here! Your new message! > > Get new email alerts with the free Yahoo! Toolbar. > > http://tools.search.yahoo.com/toolbar/features/mail/ > > > -- > ------------------------------------------------------------ > Gary Thomas | Consulting for the > MLB Associates | Embedded world > ------------------------------------------------------------ > > -- > Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos > and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss > > ____________________________________________________________________________________ Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail beta. http://new.mail.yahoo.com -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss