網站首頁 編程語言 正文
如果用 PlatformIO 創建 libopencm3 項目可以做到零配置, 只是 libopencm3 的版本會舊一點. 這里說的是僅使用 VSCode 創建C/CPP項目時的配置. VSCode 有代碼提示, 定位來源和各種快捷鍵, 更適合日常編碼工作.
說明
因為 PlatformIO 的 platform:st-stm32 自帶 libopencm3, 如果用 PlatformIO 創建 libopencm3 項目可以做到零配置, 只是 libopencm3 的版本會舊一點. 這里說的是僅使用 VSCode 創建C/CPP項目時的配置. VSCode 有代碼提示, 定位來源和各種快捷鍵, 更適合日常編碼工作.
前提條件
參考如何linux環境下配置環境變量過程圖解 ?,自行百度先將 GNU Arm Embedded Toolchain 和 st-flash 工具準備好
創建項目
導出模板項目
git clone --recurse-submodules https://github.com/libopencm3/libopencm3-template.git 或者 git clone --recurse-submodules https://gitee.com/iosetting/libopencm3-template.git
VSCode 創建項目
用 VSCode 的 Open Folder 打開. 需要修改一下 my-project/Makefile 中的配置, 將 DEVICE 修改為實際使用的MCU型號
DEVICE=stm32f103c8t6
配置C/CPP環境
快捷鍵Ctrl
+Shift
+P
, 在打開的對話框中, 輸入/找到 C/C++: Edit Configurations (JSON)
, 用JSON進行配置
配置內容
{ "configurations": [ { "name": "Linux", "includePath": [ "${workspaceFolder}/**", "${workspaceFolder}/libopencm3/include" ], "defines": [ "STM32F1" ], "compilerPath": "/opt/gcc-arm/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gcc", "cStandard": "gnu11", "cppStandard": "gnu++14", "intelliSenseMode": "gcc-arm" } ], "version": 4 }
- compilerPath 根據自己的工具鏈路徑進行修改
- defines 下的 STM32F1 與編譯無關(編譯使用的是DEVICE和鏈接庫), 不設置也能正確編譯, 設置這個是為了 VSCode 能正確定位變量和函數聲明
配置編譯任務
快捷鍵Ctrl
+Shift
+P
, 在打開的對話框中, 輸入/找到 Tasks: Configure Task
, 用others模板創建
配置內容, 其中TARGETS=stm32/f1
根據實際的MCU型號修改
{ // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "2.0.0", "tasks": [ { "label": "build libopencm3", "type": "shell", "command": "PREFIX=/opt/gcc-arm/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi- TARGETS=stm32/f1 make -C libopencm3", "problemMatcher": [] }, { "label": "build clean libopencm3", "type": "shell", "command": "PREFIX=/opt/gcc-arm/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi- make -C libopencm3 clean", "problemMatcher": [] }, { "label": "build", "type": "shell", "command": "PREFIX=/opt/gcc-arm/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi- make -C my-project", "problemMatcher": [] }, { "label": "build clean", "type": "shell", "command": "PREFIX=/opt/gcc-arm/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi- make -C my-project clean", "problemMatcher": [] }, { "label": "build download", "type": "shell", "command": "st-flash --reset write my-project/awesomesauce.bin 0x8000000", "problemMatcher": [] } ] }
使用時, 通過Shift
+ Alt
+ F10
調出菜單并選中執行.
先執行一次 build libopencm3 , 生成 libopencm3 的鏈接庫之后, 編譯項目就只需要執行 build 了.
原文鏈接:https://www.cnblogs.com/milton/p/15929905.html
相關推薦
- 2022-04-14 k8s安裝過程遇到的問題
- 2023-07-06 springBoot JWT實現websocket的token登錄攔截認證
- 2024-03-09 【Redis】Redisson分布式鎖原理與使用
- 2022-05-31 詳解Docker?Compose配置文件參數_docker
- 2022-08-29 .NET?Core獲取配置文件內容_實用技巧
- 2022-12-08 C/C++高精度運算(大整數運算)詳細講解_C 語言
- 2022-05-22 vscode調試container中的程序的方法步驟_相關技巧
- 2022-03-27 關于Android?Device?Monitor?無法打開問題_Android
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支