This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

NAND Flash Size Only 512MB

Other Parts Discussed in Thread: TEST2

Hi

I use Macronix MX60LF8G28AB for NAND booting.

In U-boot, it can be detected and get correct size (1024 MiB ) and read/write normally.

But in kernel, it only get 512MiB size. 

Here is my MTD partition table and kernel message.

-------------------------------------------------------------------------------------------------------------

----- board-am335xevm.c

static struct mtd_partition am335x_nand_partitions[] = {
/* All the partition sizes are listed in terms of NAND block size */
{
.name = "SPL",
.offset = 0,
.size = SZ_128K,
},
{
.name = "Env",
.offset = MTDPART_OFS_APPEND,
.size = SZ_128K,
},
{
.name = "U-Boot",
.offset = MTDPART_OFS_APPEND,
.size = 4 * SZ_128K,
},
{
.name = "kernel",
.offset = MTDPART_OFS_APPEND,
.size = 40 * SZ_128K,
},
{
.name = "rootfs",
.offset = MTDPART_OFS_APPEND,
.size = 880 * SZ_128K,
},
{
.name = "test1",
.offset = MTDPART_OFS_APPEND,
.size = 80 * SZ_128K,
},
{
.name = "test2",
.offset = MTDPART_OFS_APPEND,
.size = 80 * SZ_128K,
},
{
.name = "test3",
.offset = MTDPART_OFS_APPEND,
.size = MTDPART_SIZ_FULL,
},
};

-------------------------------------------------------------------------------------------------------------

----- kernel message

omap2-nand driver initializing
ONFI flash detected
ONFI param page 0 valid
NAND device: Manufacturer ID: 0xc2, Chip ID: 0xd3 (Macronix MX60LF8G28AB)
Creating 8 MTD partitions on "omap2-nand.0":
0x000000000000-0x000000020000 : "SPL"
0x000000020000-0x000000040000 : "Env"
0x000000040000-0x0000000c0000 : "U-Boot"
0x0000000c0000-0x0000005c0000 : "kernel"
0x0000005c0000-0x0000073c0000 : "rootfs"
0x0000073c0000-0x000007dc0000 : "test1"
0x000007dc0000-0x0000087c0000 : "test2"
0x0000087c0000-0x000020000000 : "test3"
OneNAND driver initializing

-------------------------------------------------------------------------------------------------------------

The mtd7 should be 0x0000087c0000-0x000040000000.

If I change MTDPART_SIZ_FULL to 0x40000000, it will show error as below

" mtd: partition "test3" extends beyond the end of device "omap2-nand.0" -- size truncated to 0x17840000 "

How to fix this problem to get correct flash size?

Thanks and Regards

Kiros

  • Hi Kiros,

    I will forward this to the SW experts. Which Linux version are you using?

  • Hi Biser

    I use linux-3.2.0-psp04.06.00.08

    Thanks

    Kiros

  • Hi,

    You do not set MTDPART_SIZ_FULL to 0x40000000, because this is the full NAND size, you have to set MTDPART_SIZ_FULL to 0x40000000 - 0x0000087c0000

    BR
    Ivan

  • Hi Ivan

    I try to change it to 0x37840000 or 7106* SZ_128K.

    But it still can't work. Kernel message will show

    " mtd: partition "test3" extends beyond the end of device "omap2-nand.0" -- size truncated to 0x17840000 "

    -----------------------------------------------------------------------------------

    NAND device: Manufacturer ID: 0xc2, Chip ID: 0xd3 (Macronix MX60LF8G28AB)
    Creating 8 MTD partitions on "omap2-nand.0":
    0x000000000000-0x000000020000 : "SPL"
    0x000000020000-0x000000040000 : "Env"
    0x000000040000-0x0000000c0000 : "U-Boot"
    0x0000000c0000-0x0000005c0000 : "kernel"
    0x0000005c0000-0x0000073c0000 : "rootfs"
    0x0000073c0000-0x000007dc0000 : "test1"
    0x000007dc0000-0x0000087c0000 : "test2"
    0x0000087c0000-0x000040000000 : "test3"
    mtd: partition "test3" extends beyond the end of device "omap2-nand.0" -- size truncated to 0x17840000
    OneNAND driver initializing

    Kiros

  • Hi Kiros,

    Please could you change the NAND_IO_SIZE in the arch/arm/plat-omap/include/plat/nand.h from 4 to 8. You can see in a file gpmc-nand.c in a line 116 gpmc_cs_request(gpmc_nand_data->cs, NAND_IO_SIZE,... ) to request the size for this CS, also in a omap2.c request request_mem_region also and remap phis to virt address.

    BR
    Ivan

  • Hi Ivan

    Thanks for your help.

    I try to change NAND_IO_SZIE to 8, but it still can't work.

    I print the kernel message to make sure NAND_IO_SIZE.

    -------------------------------------------------------------------------------------------------

    ....

    Registering NAND on CS0 and NAND_IO_SIZE is 8
    registered am33xx_sr device
    mtdoops: mtd device (mtddev=name/number) must be supplied
    omap2-nand driver initializing
    ONFI flash detected
    ONFI param page 0 valid
    NAND device: Manufacturer ID: 0xc2, Chip ID: 0xd3 (Macronix MX60LF8G28AB)
    Creating 8 MTD partitions on "omap2-nand.0":
    0x000000000000-0x000000020000 : "SPL"
    0x000000020000-0x000000040000 : "Env"
    0x000000040000-0x0000000c0000 : "U-Boot"
    0x0000000c0000-0x0000005c0000 : "kernel"
    0x0000005c0000-0x0000073c0000 : "rootfs"
    0x0000073c0000-0x000007dc0000 : "test1"
    0x000007dc0000-0x0000087c0000 : "test2"
    0x0000087c0000-0x000040000000 : "test3"
    mtd: partition "test3" extends beyond the end of device "omap2-nand.0" -- size truncated to 0x17840000
    OneNAND driver initializing

    .....

    -------------------------------------------------------------------------------------------------

    Kiros

  • Hi Kiros,

    The NAND size depending from his parameters. They are reading from kernel from drivers/mtd/nand/nand_base.c nand_flash_detect_onfi(...). There you can see the lines:
        mtd->writesize = le32_to_cpu(p->byte_per_page);
        mtd->erasesize = le32_to_cpu(p->pages_per_block) * mtd->writesize;
        mtd->oobsize = le16_to_cpu(p->spare_bytes_per_page);
        chip->chipsize = (uint64_t)le32_to_cpu(p->blocks_per_lun) * mtd->erasesize;

    Here are calculated the NAND size. Please analyze this code and see parameters for your NAND. Here you can change some parameters if they don't read correctly.

    BR
    Ivan

  • Hi Ivan

    I compare the latest SDK ( SDK 07_00_00_00) and modify the code.

    --- a/drivers/mtd/nand/nand_base.c
    +++ b/drivers/mtd/nand/nand_base.c

    mtd->writesize = le32_to_cpu(p->byte_per_page);
    mtd->erasesize = le32_to_cpu(p->pages_per_block) * mtd->writesize;
    mtd->oobsize = le16_to_cpu(p->spare_bytes_per_page);
    - chip->chipsize = (uint64_t)le32_to_cpu(p->blocks_per_lun) * mtd->erasesize;

    + chip->chipsize = 1 << (fls(le32_to_cpu(p->blocks_per_lun)) - 1);
    + chip->chipsize *= (uint64_t)mtd->erasesize * p->lun_count;

    Now kernel can detect the correct flash size without error message.

    And I can read/write the whole flash partition.

    Thanks for your help.

    Kiros