首页 > 其他分享 >VScode Configuration STM32

VScode Configuration STM32

时间:2022-10-31 23:57:12浏览次数:89  
标签:OpenOCD Documents openocd VScode cfg Drivers STM32 workspaceFolder Configuration

基于VScode搭建STM32运行环境

所需软件

  • vscode: 是我们的代码编辑器
  • STM32CubeMX: 是我们配置和初始化的软件
  • OpenOCD: 是开源片上调试器, 他下载完是一个压缩包, 需要配置环境
  • arm-none-eabi-gcc: 是编译器, 需要配置环境
  • make: 是编译工具
  • stmf4: SVD 文件

插件

  • Arm Assembly
  • C/C++
  • C/C++ Snippets
  • Cortex-Debug

生成一个 STM32CubeMX 工程

设置生成为makefile文件
用vscode打开这个生成的工程文件
在终端运行make -j4, 以4核心编译代码

配置下载

task文件

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "download",
            "type": "shell",
            "command": "openocd",
            "args": [
                "-f",
                "C:/Users/Administrator/Documents/Tools/OpenOCD/share/openocd/scripts/interface/stlink-v2.cfg",
                "-f",
                "C:/Users/Administrator/Documents/Tools/OpenOCD/share/openocd/scripts/target/stm32f4x.cfg",
                "-c",
                "program build/a.elf verify reset exit"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "presentation": {
                "reveal": "silent"
            },
            "problemMatcher": "$gcc"
        }
    ]
}

使用快捷方式 ctrl+shift+b 执行download

Cortex Debug配置

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "cwd": "${workspaceRoot}",
            "executable": "./build/a.elf",
            "name": "STM32 Debug",
            "request": "launch",
            "type": "cortex-debug",
            "servertype": "openocd",
            "device": "STM32F407VE",
            "configFiles": [
                "C:/Users/Administrator/Documents/Tools/OpenOCD/share/openocd/scripts/interface/stlink-v2.cfg",
                "C:/Users/Administrator/Documents/Tools/OpenOCD/share/openocd/scripts/target/stm32f4x.cfg",
            ],
            "svdFile": "./STM32F407.svd"
        },
    ]
}

C/C++报错

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "${workspaceFolder}/Drivers/STM32F4xx_HAL_Driver/Inc",
                "${workspaceFolder}/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy",
                "${workspaceFolder}/Drivers/CMSIS/Device/ST/STM32F4xx/Include",
                "${workspaceFolder}/Drivers/CMSIS/Include",
                "${workspaceFolder}/Drivers/CMSIS/Include",
                "${workspaceFolder}/Core/Inc",
                "C:\\Program Files (x86)\\GNU Arm Embedded Toolchain\\10 2021.10\\arm-none-eabi\\include"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE",
                "USE_HAL_DRIVER",
                "STM32F407xx"
            ],
            "compilerPath": "C:\\Program Files (x86)\\GNU Arm Embedded Toolchain\\10 2021.10\\bin\\arm-none-eabi-gcc.exe",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "windows-gcc-x86"
        }
    ],
    "version": 4
}

参考资料

csdn

标签:OpenOCD,Documents,openocd,VScode,cfg,Drivers,STM32,workspaceFolder,Configuration
From: https://www.cnblogs.com/Ahtelek/p/VScode-Configuration-STM32.html

相关文章

  • [vscode] 如何在终端添加git bash?
    设置-搜索"terminal.integrated.profiles.windows"将以下内容复制进入,注意要修改gitbash实际路径{"terminal.integrated.profiles.windows":{"PowerShell":......
  • [VScode] 常用设置以及常用操作
    常用快捷键:Ctrl+P:搜索打开文件Ctrl+`:快速打开关闭终端.Ctrl+T:全局字符搜索Ctrl+Shift+O:在当前文件中搜索变量函数Alt+O:切换源头文件Ctrl+......
  • [VScode] 嵌入式软件开发必备插件
    C/C++c/c++智能提示、调试和代码浏览C++Intellisense借助GNUGlobal标签的c/c++智能提示BracketPairColorizer一个可定制的扩展为匹配括号着色Chinese(Simplified)......
  • [I.MX6UL] 用STM32的方式来写I.MX6UL程序
    /**************************************************************Copyright©zuozhongkaiCo.,Ltd.1998-2019.Allrightsreserved.文件名:mian.c作者:左......
  • STM32 HAL IIC软模拟
    IIC(Inter-IntegratedCircuit)其实是IICBus简称,所以中文应该叫集成电路总线,它是一种串行通信总线,使用多主从架构,由飞利浦公司在1980年代为了让主板、嵌入式系统或手机用以连......
  • 单片机 STM32 HAL GSM通讯 SIM800L
    /*************笔记****************1、本SIM800L模块采用huart3(串口3),然后huart1(串口1)作为调试输出。2、CudeMX配置huart3:----------------------------------------......
  • 单片机 STM32 HAL PCF8574 例子代码
    #include"extgpio.h"#include"pcf8574.h"#include"74hc595.h"/******************笔记:1、X输入Y输出2、NPN(箭头向下)高电平时导通,PNP(箭头向上)低电平时导通;3、PCF8574......
  • 单片机 STM32 HAL IO扩展 74HC595 例子代码
    #include"74hc595.h"/******************功能:定义HC595的功能引脚备注:变更引脚,由MX配置完成*******************/constT_HC595_PINhc595={.sck_port=HC595_......
  • STM32 HAL CPU Monitor 查询CPU使用率 查询CPU温度
    /*********************************************************************************@filecpu_utils.c*@authorMCDApplicationTeam*@versionV1.1.0......
  • Cannot initialize Cluster. Please check your configuration for mapreduce.framewo
    背景利用ambari搭建的新环境,跑数据出现了不少问题,但如下问题困扰了很长时间,直到今天才得以解决,每次报错。按照网上的各种方式都不行。我知道问题点肯定在spark2.3.1集成h......