VSCode 插件下载
必须的像是C++,makefile,ARM都需要下载下来
以下仅供参考:
STM32MX 工程配置
需要在STM32MX里面生成一个工程文件,具体在generate code时需要特殊配置;参考如下
一定要生成基于Makefile的工具链
下面是工程的必要的文件抽取,可以选择默认也行
工程架构
生成的工程如下参考,有build , Drivers, Inc, Src等目录
新建一个.vscode的配置
在工程目录下面新建一个.vscode的配置,包括编译环境,终端,以及task格式
c_cpp_properties.json
工程配置如下,请参考我当前的配置
{
"configurations": [
{
"name": "STM32",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/Drivers/CMSIS/Device/ST/STM32F4xx/Include",
"${workspaceFolder}/Drivers/CMSIS/Include",
"${workspaceFolder}/Drivers/STM32F4xx_HAL_Driver/Inc",
"${workspaceFolder}/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy",
"${workspaceFolder}/Inc"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE",
"USE_HAL_DRIVER"
],
"compilerPath": "F:\\Program Files (x86)\\MinGW\\bin\\gcc.exe",
"cStandard": "c99",
"cppStandard": "c++98",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
settings.json
{
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
}
task.json
{
// 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",
"command": "make",
"args": [
// Ask msbuild to generate full paths for file names.
"/property:GenerateFullPaths=true",
"/t:build",
// Do not generate summary otherwise it leads to duplicate errors in Problems panel
"/consoleloggerparameters:NoSummary"
],
"group": "build",
"presentation": {
// Reveal the output only if unrecognized errors occur.
"reveal": "silent"
},
// Use the standard MS compiler pattern to detect errors, warnings and infos
"problemMatcher": "$msCompile"
}
]
}
终端编译bash
如果用Makefile的话,需要使用bash的中断进行编译,因此将终端从powershell切换到git bash;
当前,也可以自己找到绝对路径,主动启动,都可以;
安装交叉编译工具链arm-none-ebai-gcc
下载路径如下:
https://launchpadlibrarian.net/287101671/gcc-arm-none-eabi-5_4-2016q3-20160926-win32.exe
安装后配置好环境变量
检查环境变量是否存在
切换到工程目录编译