Jessica García

Can't open NAND FLASH Device

Discussion created by Jessica García on Mar 7, 2013
Latest reply on Jun 14, 2013 by friederschrempf

I am trying to install MFS over NAND FLASH in TWRK70F120, such as it is expected to be done with new "NAND Flash File System patch for Freescale MQX™ RTOS 4.0.0 ". Basically, I am following the installed example that uses shell commands.

 

Here is my initiallization code for NAND FLASH Device:

 

_mqx_int error_code;

MQX_FILE_PTR nandflash_handle;

MQX_FILE_PTR filesystem_handle;

_S8 filesystem_name[] = "d:";

 

_U8 NandFlash_Install_FileSystem(void)

{

     if (_io_nandflash_wl_install(&_bsp_nandflash_wl_init, NAND_FLASH_DEVICE) != MQX_OK)

     {

          return NAND_FLASH_FILE_SYSTEM_ERROR;

     }

 

     nandflash_handle = fopen(NAND_FLASH_DEVICE, NANDWL_OPEN_FORCE_REPAIR_WHEN_FAILED); // BREAKPOINT 1

     if ( nandflash_handle == NULL ) // BREAKPOINT 2                             

     {

          return NAND_FLASH_FILE_SYSTEM_ERROR;

     }

     ......

     ......

     return NAND_FLASH_FILE_SYSTEM_OK;

}

 

Line commented with "BREAKPOINT 1" is always executed, so the fopen function associated to NAND FLASH is called. But line with comment "BREAKPOINT 2" is not executed because an assert fails on this function from MQX Library:

 

bool PageOrderMap::isOccupied

(

    /* [IN] Logical index */

    unsigned logicalIndex

) const

{ /* Body */

    assert(logicalIndex < m_entryCount);    // ASSERT ERROR

    unsigned coarse = logicalIndex / BITS_PER_WORD;

    unsigned fine = logicalIndex % BITS_PER_WORD;

    return ((m_occupied[coarse] >> fine) & 0x1) != 0;

} /* Endbody */

 

This happens every time I enter on a debug session, but is not happening if I reset the CPU (without leaving debug session).

 

The method PageOrderMap::isOccupied(..) is called from RtStatus_t PersistentMap::retrieveSection(...), who passes a logicalIndex that is out of scope for me when debugging. I have no evidences about what causes this situation. I hope anebody can help.

 

 

Outcomes