mac下使用vscode搭建stm32开发环境

1 篇文章 0 订阅

1. 使用stm32Cube 生成makefile的工程

2. 安装arm-gcc编译器,Jlink等

3. 创建tasks.json文件

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Build",  // 任务名
            "type": "shell",   // 任务执行的是shell命令
            "command": "make", // 任务命令
            "problemMatcher": "$gcc", // GCC捕获错误
        },
        {
            "label": "Build Clean",  // 任务名
            "type": "shell",   // 任务执行的是shell命令
            "command": "make clean", // 任务命令
            "problemMatcher": "$gcc", // GCC捕获错误
        },
        {
            "label": "Program",     //下载代码
            "type": "shell",
            "command": "JLinkExe -device stm32f103vb -autoconnect 1 -if SWD -speed 4000 -CommandFile CommandFile.jlink",
            "dependsOn": "Build",  // 依赖"Build"命令先运行
            "problemMatcher": [],
            "group": {  // 设置为默认"build"组命令,⇧⌘B 按键快速编译烧录
                "kind": "build",
                "isDefault": true
            }
        },
        {
            "label": "Disassembly",
            "type": "shell",
            "command": "arm-none-eabi-objdump -ldS OBJ/STM32_REG_TEST1.elf > STM32_REG_TEST1.asm",
            "problemMatcher": [],
        },
        {
            "label": "GDBServer",
            "type": "shell",
            "command": "JLinkGDBServer -select USB -device STM32F103RC -endian little -if SWD -speed 4000 -noir -noLocalhostOnly",
            "problemMatcher": [],
        },
        {
            "label": "Connect to JLink",
            "type": "shell",
            "command": "JLinkExe -device stm32f103vb -autoconnect 1 -if SWD -speed 4000",
            "dependsOn": "make",
            "problemMatcher": [],
        },
        {
            "label": "JLink RTT log",
            "type": "shell",
            "command": "JLinkRTTClient",
            "problemMatcher": [],
        }
    ]
}

4. 创建launch.json文件

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "DGB debug",
            "type": "cppdbg",
            "request": "launch",
            "targetArchitecture": "arm",
            "program": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",  // 工作路径
            "environment": [],
            "externalConsole": false,
            //"preLaunchTask": "Program", // 前置任务
            //"postDebugTask": "...",     // 后置任务
            "MIMode": "gdb",
            "miDebuggerPath": "/Users/peixu/toolchain/gcc-arm-none-eabi-5_4-2016q3/bin/arm-none-eabi-gdb",  // GDB command路径
            "launchCompleteCommand": "None",
            "miDebuggerServerAddress": "localhost:2331", // GDBSerevr IP:Port
            "customLaunchSetupCommands": [
                {
                    "text": "file /Users/peixu/Documents/Embedded/Project/21_cleaner_x/cleaner_x/sdk/source/mcu/vscode_envirment_bootloader_test/bootloader_vscode_makefile/build/bootloader_vscode_makefile.elf",
                    "description": "Load symbol file",
                    "ignoreFailures": false
                },
                {
                    "text": "target remote :2331",
                    "description": "Connet to GDB server",
                    "ignoreFailures": false    
                },
                {
                    "text": "break main",
                    "description": "Set breakpoints at main",
                    "ignoreFailures": false
                },
                {
                    "text": "monitor reset",
                    "description": "Reset the target",
                    "ignoreFailures": false
                },
            ]
        }
    ]
}

5. 创建jlink文件

% vim CommandFile.jlink
h
loadbin build/bootloader_vscode_makefile.bin 0x8000000
r
g
qc
% JLinkExe -device stm32f103rc -autoconnect 1 -if SWD -speed 4000 -CommandFile CommandFile.jlink

 

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值