Arvin_JIN

PlatformIO+Jlink进行调试

PlatformIO自带调试功能具体配置如下
https://docs.platformio.org/en/latest/plus/debug-tools/jlink.html
 
 
我是用的是直接用jlink连接STM32进行所有的开发和调试功能
只需要几步简单的操作:

1、Add Configuration文件


在Platformio.ini中添加如下配置
1 [env:genericSTM32F103ZE]
2 platform = ststm32
3 board = genericSTM32F103ZE
4 framework = cmsis
5 upload_protocol = jlink
6 build_flags = -g
7 debug_tool = jlink

2、点击甲壳虫,选择configuration文件里添加的那个name的调试器来进行调试。


如图为调试界面,各种寄存器信息、变量信息、和调试操作按键。

 

上面的是用PlatformIO自带的调试功能。
还用另外一种调试是通过Cortex-Debug插件来进行调试的

1、VS code 插件管理器中搜索 Cortex Debug


2、platformio.ini中添加

1 build_flags=-g

3、添加调试配置

VS Code 菜单栏——调试——添加配置
选择{}Cortex Debug:JLink
更改配置为如下:
   
 {
            "cwd": "${workspaceRoot}",
            "executable": "/Users/arvin_jin/Documents/PlatformIO/Projects/MY_STM32_OS/.pio/build/genericSTM32F103ZE/firmware.elf",
            "name": "Debug Microcontroller",
            "request": "launch",
            "type": "cortex-debug",
            "servertype": "jlink",
            "device": "STM32F103ZE"
 }
调试过程总可能会出现toolchain,JLinkGDBServer不存在的问题,解决办法为将其这些工具添加到环境变量中即可,添加完后要重启才能生效。Mac下管理换件变量的文件为.bash_profile,我的添加如下:
export PATH="/Users/arvin_jin/.platformio/packages/toolchain-gccarmnoneeabi/bin:$PATH"
export PATH="/Users/arvin_jin/.platformio/packages/tool-jlink:$PATH"
 
cortex-debug参考指南:
https://marcelball.ca/projects/cortex-debug/cortex-debug-launch-configurations/

posted on 2019-08-19 16:06  Arvin_JIN  阅读(3226)  评论(0编辑  收藏  举报

导航