基于 Clion 的 ESP32 开发环境配置
在 Clion 中编辑代码,在 VSCode 中对代码进行调试。
版本说明
- ESP-IDF: v5.2
- Clion: 2023.2
准备工作
Toolchains 配置
-
新建一个 MinGW 配置,命名为
ESP-V520
-
写入
Cmake
以及Build Tools
的地址。
Cmake 配置
- 选择
Toolchain
为ESP-v520
- 配置
Environment
项目
在环境变量中添加IDF_PATH
以及PYTHON
变量
IDF_PATH
: C:\Users\Administrator\esp\v5.2\esp-idfPYTHON
: C:\Users\Administrator.espressif\python_env\idf5.2_py3.11_env\Scripts\python.exe- 在 Path 中添加以下环境变量,注意分号分隔符:
C:\Users\Administrator\esp\esp-idf\components\esptool_py\esptool;C:\Users\Administrator\esp\esp-idf\components\espcoredump;C:\Users\Administrator\esp\esp-idf\components\partition_table;C:\Users\Administrator\.espressif\tools\xtensa-esp-elf-gdb\12.1_20231023\xtensa-esp-elf-gdb\bin;C:\Users\Administrator\.espressif\tools\riscv32-esp-elf-gdb\12.1_20231023\riscv32-esp-elf-gdb\bin;C:\Users\Administrator\.espressif\tools\xtensa-esp32-elf\esp-12.2.0_20230208\xtensa-esp32-elf\bin;C:\Users\Administrator\.espressif\tools\xtensa-esp-elf\esp-13.2.0_20230928\xtensa-esp-elf\bin;C:\Users\Administrator\.espressif\tools\riscv32-esp-elf\esp-13.2.0_20230928\riscv32-esp-elf\bin;C:\Users\Administrator\.espressif\tools\esp32ulp-elf\2.35_20220830\esp32ulp-elf\bin;C:\Users\Administrator\.espressif\tools\cmake\3.24.0\bin;C:\Users\Administrator\.espressif\tools\openocd-esp32\v0.12.0-esp32-20230921\openocd-esp32\bin;C:\Users\Administrator\.espressif\tools\ninja\1.10.2;C:\Users\Administrator\.espressif\tools\idf-exe\1.0.3;C:\Users\Administrator\.espressif\tools\ccache\4.8\ccache-4.8-windows-x86_64;C:\Users\Administrator\.espressif\tools\dfu-util\0.11\dfu-util-0.11-win64;C:\Users\Administrator\.espressif\tools\esp-rom-elfs\20230320;C:\Users\Administrator\.espressif\python_env\idf5.1_py3.11_env\Scripts;C:\Users\Administrator\esp\esp-idf\tools;C:\Users\Administrator\.espressif\tools\idf-git\2.39.2\cmd;
运行 Cmake Reload 命令
运行成功后,日志如下:
C:\Users\Administrator\.espressif\tools\cmake\3.24.0\bin\cmake.exe -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=C:/Users/Administrator/.espressif/tools/ninja/1.11.1/ninja.exe -G Ninja -S D:\DesignWorkspace\EmbeddedWorkspace\ESP_IDF_EXAMPLE -B D:\DesignWorkspace\EmbeddedWorkspace\ESP_IDF_EXAMPLE\cmake-build-debug
-- Building ESP-IDF components for target esp32
-- Checking Python dependencies...
Python requirements are satisfied.
Constraint file: C:\Users\Administrator\.espressif\espidf.constraints.v5.2.txt
Requirement files:
- C:\Users\Administrator\esp\v5.2\esp-idf\tools\requirements\requirements.core.txt
Python being checked: C:\Users\Administrator\.espressif\python_env\idf5.2_py3.11_env\Scripts\python.exe
Processing 1 dependencies:
[1/1] idf (5.2.0)
-- Project sdkconfig file D:/DesignWorkspace/EmbeddedWorkspace/ESP_IDF_EXAMPLE/sdkconfig
-- Compiler supported targets: xtensa-esp-elf
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of time_t
-- Check size of time_t - done
-- Found Python3: C:/Users/Administrator/.espressif/python_env/idf5.2_py3.11_env/Scripts/python.exe (found version "3.11.2") found components: Interpreter
-- Performing Test C_COMPILER_SUPPORTS_WFORMAT_SIGNEDNESS
-- Performing Test C_COMPILER_SUPPORTS_WFORMAT_SIGNEDNESS - Success
-- App "ESP_IDF_EXAMPLE" version: 6a6aa52-dirty
-- Adding linker script D:/DesignWorkspace/EmbeddedWorkspace/ESP_IDF_EXAMPLE/cmake-build-debug/esp-idf/esp_system/ld/memory.ld
-- Adding linker script C:/Users/Administrator/esp/v5.2/esp-idf/components/esp_system/ld/esp32/sections.ld.in
-- Adding linker script C:/Users/Administrator/esp/v5.2/esp-idf/components/esp_rom/esp32/ld/esp32.rom.ld
-- Adding linker script C:/Users/Administrator/esp/v5.2/esp-idf/components/esp_rom/esp32/ld/esp32.rom.api.ld
-- Adding linker script C:/Users/Administrator/esp/v5.2/esp-idf/components/esp_rom/esp32/ld/esp32.rom.libgcc.ld
-- Adding linker script C:/Users/Administrator/esp/v5.2/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-data.ld
-- Adding linker script C:/Users/Administrator/esp/v5.2/esp-idf/components/esp_rom/esp32/ld/esp32.rom.syscalls.ld
-- Adding linker script C:/Users/Administrator/esp/v5.2/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-funcs.ld
-- Adding linker script C:/Users/Administrator/esp/v5.2/esp-idf/components/soc/esp32/ld/esp32.peripherals.ld
-- Components: BSP app app_trace app_update bootloader bootloader_support bt cmock console cxx driver dw1000 efuse esp-tls esp_adc esp_app_format esp_bootloader_format esp_coex esp_common esp_eth esp_event esp_gdbstub esp_hid esp_http_client esp_http_server esp_https_ota esp_https_server esp_hw_support esp_lcd esp_local_ctrl esp_mm esp_netif esp_netif_stack esp_partition esp_phy esp_pm esp_psram esp_ringbuf esp_rom esp_system esp_timer esp_wifi espcoredump esptool_py fatfs freertos hal hal_interface heap http_parser idf_test ieee802154 json log lvgl lvgl_drivers lwip main mbedtls mqtt newlib nvs_flash nvs_sec_provider openthread partition_table perfmon protobuf-c protocomm pthread sdmmc soc spi_flash spiffs tcp_transport ulp unity usb utils vfs wear_levelling wifi_provisioning wpa_supplicant xtensa
-- Component paths: D:/DesignWorkspace/EmbeddedWorkspace/ESP_IDF_EXAMPLE/components/BSP D:/DesignWorkspace/EmbeddedWorkspace/ESP_IDF_EXAMPLE/components/app C:/Users/Administrator/esp/v5.2/esp-idf/components/app_trace C:/Users/Administrator/esp/v5.2/esp-idf/components/app_update C:/Users/Administrator/esp/v5.2/esp-idf/components/bootloader C:/Users/Administrator/esp/v5.2/esp-idf/components/bootloader_support C:/Users/Administrator/esp/v5.2/esp-idf/components/bt C:/Users/Administrator/esp/v5.2/esp-idf/components/cmock C:/Users/Administrator/esp/v5.2/esp-idf/components/console C:/Users/Administrator/esp/v5.2/esp-idf/components/cxx C:/Users/Administrator/esp/v5.2/esp-idf/components/driver D:/DesignWorkspace/EmbeddedWorkspace/ESP_IDF_EXAMPLE/components/dw1000 C:/Users/Administrator/esp/v5.2/esp-idf/components/efuse C:/Users/Administrator/esp/v5.2/esp-idf/components/esp-tls C:/Users/Administrator/esp/v5.2/esp-idf/components/esp_adc C:/Users/Administrator/esp/v5.2/esp-idf/components/esp_app_format C:/Users/Administrator/esp/v5.2/esp-idf/components/esp_bootloader_format C:/Users/Administrator/esp/v5.2/esp-idf/components/esp_coex C:/Users/Administrator/esp/v5.2/esp-idf/components/esp_common C:/Users/Administrator/esp/v5.2/esp-idf/components/esp_eth C:/Users/Administrator/esp/v5.2/esp-idf/components/esp_event C:/Users/Administrator/esp/v5.2/esp-idf/components/esp_gdbstub C:/Users/Administrator/esp/v5.2/esp-idf/components/esp_hid C:/Users/Administrator/esp/v5.2/esp-idf/components/esp_http_client C:/Users/Administrator/esp/v5.2/esp-idf/components/esp_http_server C:/Users/Administrator/esp/v5.2/esp-idf/components/esp_https_ota C:/Users/Administrator/esp/v5.2/esp-idf/components/esp_https_server C:/Users/Administrator/esp/v5.2/esp-idf/components/esp_hw_support C:/Users/Administrator/esp/v5.2/esp-idf/components/esp_lcd C:/Users/Administrator/esp/v5.2/esp-idf/components/esp_local_ctrl C:/Users/Administrator/esp/v5.2/esp-idf/components/esp_mm C:/Users/Administrator/esp/v5.2/esp-idf/components/esp_netif C:/Users/Administrator/esp/v5.2/esp-idf/components/esp_netif_stack C:/Users/Administrator/esp/v5.2/esp-idf/components/esp_partition C:/Users/Administrator/esp/v5.2/esp-idf/components/esp_phy C:/Users/Administrator/esp/v5.2/esp-idf/components/esp_pm C:/Users/Administrator/esp/v5.2/esp-idf/components/esp_psram C:/Users/Administrator/esp/v5.2/esp-idf/components/esp_ringbuf C:/Users/Administrator/esp/v5.2/esp-idf/components/esp_rom C:/Users/Administrator/esp/v5.2/esp-idf/components/esp_system C:/Users/Administrator/esp/v5.2/esp-idf/components/esp_timer C:/Users/Administrator/esp/v5.2/esp-idf/components/esp_wifi C:/Users/Administrator/esp/v5.2/esp-idf/components/espcoredump C:/Users/Administrator/esp/v5.2/esp-idf/components/esptool_py C:/Users/Administrator/esp/v5.2/esp-idf/components/fatfs C:/Users/Administrator/esp/v5.2/esp-idf/components/freertos C:/Users/Administrator/esp/v5.2/esp-idf/components/hal D:/DesignWorkspace/EmbeddedWorkspace/ESP_IDF_EXAMPLE/components/hal_interface C:/Users/Administrator/esp/v5.2/esp-idf/components/heap C:/Users/Administrator/esp/v5.2/esp-idf/components/http_parser C:/Users/Administrator/esp/v5.2/esp-idf/components/idf_test C:/Users/Administrator/esp/v5.2/esp-idf/components/ieee802154 C:/Users/Administrator/esp/v5.2/esp-idf/components/json C:/Users/Administrator/esp/v5.2/esp-idf/components/log D:/DesignWorkspace/EmbeddedWorkspace/ESP_IDF_EXAMPLE/components/lvgl D:/DesignWorkspace/EmbeddedWorkspace/ESP_IDF_EXAMPLE/components/lvgl_drivers C:/Users/Administrator/esp/v5.2/esp-idf/components/lwip D:/DesignWorkspace/EmbeddedWorkspace/ESP_IDF_EXAMPLE/main C:/Users/Administrator/esp/v5.2/esp-idf/components/mbedtls C:/Users/Administrator/esp/v5.2/esp-idf/components/mqtt C:/Users/Administrator/esp/v5.2/esp-idf/components/newlib C:/Users/Administrator/esp/v5.2/esp-idf/components/nvs_flash C:/Users/Administrator/esp/v5.2/esp-idf/components/nvs_sec_provider C:/Users/Administrator/esp/v5.2/esp-idf/components/openthread C:/Users/Administrator/esp/v5.2/esp-idf/components/partition_table C:/Users/Administrator/esp/v5.2/esp-idf/components/perfmon C:/Users/Administrator/esp/v5.2/esp-idf/components/protobuf-c C:/Users/Administrator/esp/v5.2/esp-idf/components/protocomm C:/Users/Administrator/esp/v5.2/esp-idf/components/pthread C:/Users/Administrator/esp/v5.2/esp-idf/components/sdmmc C:/Users/Administrator/esp/v5.2/esp-idf/components/soc C:/Users/Administrator/esp/v5.2/esp-idf/components/spi_flash C:/Users/Administrator/esp/v5.2/esp-idf/components/spiffs C:/Users/Administrator/esp/v5.2/esp-idf/components/tcp_transport C:/Users/Administrator/esp/v5.2/esp-idf/components/ulp C:/Users/Administrator/esp/v5.2/esp-idf/components/unity C:/Users/Administrator/esp/v5.2/esp-idf/components/usb D:/DesignWorkspace/EmbeddedWorkspace/ESP_IDF_EXAMPLE/components/utils C:/Users/Administrator/esp/v5.2/esp-idf/components/vfs C:/Users/Administrator/esp/v5.2/esp-idf/components/wear_levelling C:/Users/Administrator/esp/v5.2/esp-idf/components/wifi_provisioning C:/Users/Administrator/esp/v5.2/esp-idf/components/wpa_supplicant C:/Users/Administrator/esp/v5.2/esp-idf/components/xtensa
-- Configuring done
-- Generating done
-- Build files have been written to: D:/DesignWorkspace/EmbeddedWorkspace/ESP_IDF_EXAMPLE/cmake-build-debug
[Finished]