ESP-IDF 安装与剪裁

开发工具安装

离线安装包下载地址:https://dl.espressif.cn/dl/esp-idf/ 需要选择Espressif IDE with ESP-IDF,该选项的离线包集成了Eclipse开发环境,安装完就可以直接使用。

虽然是离线安装包,但安装时根据你选择的芯片类型,有些芯片还是需要需要联网,且需要保证网络能正常访问github
image

对于ESP32,ESP32S2,ESP32S3:
因为离线安装工具不包含esp32ulp-elf,esp32ulp是esp32, esp32s2, esp32s3集成的一个低功耗专用内核的编译器,因此安装的最后需要链接到Github进行下载,如果下载中断则会安装失败(安装失败请手动添加下图ESP-IDF4.4 CMD内显示的环境变量值)。

对于ESP32C3:
因为esp32c3没有低功耗专用内核,只需要的riscv32-esp-elf编译器已经包含在离线安装包内,就可用不联网了。

安装成功会自动添加PATH环境变量,如果最后一步下载esp32ulp失败导致安装过程中断的,需要手动添加。

首次运行建议断开电脑网络,创建一个esp32样例工程,进行编译,从日志窗口可以看到,espidf会使用.git目录的资源自动更新一些内置的组件。
image
image

移除Git工具检查

update 2023-02-05:
对于espid2.7 + espidf5.0,下面的涉及的cmake文件行号变了,但要删除的内容还是一样的。

如果不想让espidf每次编译前都访问github检查组件更新情况,可以删除esp-idf-v4.4.2目录下的.git .github .gitlab这三个文件夹,或者把git.exe从环境变量移除。
但这样每次cleanbuild项目都会有下面的警告:
image
因此还需要改动下编译相关的cmake文件。
错误信息出现在git_submodules.cmake

if(NOT GIT_FOUND)
    message(WARNING "Git executable was not found. Git submodule checks will not be executed. "
        "If you have any build issues at all, start by adding git executable to the PATH and "
        "rerun cmake to not see this warning again.")

    function(git_submodule_check root_path)
        # no-op
    endfunction()
else()

根据输出日志的Call Stack 信息,找到报错的调用链:
project.cmake第12行包含了idf.cmake

# The mere inclusion of this CMake file sets up some interal build properties.
# These properties can be modified in between this inclusion the the idf_build_process
# call.
include(${CMAKE_CURRENT_LIST_DIR}/idf.cmake)

idf.cmake第39行引入了git_submodules

    include(git_submodules)

删除idf.cmake第39行
image
再次执行build或者clean操作,发现build.cmake还有使用到git_submodules.cmake
image
删除build.cmake第77行
image
警告消失了
image
最后直接删除git_submodules.cmake文件。
image

修改工程目录字体

默认的ProjectExplorer比较小,修改方式和普通eclipse一样:
进入Espressif\tools\espressif-ide\2.6.0\plugins\org.eclipse.ui.themes_1.2.1800.v20220316-1102\css
暗色主题下,打开e4-dark_win.css添加下面的内容即可。

CTabFolder Tree{
    font-size: 15px;
}

移除无用组件

ESP-IDF自带组件路径:\Espressif\frameworks\esp-idf-v4.4.3\components,推荐将components文件夹整个压缩备份,当以后使用到已删除的组件时,可进行还原操作。
image

posted @ 2023-02-05 19:47  Yanye  阅读(578)  评论(0编辑  收藏  举报