vscode JLinkGDBServer 调试单片机
Posted ljymoonlight
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vscode JLinkGDBServer 调试单片机相关的知识,希望对你有一定的参考价值。
背景
-
原来的项目使用lpcx某款IC自家的IDE,而公司老一辈子工程师自由他自己一套开发环境;而对于我这种新人来说,只能重新建立一套符合
自己的开发环境。 -
之前一直在vscode上看代码,编辑代码; 但很少调试,才发现把这强大的功能给浪费掉了。
配置文件
- 该配置文件还没有自己验证过,目前找到了相关的资料;还是需要回到公司换将这个给操作验证。
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Debug with Jlink",
"type": "cppdbg",
"request": "launch",
"targetArchitecture": "arm",//虽然官方说弃用了,但实际上必须指明
"program": "${workspaceFolder}/STM32F429IGT/a.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/STM32F429IGT",
"environment": [],
"externalConsole": true,
"preLaunchTask": "Build",
"MIMode": "gdb",
"miDebuggerPath": "arm-none-eabi-gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"miDebuggerServerAddress": "localhost:2331",
"customLaunchSetupCommands": [
{
"text": "target remote :2331",
"description": "connect to server",
"ignoreFailures": false
},
{
"text": "file E:/Git/STM32/STM32F429/STM32F429IGT/build/STM32F429IGT.elf",
"description": "load file to gdb",
"ignoreFailures": false
},
{
"text": "load",
"description": "download file to MCU",
"ignoreFailures": false
},
{
"text": "monitor reset",
"description": "reset MCU",
"ignoreFailures": false
},
{
"text": "b main",
"description": "set breakpoints at main",
"ignoreFailures": false
},
]
}
]
}
vscode 启动脚本程序
echo off
cd %ProgramFiles(x86)%/SEGGER/JLink_V512f
tasklist /fi "Imagename eq JLinkGDBServer.exe"|find "JLinkGDBServer.exe"&&taskkill /f /im "JLinkGDBServer.exe"
tasklist /fi "Imagename eq JLinkGDBServer.exe"|find "JLinkGDBServer.exe"&&taskkill /f /im "JLinkGDBServer.exe"
start JLinkGDBServer.exe -select USB -device %1 -if JTAG -speed 1000 -noir
mingw32-make
vscode 建立调试前的启动。参考网上其他人的做法是直接编译也在vscode中实现,我这里就懒的这样子配置,直接只是启动JLinkGDBserver
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build",
"type": "shell",
"options": {
"cwd": "${workspaceRoot}/STM32F429IGT"
},
"command": "mingw32-make",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
},
{
"label": "Clean",
"type": "shell",
"options": {
"cwd": "${workspaceRoot}/STM32F429IGT"
},
"command": "mingw32-make -f makefile clean",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
},
{
"label": "RebuildAll",
"type": "shell",
"options": {
"cwd": "${workspaceRoot}/STM32F429IGT"
},
"command": "E:/Git/STM32/STM32F429/.vscode/RebuildAll.cmd",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
},
{
"label": "Jlink GDB Server",
"type": "process",
"options": {
"cwd": "${workspaceRoot}/STM32F429IGT"
},
"command": "E:/Git/STM32/STM32F429/.vscode/MakeAndStartJlink.cmd",
"args": ["STM32F429IG"],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
}
]
}
以上是关于vscode JLinkGDBServer 调试单片机的主要内容,如果未能解决你的问题,请参考以下文章