Other Parts Discussed in Thread: C2000WARE
Referencing this forum post:
While I was able to find that the ITRAP I was getting was because a function pointer was being overwritten, thus an invalid function call took place, I wasn't able to figure out why the function pointer was being overwritten in memory. In fact, I don't believe anything in my code is overwriting this function pointer. The issue I'm finding is that, say I assign a void pointer to the function pointer so it would be something like functPointer = (void*)0. Ideally after compile time the function pointer should read 0x00000000:

However, the first time I press the debug button and FLASH code onto CPU1 and CPU2 the function pointer value changes before I reach main(). Note that I have a single debug configuration that is set to program both cores one after the other. It will build code for each core then erase FLASH and load code onto each core:

0x0608015A is not a valid void function pointer so an ITRAP (illegal instruction ISR) is triggered. What would cause this function pointer to be overwritten prior to main.c during boot? Is something in Boot ROM going rogue and overwriting other memory regions?
To try to debug this further, I tried disabling Auto Run on program load/restart to step through Boot ROM and see if something changes the function pointer value:

However, the function pointer remains a void pointer throughout Boot ROM and never gets overwritten (i.e. I can't replicate the function pointer being overwritten with auto run on program load or restart disabled). As soon as I enable Auto Run to main on program load or restart and try flashing again, the problem re-surfaces...boggles my mind.
Here's another wrinkle. If I am already in an active debug session, I can't replicate the issue after the first time I load the code onto both cores in FLASH. If I try a CPU reset/restart, the function pointer goes back to a normal value of 0x00000000. This problem seems to only occur on the first time I start a new debug session and FLASH code onto both cores. I have to stop the current debug session and re-start the debug session and FLASH code again onto both cores in order to see the problem again.
Could it be some weird issue with emulator debugger mode or boot ROM or linker CMD files not setup correctly? There is an errata out there for "Memory: Prefetching Beyond Valid Memory" so I'll have to investigate whether we are using M1 GS11 or GS15 as specified in errata SPRZ413L. Double checked the linker files and they specifically do not allow the endings of the invalid memory regions to be used as per the errata so it doesn't seem like the linker files are the issue. Although I do merge RAMLS0 and RAMLS1 to make RAMLS0_1 for TI ramfuncs on CPU1 (CPU2 only needs RAMLS0), not sure if this affects anything.
EDIT 5/12/2021: cleaned up & simplified the question
