ESP-IDF编译系统详解(1)

接前一篇文章:VSCode + ESP-IDF安装与配置全过程

本文内容主要参考:

《ESP32-C3物联网工程开发实战》 —— 乐鑫科技 编著

特此致谢!

前文已经详述了ESP-IDF开发环境的搭建,包括ESP-IDF的下载与安装完整流程,以及VSCode + ESP-IDF的安装与配置。本文对于ESP-IDF编译系统进行详解。

1. 编译系统基本概念

ESP-IDF工程是一个包含入口函数的主程序多个独立功能组件的集合。例如,一个控制LED开关的项目主要包含一个入口函数main和控制GPIO的driver组件。如果要实现LED远程控制功能,则还需要额外添加Wi-Fi、TCP/IP协议栈等。

编译系统通过一套构建规则可对代码进行编译、链接,并生成可执行文件(.bin)。ESP-IDF v4.0及以上版本的编译系统默认以CMake为基础搭建,编译脚本CMakeLists.txt可用于控制代码的编译行为ESP-IDF编译系统除了支持CMake基础语法外,还定义了一套默认的编译规则和CMake函数,用户使用简单的语句即可完成编译脚本的编写

2. 工程文件结构

工程(Project,也称为项目)是指一个包含入口函数main用户自定义组件,以及构建可执行应用程序所需的编译脚本、配置文件、分区表等文件的文件夹。工程可以被复制和传递,并可在安装了相同版本ESP-IDF开发环境的机器中编译生成相同的可执行文件。

笔者之前建立的VSCODE+ESP-IDF的工程结构如下所示:

  • main目录内容

  • build目录内容

由于ESP-IDF具有跨芯片平台的特性,同时支持乐鑫的多款物联网芯片,包括ESP32、ESP32-S系列、ESP32-C系列、ESP32-H系列等,因此在编译代码之前,需要确定一个目标此目标既是运行应用程序的硬件设备,也是编译系统的生成目标

工程可以指定编译目标,也可以同时兼容多种目标,在编译时由用户选择。例如,可以通过命令“idf.py set-target esp32c3”将编译目标设置为ESP-C3,期间将加载针对ESP32-C3的默认参数和编译工具链路径,经过编译后即可为ESP32-C3生成可执行程序。用户也可以再次运行set-target命令来设置其它目标,编译系统将自动清理并重新进行配置。

这里,分别给出通过ESP-IDF命令行方式和VSCode+ESP-IDF方式执行set-target命令的实际操作。

  • ESP-IDF命令行方式

实际命令及结果如下:

C:\Users\ns\esp32\helloworld>idf.py set-target esp32-c3
Adding "set-target"'s dependency "fullclean" to list of commands with default set of options.
Executing action: fullclean
Executing action: set-target
Set Target to: esp32c3, new sdkconfig will be created.
Running cmake in directory C:\Users\ns\esp32\helloworld\build
Executing "cmake -G Ninja -DPYTHON_DEPS_CHECKED=1 -DPYTHON=C:\Espressif\python_env\idf5.2_py3.11_env\Scripts\python.exe -DESP_PLATFORM=1 -DIDF_TARGET=esp32c3 -DCCACHE_ENABLE=1 C:\Users\ns\esp32\helloworld"...
-- Existing sdkconfig 'C:/Users/ns/esp32/helloworld/sdkconfig' renamed to 'C:/Users/ns/esp32/helloworld/sdkconfig.old'.
-- Found Git: C:/Espressif/tools/idf-git/2.43.0/cmd/git.exe (found version "2.43.0.windows.1")
-- ccache will be used for faster recompilation
-- The C compiler identification is GNU 13.2.0
-- The CXX compiler identification is GNU 13.2.0
-- The ASM compiler identification is GNU
-- Found assembler: C:/Espressif/tools/riscv32-esp-elf/esp-13.2.0_20230928/riscv32-esp-elf/bin/riscv32-esp-elf-gcc.exe
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Espressif/tools/riscv32-esp-elf/esp-13.2.0_20230928/riscv32-esp-elf/bin/riscv32-esp-elf-gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Espressif/tools/riscv32-esp-elf/esp-13.2.0_20230928/riscv32-esp-elf/bin/riscv32-esp-elf-g++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- git rev-parse returned 'fatal: not a git repository (or any of the parent directories): .git'
-- Could not use 'git describe' to determine PROJECT_VER.
-- Building ESP-IDF components for target esp32c3
-- Project sdkconfig file C:/Users/ns/esp32/helloworld/sdkconfig
-- 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:/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 "hello_world" version: 1
-- Adding linker script C:/Users/ns/esp32/helloworld/build/esp-idf/esp_system/ld/memory.ld
-- Adding linker script C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_system/ld/esp32c3/sections.ld.in
-- Adding linker script C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_rom/esp32c3/ld/esp32c3.rom.ld
-- Adding linker script C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_rom/esp32c3/ld/esp32c3.rom.api.ld
-- Adding linker script C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_rom/esp32c3/ld/esp32c3.rom.libgcc.ld
-- Adding linker script C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_rom/esp32c3/ld/esp32c3.rom.newlib.ld
-- Adding linker script C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_rom/esp32c3/ld/esp32c3.rom.version.ld
-- Adding linker script C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_rom/esp32c3/ld/esp32c3.rom.eco3.ld
-- Adding linker script C:/Espressif/frameworks/esp-idf-v5.2.1/components/soc/esp32c3/ld/esp32c3.peripherals.ld
-- Components: app_trace app_update bootloader bootloader_support bt cmock console cxx driver 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 heap http_parser idf_test ieee802154 json log lwip main mbedtls mqtt newlib nvs_flash nvs_sec_provider openthread partition_table protobuf-c protocomm pthread riscv sdmmc soc spi_flash spiffs tcp_transport ulp unity usb vfs wear_levelling wifi_provisioning wpa_supplicant
-- Component paths: C:/Espressif/frameworks/esp-idf-v5.2.1/components/app_trace C:/Espressif/frameworks/esp-idf-v5.2.1/components/app_update C:/Espressif/frameworks/esp-idf-v5.2.1/components/bootloader C:/Espressif/frameworks/esp-idf-v5.2.1/components/bootloader_support C:/Espressif/frameworks/esp-idf-v5.2.1/components/bt C:/Espressif/frameworks/esp-idf-v5.2.1/components/cmock C:/Espressif/frameworks/esp-idf-v5.2.1/components/console C:/Espressif/frameworks/esp-idf-v5.2.1/components/cxx C:/Espressif/frameworks/esp-idf-v5.2.1/components/driver C:/Espressif/frameworks/esp-idf-v5.2.1/components/efuse C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp-tls C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_adc C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_app_format C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_bootloader_format C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_coex C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_common C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_eth C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_event C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_gdbstub C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_hid C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_http_client C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_http_server C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_https_ota C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_https_server C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_hw_support C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_lcd C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_local_ctrl C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_mm C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_netif C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_netif_stack C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_partition C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_phy C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_pm C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_psram C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_ringbuf C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_rom C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_system C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_timer C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_wifi C:/Espressif/frameworks/esp-idf-v5.2.1/components/espcoredump C:/Espressif/frameworks/esp-idf-v5.2.1/components/esptool_py C:/Espressif/frameworks/esp-idf-v5.2.1/components/fatfs C:/Espressif/frameworks/esp-idf-v5.2.1/components/freertos C:/Espressif/frameworks/esp-idf-v5.2.1/components/hal C:/Espressif/frameworks/esp-idf-v5.2.1/components/heap C:/Espressif/frameworks/esp-idf-v5.2.1/components/http_parser C:/Espressif/frameworks/esp-idf-v5.2.1/components/idf_test C:/Espressif/frameworks/esp-idf-v5.2.1/components/ieee802154 C:/Espressif/frameworks/esp-idf-v5.2.1/components/json C:/Espressif/frameworks/esp-idf-v5.2.1/components/log C:/Espressif/frameworks/esp-idf-v5.2.1/components/lwip C:/Users/ns/esp32/helloworld/main C:/Espressif/frameworks/esp-idf-v5.2.1/components/mbedtls C:/Espressif/frameworks/esp-idf-v5.2.1/components/mqtt C:/Espressif/frameworks/esp-idf-v5.2.1/components/newlib C:/Espressif/frameworks/esp-idf-v5.2.1/components/nvs_flash C:/Espressif/frameworks/esp-idf-v5.2.1/components/nvs_sec_provider C:/Espressif/frameworks/esp-idf-v5.2.1/components/openthread C:/Espressif/frameworks/esp-idf-v5.2.1/components/partition_table C:/Espressif/frameworks/esp-idf-v5.2.1/components/protobuf-c C:/Espressif/frameworks/esp-idf-v5.2.1/components/protocomm C:/Espressif/frameworks/esp-idf-v5.2.1/components/pthread C:/Espressif/frameworks/esp-idf-v5.2.1/components/riscv C:/Espressif/frameworks/esp-idf-v5.2.1/components/sdmmc C:/Espressif/frameworks/esp-idf-v5.2.1/components/soc C:/Espressif/frameworks/esp-idf-v5.2.1/components/spi_flash C:/Espressif/frameworks/esp-idf-v5.2.1/components/spiffs C:/Espressif/frameworks/esp-idf-v5.2.1/components/tcp_transport C:/Espressif/frameworks/esp-idf-v5.2.1/components/ulp C:/Espressif/frameworks/esp-idf-v5.2.1/components/unity C:/Espressif/frameworks/esp-idf-v5.2.1/components/usb C:/Espressif/frameworks/esp-idf-v5.2.1/components/vfs C:/Espressif/frameworks/esp-idf-v5.2.1/components/wear_levelling C:/Espressif/frameworks/esp-idf-v5.2.1/components/wifi_provisioning C:/Espressif/frameworks/esp-idf-v5.2.1/components/wpa_supplicant
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/ns/esp32/helloworld/build
  • VSCode+ESP-IDF方式

实际图形配置界面及结果如下图所示:

更多内容请看下回。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/577401.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

【Docker】Docker 实践(一):在 Docker 中部署第一个应用

Docker 实践(一):在 Docker 中部署第一个应用 1.使用 YUM 方式安装 Docker2.验证 Docker 环境3.在 Docker 中部署第一个应用3.1 小插曲:docker pull 报 missing signature key 错误3.2 重新安装 Nginx 1.使用 YUM 方式安装 Docker…

MySQL中脏读与幻读

一般对于我们的业务系统去访问数据库而言,它往往是多个线程并发执行多个事务的,对于数据库而言,它会有多个事务同时执行,可能这多个事务还会同时更新和查询同一条数据,所以这里会有一些问题需要数据库来解决 我们来看…

IoT Scenario: Smart Retail System-Multiple Sources and Multiple Terminals

物联网/大数据可视化领域发文可以联系:nascimsina.com IoT Scenario: Smart Retail System Overview The use of IoT in the retail industry enhances customer experiences, optimizes inventory management, and provides valuable insights into consumer beh…

【HarmonyOS】Stage 模型 - 基本概念

一、项目结构 如图1所示: 图1 从项目结构来看,这个应用的内部包含了一个子模块叫 entry,模块是应用的基本功能单元,它里面包含源代码、资源、配置文件等。 像这样的模块在应用内部可以创建很多。但模块整体来讲就分成两大类&am…

js 实现记住密码功能

这是我弄得一点源码 使用 js 记住密码 选了半天最后 选择了 js.cookie.min.js 实现的 当然 也加了一点 加密手段 用的 crypto-js 这个 自己封装了一下 感觉还行 以后能重复用的 二话不说 先放资源 : 这么多资源 不得给个赞 关注一下的 当然 最简单的就是…

拖拽式工作流开发有什么突出优势?

想要实现高效率的办公方式,可以试着了解低代码技术平台及拖拽式工作流开发的优势特点。具有好操作、好维护、够灵活、可视化界面操作等优势特点的低代码技术平台可以助力企业实现流程化办公,在发展越来越快速的今天,拖拽式工作流开发得到了很…

陪丨玩丨系丨统前后端开发流程,APP小程序H5前后端源码交付支持二开!多人语音,开黑,线上线下两套操作可在一个系统完成!

100%全部源码出售 官网源码APP源码 管理系统源码 终身免费售后 产品免费更新 产品更新频率高 让您时刻立足于行业前沿 软件开发流程步骤及其作用: 软件开发是一个复杂而系统的过程,涉及多个环节,以下是软件开发的主要流程步骤及其作用…

小程序使用阿里巴巴矢量图标库

一、登录官网 www.iconfont.cn 二、在搜索框中搜索想要的图标,将鼠标移动到图标上会看到三个标记 可以使用下载,直接使用: 可以使用css文件使用: 首先点击购物车样式的选项,而后点击下图位置: 点击自己创…

怎么排查K8S容器当中的Java程序内存泄露问题

今天早上发现生产线其中的一个服务在凌晨的时候突然重启了,内存突然从1G升到1.8G,CPU使用量从0.1升到了0.28,说明在这个时间点,内存突增达到了限额以上,服务重启了。因为这个服务布署了多节点,这次重启对业…

实验7:路由冗余协议HSRP配置管理(课内实验以及解答)

实验目的及要求: 理解首跳冗余协议(FHRP)的工作原理,掌握热备份路由器协议 (HSRP)(思科私有协议)原理和配置。能够实现网络终端设备虚拟网关的配置和网络故障的灵活切换,完成相应网络的联通性测…

ubuntu samba 安装与配置

ubuntu samba 安装与配置 一:安装二:添加samba访问账号及密码三:修改配置文件四:重启服务五:登录 一:安装 sudo apt update sudo apt install samba samba-common二:添加samba访问账号及密码 …

链表与模拟LinkedList的实现

1. ArrayList的缺陷 ArrayList底层使用数组来存储元素 由于其底层是一段连续空间,当在ArrayList任意位置插入或者删除元素时,就需要将后序元素整体往前或者往后 搬移,时间复杂度为O(n),效率比较低。因此ArrayList不适合做任意位…

Restful API 具体设计规范(概述)

协议 https 域名 https://www.baidu.com/api 版本 https://www.baidu.com/v1 路径 https://www.baidu.com/v1/blogs 方法 数据过滤 状态码返回结果 返回的数据格式 尽量使用 JSON,避免使用 XML。 总结: 看 url 就知道要什么看 http method 就知道干…

【面试经典 150 | 二叉树】二叉搜索树迭代器

文章目录 写在前面Tag题目来源解题思路方法一:中序遍历到数组方法二:迭代 写在最后 写在前面 本专栏专注于分析与讲解【面试经典150】算法,两到三天更新一篇文章,欢迎催更…… 专栏内容以分析题目为主,并附带一些对于本…

记录wordpress网站搭建及当天被SEO优化收录

网站是前不就前搭建的,但是一直没有做SEO优化,今天花了点时间做下优化。记录下,喜欢的朋友点赞收藏下。 1.wordpress后台下载插件Yoast SEO插件,setting中搜索XML sitemaps,点view the XML sitemap,暂时不…

【Ant-Desgin 头像上传框】限制数量为1张图片,base64,其他需求可以改我组件中的代码

Ant-Desgin 头像上传框 样式图参数主要代码UpLoad 组件父组件 样式图 图片数量限制为1,当选择了图片后,需要切换图像时需点击头像完成切换 参数 /*** description: 图片上传组件* param {*} action: 上传地址* param {*} width: 宽度* param {*} height…

【网络技术】【Kali Linux】Wireshark嗅探(十一)以太网Ethernet协议报文捕获及分析

往期 Kali Linux 上的 Wireshark 嗅探实验见博客: 【网络技术】【Kali Linux】Wireshark嗅探(一)ping 和 ICMP 【网络技术】【Kali Linux】Wireshark嗅探(二)TCP 协议 【网络技术】【Kali Linux】Wireshark嗅探&…

Eagle for Mac:强大的图片管理工具

Eagle for Mac是一款专为Mac用户设计的图片管理工具,旨在帮助用户更高效、有序地管理和查找图片资源。 Eagle for Mac v1.9.2中文版下载 Eagle支持多种图片格式,包括JPG、PNG、GIF、SVG、PSD、AI等,无论是矢量图还是位图,都能以清…

SnapGene Mac v5.3.1中文激活版:综合性分子生物学软件

SnapGene Mac是一款功能全面、操作便捷的综合性分子生物学软件,专为Mac用户打造。它集成了DNA序列编辑、分析、可视化和团队协作等多种功能,为科研人员提供了一个高效、可靠的分子生物学研究工具。 SnapGene Mac v5.3.1中文激活版下载 在SnapGene Mac中&…

Spring Boot 3.2.5 集成 MyBatisPlus

前置条件&#xff0c;先连接好数据库&#xff0c;并且数据库里新建表插入几条数据 连接mysql传送门 版本 Spring Boot 3.2.5 第一步&#xff0c;添加依赖 <dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-spring-boot3-start…
最新文章