Debugging a relocated target application

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

Debugging a relocated target application

Jump to solution
794 Views
fractalgarden
Contributor III

Hello,

MCUXpresso 11.6.0 [Build 8187] [2022-07-13]
mimxrt-1052 with external QFlash
Segger JLink Plus V7.88g

The IDE debugger is working properly via Telnet connection to GDB server on localhost.
When the application is located at entry point, at the beginning of QFlash 0x60000000, everything works correctly.

The next step we need is to move the application further ahead, because at entry point we need to put a bootloader. Therefore, we configure the application to be located for example at 0x60100000.
In standalone normal operation, the bootloader will start from the entry point and then jump to the application.
During debugging, however, the debugger should program, start, and debug the application directly at its address.
In McuXpresso, I have set the following configurations:
Project properties -> C/C++ Build -> MCU Settings -> Memory Details -> Flash [Location]
Project properties -> Run/Debug Settings -> Edit -> GUI Flash tool -> Base Address

Inspection of .map file confirms that the application is correctly linked at address 0x60100000.
The application is programmed at the correct address (verified with J-Flash application).

But the debugger is not working, it fails to start the application or debug it.
I haven't found anything else to configure; any ideas to suggest?

0 Kudos
1 Solution
743 Views
fractalgarden
Contributor III

Thanks @ErichStyger , I looked at those articles.
The problem was not in the symbols loading, though. This is automatically managed by MCUXpresso in the debug script.

I solved the problem now, here is a breakdown hoping it's useful for similar cases in MCUXpresso with JLink.

When starting a relocated application from the debugger,
it is necessary to consider if a booting mechanism is present at entry point to jump at the relocated address.
If not, maybe because you are in early debug stage and rely only on the debugger to start the application,
then the debugger script must be configured to set the initial PC (program counter).
In the debug configuration, section Start, "Set program counter at (hex)"
set the address of the reset isr function as found in the .map file. Look for names like ResetISR.

If no booting mechanism is present, you must also ensure that no other reset commands are issued by the debugger script after the PC is set.
Check the JLinkServer console output (select from the "Display selected console" pulldown in the Console view).
Check everything that follows the step "Writing register (PC = 0x12345678)" - (where 0x12345678 is your ResetISR address).
To avoid resets after PC setting, remove the following options from the debugger configuration:
"Reset before running" in section JLink Debugger,
"Halt" in section Startup,
"monitor reset" in the custom commands textbox in section Startup

View solution in original post

2 Replies
744 Views
fractalgarden
Contributor III

Thanks @ErichStyger , I looked at those articles.
The problem was not in the symbols loading, though. This is automatically managed by MCUXpresso in the debug script.

I solved the problem now, here is a breakdown hoping it's useful for similar cases in MCUXpresso with JLink.

When starting a relocated application from the debugger,
it is necessary to consider if a booting mechanism is present at entry point to jump at the relocated address.
If not, maybe because you are in early debug stage and rely only on the debugger to start the application,
then the debugger script must be configured to set the initial PC (program counter).
In the debug configuration, section Start, "Set program counter at (hex)"
set the address of the reset isr function as found in the .map file. Look for names like ResetISR.

If no booting mechanism is present, you must also ensure that no other reset commands are issued by the debugger script after the PC is set.
Check the JLinkServer console output (select from the "Display selected console" pulldown in the Console view).
Check everything that follows the step "Writing register (PC = 0x12345678)" - (where 0x12345678 is your ResetISR address).
To avoid resets after PC setting, remove the following options from the debugger configuration:
"Reset before running" in section JLink Debugger,
"Halt" in section Startup,
"monitor reset" in the custom commands textbox in section Startup

788 Views
ErichStyger
Senior Contributor V
0 Kudos