ESP-IDF VSCode 插件配置方法(2)


本文仅介绍已经安装 ESP-IDF 想要基于已有的安装环境使用 Espressif IDF vscode 插件的情况,这种情况下需要手动指定一些配置项,过程比较繁琐。对于需要全新安装 ESP-IDF环境的机器,安装Espressif IDF vscode 插件之后,按照过程一步步选择即可,比较简单,过程不再描述。


注意事项:

  1. 必须使用绝对路径,路径中不能使用 ~, $HOME , %HOME% ;
  2. 如果一个配置项包含多个内容,Linux 上必须使用 :(英文冒号) 分隔,Windows 必须使用 ;(英文分号) 分隔。
  3. 请将配置指令中的 {user} 换成自己的用户名

注意 Windows 和 Linux 分隔符不同

主要配置项:

  • espIdfPath:指定已经下载的 IDF 路径;
  • toolsPath:指定已经安装的 IDF 工具链目录(.espressif 目录);
  • customExtraPaths:当前版本 IDF 对应的工具链 bin 位置(.espressif 中具体的某个 bin 目录);
  • customExtraVars:需要附加的环境变量;
  • pythonBinPath:当前版本 IDF 对应的 python 虚拟环境位置。

配置方法:

  • 方法1. 可以直接在 settings 中搜索 idf,修改以上配置项;
  • 方法2. 可以直接在 settings.json 中添加直接添加以上配置项;
  • 方法3. 使用 idf vscode 插件配置引导 Configure ESP-IDF Extension

详细配置过程(方法3)

1. 打开配置引导界面

在 vscode 中点击键盘Ctrl+Shift+P,呼出 command palette,输入Configure ESP-IDF Extension,选择并打开

在这里插入图片描述

2. 选择 python 版本

选择为 python3

在这里插入图片描述

3. 添加 esp-idf 路径

添加已经下载安装的 esp-idf 路径

在这里插入图片描述

4. 已经下载过工具链,这里不再下载

在这里插入图片描述

5. 填写配置项参数

在这里插入图片描述

5.1 添加 Python 虚拟环境路径,并安装依赖

由于 install.shinstall.bat 安装工具默认配置在 Python 虚拟环境中。因此这里需要指定当前版本 IDF 的 Python 虚拟环境位置。

Example (Linux master-20-08-14) :

/home/{user}/.espressif/python_env/idf4.3_py3.6_env/bin/python3

Example (Windows v4.0.1) :

C:\\.espressif\\python_env\\idf4.3_py3.8_env\\Scripts\\python

安装 vscode 插件依赖的工具包

Example (Linux master-20-08-14) :

/home/{user}/.espressif/python_env/idf4.3_py3.6_env/bin/python -m pip install -r /home/{user}/.vscode/extensions/espressif.esp-idf-extension-0.4.0/esp_debug_adapter/requirements.txt

Example (Windows v4.0.1) :

c:\\.espressif\\python_env\\idf4.0_py3.8_env\\Scripts\\python.exe -m pip install -r c:\\{
    
    user}s\\Administrator\\.vscode\\extensions\\espressif.esp-idf-extension-0.4.0\\esp_debug_adapter\\requirements.txt

5.2 添加工具链可执行文件路径

这里主要包含 ESP-IDF 编译工具链的可执行文件位置,对于 Windows 系统,还需要包含 `CMake and Ninja-build):

Example (Linux master-20-08-14) :

/home/{user}/.espressif/tools/xtensa-esp32-elf/esp-2020r2-8.2.0/xtensa-esp32-elf/bin:/home/{user}/.espressif/tools/esp32ulp-elf/2.28.51-esp-20191205/esp32ulp-elf-binutils/bin:/home/{user}/.espressif/tools/openocd-esp32/v0.10.0-esp32-20200420/openocd-esp32/bin:/home/{user}/.espressif/tools/xtensa-esp32s2-elf/esp-2020r2-8.2.0/xtensa-esp32s2-elf/bin:/home/{user}/.espressif/tools/esp32s2ulp-elf/2.28.51-esp-20191205/esp32s2ulp-elf-binutils/bin
linux 主要包含下列路径
xtensa-esp32-elf xtensa-esp32s2-elf esp32ulp-elf esp32s2ulp-elf openocd-esp32
/home/{user}/.espressif/tools/xtensa-esp32-elf/esp-2020r2-8.2.0/xtensa-esp32-elf/bin /home/{user}/.espressif/tools/xtensa-esp32s2-elf/esp-2020r2-8.2.0/xtensa-esp32s2-elf/bin /home/{user}/.espressif/tools/esp32ulp-elf/2.28.51-esp-20191205/esp32ulp-elf-binutils/bin /home/{user}/.espressif/tools/esp32s2ulp-elf/2.28.51-esp-20191205/esp32s2ulp-elf-binutils/bin /home/{user}/.espressif/tools/openocd-esp32/v0.10.0-esp32-20200420/openocd-esp32/bin

Example (Windows v4.0.1):

.;C:\Program Files;c:\.espressif\tools\xtensa-esp32-elf\esp-2019r2-8.2.0\xtensa-esp32-elf\bin;c:\.espressif\tools\esp32ulp-elf\2.28.51.20170517\esp32ulp-elf-binutils\bin;c:\.espressif\tools\cmake\3.13.4\bin;c:\.espressif\tools\openocd-esp32\v0.10.0-esp32-20190313\openocd-esp32\bin;c:\.espressif\tools\mconf\v4.6.0.0-idf-20190628;c:\.espressif\tools\ninja\1.9.0;c:\.espressif\tools\idf-exe\1.0.1;c:\.espressif\tools\ccache\3.7
Windows 主要包含下列路径
xtensa-esp32-elf esp32ulp-elf openocd-esp32 cmake mconfig ninja idf.exe ccache
C:\Program Files;c:.espressif\tools\xtensa-esp32-elf\esp-2019r2-8.2.0\xtensa-esp32-elf\bin c:.espressif\tools\esp32ulp-elf\2.28.51.20170517\esp32ulp-elf-binutils\bin c:.espressif\tools\openocd-esp32\v0.10.0-esp32-20190313\openocd-esp32\bin c:.espressif\tools\cmake\3.13.4\bin c:.espressif\tools\mconf\v4.6.0.0-idf-20190628 c:.espressif\tools\ninja\1.9.0 c:.espressif\tools\idf-exe\1.0.1 c:.espressif\tools\ccache\3.7

5.3 添加环境变量

Example (Linux master-20-08-14) :

/home/{user}/.espressif/tools/openocd-esp32/share/openocd/scripts

Example (Windows v4.0.1):

{"OPENOCD_SCRIPTS":"~/.espressif/tools/openocd-esp32/v0.10.0-esp32-20200420/openocd-esp32/share/openocd/scripts","IDF_CCACHE_ENABLE":"1"}

6. 配置完成检查

Example (Linux master-20-08-14) :

在这里插入图片描述

Example (Windows v4.0.1):

在这里插入图片描述

Example (Windows v4.0.1):

{
    
    
    "idf.espIdfPathWin": "c:\\esp\\esp-idf",
    "idf.toolsPathWin": "c:\\.espressif",
    "idf.customExtraPaths": ".;C:\\Program Files;c:\\.espressif\\tools\\xtensa-esp32-elf\\esp-2019r2-8.2.0\\xtensa-esp32-elf\\bin;c:\\.espressif\\tools\\esp32ulp-elf\\2.28.51.20170517\\esp32ulp-elf-binutils\\bin;c:\\.espressif\\tools\\cmake\\3.13.4\\bin;c:\\.espressif\\tools\\openocd-esp32\\v0.10.0-esp32-20190313\\openocd-esp32\\bin;c:\\.espressif\\tools\\mconf\\v4.6.0.0-idf-20190628;c:\\.espressif\\tools\\ninja\\1.9.0;c:\\.espressif\\tools\\idf-exe\\1.0.1;c:\\.espressif\\tools\\ccache\\3.7",
    "idf.customExtraVars": "{\"OPENOCD_SCRIPTS\":\"c:\\\\.espressif\\\\tools\\\\openocd-esp32\\\\v0.10.0-esp32-20190313/openocd-esp32/share/openocd/scripts\",\"IDF_CCACHE_ENABLE\":\"1\"}",
    "idf.pythonBinPathWin": "C:\\\\.espressif\\\\python_env\\\\idf4.3_py3.8_env\\\\Scripts\\\\python"
}

Example (Linux master-20-08-14) :

{
    
    
    "idf.adapterTargetName": "esp32s2",
    "idf.espIdfPath": "/home/{user}/esp/esp-idf",
    "idf.toolsPath": "/home/{user}/.espressif",
    "idf.customExtraPaths": "/home/{user}/.espressif/tools/xtensa-esp32-elf/esp-2020r2-8.2.0/xtensa-esp32-elf/bin:/home/{user}/.espressif/tools/esp32ulp-elf/2.28.51-esp-20191205/esp32ulp-elf-binutils/bin:/home/{user}/.espressif/tools/openocd-esp32/v0.10.0-esp32-20200420/openocd-esp32/bin:/home/{user}/.espressif/tools/xtensa-esp32s2-elf/esp-2020r2-8.2.0/xtensa-esp32s2-elf/bin:/home/{user}/.espressif/tools/esp32s2ulp-elf/2.28.51-esp-20191205/esp32s2ulp-elf-binutils/bin",
    "idf.customExtraVars": "{\"OPENOCD_SCRIPTS\":\"${TOOL_PATH}/openocd-esp32/share/openocd/scripts\"}",
    "idf.pythonBinPath": "/home/{user}/.espressif/python_env/idf4.3_py3.6_env/bin/python",
}

猜你喜欢

转载自blog.csdn.net/qq_20515461/article/details/107982341