1 Star 0 Fork 280

wjj232 / esp-idf

forked from 乐鑫开源 / esp-idf 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

Espressif 物联网开发框架

ESP-IDF 是乐鑫官方推出的物联网开发框架,支持 Windows、Linux 和 macOS 操作系统。

ESP-IDF 版本支持期限

支持期限

ESP-IDF 与乐鑫芯片

下表总结了乐鑫芯片在 ESP-IDF 各版本中的支持状态,其中 alt text 代表已支持,alt text 代表目前处于预览支持状态。预览支持状态通常有时间限制,而且仅适用于测试版芯片。请确保使用与芯片相匹配的 ESP-IDF 版本。

芯片 v4.1 v4.2 v4.3 v4.4 v5.0 v5.1
ESP32 alt text alt text alt text alt text alt text alt text
ESP32-S2 alt text alt text alt text alt text alt text
ESP32-C3 alt text alt text alt text alt text
ESP32-S3 alt text alt text alt text 芯片发布公告
ESP32-C2 alt text alt text 芯片发布公告
ESP32-C6 alt text 芯片发布公告
ESP32-H2 alt text alt text alt text 芯片发布公告

对于 2016 年之前发布的乐鑫芯片(包括 ESP8266 和 ESP8285),请参考 RTOS SDK

使用 ESP-IDF 进行开发

搭建 ESP-IDF 开发环境

关于不同芯片如何搭建 ESP-IDF 的开发环境,请参考 https://idf.espressif.com/

注意: 不同系列芯片和不同 ESP-IDF 版本都有其对应的文档。请参阅版本部分,获得关于如何查找文档以及如何检出 ESP-IDF 的特定发行版的详细信息。

非 GitHub 分叉的 ESP-IDF 项目

ESP-IDF 中的子模块采用相对路径(详见 .gitmodules 文件),所以它们会指向 GitHub。 如果 ESP-IDF 被分叉到的仓库不在 GitHub 上,那么你需要在克隆结束后运行该脚本 tools/set-submodules-to-github.sh

这个脚本会为所有的子模块设置绝对路径,接着可以通过 git submodule update --init --recursive 完成子模块的更新。如果 ESP-IDF 是从 GitHub 上克隆得到,则不需要此步骤。

寻找项目

除了入门指南中提到的 esp-idf 模板项目,ESP-IDF 的 examples 目录下还带有很多其它示例项目。

一旦找到了需要的项目,便可以进入该目录,执行配置和构建操作。

如果要基于示例工程开始你自己的项目,请将示例工程复制到 ESP-IDF 目录之外。

快速参考

详细的使用方法请参考上面入门指南的链接,这里仅仅列举一些 ESP-IDF 项目开发中常用的命令:

设置构建环境

请参考入门指南中列出的详细步骤。

  • 在主机中安装入门指南中提到的构建所依赖的工具。
  • 运行安装脚本来设置构建环境。可为 Windows shell 选择 install.batinstall.ps1,为 Unix shell 选择 install.shinstall.fish
  • 在使用 ESP-IDF 之前,需要在 shell 中运行导出脚本。Windows 下可运行 export.bat,Unix 下可运行 source export.sh

配置项目

  • idf.py set-target <chip_name> 可将项目的目标芯片设置为 <chip_name>。运行 idf.py set-target,不用带任何参数,可查看所有支持的目标芯片列表。
  • idf.py menuconfig 可打开一个基于文本的配置菜单,可以用来对项目进行配置。

编译项目

idf.py build

编译应用程序,引导程序,并根据配置生成分区表。

烧写项目

当构建结束,终端会打印出一条命令行,告知如何使用 esptool.py 工具烧写项目到芯片中。但你也可以运行下面这条命令来自动烧写:

idf.py -p PORT flash

将其中的 PORT 替换为系统中实际串口的名字(比如 Windows 下的 COM3,Linux 下的 /dev/ttyUSB0,或者 macOS 下的 /dev/cu.usbserial-X。如果省略 -p 选项,idf.py flash 会尝试使用第一个可用的串口进行烧写。

这会烧写整个项目(包括应用程序,引导程序和分区表)到芯片中,此外还可以使用 idf.py menuconfig 来调整串口烧写相关的配置。

不必先运行 idf.py build 再运行 idf.py flashidf.py flash 会根据需要自动重新构建项目。

观察串口输入

idf.py monitor 会调用 idf_monitor 工具来显示乐鑫芯片的串口输出。idf_monitor 还包含一系列的功能来解析程序崩溃后的输出结果并与设备进行交互。更多详细内容,请参阅文档.

输入 Ctrl-] 可退出监视器。

想要一次性执行构建、烧写和监视,可以运行如下命令:

idf.py flash monitor

仅编译并烧写应用程序

在第一次烧写过后,你可能只想构建并烧写你的应用程序,不包括引导程序和分区表:

  • idf.py app - 仅构建应用程序。
  • idf.py app-flash - 仅烧写应用程序。

idf.py app-flash 会自动判断是否有源文件发生了改变然后重新构建应用程序。

(在正常的开发中,即使引导程序和分区表没有发生变化,每次都重新烧写它们并不会带来什么危害。)

擦除 Flash

idf.py flash 并不会擦除 flash 上所有的内容,但是有时候我们需要设备恢复到完全擦除的状态,尤其是分区表发生了变化或者 OTA 应用升级时。要擦除整块 flash 请运行 idf.py erase-flash

这条命令还可以和其余命令整合在一起,idf.py -p PORT erase-flash flash 会擦除一切然后重新烧写新的应用程序、引导程序和分区表。

其它参考资源

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

ESP-IDF 是由乐鑫官方推出的针对 ESP32 和 ESP32-S2 系列芯片的开发框架。ESP-IDF 国内镜像仓库,Issues 和 PRs 请仍旧提交到 github。 重要:Gitee 中 ESP-IDF 仓库的使用,请先参看 https://gitee.com/EspressifSystems/esp-gitee-tools 中的说明文档。ESP-IDF 及其子模块,每日会自动同步若干次。 展开 收起
C
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C
1
https://gitee.com/wjj232/esp-idf.git
git@gitee.com:wjj232/esp-idf.git
wjj232
esp-idf
esp-idf
master

搜索帮助

14c37bed 8189591 565d56ea 8189591