* writing environment in NAND flash
@ 2011-02-25 9:31 Vanalme Filip
0 siblings, 0 replies; 5+ messages in thread
From: Vanalme Filip @ 2011-02-25 9:31 UTC (permalink / raw)
To: barebox
I have problems to save my environment settings. Although I set e.g. the MAC address and some other values and do the saveenv command, after reset, all settings have disappeared.
In the logging on the console port, I detected this :
"wrong crc on env
no valid environment found on /dev/env0. Using default environment"
That will be, of course, the cause why the settings disappear.
Further investigation with debugging enabled in nand_imx.c showed that Barebox reads 4 pages when starting up (0x80..0x83). That looks OK, because the environment's size is 6156 bytes. So, indeen 4 pages needed. However, when saving the environment, I only see appear one page write, i.e. on page 0x80. Of course, when reading back the four pages, the 2nd, 3rd and 4th page have all FF because they have never been written (causing a wrong CRC). Any idea why I only see 1 page write when saving the environment although the size is 6156 bytes ? Any hints where to look in the sources ?
Thanks in advance !
Filip
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* writing environment in NAND flash
@ 2011-02-25 13:50 Vanalme Filip
2011-02-25 13:56 ` Juergen Beisert
2011-02-25 14:13 ` Vanalme Filip
0 siblings, 2 replies; 5+ messages in thread
From: Vanalme Filip @ 2011-02-25 13:50 UTC (permalink / raw)
To: barebox
I have problems to save my environment settings. Although I set e.g. the MAC address and some other values and do the saveenv command, after reset, all settings have disappeared.
In the logging on the console port, I detected this :
"wrong crc on env
no valid environment found on /dev/env0. Using default environment"
That will be, of course, the cause why the settings disappear.
Further investigation with debugging enabled in nand_imx.c showed that Barebox reads 4 pages when starting up (0x80..0x83). That looks OK, because the environment's size is 6156 bytes. So, indeen 4 pages needed. However, when saving the environment, I only see appear one page write, i.e. on page 0x80. Of course, when reading back the four pages, the 2nd, 3rd and 4th page have all FF because they have never been written (causing a wrong CRC). Any idea why I only see 1 page write when saving the environment although the size is 6156 bytes ? Any hints where to look in the sources ?
Thanks in advance !
Filip
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: writing environment in NAND flash
2011-02-25 13:50 Vanalme Filip
@ 2011-02-25 13:56 ` Juergen Beisert
2011-02-25 14:13 ` Vanalme Filip
1 sibling, 0 replies; 5+ messages in thread
From: Juergen Beisert @ 2011-02-25 13:56 UTC (permalink / raw)
To: barebox
Hi Filip,
Vanalme Filip wrote:
> [...]
> CRC). Any idea why I only see 1 page write when saving the environment
> although the size is 6156 bytes ?
Is the write of the first page successfull?
jbe
--
Pengutronix e.K. | Juergen Beisert |
Linux Solutions for Science and Industry | Phone: +49-8766-939 228 |
Vertretung Sued/Muenchen, Germany | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de/ |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: writing environment in NAND flash
2011-02-25 13:50 Vanalme Filip
2011-02-25 13:56 ` Juergen Beisert
@ 2011-02-25 14:13 ` Vanalme Filip
2011-02-25 15:25 ` Vanalme Filip
1 sibling, 1 reply; 5+ messages in thread
From: Vanalme Filip @ 2011-02-25 14:13 UTC (permalink / raw)
To: Vanalme Filip, barebox
> -----Original Message-----
> From: barebox-bounces@lists.infradead.org [mailto:barebox-
> bounces@lists.infradead.org] On Behalf Of Vanalme Filip
> Sent: vrijdag 25 februari 2011 14:50
> To: barebox@lists.infradead.org
> Subject: writing environment in NAND flash
>
> I have problems to save my environment settings. Although I set e.g. the MAC
> address and some other values and do the saveenv command, after reset, all
> settings have disappeared.
> In the logging on the console port, I detected this :
> "wrong crc on env
> no valid environment found on /dev/env0. Using default environment"
>
> That will be, of course, the cause why the settings disappear.
> Further investigation with debugging enabled in nand_imx.c showed that Barebox
> reads 4 pages when starting up (0x80..0x83). That looks OK, because the
> environment's size is 6156 bytes. So, indeen 4 pages needed. However, when
> saving the environment, I only see appear one page write, i.e. on page 0x80. Of
> course, when reading back the four pages, the 2nd, 3rd and 4th page have all FF
> because they have never been written (causing a wrong CRC). Any idea why I
> only see 1 page write when saving the environment although the size is 6156
> bytes ? Any hints where to look in the sources ?
>
> Thanks in advance !
>
>
>
> Filip
>
[Filip] Sorry for sending this message twice to the mailing list....
I have found the cause of this problem.
I have CONFIG_MTD_NAND_VERIFY_WRITE=y.
So, after a write, the code performs a read to verify the written data. For i.MX27, this mean that the function imx_nand_very_buf() is called. Well, that function looks like this :
static int
imx_nand_verify_buf (struct mtd_info *mtd, const u_char * buf, int len) {
return -EFAULT;
}
Yep...verification always fails... !
Must be a function that still is under development, no ? (although I would have expected a "TODO" somewhere in that function....).
Two things I can do : set the configuration flag to n or add code to this function to really verify the written data.
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: writing environment in NAND flash
2011-02-25 14:13 ` Vanalme Filip
@ 2011-02-25 15:25 ` Vanalme Filip
0 siblings, 0 replies; 5+ messages in thread
From: Vanalme Filip @ 2011-02-25 15:25 UTC (permalink / raw)
To: Vanalme Filip, barebox
> -----Original Message-----
> From: Vanalme Filip
> Sent: vrijdag 25 februari 2011 15:14
> To: Vanalme Filip; barebox@lists.infradead.org
> Subject: RE: writing environment in NAND flash
>
> > -----Original Message-----
> > From: barebox-bounces@lists.infradead.org [mailto:barebox-
> > bounces@lists.infradead.org] On Behalf Of Vanalme Filip
> > Sent: vrijdag 25 februari 2011 14:50
> > To: barebox@lists.infradead.org
> > Subject: writing environment in NAND flash
> >
> > I have problems to save my environment settings. Although I set e.g. the MAC
> > address and some other values and do the saveenv command, after reset, all
> > settings have disappeared.
> > In the logging on the console port, I detected this :
> > "wrong crc on env
> > no valid environment found on /dev/env0. Using default environment"
> >
> > That will be, of course, the cause why the settings disappear.
> > Further investigation with debugging enabled in nand_imx.c showed that
> Barebox
> > reads 4 pages when starting up (0x80..0x83). That looks OK, because the
> > environment's size is 6156 bytes. So, indeen 4 pages needed. However, when
> > saving the environment, I only see appear one page write, i.e. on page 0x80. Of
> > course, when reading back the four pages, the 2nd, 3rd and 4th page have all
> FF
> > because they have never been written (causing a wrong CRC). Any idea why I
> > only see 1 page write when saving the environment although the size is 6156
> > bytes ? Any hints where to look in the sources ?
> >
> > Thanks in advance !
> >
> >
> >
> > Filip
> >
> [Filip] Sorry for sending this message twice to the mailing list....
>
> I have found the cause of this problem.
> I have CONFIG_MTD_NAND_VERIFY_WRITE=y.
> So, after a write, the code performs a read to verify the written data. For i.MX27, this
> mean that the function imx_nand_very_buf() is called. Well, that function looks
> like this :
>
> static int
> imx_nand_verify_buf (struct mtd_info *mtd, const u_char * buf, int len) {
> return -EFAULT;
> }
>
> Yep...verification always fails... !
> Must be a function that still is under development, no ? (although I would have
> expected a "TODO" somewhere in that function....).
>
> Two things I can do : set the configuration flag to n or add code to this function to
> really verify the written data.
[Filip]
I changed the code in nand_imx.c like this :
* This function is used by the upper layer to verify the data in NAND Flash
* with the data in the \b buf.
*
* @param mtd MTD structure for the NAND Flash
* @param buf data to be verified
* @param len length of the data to be verified
*
* @return -EFAULT if error else 0
*
*/
static int
imx_nand_verify_buf(struct mtd_info *mtd, const u_char * buf, int len) {
int i;
struct nand_chip *chip = mtd->priv;
struct imx_nand_host *host = chip->priv;
for (i = 0; i < len; i++)
{
if (buf[i] != host->data_buf[i])
{
MTD_DEBUG(MTD_DEBUG_LEVEL0, "Verify failed on byte %d : 0x%0x <-> 0x%0x\n", i, buf[i], host->data_buf[i]);
return -EFAULT;
}
}
return 0;
}
It looks OK now. I can now save the environment.
Maybe someone can verify if this is correct. And maybe adjust the Barebox mainline sources like that ?
>
> > _______________________________________________
> > barebox mailing list
> > barebox@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-02-25 15:25 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-25 9:31 writing environment in NAND flash Vanalme Filip
2011-02-25 13:50 Vanalme Filip
2011-02-25 13:56 ` Juergen Beisert
2011-02-25 14:13 ` Vanalme Filip
2011-02-25 15:25 ` Vanalme Filip
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox