基于 Clion 的 ESP32 开发环境配置

基于 Clion 的 ESP32 开发环境配置

在 Clion 中编辑代码,在 VSCode 中对代码进行调试。

版本说明

  • ESP-IDF: v5.2
  • Clion: 2023.2

准备工作

Toolchains 配置

  1. 新建一个 MinGW 配置,命名为 ESP-V520
    在这里插入图片描述

  2. 写入 Cmake 以及 Build Tools 的地址。
    在这里插入图片描述

Cmake 配置

  1. 选择 ToolchainESP-v520
    在这里插入图片描述
  2. 配置 Environment 项目
    在这里插入图片描述
    在环境变量中添加 IDF_PATH 以及 PYTHON 变量
  • IDF_PATH: C:\Users\Administrator\esp\v5.2\esp-idf
  • PYTHON: 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]
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
好的,下面是搭建ESP32开发环境的步骤: 1. 安装ESP-IDF 首先需要下载和安装ESP-IDF(ESP32 IoT Development Framework)。可以在以下链接中找到最新版本的ESP-IDF:https://github.com/espressif/esp-idf/releases 下载后解压到合适的位置,并设置环境变量IDF_PATH,以便后续使用。 2. 安装CLion CLion是一款非常优秀的跨平台C/C++开发工具,可以在JetBrains官网下载:https://www.jetbrains.com/clion/ 安装完成后,打开CLion,并安装ESP32插件,方法如下: - 在File -> Settings -> Plugins中搜索ESP32,并安装。 - 安装完成后,重启CLion。 3. 创建ESP32项目 打开CLion,选择Create New Project,然后选择ESP32 Project,填写项目信息,如下图所示: 在下一步中,可以选择使用默认的ESP-IDF路径,也可以修改为自己的ESP-IDF路径。 在选择完ESP-IDF路径后,可以根据需要选择其他配置,如下图所示: 最后,点击Finish按钮,CLion会自动创建ESP32项目。 4. 配置编译和烧录环境 在CLion中,可以使用CMake来管理编译和烧录环境。在ESP32项目中,需要配置CMakeLists.txt文件,以便正确编译和烧录代码。 具体的配置方法可以参考ESP-IDF官方文档:https://docs.espressif.com/projects/esp-idf/en/latest/get-started-cmake/index.html 5. 编写代码 在CLion中,可以使用C/C++的代码编辑器来编写ESP32代码。同时,ESP32插件也提供了一些ESP32特有的API和示例代码,可以方便地进行开发调试。 6. 编译和烧录代码 在CLion中,可以使用CMake来编译ESP32代码,并使用ESP-IDF提供的烧录工具来烧录代码到ESP32开发板中。 具体的编译和烧录方法可以参考ESP-IDF官方文档:https://docs.espressif.com/projects/esp-idf/en/latest/get-started/index.html 以上就是在CLion中搭建ESP32开发环境的步骤,希望能对你有所帮助。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值