Tool/software: Code Composer Studio
Hello,
I have a C2000 project where the Fapi_setActiveFlashBank() crashes one of the 2 cores of my TMS320F28377D. When I am connected to the debugger, everything seems to be working fine, I can program my Flash via Can. Even if I load the program with code composer, I disconnect the probe and restart the supply, and then load the symbols with a reset/restart or just restart, everything works fine.
However, when I disconnect the debugger and boot from Flash, the same software does not work. After some debug, I found the crash is during the call of the function Fapi_setActiveFlashBank().
I placed this function in RAM:
GROUP
{
ramfuncs
{ -l F021_API_F2837xD_FPU32.lib}
} LOAD = FLASHA,
RUN = RAMLS0123,
LOAD_START(_RamfuncsLoadStart),
LOAD_SIZE(_RamfuncsLoadSize),
LOAD_END(_RamfuncsLoadEnd),
RUN_START(_RamfuncsRunStart),
RUN_SIZE(_RamfuncsRunSize),
RUN_END(_RamfuncsRunEnd),
PAGE = 0 ALIGN(4) /* executable code with automatic link between flash load and RAM run*/
/* Allocate program areas: */
.cinit : > FLASHA PAGE = 0, ALIGN(4)
.pinit : > FLASHA, PAGE = 0, ALIGN(4)
.text : >> FLASHA | FLASHB | FLASHC PAGE = 0, ALIGN(4) /* executable code */
codestart : > BEGIN PAGE = 0, ALIGN(4)
appstart : > BEGINAPP PAGE = 0, ALIGN(4)
In my .map the function is well placed in the ramfuncs section :
ramfuncs 0 00080004 000009d0 RUN ADDR = 00008000
00080004 00000259 F021_API_F2837xD_FPU32.lib : FlashStateMachine.obj (.text:__Fapi_setupFlashStateMachine)
0008025d 0000019d : Program.obj (.text:_Fapi_issueProgrammingCommand)
000803fa 00000088 : Read.obj (.text:__Fapi_loopRegionForValue)
00080482 0000007f : Read.obj (.text:__Fapi_checkRegionForValue)
00080501 0000007f : Read.obj (.text:__Fapi_checkRegionForValueByByte)
00080580 00000042 : BlankCheck.obj (.text:_Fapi_doBlankCheck)
000805c2 0000003a : Read.obj (.text:__Fapi_loopRegionForValueByByte)
000805fc 00000034 : Init.obj (.text:_Fapi_initializeAPI)
00080630 0000002e : Utilities.obj (.text:_Fapi_calculateFletcherChecksum)
0008065e 0000002d : FlashStateMachine.obj (.text:__Fapi_issueFsmCommand)
0008068b 0000002c : Utilities.obj (.text:__Fapi_divideUnsignedLong)
000806b7 00000025 : FlashStateMachine.obj (.text:_Fapi_setActiveFlashBank)
000806dc 00000022 : FlashStateMachine.obj (.text:_Fapi_isAddressEcc)
000806fe 00000022 : FlashStateMachine.obj (.text:__Fapi_setupSectorsForWrite)
Then I call the function during the initialization of CPU2:
void main(void) { InitSysCtrl(); IpcRegs.IPCBOOTSTS = C2_BOOTROM_BOOTSTS_SYSTEM_READY; CAL2_InitFlash(F021_CPU0_BASE_ADDRESS) ... }
#pragma CODE_SECTION(CAL2_InitFlash, "ramfuncs" ); U16 CAL2_InitFlash(Fapi_FmcRegistersType * F021BaseAddr) { U16 RetStatus; RetStatus = Fapi_Status_Success; // Check the arguments ASSERT((F021BaseAddr == F021_CPU0_BASE_ADDRESS)); // Gain pump semaphore SeizeFlashPump(); EALLOW; // This function is required to initialize the Flash API based on System // frequency before any other Flash API operation can be performed // Currently RetStatus not checked since it is always Fapi_Status_Success RetStatus = Fapi_initializeAPI(F021BaseAddr, CAL2_kSYSCLK_FREQUENCY); EALLOW; RetStatus = Fapi_setActiveFlashBank(Fapi_FlashBank0); EDIS; // Leave control over flash pump ReleaseFlashPump(); return RetStatus; }
Any help would be appreciated. I already read the topics and
but it didn't help enough to resolve my problem.
Thank's,
Clement