当前位置:   article > 正文

vscode stm32 openocd 在线调试,下载_openocd下载

openocd下载

1、下载vscode

2、下载openocd

3、下载GNU Tools ARM Embedded

操作:

调试: F5

下载: make flash

清楚:make clean

复位:make reset , 复位之前需要断开openocd, 所以直接输入这个命令是复位不成功的, 这也是为什么下载之前需要杀掉Openocd.exe的原因

 

需要几个配置文件,路径分别:

stlink.cfg :........\OpenOCD-20200310-0.10.0\share\openocd\scripts\interface\stlink.cfg

STM32WB5x.svd:C:\Program Files (x86)\IAR Systems\Embedded Workbench 8.3\arm\config\debugger\ST\STM32WB5x.svd

stm32wbx.cfg : ......\OpenOCD-20200310-0.10.0\share\openocd\scripts\target\stm32wbx.cfg

Makefile,这个是从STM32CubeMX自动生成的,添加的信息如下

  1. #######################################
  2. # download file
  3. #######################################
  4. flash:
  5. taskkill /f /im openocd.exe
  6. STM32_Programmer_CLI -c port=SWD -hardRst
  7. STM32_Programmer_CLI -c port=SWD -d ./build/123123.hex -v -s 0x08000000
  8. reset:
  9. STM32_Programmer_CLI -c port=SWD -hardRst
  10. #taskkill /f /im openocd.exe

 

新建文件:openocd.cfg

  1. source [find stlink.cfg]
  2. source [find stm32wbx.cfg]

 

launch.json 配置

  1. {
  2. "version": "0.2.0",
  3. "configurations": [
  4. {
  5. "name": "Debug",
  6. "type": "cppdbg",
  7. "request": "launch",
  8. "miDebuggerPath": "C:/Program Files (x86)/GNU Tools ARM Embedded/9 2019-q4-major/bin/arm-none-eabi-gdb.exe",
  9. "targetArchitecture": "arm",
  10. "program": "${workspaceRoot}/build/123123.elf",
  11. "setupCommands": [
  12. {
  13. "text": "file 'C:/Users/15652/Desktop/STM32TWST/123123/build/123123.elf'"
  14. },
  15. {
  16. "text": "target remote localhost:3333" //连接Openocd
  17. },
  18. {
  19. "text": "monitor reset halt" //复位
  20. },
  21. {
  22. "text": "load" //加载文件
  23. },
  24. {
  25. "text": "break main" //跳转main
  26. }
  27. ],
  28. "preLaunchTask": "debug", //调试开始之前,运行debug
  29. "postDebugTask": "stop_debug", //调试结束之后,运行stop_debug
  30. "launchCompleteCommand": "None",
  31. "externalConsole": true,
  32. "cwd": "${workspaceRoot}"
  33. }
  34. ]
  35. }

 

tasks.json

  1. {
  2. // See https://go.microsoft.com/fwlink/?LinkId=733558
  3. // for the documentation about the tasks.json format
  4. "version": "2.0.0",
  5. "tasks": [
  6. {
  7. "label": "debug",
  8. "options": {
  9. "cwd": "${workspaceRoot}"
  10. },
  11. "problemMatcher": {
  12. "owner": "cpp",
  13. "fileLocation": [
  14. "relative",
  15. "${workspaceRoot}"
  16. ],
  17. "pattern": {
  18. "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
  19. "file": 1,
  20. "line": 2,
  21. "column": 3,
  22. "severity": 4,
  23. "message": 5
  24. }
  25. },
  26. "args": [],
  27. "linux": {
  28. "command": "make"
  29. },
  30. "osx": {
  31. "command": "make"
  32. },
  33. "windows": {
  34. "command": "make.exe"
  35. },
  36. "dependsOn": [
  37. "openocd"
  38. ]
  39. },
  40. {
  41. "label": "openocd",
  42. "type": "shell",
  43. "command": "./debug.bat",
  44. },
  45. {
  46. "label": "download",
  47. "type": "shell",
  48. "command": "make update",
  49. "problemMatcher": [
  50. "$gcc"
  51. ],
  52. },
  53. {
  54. "label": "stop_debug",
  55. "type": "shell",
  56. "command": "make reset",
  57. "problemMatcher": [],
  58. }
  59. ]
  60. }

 

debug.bat

  1. @echo off
  2. tasklist|findstr /i "openocd.exe" > nul
  3. if ERRORLEVEL 1 (
  4. echo openocd is closed,open it.
  5. start cmd /k "openocd"
  6. )
  7. ::else (
  8. ::echo openocd hasbeen open, close and restart.
  9. ::close openocd
  10. ::taskkill /f /im openocd.exe
  11. ::delay 200ms
  12. ::choice /t 0.5 /d y /n >nul
  13. ::start cmd /k "openocd"
  14. ::)

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/码创造者/article/detail/984511
推荐阅读
相关标签
  

闽ICP备14008679号