如何使用arm-none-eabi-gcc編譯器搭建STM32的Vscode開發(fā)環(huán)境
工具
- make:Windows中沒有make,但是可以通過安裝MinGW或者MinGW-w64,得到make。
- gcc-arm-none-eabi:建議最新版,防止調試報錯
- OpenOCD
- vscode
- cubeMX
VSCODE 插件
- Arm Assembly:匯編文件解析
- C/C++:c語言插件
- Cortex-Debug:調試插件
添加環(huán)境變量路徑
- gcc-arm-none-eabi\bin
- OpenOCD\bin
- 建議MinGW-make工具重命名為make.exe并添加到gcc-arm-none-eabi\bin路徑
測試工具環(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 -------------------------------
工程添加文件
調試器配置OpenOCD\share\openocd\scripts\interfacestlink-v2.cfg芯片配置OpenOCD\share\openocd\scripts\targetstm32f7x.cfg
vscode 配置任務腳本
創(chuàng)建任務腳本
F1
輸入 tasks
選擇 運行任務
選擇 配置任務
選擇 使用模板創(chuàng)建task.json
選擇 other
選擇創(chuàng)建 tasks
使用任務腳本
CTRL + SHIFT + B 選擇對應的任務
tasks.json
{ // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format “version”: “2.0.0”, “tasks”: [ //make 任務 { “l(fā)abel”: “build”, “type”: “shell”, “command”: “make”, “problemMatcher”: [], “group”: { “kind”: “build”, “isDefault”: true } }, // clean 任務 { “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 配置調試腳本
1.創(chuàng)建調試腳本
選擇調試窗口
選擇 創(chuàng)建 launch.json 文件2. 啟用調試
快捷鍵 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", ] } ] }
調試過程中報錯:仔細查看報錯信息,gcc版本過低也會造成調試報錯
到此這篇關于使用arm-none-eabi-gcc編譯器搭建STM32的Vscode開發(fā)環(huán)境的文章就介紹到這了,更多相關arm-none-eabi-gcc編譯器搭建Vscode開發(fā)環(huán)境內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
深入理解c++中char*與wchar_t*與string以及wstring之間的相互轉換
本篇文章是對c++中的char*與wchar_t*與string以及wstring之間的相互轉換進行了詳細的分析介紹,需要的朋友參考下2013-05-05