如何使用arm-none-eabi-gcc編譯器搭建STM32的Vscode開發(fā)環(huán)境
工具
- make:Windows中沒有make,但是可以通過安裝MinGW或者M(jìn)inGW-w64,得到make。
- gcc-arm-none-eabi:建議最新版,防止調(diào)試報(bào)錯(cuò)
- OpenOCD
- vscode
- cubeMX
VSCODE 插件
- Arm Assembly:匯編文件解析
- C/C++:c語言插件
- Cortex-Debug:調(diào)試插件
添加環(huán)境變量路徑
- gcc-arm-none-eabi\bin
- OpenOCD\bin
- 建議MinGW-make工具重命名為make.exe并添加到gcc-arm-none-eabi\bin路徑
測(cè)試工具環(huán)境變量是否生效
arm-none-eabi-gcc -v OpenOCD -v make -v
創(chuàng)建工程
使用cubeMX創(chuàng)建Makefile工程
Makefile:由于window沒有rm指令,所以這里修改為 del,并添加了系統(tǒng)判斷
將makefile一下 ------------------------------- clean: -rm -fR $(BUILD_DIR) ------------------------------- 修改 ------------------------------- ifeq ($(OS),Windows_NT) clean: del $(BUILD_DIR) else clean: -rm -fR $(BUILD_DIR) endif -------------------------------
工程添加文件
調(diào)試器配置OpenOCD\share\openocd\scripts\interfacestlink-v2.cfg芯片配置OpenOCD\share\openocd\scripts\targetstm32f7x.cfg
vscode 配置任務(wù)腳本
創(chuàng)建任務(wù)腳本
F1
輸入 tasks
選擇 運(yùn)行任務(wù)
選擇 配置任務(wù)
選擇 使用模板創(chuàng)建task.json
選擇 other
選擇創(chuàng)建 tasks
使用任務(wù)腳本
CTRL + SHIFT + B 選擇對(duì)應(yīng)的任務(wù)
tasks.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
“version”: “2.0.0”,
“tasks”: [
//make 任務(wù)
{
“l(fā)abel”: “build”,
“type”: “shell”,
“command”: “make”,
“problemMatcher”: [],
“group”: {
“kind”: “build”,
“isDefault”: true
}
},
// clean 任務(wù)
{
“l(fā)abel”: “clean”,
“type”: “shell”,
“command”: “make clean”,
“problemMatcher”: [],
“group”: {
“kind”: “build”,
“isDefault”: true
}
},
//下載任物
{
“l(fā)abel”: “download”,
“type”: “shell”,
“command”: “openocd”,
// openocd 傳遞的參數(shù)
“args”: [
“-f”,
“stlink-v2.cfg”,
“-f”,
“stm32f7x.cfg”,
“-c”,
“program build/stm32f767_project.elf verify reset exit”,
],
“group”: {
“kind”: “build”,
“isDefault”: true
},
},
]
}vscode 配置調(diào)試腳本
1.創(chuàng)建調(diào)試腳本
選擇調(diào)試窗口
選擇 創(chuàng)建 launch.json 文件2. 啟用調(diào)試
快捷鍵 F5
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Cortex Debug",
"cwd": "${workspaceFolder}",
"executable": "${workspaceFolder}/build/stm32f767_project.elf", // 編譯文件
"request": "launch",
"type": "cortex-debug",
"servertype": "openocd",
"interface":"swd",
"device": "STM32F7IGT6",
"configFiles": [
"stlink-v2.cfg",
"stm32f7x.cfg",
]
}
]
}調(diào)試過程中報(bào)錯(cuò):仔細(xì)查看報(bào)錯(cuò)信息,gcc版本過低也會(huì)造成調(diào)試報(bào)錯(cuò)
到此這篇關(guān)于使用arm-none-eabi-gcc編譯器搭建STM32的Vscode開發(fā)環(huán)境的文章就介紹到這了,更多相關(guān)arm-none-eabi-gcc編譯器搭建Vscode開發(fā)環(huán)境內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
c++調(diào)用實(shí)現(xiàn)yolov5轉(zhuǎn)onnx介紹
大家好,本篇文章主要講的是c++調(diào)用實(shí)現(xiàn)yolov5轉(zhuǎn)onnx介紹,感興趣的同學(xué)趕快來看一看吧,對(duì)你有幫助的話記得收藏一下,方便下次瀏覽2021-12-12
OpenGL實(shí)現(xiàn)3D空間中移動(dòng)圖像
這篇文章主要為大家詳細(xì)介紹了OpenGL實(shí)現(xiàn)3D空間中移動(dòng)圖像,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-08-08
C++實(shí)現(xiàn)類似延時(shí)停頓的打字效果
這篇文章主要介紹的是使用C++實(shí)現(xiàn)類似延時(shí)停頓的打字效果的代碼,非常的簡(jiǎn)單,推薦給大家,有需要的小伙伴可以參考下。2015-03-03
解析C++編程中異常相關(guān)的堆棧展開和throw()異常規(guī)范
這篇文章主要介紹了C++編程中異常相關(guān)的堆棧展開和throw()異常規(guī)范,throw()規(guī)范部分文中結(jié)合了C++11標(biāo)準(zhǔn)的新特性來講,需要的朋友可以參考下2016-01-01

