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

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

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

ソリューションへジャンプ
1,721件の閲覧回数
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,411件の閲覧回数
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,412件の閲覧回数
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,411件の閲覧回数
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,411件の閲覧回数
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 件の賞賛