/* * 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