I am using the Jg-Link Segger base with gdb for Linux to debug the Atmel SAM4S8C MCU. I have the following in the gdb batch file that I specify with the --command argument when gdb starts:
target remote localhost:2331 monitor flash device SAM4S8C
I also specify my ELF file and load program in the batch file.
I noticed that when I load my program (using load ), the stack pointer is not set correctly. monitor reset also does not change the stack pointer.
The J-Link User Guide says (for Cortex-M3 devices):
In addition, the user needs to adjust the stack pointer (R13) and the PC (R15) manually after reset to debug the application.
What is the command for this from gdb?
It is strange that I needed to do this manually. The stack pointer is the first record of the reset vector. When I develop my code, the start stack pointer changes (in particular, switching between applications that have very different start stack pointers, as I first noticed).
Is there a way to get gdb to read this from an ELF file during load and automatically install it?
source share