Tool/software:
Hi all,
I am trying to use the F021 api on a TMS570LS0914PGE, but I am having trouble with it. After the system has been intialized, I call:
Fapi_StatusType status = Fapi_initializeFlashBanks(HCLK_FREQ);
status = Fapi_setActiveFlashBank((Fapi_FlashBankType)Fapi_FlashBank0);
Fapi_setActiveFlashBank() causes a undefined instruction exception.
In CCS 12 I included these F021 files:
- F021_API_CortexR4_BE_V3D16.lib // Flash Module Controller, Big Endian, FPU
- CGT.CCS.h
- Registers_FMC_BE.h
Following note from the F021 guide (chapter 3.3.4) confuses me a little:
NOTE: The F021 Flash API library cannot be executed from the same bank as the active bank selected for the API commands to operate on.
On single bank devices, the F021 Flash API must be executed from RAM.
Is that the problem? I would't know what to do about it.
Regards,
Juergen
Hi Juergen,
Yes, this is a problem.
Please refer below thread, here i explained in detailed about this problem:
--
Thanks & regards,
Jagadish.
Hi Jagadish,
thanks for your response, I think I still need a little guidance to get this to work.
I modified my linker script according to the link you suggested and added
extern unsigned int api_load;
extern unsigned int api_size;
extern unsigned int api_run;
memcpy(&api_run, &api_load, (uint32)&api_size);
to my main file.
--retain="*(.intvecs)" MEMORY { VECTORS (X) : origin=0x00000000 length=0x00000020 FLASH_API (RX) : origin=0x00000020 length=0x000014E0 FLASH0 (RX) : origin=0x00001500 length=0x0000EB00 STACKS (RW) : origin=0x08000000 length=0x00001500 RAM (RW) : origin=0x08001500 length=0x0001EB00 } SECTIONS { .intvecs : {} > VECTORS flashAPI : { ../../../IDE/CSS/Debug/port/TMS570LS0914PGE/F021_API/source/Fapi_UserDefinedFunctions.obj (.text) --library= F021_API_CortexR4_BE_V3D16.lib (.text) } load = FLASH_API, run = RAM, LOAD_START(api_load), RUN_START(api_run), SIZE(api_size) .text : {} > FLASH0 .const : {} > FLASH0 .cinit : {} > FLASH0 .pinit : {} > FLASH0 .bss : {} > RAM .data : {} > RAM .sysmem : {} > RAM FEE_TEXT_SECTION : {} > FLASH0 FEE_CONST_SECTION : {} > FLASH0 FEE_DATA_SECTION : {} > RAM } .ref api_load flash_load .word api_load .ref api_run flash_run .word api_run .ref api_size flash_size .word api_size ldr r0, flash_load ldr r1, flash_run ldr r2, flash_size add r2, r1, r2 copy_loop1: ldr r3, [r0], #4 str r3, [r1], #4 cmp r1, r2 blt copy_loop1 bx lr .endasmfunc
Starting with line " .ref api_load" I get errors like: #10008-D cannot find file ".ref" ....
For the line ../../../IDE/CSS/Debug/port/TMS570LS0914PGE/F021_API/source/Fapi_UserDefinedFunctions.obj (.text) I get the error:
#10068-D no matching section.
The path is relative to the location of the linker script?
Ist there a macro whtich replaces "Debug" fills in Debug or Release depending on which one of the two I build?
Best Regards,
Juergen
A little update . I removed the assembler code from the linker script. memcpy in the main file does the job and copies the Flash Api into RAM. I can step over Fapi_setActiveFlashBank() now.
I am still wondering if there is a way of replacing Debug in this line with a macro which depends on the type of build (Debug or Release)
../../../IDE/CSS/Debug/port/TMS570LS0914PGE/F021_API/source/Fapi_UserDefinedFunctions.obj (.text)
Best Regards,
Juergen
I am still having trouble with the flash api. As long as I single step through the code, Fapi_issueProgrammingCommand() works five out of ten times. It never works when I don't single step through the code, it ends up in the undefined instruction exceptio handler.The global interrupt flag in the cpsr register is 1, interrupts shouldn't occur. Fapi_issueAsyncCommandWithAddress() never works, not even in single step. The test setup writes four bytes into the beginning of sectors 4,5,6. It's followed by a blank check which will always correctly reports that the sectors are not blank. This is followed by a Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector, addr) for each sector but always ends up in the undefined instruction exception handler.
.
#define NUMBEROFSECTORS 14 const SECTORS flash_sector[NUMBEROFSECTORS] = { /*start len bank sector */ (void *)0x00000000, 0x04000, 0, 0, (void *)0x00004000, 0x04000, 0, 1, (void *)0x00008000, 0x04000, 0, 2, (void *)0x0000C000, 0x04000, 0, 3, (void *)0x00010000, 0x04000, 0, 4, (void *)0x00014000, 0x04000, 0, 5, (void *)0x00018000, 0x08000, 0, 6, (void *)0x00020000, 0x20000, 0, 7, (void *)0x00040000, 0x20000, 0, 8, (void *)0x00060000, 0x20000, 0, 9, (void *)0x00080000, 0x20000, 0, 10, (void *)0x000A0000, 0x20000, 0, 11, (void *)0x000C0000, 0x20000, 0, 12, (void *)0x000E0000, 0x20000, 0, 13 }; void main(void){ memcpy(&api_run, &api_load, (uint32)&api_size); // copy api to RAM status = Fapi_initializeFlashBanks(HCLK_FREQ); while(FAPI_CHECK_FSM_READY_BUSY == Fapi_Status_FsmBusy); status = Fapi_setActiveFlashBank((Fapi_FlashBankType)Fapi_FlashBank0); while(FAPI_CHECK_FSM_READY_BUSY == Fapi_Status_FsmBusy); status = Fapi_enableMainBankSectors(0x03FFF); while(FAPI_CHECK_FSM_READY_BUSY == Fapi_Status_FsmBusy); int i = 4; uint8_t pattern[4] = {0xAA, 0xBB, 0xCC, 0xDD}; uint8_t eccbuf[4] = {0}; for(i = 4; i < 7; i++){ status = Fapi_issueProgrammingCommand((uint32_t *)flash_sector[i].start, pattern, sizeof(pattern), eccbuf, 0, Fapi_DataOnly); while(FAPI_CHECK_FSM_READY_BUSY == Fapi_Status_FsmBusy); uint32_t fmstat = 0; do{ fmstat = FAPI_GET_FSM_STATUS; }while(fmstat != 0); } for(i = 4; i < 7; i++){ status = Fapi_Error_Fail; do{ status = Fapi_doBlankCheck((uint32_t *)flash_sector[i].start, flash_sector[i].length - 1, // not sure yet why it only work with length -1 &poFlashStatusWord); if(status == Fapi_Error_Fail){ // sector blank? Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector, (uint32_t *)flash_sector[i].start); while(FAPI_CHECK_FSM_READY_BUSY == Fapi_Status_FsmBusy); if(FAPI_GET_FSM_STATUS != 0){ while(1); } } }while(status == Fapi_Error_Fail); } }