[英]Openocd/GDB cortex-m3 debug issue
i have written a very simple program to turn on the 2 LEDs (GPIO port B) on the STM32L-discovery kit. 我编写了一个非常简单的程序来打开STM32L发现套件上的2个LED(GPIO端口B)。
I am using GNU toolchain and openocd for my debugging. 我正在使用GNU工具链和openocd进行调试。
Compilation and linking went ok. 编译和链接正常。 I linked the code such that the LMA and VMA are in the ram region. 我链接了代码,以使LMA和VMA处于ram区域。
I opened the .elf in GDB-insight, inserted some breakpoints and ran openocd with 'openocd-x64-0.7.0 -f stm32ldiscovery.cfg'
我在GDB洞察力中打开了.elf,插入了一些断点,并使用'openocd-x64-0.7.0 -f stm32ldiscovery.cfg'
运行了'openocd-x64-0.7.0 -f stm32ldiscovery.cfg'
At gdb prompt, i ran the following: 在gdb提示符下,我运行了以下命令:
(gdb)target remote localhost:3333
(gdb)monitor reset halt
(gdb)load
(gdb)continue
(gdb)stepi
...
Full source code and object files here 完整的源代码和目标文件在这里
====================...part of source code...=============================== ==================== ...部分源代码... ====================== ===========
const1: .word 0x40020400 @@GPIOB base mode register
const2: .word 0x55555555
const3: .word 0x40020414 @@GPIOB base output register
const4: .word 0x0000FFFF
...
...
...
reset_handler:
ldr r0, =const2
ldr r2, [r0] @r2=const2
ldr r0, =const1
ldr r1, [r0] @r1=const1
str r2, [r1] @@set mode to output
ldr r0, =const4
ldr r2, [r0] @r2=const4
ldr r0, =const3
ldr r1, [r0] @r1=const3
str r2, [r1] @@set output register to 1
loop:
b loop
=================================================== ================================================== =
Basically, i set the GPIO port B ( 0x40020400
) to output mode ( 0x55555555
) and then set '1's ( 0x0000FFFF
) to the port B output register ( 0x40020414
)... 基本上,我将GPIO端口B( 0x40020400
)设置为输出模式( 0x55555555
),然后将'1'( 0x0000FFFF
)设置为端口B输出寄存器( 0x40020414
)...
I was able to step through the assembly instructions and see that the registers (r0, r1 ...) are updating to the expected values... 我能够逐步完成汇编说明,并看到寄存器(r0,r1 ...)正在更新为预期值...
but when i came to str r2, [r1]
and str r2, [r1]
which are basically writing new values to the peripheral registers, i found that these peripheral memory locations ( 0x40020400
and 0x40020414
) are not updating to the new values ( 0x55555555
and 0x0000FFFF
). 但是当我来到str r2, [r1]
和str r2, [r1]
,它们基本上将新值写入外设寄存器,我发现这些外设存储位置( 0x40020400
和0x40020414
)没有更新为新值( 0x55555555
和0x0000FFFF
)。
From gdb prompt, I tried running monitor mdw 0x40020400
and confirmed that this memory location is not having the new value 0x55555555
. 在gdb提示符下,我尝试运行monitor mdw 0x40020400
并确认此内存位置没有新值0x55555555
。 I also tried monitor mww 0x40020400 0x55555555
to write the memory location but to no avail... i also tried set *0x40020400 = 0x55555555
but to no avail also... 我还尝试了监视器mww 0x40020400 0x55555555
写内存位置但是无济于事...我也尝试设置*0x40020400 = 0x55555555
但也无济于事...
Can anyone help me out? 谁能帮我吗? is it some openocd/gdb configurations or settings i got wrong? 我弄错了一些openocd / gdb配置或设置吗?
Ok, found the problem. 好,找到问题了。
I did not enable the GPIOB clock. 我没有启用GPIOB时钟。
I enabled it through the RCC_AHBENR register before accessing/modifying the GPIOB registers as above code... Now it works. 在通过上述代码访问/修改GPIOB寄存器之前,我通过RCC_AHBENR寄存器启用了它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.