This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi,
I'm trying to use the Flash API 021 (F021_API_CortexR4_BE_V3D16.lib) with the TMS570LS3137. Whenever calling a function from the Fapi Library I get a prefetchEntry Interrupt.
There seem to be quite a few entries in this Board about the same problem. So, I already checked following points:
Do you have any further ideas what could cause the probelm ?
Thank you very much for your Help
Best Regards
Thomas
Software used:
void useFlashApi() { Fapi_StatusType oReturnCheck = Fapi_Status_Success; oReturnCheck = Fapi_initializeFlashBanks(160); // Example code is assuming operating frequency of 160 MHz // if((oReturnCheck == Fapi_Status_Success) && (FLASH_CONTROL_REGISTER->FmStat.FMSTAT_BITS.BUSY != Fapi_Status_FsmBusy)) { oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank0); Fapi_enableMainBankSectors(Fapi_FlashBank0); // Place specific example code here // // Wait for FSM to finish // while(FLASH_CONTROL_REGISTER->FmStat.FMSTAT_BITS.BUSY == Fapi_Status_FsmBusy); // Check the FSM Status to see if there were no errors // if (FLASH_CONTROL_REGISTER->FmStat.u32Register != 0) { // Put Error handling code here // } } Fapi_flushPipeline(); }
--retain="*(.intvecs)" MEMORY { VECTORS (X) : origin=0x00000000 length=0x00000020 FLASH_API (RX) : origin=0x00000020 length=0x000014E0 FLASH0 (RX) : origin=0x00001500 length=0x002FEB00 //LS31x and RM48 Flash size is 0x300000 SRAM (RW) : origin=0x08002000 length=0x0002D000 STACK (RW) : origin=0x08000000 length=0x00002000 } SECTIONS { .intvecs : {} > VECTORS flashAPI : { ..\Release\Fapi_UserDefinedFunctions.obj (.text) ..\Release\bl_flash.obj (.text) --library= F021_API_CortexR4_BE.lib < FlashStateMachine.IssueFsmCommand.obj FlashStateMachine.SetActiveBank.obj FlashStateMachine.InitializeFlashBanks.obj FlashStateMachine.EnableMainSectors.obj FlashStateMachine.IssueFsmCommand.obj FlashStateMachine.ScaleFclk.obj Init.obj Utilities.CalculateEcc.obj Utilities.WaitDelay.obj Utilities.CalculateFletcher.obj Read.MarginByByte.obj Read.Common.obj Read.FlushPipeline.obj Read.WdService.obj Async.WithAddress.obj Program.obj > (.text) } load = FLASH_API, run = SRAM, LOAD_START(api_load), RUN_START(api_run), SIZE(api_size) .text > FLASH0 .const > FLASH0 .cinit > FLASH0 .pinit > FLASH0 .data > SRAM .bss > SRAM }
Hi Thomas,
Can you read out the Instruction Fault Status Register and the Instruction Fault Address Register from the CPU core? It will help us track the cause of the prefetch abort?
Hi Thomas,
Is ECC ever enabled in your code at any point of time? When you program the code into the flash memory did you generate the ECC using the auto-ECC feature in CCS or your .out file is already appended with the corresponding ECC? The reason I'm asking is because the moment you enable ECC you need to make sure that the program image has the corresponding ECC checksum. Otherwise, you will have ECC errors even running code out of the flash. However, the Fault address register is showing the SRAM area.
If you single step through the code, can you tell me at which line did it start to abort?
Hi Charles,
I tried enabeling ECCat the beginning of the main Routine with _coreEnableFlashEcc_() and _coreEnableRamEcc_(), however the prefetchEntry still occurs with the same Error Code.
The ECC Code is generated with the auto-ECC feature in CCS.
When single stepping through the Code the abort happens right after executing the last Flash API function, before jumping back into the main routine where the wrapper function was called from.
Could the problem be that one has to create the ECC Code manually after using the Flash API Function with Fapi_calculateEcc() and copy it to flash manually?
Hi Charles
After disabling ECC ,the IFSR and the IFDR still have the same Entries (IFSR = 0x00000409 and IFDR = 0x08040000 = end of RAM). For the MPU all registers are configured as read/write/execute, so the MPU shouldn't restrict execution from RAM.
I attached a minimalist example of my programm code which illustrates the basic problem below:
Hi Thomas,
I think what happened was that you did not copy the flashAPI library to the SRAM. In your linker command file, the RUN_START(api_run) does not mean the linker will automatically copy the library from the load address to the run address. You will need to copy your self. Without the executable code copied to the RAM area, the CPU will execute the code currently stored in the RAM which is nothing but all zeros. I don't know why the ARM CPU is giving an ECC error rather than undefined instruction.
Please find attached modified project where I inserted a _copyAPIRAM_() right before the call to the main() in the sys_startup.c file. The _copyAPIRAM_() is defined in the copyAPI2RAM.asm file. Please give a try.
6840.Flash_programming_using_flashAPI.zip