当前位置:   article > 正文

STM32 VSCODE 与 openocd的一套东西_failed to execute mi command: -target-select remot

failed to execute mi command: -target-select remote localhost:3333
  • 个人笔记
  1. 安装VSCODE。
  2. 安装CYGWIN以及里面的一套东西。
  3. 安装OPENOCD。
  4. 安装STM32CUBE以及一套库的下载。

帮助: CYGWIN:https://cygwin.com/

ARM:  https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads

OPENOCD:http://openocd.org/

STLINK:https://www.st.com/content/st_com/en/products/development-tools/software-development-tools/stm32-software-development-tools/stm32-utilities/stsw-link009.html

STM32-LINK UTILITY:https://www.st.com/content/st_com/en/products/development-tools/software-development-tools/stm32-software-development-tools/stm32-programmers/stsw-link004.html

STM32CUBE:https://www.st.com/en/embedded-software/stm32cubef4.html

 

  1. 开发环境搭建 用stm32cube生成一个带makefile的文件,里面部分头文件可能需要自己添加。
  2. 用VSCODE打开此文件夹,配置好以c_cpp_properaties.json,特别是include目录。
    1. {
    2. "configurations": [
    3. {
    4. "name": "Win32",
    5. "includePath": [
    6. "${workspaceFolder}/**"
    7. ],
    8. "defines": [
    9. "_DEBUG",
    10. "UNICODE",
    11. "_UNICODE"
    12. ],
    13. "compilerPath": "/usr/bin/gcc",
    14. "cStandard": "c11",
    15. "cppStandard": "c++17",
    16. "intelliSenseMode": "clang-x64"
    17. }
    18. ],
    19. "version": 4
    20. }
  3. 配置好setting.json。
  4. launch.json配置如下,如果使用openocd的话:
    1. {
    2. "version": "0.2.0",
    3. "configurations": [
    4. {
    5. "name": "ARM Debug",
    6. "type": "cppdbg",
    7. "request": "launch",
    8. "miDebuggerPath": "C:/Program Files (x86)/GNU Tools Arm Embedded/5.4 2016q3/bin/arm-none-eabi-gdb.exe",
    9. "targetArchitecture": "arm",
    10. "program": "${workspaceRoot}/build/pwmTest.elf",
    11. "setupCommands": [
    12. {
    13. "text": "file 'C:/Users/Cairne/OneDrive/Code/stm32/nucleo/PWMTest/CubeMX/PWMTest/build/pwmTest.elf'"
    14. },
    15. {
    16. "text": "target remote localhost:3333"
    17. },
    18. {
    19. "text": "monitor reset"
    20. },
    21. {
    22. "text": "monitor halt"
    23. },
    24. {
    25. "text": "load"
    26. }
    27. ],
    28. "preLaunchTask": "build",
    29. "launchCompleteCommand": "None",
    30. "externalConsole": true,
    31. "cwd": "${workspaceRoot}"
    32. }
    33. ]
    34. }

     

    关于端口的解释:

  • 在安装完openocd后可以使用代码
  1. PS C:\OpenOCD-20190828-0.10.0\share\openocd\scripts\interface> openocd -v
  2. Open On-Chip Debugger 0.10.0 (2019-08-28) [https://github.com/sysprogs/openocd]
  3. Licensed under GNU GPL v2
  4. For bug reports, read
  5. http://openocd.org/doc/doxygen/bugs.html

来查看是否安装成功,然后安装成功STLINK驱动后可以查到到

这个设备。

  • 使用命令:
  1. openocd -f .\stlink-v2-1.cfg -f C:\OpenOCD-20190828-0.10.0\share\openocd\scripts\target\stm32f3x.cfg
  2. Open On-Chip Debugger 0.10.0 (2019-08-28) [https://github.com/sysprogs/openocd]
  3. Licensed under GNU GPL v2
  4. For bug reports, read
  5. http://openocd.org/doc/doxygen/bugs.html
  6. WARNING: interface/stlink-v2-1.cfg is deprecated, please switch to interface/stlink.cfg
  7. Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
  8. Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
  9. Info : Listening on port 6666 for tcl connections
  10. Info : Listening on port 4444 for telnet connections
  11. Info : clock speed 1000 kHz
  12. Info : STLINK V2J28M17 (API v2) VID:PID 0483:374B
  13. Info : Target voltage: 3.252528
  14. Info : stm32f3x.cpu: hardware has 6 breakpoints, 4 watchpoints
  15. Info : Listening on port 3333 for gdb connections
  16. Info : accepting 'gdb' connection on tcp/3333

可以看到端口是3333,对应上面的VSCODE的配置文件里的设置。可以在每次调试前输入这个命令以连上openocd。或者在launch.json里写一个任务,每次调试之前都自动连接。

  • 成功界面:

 

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

闽ICP备14008679号