When I try to fully erase and flash the C2800 of a F25M35 concerto, i have the problem that the processor gets trapped in an illegal operation trap when I call Fapi_issueProgrammingCommand() (F021_API_C28x_FPU32.lib already is in the .ramfuncs section). I could retrace the problem so far that i can tell that the reason is the function “LL$$OR” which is in the (at this moment already erased) flash memory and called from the flash API state machine. How can I put this function also into the RAM to make it working?
flash.c:
int flashWritePage(unsigned long address, unsigned char *data, unsigned long len)
{
unsigned long origin, remaining_len, write_len;
address += FLASH_SECTOR_N_START;
remaining_len = len;
origin = address;
EALLOW;
FlashEccRegs.ECC_ENABLE.bit.ENABLE = 0x0;
ipcFlashGainPump();
while (address < origin + len){
write_len = remaining_len > 8 ? 8 : remaining_len;
if (address + write_len > FLASH_SECTOR_A_END + 1){
ipcFlashLeavePump();
return ERROR;
}
if(Fapi_issueProgrammingCommand((uint32 *) address,(uint8*) data + (address - origin), write_len, 0, 0, Fapi_AutoEccGeneration) != Fapi_Status_Success) {
ipcFlashLeavePump();
return ERROR;
}
address += write_len;
remaining_len -= write_len;
while(Fapi_checkFsmForReady() == Fapi_Status_FsmBusy);
}
ipcFlashLeavePump();
EDIS;
return ERROR_NONE;
}
.map:
GLOBAL SYMBOLS: SORTED ALPHABETICALLY BY Name
address name
-------- ----
00130000 .text
00132824 C$$EXIT
0013222b FS$$DIV
0013283d LL$$AND
00132845 LL$$OR
0013284d LL$$XOR
00132855 ULL$$TOFS
…
00008ace _Fapi_GlobalInit
0000894d _Fapi_calculateEcc
00008906 _Fapi_calculateFletcherChecksum
00008a62 _Fapi_checkFsmForReady
Linker command file:
MEMORY
{
PAGE 0: /* Program Memory */
/* Memory (RAM/FLASH/OTP) blocks can be moved to PAGE1 for data allocation */
RAML0 : origin = 0x008000, length = 0x001000 /* on-chip RAM block L0 */
RAML1 : origin = 0x009000, length = 0x001000 /* on-chip RAM block L1 */
FLASHN : origin = 0x100000, length = 0x002000 /* on-chip FLASH */
FLASHM : origin = 0x102000, length = 0x002000 /* on-chip FLASH */
FLASHL : origin = 0x104000, length = 0x002000 /* on-chip FLASH */
FLASHK : origin = 0x106000, length = 0x002000 /* on-chip FLASH */
FLASHJ : origin = 0x108000, length = 0x008000 /* on-chip FLASH */
FLASHI : origin = 0x110000, length = 0x008000 /* on-chip FLASH */
FLASHH : origin = 0x118000, length = 0x008000 /* on-chip FLASH */
FLASHG : origin = 0x120000, length = 0x008000 /* on-chip FLASH */
FLASHF : origin = 0x128000, length = 0x008000 /* on-chip FLASH */
FLASHE : origin = 0x130000, length = 0x008000 /* on-chip FLASH */
FLASHD : origin = 0x138000, length = 0x002000 /* on-chip FLASH */
FLASHC : origin = 0x13A000, length = 0x002000 /* on-chip FLASH */
FLASHA : origin = 0x13E000, length = 0x001F80 /* on-chip FLASH */
CSM_RSVD : origin = 0x13FF80, length = 0x000070 /* Part of FLASHA. Program with all 0x0000 when CSM is in use. */
BEGIN : origin = 0x13FFF0, length = 0x000002 /* Part of FLASHA. Used for "boot to Flash" bootloader mode. */
FLASH_EXE_ONLY_P0 : origin = 0x13FFF2, length = 0x000002 /* Part of FLASHA. Flash execute only locations in FLASHA */
ECSL_PWL_P0 : origin = 0x13FFF4, length = 0x000004 /* Part of FLASHA. ECSL password locations in FLASHA */
CSM_PWL_P0 : origin = 0x13FFF8, length = 0x000008 /* Part of FLASHA. CSM password locations in FLASHA */
FPUTABLES : origin = 0x3FD258, length = 0x0006A0 /* FPU Tables in Boot ROM */
IQTABLES : origin = 0x3FD8F8, length = 0x000B50 /* IQ Math Tables in Boot ROM */
IQTABLES2 : origin = 0x3FE448, length = 0x00008C /* IQ Math Tables in Boot ROM */
IQTABLES3 : origin = 0x3FE4D4, length = 0x0000AA /* IQ Math Tables in Boot ROM */
BOOTROM : origin = 0x3FEDA8, length = 0x001200 /* Boot ROM */
PIEMISHNDLR : origin = 0x3FFFBE, length = 0x000002 /* part of boot ROM */
RESET : origin = 0x3FFFC0, length = 0x000002 /* part of boot ROM */
VECTORS : origin = 0x3FFFC2, length = 0x00003E /* part of boot ROM */
/*...*/
.cinit : > FLASHE PAGE = 0
.pinit : > FLASHE, PAGE = 0
.text : > FLASHE PAGE = 0
codestart : > BEGIN PAGE = 0
GROUP
{
.ramfuncs
{ -l F021_API_C28x_FPU32.lib}
} LOAD = FLASHA,
RUN = RAML0,
LOAD_START(_ramfuncsLoadStart),
LOAD_END(_ramfuncsLoadEnd),
RUN_START(_ramfuncsRunStart),
PAGE = 0