[ESP32]Win系統vscode集成idf4.1開發esp32項目

Win系統vscode集成idf4.1開發esp32項目

下載安裝idf4.1

需要先安裝git,然後通過git clone官方的代碼:

git clone https://github.com/espressif/esp-idf.git

或是直接下載官方的sdk,目前提供的是v4.0
https://dl.espressif.com/dl/esp-idf/releases/esp-idf-v4.0.zip
如果需要更新到最新的代碼,可以直接git pull

git pull

切換idf的代碼版本:

git checkout -b xxxx v4.1-dev
git checkout -b v4.1 origin/release/v4.1

下載完成之後,運行IDF裏面的install.bat腳本,它會檢查安裝編譯工具鏈,和python的依賴庫。最好打開cmd終端,然後在這裏面運行,不然直接運行出錯的話,會直接關掉,看不到提示信息。
在這裏插入圖片描述
這個會從github上面下載指定版本的工具,會比較慢,大家還是需要自己去網上搜索下載。
安裝完成之後,可以運行export.bat腳本設置編譯環境,然後再去編譯一下hello,看能不能正常:

export.bat
cd examples\get-started\hello_world
idf.py build

安裝配置vs code

安裝vscode.
安裝espressif idf插件,搜索“IDF”,可以看到該插件。
在這裏插入圖片描述
配置idf
在這裏插入圖片描述
配置python路徑,這裏需要注意,不要選中系統的python,需要選擇.espressif裏面的python,因爲安裝的包是在這個環境裏面的

C:\Users\Administrator.espressif\python_env\idf4.2_py3.7_env\Scripts\python.exe
在這裏插入圖片描述
配置idf路徑:
在這裏插入圖片描述
配置編譯工具路徑:
在這裏插入圖片描述
在這裏插入圖片描述
編譯工具( | xtensa-esp32-elf | xtensa-esp32s2-elf | esp32ulp-elf | esp32s2ulp-elf | cmake | openocd-esp32 | ninja | idf-exe | ccache |)路徑,它會解壓到用戶路徑裏面,大家可以自己去複製,每個文件夾用“;”隔開:
C:\Users\Administrator.espressif\tools\ccache\3.7;C:\Users\Administrator.espressif\tools\cmake\3.13.4\bin;C:\Users\Administrator.espressif\tools\esp32s2ulp-elf\2.28.51-esp-20191205\esp32s2ulp-elf-binutils\bin;C:\Users\Administrator.espressif\tools\esp32ulp-elf\2.28.51-esp-20191205\esp32ulp-elf-binutils\bin;C:\Users\Administrator.espressif\tools\idf-exe\1.0.1;C:\Users\Administrator.espressif\tools\ninja\1.9.0;C:\Users\Administrator.espressif\tools\openocd-esp32\v0.10.0-esp32-20191114\openocd-esp32\bin;C:\Users\Administrator.espressif\tools\xtensa-esp32-elf\esp-2019r2-8.2.0\xtensa-esp32-elf\bin;C:\Users\Administrator.espressif\tools\xtensa-esp32s2-elf\esp-2019r2-8.2.0\xtensa-esp32s2-elf\bin

opencd scripts路徑大概是這個,若不一樣,請自行查看:

C:\Users\Administrator.espressif\tools\openocd-esp32\v0.10.0-esp32-20191114\openocd-esp32\share\openocd\scripts

檢測:
在這裏插入圖片描述
配置完成:
在這裏插入圖片描述
可以通過examples創建工程。在這裏插入圖片描述
編譯,直接按F1,再輸入esp可以看到相應的編譯和下載選項:
在這裏插入圖片描述
下載之前需要先選一個串口!
在這裏插入圖片描述
不懂什麼因,每次打開vscode,如果不走一次上面的配置流程,就會出錯,沒有辦法,把python都用絕對路徑算了。
打開“file->preferences->settings”,輸入“idf”過濾
把下面的python都替換爲:

C:\Users\Administrator.espressif\python_env\idf4.2_py3.7_env\Scripts\python.exe
在這裏插入圖片描述
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章