[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
git submodule update --init --recursive

下载完成之后,运行IDF里面的install.bat脚本,它会检查安装编译工具链,和python的依赖库。最好打开cmd终端,然后在这里面运行,不然直接运行出错的话,会直接关掉,看不到提示信息。
[ESP32]Win系统vscode集成idf4.1开发esp32项目_第1张图片
这个会从github上面下载指定版本的工具,会比较慢,大家还是需要自己去网上搜索下载。
安装完成之后,可以运行export.bat脚本设置编译环境,然后再去编译一下hello,看能不能正常:

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

安装配置vs code

安装vscode.
安装espressif idf插件,搜索“IDF”,可以看到该插件。
[ESP32]Win系统vscode集成idf4.1开发esp32项目_第2张图片
配置idf
[ESP32]Win系统vscode集成idf4.1开发esp32项目_第3张图片
配置python路径,这里需要注意,不要选中系统的python,需要选择.espressif里面的python,因为安装的包是在这个环境里面的

C:\Users\Administrator.espressif\python_env\idf4.2_py3.7_env\Scripts\python.exe

[ESP32]Win系统vscode集成idf4.1开发esp32项目_第4张图片
配置idf路径:
[ESP32]Win系统vscode集成idf4.1开发esp32项目_第5张图片
配置编译工具路径:
[ESP32]Win系统vscode集成idf4.1开发esp32项目_第6张图片
[ESP32]Win系统vscode集成idf4.1开发esp32项目_第7张图片
编译工具( | 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

检测:
[ESP32]Win系统vscode集成idf4.1开发esp32项目_第8张图片
配置完成:
[ESP32]Win系统vscode集成idf4.1开发esp32项目_第9张图片
可以通过examples创建工程。[ESP32]Win系统vscode集成idf4.1开发esp32项目_第10张图片
编译,直接按F1,再输入esp可以看到相应的编译和下载选项:
[ESP32]Win系统vscode集成idf4.1开发esp32项目_第11张图片
下载之前需要先选一个串口!
[ESP32]Win系统vscode集成idf4.1开发esp32项目_第12张图片
不懂什么因,每次打开vscode,如果不走一次上面的配置流程,就会出错,没有办法,把python都用绝对路径算了。
打开“file->preferences->settings”,输入“idf”过滤
把下面的python都替换为:

C:\Users\Administrator.espressif\python_env\idf4.2_py3.7_env\Scripts\python.exe

[ESP32]Win系统vscode集成idf4.1开发esp32项目_第13张图片
[ESP32]Win系统vscode集成idf4.1开发esp32项目_第14张图片

你可能感兴趣的:(esp32)