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

Otavio Salvador otavio at ossystems.com.br
Wed Sep 25 14:26:42 CEST 2013


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);

        if (nand_curr_device == -1)
                nand_curr_device = devnum;

+       printf("%s (%d) mtd->size: %d\n", __FUNCTION__, __LINE__, mtd->size);
        return 0;
 }

@@ -94,7 +97,9 @@ static void nand_init_chip(int i)
        if (nand_scan(mtd, maxchips))
                return;

+       printf("%s (%d) mtd->size: %d\n", __FUNCTION__, __LINE__, mtd->size);
        nand_register(i);
+       printf("%s (%d) mtd->size: %d\n", __FUNCTION__, __LINE__, mtd->size);
 }
 #endif

diff --git a/include/configs/mx28evk.h b/include/configs/mx28evk.h
index 07f88ca..1083a88 100644
--- a/include/configs/mx28evk.h
+++ b/include/configs/mx28evk.h
@@ -90,6 +90,8 @@
 #define CONFIG_LZO
 #define CONFIG_MTD_DEVICE
 #define CONFIG_MTD_PARTITIONS
+#define CONFIG_MTD_DEBUG
+#define CONFIG_MTD_DEBUG_VERBOSE 1
 #define MTDIDS_DEFAULT                 "nand0=gpmi-nand"
 #define MTDPARTS_DEFAULT                       \
        "mtdparts=gpmi-nand:"                   \

and what surprises me is the U-Boot log using the above patch:

U-Boot 2013.10-rc2-00159-g06f700a-dirty (Sep 25 2013 - 09:17:17)

CPU:   Freescale i.MX28 rev1.2 at 454 MHz
BOOT:  NAND, 3V3
DRAM:  128 MiB
NAND:  NAND device: Manufacturer ID: 0xec, Chip ID: 0xd7 (Samsung NAND
4GiB 3,3V 8-bit), page size: 4096, OOB size: 218
nand_init_chip (100) mtd->size: 1
nand_register (69) mtd->size: 0
nand_register (71) mtd->size: 4194304
nand_register (76) mtd->size: 1
nand_init_chip (102) mtd->size: 1
4096 MiB
MMC:   MXS MMC: 0
Video: MXSFB: 'videomode' variable not set!
In:    serial
Out:   serial
Err:   serial
Net:   FEC0 [PRIME], FEC1

So the mtd->size value has change from 0 to 4194304 in the code:

int nand_register(int devnum)
{
    ...
    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);
    ...
}

and when it gets in the mtdparts code it is '0' thus resulting in the error:

MX28EVK U-Boot > mtdparts default
gpmi-nand: partitioning exceeds flash size

Does someone has a clue about what is going on?

-- 
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750


More information about the U-Boot mailing list