I was playing with blue pill (Stm32F103CB) and trying to set r7 register via assembly,
.syntax unified
.cpu cortex-m3
.fpu softvfp
.thumb
.global vtable
.global reset_handler
.type vtable, %object
vtable:
.word _estack
.word reset_handler
.size vtable, .-vtable
.type reset_handler, %function
reset_handler:
LDR r0, =_estack
MOV sp, r0
LDR r7, =0xDEADBEEF
.size reset_handler, .-reset_handler
The bug is that when i observe the register values via gdb -> info registers i see r8 register set instead of r7 as can be seen in below image.
objdump disassembly of elf also seems correct.
I am unable to understand why this is happening, tried the same with multiple boards, how can i debug and resolve this issue.
Thanks in advance.
Ok so i did some further tests.
The issue is with this opensource stlink gdb server:
https://github.com/stlink-org/stlink
All the registers are numbered as r# + 1 for some reason, and even the sp value is shown as lr.
I tried with openocd instead and everything works as expected.
https://repo.or.cz/w/openocd.git
Will raise a ticket in the stlink-org repo for this.
User contributions licensed under CC BY-SA 3.0