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.

Confusion regarding BLOCK size in NAND chip and NAND sector size in u-boot

I have a fundamental doubt regarding NAND chip,
We are trying to bring up custom board based on DM365,

We are trying to boot from the NAND,

NAND used is from micron MT29F8G08ABABA. (1Giga bytes = 8 Gigabits)

Organization
– Page size x8: 4320 bytes (4096 + 224 bytes)
Block size: 128 pages (512K +28 K bytes)
– Plane size: 2 planes x 1024 blocks per plane
– Device size: 8Gb: 2048 blocks

Now as per datasheet of MT29F8G08BABA i think block size is (512K+224)bytes.

But in u-boot terminologies they use Sector size for NAND device.
Because when i use command "nand info" from u-boot commandline,
I get nand size as follows

Device 0: NAND 1GiB 3,3V 8-bit, sector size 256 KiB

Is this sector size is block size(which is actually 512k as per datasheet) or Environment sector?
NAND read/Write is working fine from u-boot, There is no issue as such.
So i just want to understand these terminologies.

Now if this is environment sector size then is there any way to get block size information from U-boot ?


Can somebody please enlighten me on this ?

Thank you,

Regards,
Ankur

  • Hi Ankur,

    Is this sector size is block size(which is actually 512k as per datasheet) or Environment sector?

    refer below thread & this one http://en.wikipedia.org/wiki/Flash_memory

    (often called blocks or sectors).

     

    Erase Size = Block size  = 256KB

    Now if this is environment sector size then is there any way to get block size information from U-boot ?

    from my example

      Erase size   131072 b ((BLOCK SIZE only = 128*1024 )

    because NAND flash ll erase in  block basis (thats why it has less time to erase) whereas NOR byte basis

    Ex from my board & nand flash:

    OMAP3 beagleboard.org # nand info

    Device 0: nand0, sector size 128 KiB
      Page size      2048 b (64 pages * 2048b = 1 block size = 128KiB)
      OOB size         64 b  (out of band {oob} area storing ECC values & meta data)
      Erase size   131072 b ((BLOCK SIZE only = 128*1024 )
    OMAP3 beagleboard.org #

    FYI, as you know
    KB = 1000

    KiB = 1024

    Refer the below link for sectors doubts

    http://www.keil.com/support/man/docs/rlarm/rlarm_fs_cfgspare.htm

  • Hi,

    As per my understanding,

    Sectors --> Pages --> blocks --> planes ---> NAND Flash

    combinations of sectors (ex: 512byte) is 1 page ---> combination of pages (ex : 64 pages) is 1 block ---> combination of blocks (1042 blocks per plane) is plane  ---> combination of planes ( ex: 2 planes per flash) is nand flash

  • Hi Titus,

    Thank you for reply,  you are life saver,
    I had also read that sector size is nothing but the block size.
    But as per datasheet block size is 512k+28k.

    Now why i am worried is when i get nand info u-boot prints sector size as 256kib, I am worried if i have wrongly configured the NAND in u-boot.
    I am able to read and write to nand but still just want to be sure about configuration.
    Unlike in your u-boot, in mine full nand info is not getting printed, i have to check nand info command implementation.

    In my understanding if we go by the datasheet nand info should print sector size as 512kib.
    I have attached the snap shot of the NAND LUN, if required you can comment about my understanding.



    Regards,
    Ankur

  • Hi,

    From my u-boot source code,

    common/cmd_nand.c

    static void nand_print_and_set_info(int idx)
    {
        nand_info_t *nand = &nand_info[idx];
        struct nand_chip *chip = nand->priv;
        char buf[32];

        printf("Device %d: ", idx);
        if (chip->numchips > 1)
            printf("%dx ", chip->numchips);
        printf("%s, sector size %u KiB\n",
               nand->name, nand->erasesize >> 10);
        printf("  Page size  %8d b\n", nand->writesize);
        printf("  OOB size   %8d b\n", nand->oobsize);
        printf("  Erase size %8d b\n", nand->erasesize);

        /* Set geometry info */
        sprintf(buf, "%x", nand->writesize);
        setenv("nand_writesize", buf);

        sprintf(buf, "%x", nand->oobsize);
        setenv("nand_oobsize", buf);

        sprintf(buf, "%x", nand->erasesize);
        setenv("nand_erasesize", buf);
    }

    As per above code,

    sector size is not equal to block size(erase block size)

    I have discussed with my seniors & TI people also, its not same in NAND context

    If your code has "nand->erasesize >> 10"  ,  then your u-boot should print "512KiB" only. ( chk ur code)

    128*1024  >>  10 = 128 (myself)

    512*1024  >>  10 = 512 ( for urs)

    So, if you want to get the sector size of nand flash, then do rgt shift for 10 times. (chk yours)

    Still  I dont kw, why there are doing right shift for 10 times?

     

    from http://www.keil.com/support/man/docs/rlarm/rlarm_fs_cfgspare.htm

    As i told you before ,

    1 page consists of parts of sectors (combination of sectors)

  • Hi Titus,

    Thank you for that reply,

    My uboot common/cmd_nand.c code also loks similar to your uboot code.

    But interestingy its not printing sectorsize as 512Kib.

    int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
    
    {
    
    int i, dev, ret = 0;
    
    ulong addr, off;
    
    size_t size;
    
    char *cmd, *s;
    
    nand_info_t *nand;
    
    #ifdef CFG_NAND_QUIET
    
    int quiet = CFG_NAND_QUIET;
    
    #else
    
    int quiet = 0;
    
    #endif
    
    const char *quiet_str = getenv("quiet");
    
    /* at least two arguments please */
    
    if (argc < 2)
    
    goto usage;
    
    if (quiet_str)
    
    quiet = simple_strtoul(quiet_str, NULL, 0) != 0;
    
    cmd = argv[1];
    
    if (strcmp(cmd, "info") == 0) {
    
    putc('\n');
    
    for (i = 0; i < CFG_MAX_NAND_DEVICE; i++) {
    
    if (nand_info[i].name)
    
    printf("Device %d: %s, sector size %u KiB\n",
    
          i, nand_info[i].name,
    
          nand_info[i].erasesize >> 10);
    
    }
    
    return 0;
    
    }
    

    I think they are doing rightshift to divide erase-block by 1024 to get the blocksize in "XXXkib" format.(purely for printing).

    Thank you,

    Regards,

    Ankur