Debugging code with non-0x0 origin

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Debugging code with non-0x0 origin

1,270 Views
steve_n
Contributor II

I am having difficulty debugging a project that places PFLASH at a location other than 0x0.

 

Everything builds without error but when I try to debug, the IDE is never able to attach itself properly. It seems like I am missing some setting in the project setting or the debugger settings.

 

I attached an example project that locations program flash at 0x8000 on a FRDM-K64F. I used the OpenSDA embedded USB connection on the FRDM-K64F.

 

If I change the origin of PFLASH to 0x0 and touch nothing else, the debugger works without an issue. So, what am I missing, to be able to debug the same project with the code starting at 0x8000?

 

Thanks in advance.

0 Kudos
Reply
1 Reply

981 Views
steve_n
Contributor II

The issue is that while the IDE places the PC register at the correct 0x8205 value, it does not touch the default setting of the SP register. SP contains all 1's, which causes the whole debugger toolchain to die as soon as a subroutine is hit, which is the second line of code in ResetISR(void). Therefore, the PC never reaches main() before the debugger crashes.

The 1's in the SP are from address 0x0000 which is 0xFFFFFFFF.

To me, the IDE should override the default SP value location if the start of CODE starts other than 0x0, because it obviously knew to NOT use the default value at address 0x4 for the PC.

If I hard code a proper value for top of ram (0x20030000) into address 0x0, everything works fine. Also, if I load in a second object file with p code starting at 0x0 this also works, because that object file sets address 0x0 to the same the top of ram value (0x20030000) needed for the code at 0x8000.

0 Kudos
Reply