[U-Boot] NAND crazy behavior - mtd->size changing without clear reason

Scott Wood scottwood at freescale.com
Thu Sep 26 01:56:09 CEST 2013


On Wed, 2013-09-25 at 20:52 -0300, Otavio Salvador wrote:
> On Wed, Sep 25, 2013 at 8:07 PM, Scott Wood <scottwood at freescale.com> wrote:
> > On Wed, 2013-09-25 at 09:26 -0300, Otavio Salvador wrote:
> >> Hello,
> >>
> >> I am using a K9LBG08U0D-PCB0 NAND IC with the i.MX28EVK board.
> >>
> >> I tested it with 2013.04 and current imx tree tip. Both same results.
> >>
> >> I am having problems to use mtdparts with it as it thinks the NAND has
> >> size as 0 when it gets there. /However/ it properly detects it
> >> initially and the mtd->size variable is magically changes on the fly.
> >>
> >> I added following patch in my local tree to debug the issue:
> >>
> >> diff --git a/drivers/mtd/nand/nand.c b/drivers/mtd/nand/nand.c
> >> index 4cf4c1c..03faf10 100644
> >> --- a/drivers/mtd/nand/nand.c
> >> +++ b/drivers/mtd/nand/nand.c
> >> @@ -66,11 +66,14 @@ int nand_register(int devnum)
> >>         add_mtd_device(mtd);
> >>  #endif
> >>
> >> +       printf("%s (%d) mtd->size: %d\n", __FUNCTION__, __LINE__, mtd->size);
> >>         total_nand_size += mtd->size / 1024;
> >> +       printf("%s (%d) mtd->size: %d\n", __FUNCTION__, __LINE__, mtd->size);
> >
> > Pay attention to compiler warnings...  mtd->size is uint64_t.
> 
> Great but this does not explain the value changing, does it?

Sure it does.  You're passing a 64-bit value as the fourth argument.
Since IIRC there are only four registers used for passing parameters on
32-bit ARM, this will move the value to the stack.  You told printf that
it was a 32-bit parameter, so printf is looking in r3 which contains
random junk.

-Scott





More information about the U-Boot mailing list