How to use NVM [internal eeprom] write api in KW40z ?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

How to use NVM [internal eeprom] write api in KW40z ?

跳至解决方案
1,718 次查看
chandramohanc
Contributor II

I am trying to use NVM [internal eeprom] read / write APIs but do not know available EEPROM size and start address

I don't see comments for startAddress and endAddress for the NVM read/write APIs for FRDM KW40Z boards

Please explain how to find nvmDestinationAddress parameter's range.

void App_NvmWrite
(
    uint32_t nvmDestinationAddress,
    void*    pvRamSource,
    uint32_t cDataSize
)

thanks, Chandra..

标签 (1)
0 项奖励
1 解答
1,408 次查看
chandramohanc
Contributor II

Hi all,

I found the solution and verified it,

In AppMain.c you can find below 2 functions to do Flash operations

void App_NvmWrite (int32_t nvmDestinationAddress,  void* pvRamSource, uint32_t cDataSize);

void App_NvmRead(uint32_t nvmDestinationAddress, void*    pvRamSource, uint32_t cDataSize);

Its destination address is defined in linker script, and its value is initialized to gNvmStartAddress_c in ApplMain.c at runtime as below

#if mAppUseNvm_d        
        /* Initialize NV module */
        NV_Init();
        
        /* NV_STORAGE_END_ADDRESS from linker file is used as NV Start Address */
        gNvmStartAddress_c = (uint32_t)((uint8_t*)NV_STORAGE_END_ADDRESS);
#endif

thanks, Chanda..

在原帖中查看解决方案

0 项奖励
3 回复数
1,409 次查看
chandramohanc
Contributor II

Hi all,

I found the solution and verified it,

In AppMain.c you can find below 2 functions to do Flash operations

void App_NvmWrite (int32_t nvmDestinationAddress,  void* pvRamSource, uint32_t cDataSize);

void App_NvmRead(uint32_t nvmDestinationAddress, void*    pvRamSource, uint32_t cDataSize);

Its destination address is defined in linker script, and its value is initialized to gNvmStartAddress_c in ApplMain.c at runtime as below

#if mAppUseNvm_d        
        /* Initialize NV module */
        NV_Init();
        
        /* NV_STORAGE_END_ADDRESS from linker file is used as NV Start Address */
        gNvmStartAddress_c = (uint32_t)((uint8_t*)NV_STORAGE_END_ADDRESS);
#endif

thanks, Chanda..

0 项奖励
1,408 次查看
jorge_a_vazquez
NXP Employee
NXP Employee

Hi Chandra

About the API that you mention, it is:

void App_NvmWrite
(
    uint32_t nvmDestinationAddress,
    void*    pvRamSource,
    uint32_t cDataSize
)
{
#if mAppUseNvm_d  
    NV_FlashProgramUnaligned(&gFlashConfig, nvmDestinationAddress, cDataSize, pvRamSource, gFlashLaunchCommand);
#endif
}‍‍‍‍‍‍‍‍‍‍‍

And aas you can see here, it is using the NV_FlashProgramUnaligned function. This function uses the global variable gFlashConfig, which is defined as:

FLASH_SSD_CONFIG gFlashConfig =
{
    FTFx_REG_BASE,          /* FTFx control register base (0x40020000) */
    P_FLASH_BASE,           /* base address of PFlash block (0x00000000)*/
    P_FLASH_SIZE,           /* size of PFlash block (65536*2+16384*2) */
    FLEXNVM_BASE,           /* base address of DFlash block  */
    0,                      /* size of DFlash block */
    EERAM_BASE,             /* base address of EERAM block */
    0,                      /* size of EEE block */
    DEBUGENABLE,            /* background debug mode enable bit */
    NULL_CALLBACK           /* pointer to callback function */
};‍‍‍‍‍‍‍‍‍‍‍‍

So, they basically are defined characteristics of internal flash, the device contains 2 program flash blocks (one 128Kbytes, one 32Kbytes).


Hope this information helps you
Have a great day,
Jorge Alcala

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
1,408 次查看
chandramohanc
Contributor II

Hi Jorge,

   Thank you for your inputs, i found it, it is in ApplMain.c

#if mAppUseNvm_d        
        /* Initialize NV module */
        NV_Init();
        
        /* NV_STORAGE_END_ADDRESS from linker file is used as NV Start Address */
        gNvmStartAddress_c = (uint32_t)((uint8_t*)NV_STORAGE_END_ADDRESS);
#endif

thanks, Chandra..

0 项奖励