-
首先下载文件:
gcc-arm-none-eabi-9-2019-q4-major-win32-sha2
mingw64
openocd-0.10.0
VSCodeSetup-x64-1.42.1 -
安装VSCode和openocd-0.10.0。将gcc-arm-none-eabi-9-2019-q4-major-win32-sha2和mingw64解压到C盘。
make,下载解压后将bin中的mingw32-make.exe重命名为make.exe;然后和openocd一样将make.exe所在完整目录添加到环境变量中;
-
环境变量包含路径
-
打开vscode安装插件如下主要安装:c/c++,
-
通过STM32CubeMX生成make。
-
通过vscode打开
找到launch.json打开后编辑如下。
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
“version”: “0.2.0”,
“configurations”: [
{
“cwd”: “${workspaceRoot}”,
“executable”: “./build/T1.elf”,
“name”: “Debug Microcontroller”,
“request”: “launch”,
“type”: “cortex-debug”,
“servertype”: “openocd”,
“configFiles”: [
“C:/openocd-0.10.0/scripts/interface/stlink-v2-1.cfg”,
“C:/openocd-0.10.0/scripts/target/stm32f4x.cfg”
]
}
]
} -
找到tasks.json
{
“version”: “2.0.0”,
“tasks”: [
{
“type”: “shell”,
“label”: “Build”,
“command”: “make”,
“args”: [
],
“problemMatcher”: [
“KaTeX parse error: Expected 'EOF', got '}' at position 34: …up": "build" }̲, { "type…gcc”
],
“group”: “build”,
“dependsOn”:“Build”
}
]
}
-
c_cpp_properties.json
{
“configurations”: [
{
“name”: “Win32”,
“includePath”: [
“ w o r k s p a c e F o l d e r / ∗ ∗ " , " {workspaceFolder}/**", " workspaceFolder/∗∗","{workspaceFolder}/Core/Inc”,
“${workspaceFolder}/Drivers/STM32F4xx_HAL_Driver/Inc”
],
“defines”: [
“_DEBUG”,
“UNICODE”,
“_UNICODE”,
“-DUSE_HAL_DRIVER”,
“-DSTM32F411xE”
],
“compilerPath”: “C:\mingw64\bin\gcc.exe”,
“cStandard”: “gnu17”,
“cppStandard”: “gnu++14”,
“intelliSenseMode”: “gcc-arm”
}
],
“version”: 4
} -
在编辑中需要用stlink-v2-1.cfg可编译下载成功。