esp32 vscode environment config

ESP32 Config

  1. 基础依赖
1xcode-select --install
2brew install cmake python
3brew link python
  1. .zshrc 配置
 1#python
 2export PATH="/usr/local/opt/python/bin:$PATH"
 3# iot config
 4export ESP32_GCC=/Users/$USER/software/esp32/xtensa-esp32-elf
 5export ESP32_C3_GCC=/Users/$USER/software/esp32c3/riscv32-esp-elf
 6export ESP8266_GCC=/Users/$USER/software/esp8266/xtensa-lx106-elf
 7export PATH=$PATH:$ESP8266_GCC/bin:$ESP32_GCC/bin:$ESP32_C3_GCC/bin:.
 8# esp32
 9alias get_esp32="export IDF_PATH=/Users/$USER/software/esp32/esp-idf; export PATH=/Users/$USER/software/esp32/esp-idf/tools:$PATH"
10# esp8266
11alias get_esp8266="export IDF_PATH=/Users/$USER/software/esp8266/ESP8266_RTOS_SDK; export PATH=/Users/$USER/software/esp8266/ESP8266_RTOS_SDK/tools:$PATH"
12# esp32-c3
13alias get_esp32_c3="export IDF_PATH=/Users/$USER/software/esp32c3/esp-idf; export PATH=/Users/$USER/software/esp32c3/esp-idf/tools:$PATH"
  1. 安装vscode插件Espressif IDF
  2. 按照提示配置esp-idf sdk配置
  3. Command + Shift + P输入esp-idf configure,输入本地已经下载的sdk、tools、gcc++等
  4. Command + Shift + P输入esp-idf example,选择demo。 需要指定位置。会将选择的项目copy到指定的目录下
  5. 启动的时候,会提示找不到IDF_PATH, 如果本地存在多个版本的SDK,在启动项目的时候会提示找不到$ENV{IDF_PATH}. 这时需要在项目中配置.vscode/settings.json文件中cmake的environment, cmake.environment
 1{
 2    "C_Cpp.intelliSenseEngine": "Tag Parser",
 3    "idf.adapterTargetName": "esp32",
 4    "idf.openOcdConfigs": [
 5      "interface/ftdi/esp32_devkitj_v1.cfg",
 6      "target/esp32.cfg"
 7    ],
 8    "cmake.environment": {
 9      "IDF_PATH": "/Users/$USER/software/esp32/esp-idf"
10    }
11}

参考信息