none
Nand flash size setting ! RRS feed

  • Question

  • Hi All ,

    I have 256M physical flash  in my development board , but after wince6 start , it just show about 75M in system , I try to modify following file in BSP (try to enlarge the setting) :

    D:\WINCE600\PUBLIC\COMMON\OAK\DRIVERS\BLOCK\MSFLASHFMD\RAM\fmd.cpp

    //#define NUMBLOCKS 512 // default set

    #define NUMBLOCKS 2048  //  modify 

     

    //#define SECTORSPERBLOCK 8 // default set

    #define SECTORSPERBLOCK 256 //  modify  

    #define SECTOR_SIZE 512

    We use Samsung "K9F2G08U0A" chipset flash . 

    but nothing happen after I rebuild system ( NK.bin)!where I can change the size setting ? thank you !

    Best Regards,

    Calvin Liu

    11/1/2011 

     

    Tuesday, November 1, 2011 2:33 AM

All replies

  • Hello , can any body give me some comment ? thanks !

    Best Regards,

    Calvin Liu

    11/1/2011 

    Tuesday, November 1, 2011 8:24 AM
  • No, no, no!!!! Never just change the public code directory! It's bad practice. if you think about it....the nand is specific to your hardware and the most likely location to find settings and code is therefore in the...? Yes, in the BSP (and related) directories.

    What board are you using? Many BSPs/bootloaders reserve a fairly significant chunk of the flash for storing NK.bin's and other stuff so only part of the flash is left to be used by the OS. How the flash is partitioned is usually BSP specific.


    Henrik Viklund | http://www.addlogic.se
    Tuesday, November 1, 2011 10:20 AM
  • Thank you for your important notice !

    Finally I find the location in "D:\WINCE600\PLATFORM\SMDKV210\SRC\COMMON\NANDFLASH\FMD\fmd.cpp"

    but I can't see what is wrong ,because it seems every parameter which is get by dynamic .

     

    following is a key function FMD_init(...) which is  part of the file :

    ...

    /*

        @func   PVOID | FMD_Init | Initializes the Smart Media NAND flash controller.

        @rdesc  Pointer to S5PV210 NAND controller registers.

        @comm

        @xref

    */

    PVOID FMD_Init(LPCTSTR lpActiveReg, PPCI_REG_INFO pRegIn, PPCI_REG_INFO pRegOut)

    {

        // Caller should have specified NAND controller address.

        //

        UINT8 nMID, nDID;

        int nCnt;

        volatile DWORD rdid;

     

    DWORD dwTACLS;

    DWORD dwTWRPH0;

    DWORD dwTWRPH1;

        DWORD dwTotalNumberOfPages;

     

    FMDMSG(FMD_FUNC, (TEXT("+%s\r\n"), _T(__FUNCTION__)));

     

     

    #if MAGNETO

        pBSPArgs = ((BSP_ARGS *) IMAGE_SHARE_ARGS_UA_START);

    #endif

     

        if (pRegIn && pRegIn->MemBase.Num && pRegIn->MemBase.Reg[0])

            v_pNFCONregs = (NAND_REG *)(pRegIn->MemBase.Reg[0]);

        else

            v_pNFCONregs = (NAND_REG *)NAND_BASE;

     

     

     

    // ECC registers

    v_pECCregs = (NAND_ECC_REG *)ECC_BASE;

     

        // Set up initial flash controller configuration.

        //

        v_pNFCONregs->NFCONF = (NAND_TACLS << 12) | (NAND_TWRPH0 << 8) | (NAND_TWRPH1 << 4);

        v_pNFCONregs->NFCONT = (0<<17)|(0<<16)|(0<<10)|(0<<9)|(0<<8)|(1<<7)|(1<<6)|(1<<5)|(1<<4)|(0x3<<1)|(1<<0);

        v_pNFCONregs->NFSTAT = (1<<4);

     

     

     

        // Get the device information

        rdid = ReadFlashID();

     

        nMID = (UINT8)(rdid >> 8);

        nDID = (UINT8)(rdid & 0xff);

     

        for (nCnt = 0; g_supportedNAND[nCnt].ucMID != 0; nCnt++)

        {

            if (nDID == g_supportedNAND[nCnt].ucDID && nMID == g_supportedNAND[nCnt].ucMID )

            {

    g_pNANDSpec = &(g_supportedNAND[nCnt]);

                break;

            }

        }

     

    if(g_pNANDSpec == NULL)

    {

    FMDERR(TRUE, (TEXT("Failed to find a supported NAND flash memory.\r\n")));

    FMDERR(FMD_INFO, (TEXT("Manufacturer code         : 0x%2X\r\n"), nMID));

    FMDERR(FMD_INFO, (TEXT("Device code               : 0x%2X\r\n"), nDID));

     

    // error return

    v_pNFCONregs = NULL;

    goto CleanUp;

    }

     

    // 

    // NFCON configuration

    // 

    dwTotalNumberOfPages = g_pNANDSpec->usNumberOfBlocks * g_pNANDSpec->usPagesPerBlock;

     

    // TACLS, TWRPH0, TWRPH1 timing parameter should be calculated based on the spec to achieve the maximum performance.

    // dwTACLS = NAND_TACLS;

    // dwTWRPH0 = NAND_TWRPH0;

    // dwTWRPH1 = NAND_TWRPH1;

    dwTACLS = g_pNANDSpec->dwTACLS;

    dwTWRPH0 = g_pNANDSpec->dwTWRPH0;

    dwTWRPH1 = g_pNANDSpec->dwTWRPH1;

     

    // -- SLC or MLC

    // -- FMD driver supports SLC NAND flash memory only.

    if(g_pNANDSpec->ucType == SLC_NAND)

    {

    if(g_pNANDSpec->usMainBytesPerPage == 2048)

    {

    if(dwTotalNumberOfPages > (1 << 16))

    {

    // SLC, Large block, 5 address cycle

    v_pNFCONregs->NFCONF = (dwTACLS  <<  12) | (dwTWRPH0 <<  8) | (dwTWRPH1 <<  4)

    | ECC_1BIT | SLC_NAND | LARGE_BLOCK | EXT_ADDR;

    NEED_EXT_ADDR = TRUE;

    }

    else

    {

    // SLC, Large block, 4 address cycle

    v_pNFCONregs->NFCONF = (dwTACLS  <<  12) | (dwTWRPH0 <<  8) | (dwTWRPH1 <<  4)

    | ECC_1BIT | SLC_NAND | LARGE_BLOCK;

    NEED_EXT_ADDR = FALSE;

    }

    }

    else if(g_pNANDSpec->usMainBytesPerPage == 512)

    {

    // Small block NAND

    FMDERR(TRUE, (TEXT("FMD doesn't support the small block NAND flash memory.\r\n")));

     

    v_pNFCONregs = NULL;

    goto CleanUp;

    }

    else

    {

    // page size > 2KB

    FMDERR(TRUE, (TEXT("FMD doesn't support the NAND flash memory whose page size is larger than 2KB\r\n")));

    v_pNFCONregs = NULL;

    goto CleanUp;

    }

    }

    else

    {

    // MLC NAND flash memory

    FMDERR(TRUE, (TEXT("FMD doesn't support the MLC NAND flash memory.\r\n")));

     

    v_pNFCONregs = NULL;

    goto CleanUp;

    }

     

     

    FlashInfo fi;

     

    FMD_GetInfo(&fi);

     

     

    #if MAGNETO

    //    DefineLayout();

    #endif

     

    CleanUp:

     

    if(v_pNFCONregs == NULL)

    {

    FMDERR(TRUE, (TEXT("FMD_Init() was failed.\r\n")));

    }

     

    FMDMSG(FMD_FUNC, (TEXT("-%s\r\n"), _T(__FUNCTION__)));

     

        return((PVOID)v_pNFCONregs);

    }

    ....

    Can you give me some tip how to solve the problem ?

    When system start , I got many many debug message like this :

    "

    ...

    [FMD:ERR] : SectorInfo is invalid, sector = 18368 

    [FMD:ERR] : SectorInfo is invalid, sector = 18432

    ...

    Is it mean the Flash have hardware error ?

    Thank you very much .

     

    Best Regards,

    Calvin Liu

    11/2/2011

    Wednesday, November 2, 2011 12:56 AM
  • Hi Calvin Liu,

    I am using micron part. I am setting nand size as shown below.

     

    C:\WINCE600\PLATFORM\COMMON\SRC\SOC\COMMON_FSL_V2_PDK1_7\NAND\FMDCOMMON\OCQ_INTERLEAVE\fmd.cpp

    PVOID FMD_Init(LPCTSTR lpActiveReg, PPCI_REG_INFO pRegIn, PPCI_REG_INFO pRegOut)
    {

    BSPNAND_GetFlashInfo(&g_FlashInfoExt);

    }

     

    #include <fmd.h>
    #include "common_nandfmd.h"
    #include "MT29F1G08.h"

    #define BBT_BLOCK_NUM           4       // Block numbers : store BBT
    #define NAND_NUM_OF_CLUSTER     1
    #define NAND_NUM_OF_DEVICES     1

    BYTE g_BBTFirstBuf[(((NAND_BLOCK_CNT * NAND_NUM_OF_DEVICES * NAND_NUM_OF_CS + 7) / 8 + NAND_PAGE_SIZE - 1) / NAND_PAGE_SIZE) * NAND_PAGE_SIZE];
    BYTE g_BBTSecondBuf[(((NAND_BLOCK_CNT * NAND_NUM_OF_DEVICES * NAND_NUM_OF_CS + 7) / 8 + NAND_PAGE_SIZE - 1) / NAND_PAGE_SIZE) * NAND_PAGE_SIZE];
    BYTE g_SectorBuf[NAND_PAGE_SIZE];

    VOID BSPNAND_GetFlashInfo(PFlashInfoExt pFlashInfo)
    {

    }

    MT29F1G08.h

    ***********

    #ifndef __MT29F1G08_H__
    #define __MT29F1G08_H__


    // NAND Flash Chip CMD
    #define CMD_READID              (0x90)      // Read ID
    #define CMD_READ                (0x00)      // Read data 1st cycle
    #define CMD_READ2               (0x30)      // Read data 2nd cycle
    #define CMD_RESET               (0xFF)      // Reset
    #define CMD_ERASE               (0x60)      // Erase setup
    #define CMD_ERASE2              (0xD0)      // Erase
    #define CMD_WRITE               (0x80)      // Sequential data input
    #define CMD_WRITE2              (0x10)      // Program
    #define CMD_STATUS              (0x70)      // Read status

    // NAND Flash Chip Size
    #define NAND_BLOCK_CNT          (1024)     
    #define NAND_PAGE_CNT           (64)      
    #define NAND_PAGE_SIZE          (2048)     
    #define NAND_SPARE_SIZE         (64)       
    #define NAND_BUS_WIDTH          (8)        

    // NAND Flash Chip
    #define NAND_NUM_OF_CS          (1)

    // NAND Flash Chip ID
    #define NAND_MAKER_CODE         (0x2C)
    #define NAND_DEVICE_CODE        (0xA1)
    #define NAND_ID_CODE            ((NAND_DEVICE_CODE << 8) | NAND_MAKER_CODE)

    // NAND Flash Chip Operation Status
    #define NAND_STATUS_ERROR_BIT   (0)         // Status Bit0 indicates error
    #define NAND_STATUS_BUSY_BIT    (6)         // Status Bit6 indicates busy

    // SWAP BBI
    #define BBI_MAIN_ADDR           (464)       // Bad block info address offset   
    #define BBI_NUM                 (1)
    BYTE    BBMarkPage[1] = {0};

    #endif    // __MT29F1G08_H__


    kiran reddy
    Wednesday, November 2, 2011 7:10 AM
  • It's probalby more complicated than that. The physical size of the flash is one thing, how much that is partitioned as a file system accessible for the OS is another.

    Many BSPs partition the flash in several partitions, so it can host both eboot, nk.bin and other data on it as well as use part of it as a flash file system. The partitions are usually created by the boot loader and the partition sizes are usually specified in imgage_cfg.h in the BSP. All this is BSP specific stuff and I don't know how this particular board is set up, but I'd start there and examine the bootloader to see if I can find any clues to how the nand is set up to be utilized.


    Henrik Viklund | http://www.addlogic.se
    Wednesday, November 2, 2011 8:00 AM
  • Big surprise ! I don't know why . 

    while read the function FMD_init(...)  , I try to show some message when execute FMD_init(...) , but not work ,

    so I doubt if this function have been execute when system start , then I try to ignore this function like below :

     

    PVOID FMD_Init(LPCTSTR lpActiveReg, PPCI_REG_INFO pRegIn, PPCI_REG_INFO pRegOut)

    {

        // Caller should have specified NAND controller address.

        UINT8 nMID, nDID;

        int nCnt;

        volatile DWORD rdid;

    DWORD dwTACLS;

    DWORD dwTWRPH0;

    DWORD dwTWRPH1;

     DWORD dwTotalNumberOfPages;

    return 0 ;

     

    ...

     

    After modify , I build the Nk.bin again , and burn to hardware  by tools. and I found 

    it still work , the surprise is : 

    Capacity of Flash memory show total : 256M  in windows CE control panel ! 

    free memory have 204M when I check Flash disk folder, it looks just right ! 

    Why this will happen and can I trust that ? 

     

    Best Regards,

    Calvin Liu

    11/2/2011

    Wednesday, November 2, 2011 9:19 AM
  • I had the same issue on some days ago. I solve this problem by changed below code:

    Thursday, November 3, 2011 1:49 AM
  • Hi zhengmeifu , 

    Thank you for your information ,

    I don't change the file your mention(my file content is same with you I think) , but strange things still happen  in my s5pv210 development board , after first time  Flash can show about 256M in winCE UI , even I burn the oldest  version file "bl1_uart.nb0 , eboot.nb0 , bootimage.nb0 , nk.bin" ,it still can show same capacity (not like before just show total about 70M size) , so now I have no idea about this question , I need test more to see what had happen . 

    Best Regards,

    Calvin Liu

    11/4/2011

    Friday, November 4, 2011 12:51 AM