vscode JLinkGDBServer 调试单片机

时间:2021-06-20 18:32:46   收藏:0   阅读:0

背景

配置文件

{
    // 使用 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": []
        }
    ]
}
评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!