gdb调试
-
- DEBUG CONSOIE
- SOLUTION
DEBUG CONSOIE
console:
Output radix now set to decimal 10, hex a, octal 12.
Input radix now set to decimal 10, hex a, octal 12.
Reset_Handler () at startup_stm32f103xb.s:69
69 ldr r2, =_sidata
Program stopped, probably due to a reset and/or halt issued by debugger
SOLUTION
{
"version": "0.2.0",
"configurations": [
{
"cwd": "${workspaceRoot}",
"executable": "build/c8motorcontrol.elf",
"name": "Debug with OpenOCD",
"request": "launch",
"type": "cortex-debug",
**"runToEntryPoint": "main",**
"servertype": "openocd",
"configFiles": [
"D:/software/OpenOCD-20231002-0.12.0/share/openocd/scripts/interface/stlink.cfg",
"D:/software/OpenOCD-20231002-0.12.0/share/openocd/scripts/target/stm32f1x.cfg"
]
}
]
}
提示是reset handler ,在keil 中的runtomain 相当于 “runToEntryPoint”: “main”,
关于cubeMX生成的stm32f103C8T6代码无法调试的坑(STLINK)–HAL_Init中死循环
在使用cubeMX生成stm32f103C8T6代码的时候,遇到一个问题,就是如果直接烧录程序,程序可以正常运行,但是进入debug,程序就会一直在HAL_Init中循环,无法执行到后面的代码。
困在这个问题好几天,查找了网上的各种资料,没有能解决我问题的答案,于是自己研究,单步调试,一步一步看问题出在哪里,发现在HAL_Init函数中调用了HAL_MspInit后,程序就会跳转到RESET_Handler,然后再跳转到main函数,这就是HAL_Init不断死循环的原因。
于是我依次对HAL_MspInit中调用的函数进行注释,看看到底是哪个函数影响了debug功能,最终确定是**__HAL_RCC_PWR_CLK_ENABLE和__HAL_AFIO_REMAP_SWJ_NOJTAG**两个函数导致无法调试,我注释了这两句以后,keil就可以正常进入调试模式了。
总结:注释HAL_Init中HAL_MspInit中的__HAL_RCC_PWR_CLK_ENABLE和__HAL_AFIO_REMAP_SWJ_NOJTAG后可以正常进行调试。
注:如果注释了__HAL_AFIO_REMAP_SWJ_NOJTAG则烧录程序后需手动按下RESET按钮才可以正常运行程序,
“runToEntryPoint”: “main” 就可以不用手动reset