Flash example for s32k116

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

Flash example for s32k116

ソリューションへジャンプ
2,000件の閲覧回数
AbhiMR
Contributor II

Hi NXP ,

             In ld file i need to define section as below,

MEMORY
{
/* Flash */
m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x000000C0
m_flash_config (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000010
m_text (RX) : ORIGIN = 0x00000410, LENGTH = 0x0001F7E0
m_layout1  (RX) : ORIGIN = 0x0001FBF0, LENGTH = 0x00000400
m_layout2  (RX) : ORIGIN = 0x0001FFF0, LENGTH = 0x00000000

}

 

after which I started using flashdriver.c and .h file .

FLASH_DRV_Init()

/* For erase */

ret = FLASH_DRV_EraseSector(&flashSSDConfig, u32Address, BLOCK_SIZE);
DEV_ASSERT(STATUS_SUCCESS == ret);

 

/* Write data which are of 4 bytes minimum */
ret = FLASH_DRV_Program(&flashSSDConfig, u32Address, MAL_MEM_FLASH_SECTOR_SIZE, u16Data);
DEV_ASSERT(STATUS_SUCCESS == ret);

/* read */

memcpy(store  , linkarray, size );

 

In my code it will work only few time and not consistent with memcpy.

what will be the way to write properly , what are all we need to do config intially ?

Do we have any read function other than memcpy ?

 

Could you please help with better example for this usage ?

0 件の賞賛
返信
1 解決策
1,876件の閲覧回数
danielmartynek
NXP TechSupport
NXP TechSupport

Hello @AbhiMR,

If you generated the SDK code in S32DS 3.4 with SDK 4.0.3 installed, you would get this structure

/* Flash user configuration 0 */
const flash_user_config_t Flash_InitConfig0 =
{
.PFlashBase = 0x0U,
.PFlashSize = 0x20000U,
.DFlashBase = 0x10000000U,
.EERAMBase = 0x14000000U,
.CallBack = NULL_CALLBACK
};

in .../board/peripherals_flash_FTFC.c

Not this:

const flash_user_config_t Flash_InitConfig =
{
/*.PFlashBase = 0x0001FBF0U,
.PFlashSize = 0x0001FBF0U,
.DFlashBase = 0x1FFFFC00U,
.EERAMBase = 0x20000000U,
.CallBack = NULL_CALLBACK
*/
.PFlashBase = 0,
.PFlashSize = 0x20000U,
.DFlashBase = 0x0001FFF0U,
.EERAMBase = 0x20000000U,
.CallBack = NULL_CALLBACK
};

 

You need to:

  1. Install S32DS 3.4
  2. Install SDK 4.0.3
  3. Create flash_partitioning_s32k116 from example
  4. Generate the SDK configuration:

     

danielmartynek_1-1734953451248.png

 

Regards,

Daniel

 

 

元の投稿で解決策を見る

0 件の賞賛
返信
5 返答(返信)
1,978件の閲覧回数
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @AbhiMR,

I'm not sure I understand the issue here.

You can refer to the S32K1xx RTD drivers.

There is Ftfc_Mem_InFls_Ip_Read() in Ftfc_Mem_InFls_Ip.c

The flash can be read through a pointer, simply like this:

  for(uint32_t i = 0; i < size; i++){
    read_buffer[i] = *((volatile uint8_t *)(address + i));
  }

Check the memory with the debugger after each write.

 

Regards,

Daniel

0 件の賞賛
返信
1,958件の閲覧回数
AbhiMR
Contributor II
extern const flash_user_config_t Flash_InitConfig0;
/* Flash user configuration 0 */
const flash_user_config_t Flash_InitConfig =
{
/*.PFlashBase = 0x0001FBF0U,
.PFlashSize = 0x0001FBF0U,
.DFlashBase = 0x1FFFFC00U,
.EERAMBase = 0x20000000U,
.CallBack = NULL_CALLBACK
*/
.PFlashBase = 0,
.PFlashSize = 0x20000U,
.DFlashBase = 0x0001FFF0U,
.EERAMBase = 0x20000000U,
.CallBack = NULL_CALLBACK
};
How to configure this? I f I change, erase will fail. Can you please provide me an example I can be able to read write above designed layout. Or how i can customise and use in s32k116 please let me know?

Basically i need to do read, write and earse operation on this
m_layout1 (RX) : ORIGIN = 0x0001FBF0, LENGTH = 0x00000400
m_layout2 (RX) : ORIGIN = 0x0001FFF0, LENGTH = 0x00000000
0 件の賞賛
返信
1,954件の閲覧回数
danielmartynek
NXP TechSupport
NXP TechSupport

Hello @AbhiMR,

Where did you get the Flash_InitConfig and the flashdriver.c and .h files? It does not mach the S32K116 memory map (S32K1xx_Memory_Map.xlsx attached to the Reference Manual).

Please use either the S32DS 3.4 IDE with the SDK drivers, or preferably the S32DS3.5 IDE with the  RTD drivers.

There is a GUI that allows you to configure the structures such as Flash_InitConfig.

 

Regards,

Daniel

0 件の賞賛
返信
1,924件の閲覧回数
AbhiMR
Contributor II

/* * Copyright 2020 NXP * All rights reserved. * * NXP Confidential. This software is owned or controlled by NXP and may only be * used strictly in accordance with the applicable license terms. By expressly * accepting such terms or by downloading, installing, activating and/or otherwise * using the software, you are agreeing that you have read, and that you agree to * comply with and are bound by, such license terms. If you do not agree to be * bound by the applicable license terms, then you may not retain, install, * activate or otherwise use the software. The production use license in * Section 2.3 is expressly granted for this software. */ /* ################################################################### ** Filename : main.c ** Project : flash_partitioning_s32k116 ** Processor : s32k116 ** Abstract : ** Main module. ** This module contains user's application code. ** Settings : ** Contents : ** No public methods ** ** ###################################################################*/ /*! ** @file main.c ** @brief ** Main module. ** This module contains user's application code. */ /*! ** @addtogroup main_module main module documentation ** @{ */ /* MODULE main */ /* Including necessary configuration files. */ #include "sdk_project_config.h" #include "interrupt_manager.h" volatile int exit_code = 0; /* User includes */ /* Declare a FLASH config struct which initialized by FlashInit, and will be used by all flash operations */ flash_ssd_config_t flashSSDConfig; /* Data source for program operation */ #define BUFFER_SIZE 0x100u /* Size of data source */ uint8_t sourceBuffer[BUFFER_SIZE]; /* Function declarations */ void CCIF_Handler(void); /* If target is flash, insert this macro to locate callback function into RAM */ START_FUNCTION_DECLARATION_RAMSECTION void CCIF_Callback(void) END_FUNCTION_DECLARATION_RAMSECTION /*! \brief The main function for the project. \details The startup initialization sequence is the following: * - startup asm routine * - main() */ int main(void) { /* Write your local variable definition here */ status_t ret; /* Store the driver APIs return code */ uint32_t address; uint32_t size; uint32_t failAddr; uint32_t i; flash_callback_t pCallBack; #if (FEATURE_FLS_HAS_PROGRAM_PHRASE_CMD == 1u) #ifndef FLASH_TARGET uint8_t unsecure_key[FTFx_PHRASE_SIZE] = {0xFFu, 0xFFu, 0xFFu, 0xFFu, 0xFEu, 0xFFu, 0xFFu, 0xFFu}; #endif #else /* FEATURE_FLASH_HAS_PROGRAM_LONGWORD_CMD */ uint8_t unsecure_key[FTFx_LONGWORD_SIZE] = {0xFEu, 0xFFu, 0xFFu, 0xFFu}; #endif /* FEATURE_FLS_HAS_PROGRAM_PHRASE_CMD */ /* Write your code here */ /* Initialize and configure clocks * - see clock manager component for details */ CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT, g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT); CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_AGREEMENT); /* Init source data */ for (i = 0u; i < BUFFER_SIZE; i++) { sourceBuffer[i] = i; } /* Disable cache to ensure that all flash operations will take effect instantly, * this is device dependent */ #ifndef FLASH_TARGET #ifdef S32K11x_SERIES MSCM->OCMDR[0u] |= MSCM_OCMDR_OCM1(0x3u); MSCM->OCMDR[1u] |= MSCM_OCMDR_OCM1(0x3u); #endif /* S32K11x_SERIES */ #endif /* FLASH_TARGET */ /* Install interrupt for Flash Command Complete event */ INT_SYS_InstallHandler(FTFC_IRQn, CCIF_Handler, (isr_t*) 0); INT_SYS_EnableIRQ(FTFC_IRQn); /* Enable global interrupt */ INT_SYS_EnableIRQGlobal(); /* Always initialize the driver before calling other functions */ ret = FLASH_DRV_Init(&Flash_InitConfig0, &flashSSDConfig); DEV_ASSERT(STATUS_SUCCESS == ret); /* Erase a sector in DFlash */ address = flashSSDConfig.DFlashBase; size = FEATURE_FLS_DF_BLOCK_SECTOR_SIZE; ret = FLASH_DRV_EraseSector(&flashSSDConfig, address, size); DEV_ASSERT(STATUS_SUCCESS == ret); /* Verify the erase operation at margin level value of 1, user read */ ret = FLASH_DRV_VerifySection(&flashSSDConfig, address, size / FTFx_PHRASE_SIZE, 1u); DEV_ASSERT(STATUS_SUCCESS == ret); /* Write some data to the erased DFlash sector */ address = flashSSDConfig.DFlashBase; size = BUFFER_SIZE; ret = FLASH_DRV_Program(&flashSSDConfig, address, size, sourceBuffer); DEV_ASSERT(STATUS_SUCCESS == ret); /* Verify the program operation at margin level value of 1, user margin */ ret = FLASH_DRV_ProgramCheck(&flashSSDConfig, address, size, sourceBuffer, &failAddr, 1u); DEV_ASSERT(STATUS_SUCCESS == ret); /* Remove warning for unused variable */ (void)ret; for(;;) { if(exit_code != 0) { break; } } return exit_code; }

 

 

Its hitting Device assert. 

In this I want to explore how to use dflash 

0 件の賞賛
返信
1,877件の閲覧回数
danielmartynek
NXP TechSupport
NXP TechSupport

Hello @AbhiMR,

If you generated the SDK code in S32DS 3.4 with SDK 4.0.3 installed, you would get this structure

/* Flash user configuration 0 */
const flash_user_config_t Flash_InitConfig0 =
{
.PFlashBase = 0x0U,
.PFlashSize = 0x20000U,
.DFlashBase = 0x10000000U,
.EERAMBase = 0x14000000U,
.CallBack = NULL_CALLBACK
};

in .../board/peripherals_flash_FTFC.c

Not this:

const flash_user_config_t Flash_InitConfig =
{
/*.PFlashBase = 0x0001FBF0U,
.PFlashSize = 0x0001FBF0U,
.DFlashBase = 0x1FFFFC00U,
.EERAMBase = 0x20000000U,
.CallBack = NULL_CALLBACK
*/
.PFlashBase = 0,
.PFlashSize = 0x20000U,
.DFlashBase = 0x0001FFF0U,
.EERAMBase = 0x20000000U,
.CallBack = NULL_CALLBACK
};

 

You need to:

  1. Install S32DS 3.4
  2. Install SDK 4.0.3
  3. Create flash_partitioning_s32k116 from example
  4. Generate the SDK configuration:

     

danielmartynek_1-1734953451248.png

 

Regards,

Daniel

 

 

0 件の賞賛
返信