|
|
@@ -1,22 +1,20 @@
|
|
|
-*******************
|
|
|
-快速入门(CMake)
|
|
|
-*******************
|
|
|
+***********
|
|
|
+快速入门
|
|
|
+***********
|
|
|
|
|
|
:link_to_translation:`en:[English]`
|
|
|
|
|
|
-本文档旨在指导用户搭建 ESP32 硬件开发的软件环境,
|
|
|
-
|
|
|
-通过一个简单的示例展示如何使用 ESP-IDF (Espressif IoT Development Framework) 配置菜单,并编译、下载固件至 ESP32 开发板等步骤。
|
|
|
+本文档旨在指导用户搭建 ESP32 硬件开发的软件环境,通过一个简单的示例展示如何使用 ESP-IDF (Espressif IoT Development Framework) 配置菜单,并编译、下载固件至 ESP32 开发板等步骤。
|
|
|
|
|
|
.. include:: /_build/inc/version-note.inc
|
|
|
|
|
|
概述
|
|
|
-====
|
|
|
+============
|
|
|
|
|
|
ESP32 SoC 芯片支持以下功能:
|
|
|
|
|
|
* 2.4 GHz Wi-Fi
|
|
|
-* 蓝牙 4.2 标准
|
|
|
+* 蓝牙 4.2
|
|
|
* 高性能双核
|
|
|
* 超低功耗协处理器
|
|
|
* 多种外设
|
|
|
@@ -26,18 +24,18 @@ ESP32 采用 40 nm 工艺制成,具有最佳的功耗性能、射频性能、
|
|
|
乐鑫为用户提供完整的软、硬件资源,进行 ESP32 硬件设备的开发。其中,乐鑫的软件开发环境 ESP-IDF 旨在协助用户快速开发物联网 (IoT) 应用,可满足用户对 Wi-Fi、蓝牙、低功耗等方面的要求。
|
|
|
|
|
|
准备工作
|
|
|
-========
|
|
|
+=============
|
|
|
|
|
|
硬件:
|
|
|
|
|
|
* 一款 **ESP32** 开发板
|
|
|
-* **USB 数据线** (USB A/Micro USB B)
|
|
|
+* **USB 数据线** (A 转 Micro-B)
|
|
|
* PC(Windows、Linux 或 Mac OS)
|
|
|
|
|
|
软件:
|
|
|
|
|
|
* 设置 **工具链**,用于编译 ESP32 代码;
|
|
|
-* **编译工具** —— CMake 和 Ninja 编译工具,用于编译 ESP32 **应用程序**;
|
|
|
+* **编译工具** —— CMake 和 Ninja 编译工具,用于编译 ESP32 **应用程序**;
|
|
|
* 获取 **ESP-IDF** 软件开发框架。该框架已经基本包含 ESP32 使用的 API(软件库和源代码)和运行 **工具链** 的脚本;
|
|
|
* 安装 C 语言编程(**工程**)的 **文本编辑器**,例如 `Eclipse <https://www.eclipse.org/>`_。
|
|
|
|
|
|
@@ -51,7 +49,7 @@ ESP32 采用 40 nm 工艺制成,具有最佳的功耗性能、射频性能、
|
|
|
|
|
|
|
|
|
开发板简介
|
|
|
-==========
|
|
|
+===========================
|
|
|
|
|
|
请点击下方连接,了解有关具体开发板的详细信息。
|
|
|
|
|
|
@@ -67,17 +65,17 @@ ESP32 采用 40 nm 工艺制成,具有最佳的功耗性能、射频性能、
|
|
|
.. _get-started-step-by-step:
|
|
|
|
|
|
详细安装步骤
|
|
|
-==============
|
|
|
+=========================
|
|
|
|
|
|
请根据下方详细步骤,完成安装过程。
|
|
|
|
|
|
设置开发环境
|
|
|
-~~~~~~~~~~~~~~~~
|
|
|
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
-* :ref:`get-started-setup-toolchain`
|
|
|
+* :ref:`get-started-get-prerequisites` (:doc:`Windows <windows-setup>` 、:doc:`Linux <linux-setup>` 和 :doc:`macOS <macos-setup>`)
|
|
|
* :ref:`get-started-get-esp-idf`
|
|
|
-* :ref:`get-started-setup-path`
|
|
|
-* :ref:`get-started-get-packages`
|
|
|
+* :ref:`get-started-set-up-tools`
|
|
|
+* :ref:`get-started-set-up-env`
|
|
|
|
|
|
创建您的第一个工程
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
@@ -90,14 +88,12 @@ ESP32 采用 40 nm 工艺制成,具有最佳的功耗性能、射频性能、
|
|
|
* :ref:`get-started-build-monitor`
|
|
|
|
|
|
|
|
|
-.. _get-started-setup-toolchain:
|
|
|
+.. _get-started-get-prerequisites:
|
|
|
|
|
|
-第一步:设置工具链
|
|
|
-====================
|
|
|
+第一步:安装准备
|
|
|
+=============================
|
|
|
|
|
|
-工具链指一套用于编译代码和应用程序的程序。
|
|
|
-
|
|
|
-为了加快开发进度,您可以直接使用乐鑫提供的预制工具链。请根据您的操作系统,点击下方对应的链接,并按照链接中的指导进行安装。
|
|
|
+在正式开始创建工程前,请先完成工具的安装,具体步骤见下:
|
|
|
|
|
|
.. toctree::
|
|
|
:hidden:
|
|
|
@@ -125,27 +121,22 @@ ESP32 采用 40 nm 工艺制成,具有最佳的功耗性能、射频性能、
|
|
|
.. _Linux: ../get-started/linux-setup.html
|
|
|
.. _Mac OS: ../get-started/macos-setup.html
|
|
|
|
|
|
-.. note::
|
|
|
-
|
|
|
- 在本文档中,Linux 和 MacOS 操作系统中 ESP-IDF 的默认安装路径为 ``~/esp``;Windows 操作系统的默认路径为 ``%userprofile%\esp``。您也可以将 ESP-IDF 安装在任何其他路径下,但请注意在使用命令行时进行相应替换。注意,ESP-IDF 不支持带有空格的路径。
|
|
|
-
|
|
|
-此外, 您也可以根据自身经验和实际需求,对环境进行个性化设置,而非使用预制工具链。此时,请前往 :ref:`工具链的个性化设置<get-started-customized-setup>` 章节获取更多信息。
|
|
|
-
|
|
|
-
|
|
|
.. _get-started-get-esp-idf:
|
|
|
-.. _get-started-set-up-tools:
|
|
|
+
|
|
|
|
|
|
第二步:获取 ESP-IDF
|
|
|
-===========================
|
|
|
+=================================
|
|
|
+
|
|
|
+在围绕 ESP32 构建应用程序之前,请先获取乐鑫提供的软件库文件 `ESP-IDF 仓库 <https://github.com/espressif/esp-idf>`_。
|
|
|
|
|
|
-除了工具链,您还需要供 ESP32 使用的 API(软件库和源代码),具体请见 `ESP-IDF 仓库 <https://github.com/espressif/esp-idf>`_。
|
|
|
+获取 ESP-IDF 的本地副本:打开终端,切换到您要保存 ESP-IDF 的工作目录,使用 ``git clone`` 命令克隆远程仓库。针对不同操作系统的详细步骤,请见下文。
|
|
|
|
|
|
-请将 ESP-IDF 下载到您的本地。
|
|
|
+.. note::
|
|
|
|
|
|
-获取本地副本:打开终端,切换到你要存放 ESP-IDF 的工作目录,使用 ``git clone`` 命令克隆远程仓库。
|
|
|
+ 在本文档中,Linux 和 MacOS 操作系统中 ESP-IDF 的默认安装路径为 ``~/esp``;Windows 操作系统的默认路径为 ``%userprofile%\esp``。您也可以将 ESP-IDF 安装在任何其他路径下,但请注意在使用命令行时进行相应替换。注意,ESP-IDF 不支持带有空格的路径。
|
|
|
|
|
|
Linux 和 MacOS 操作系统
|
|
|
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
打开终端,后运行以下命令:
|
|
|
|
|
|
@@ -156,71 +147,103 @@ ESP-IDF 将下载至 ``~/esp/esp-idf``。
|
|
|
请前往 :doc:`/versions`,查看 ESP-IDF 不同版本的具体适用场景。
|
|
|
|
|
|
Windows 操作系统
|
|
|
-~~~~~~~~~~~~~~~~~~
|
|
|
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
-.. note::
|
|
|
+除了安装必要工具外,第一步中介绍的 :ref:`get-started-windows-tools-installer` 也能同时下载 ESP-IDF 本地副本。
|
|
|
+
|
|
|
+请前往 :doc:`/versions`,查看 ESP-IDF 不同版本的具体适用场景。
|
|
|
|
|
|
- 较早版本 ESP-IDF 使用了 **MSYS2 bash 终端** 命令行。目前,基于 CMake 的编译系统可使用常见的 **Windows 命令窗口**,即本指南中使用的终端。
|
|
|
+除了使用 ESP-IDF 工具安装器,您也可以参考 :ref:`指南 <get-esp-idf-windows-command-line>` 手动下载 ESP-IDF。
|
|
|
|
|
|
-请注意,如果您使用基于 bash 的终端或 PowerShell 终端,一些命令语法将与下面描述有所不同。
|
|
|
+.. _get-started-set-up-tools:
|
|
|
|
|
|
-打开命令提示符,后运行以下命令:
|
|
|
+第三步:设置工具
|
|
|
+=================================
|
|
|
|
|
|
-.. include:: /_build/inc/git-clone-windows.inc
|
|
|
+除了 ESP-IDF 本身,您还需要安装 ESP-IDF 使用的各种工具,比如编译器、调试器、Python 包等。
|
|
|
|
|
|
-ESP-IDF 将下载至 ``%userprofile%\esp\esp-idf``。
|
|
|
+Windows 操作系统
|
|
|
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
-请前往 :doc:`/versions`,查看 ESP-IDF 不同版本的具体适用场景。
|
|
|
+请根据第一步中对 Windows (:ref:`get-started-windows-tools-installer`) 的介绍,安装所有必需工具。
|
|
|
|
|
|
-.. include:: /_build/inc/git-clone-notes.inc
|
|
|
+除了使用 ESP-IDF 工具安装器,您也可以通过 **命令提示符** 窗口手动安装这些工具。具体步骤见下:
|
|
|
|
|
|
-.. note::
|
|
|
+.. code-block:: batch
|
|
|
+
|
|
|
+ cd %userprofile%\esp\esp-idf
|
|
|
+ install.bat
|
|
|
+
|
|
|
+或使用 Windows PowerShell
|
|
|
+
|
|
|
+.. code-block:: powershell
|
|
|
+
|
|
|
+ cd ~/esp/esp-idf
|
|
|
+ ./install.ps1
|
|
|
+
|
|
|
+Linux 和 MacOS 操作系统
|
|
|
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
- 在克隆远程仓库时,不要忘记加上 ``--recursive`` 选项。否则,请接着运行以下命令,获取所有子模块: ::
|
|
|
+.. code-block:: bash
|
|
|
+
|
|
|
+ cd ~/esp/esp-idf
|
|
|
+ ./install.sh
|
|
|
+
|
|
|
+自定义工具安装路径
|
|
|
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
+
|
|
|
+本步骤中介绍的脚本将 ESP-IDF 所需的编译工具默认安装在用户根文件夹中,即 Linux 和 MacOS 系统中的 ``$HOME/.espressif`` 和 Windows 系统的 ``%USERPROFILE%\.espressif``。此外,您可以可以将工具安装到其他目录中,但请在运行安装脚本前,重新设置环境变量 ``IDF_TOOLS_PATH``。注意,请确保您的用户已经具备了读写该路径的权限。
|
|
|
|
|
|
- cd esp-idf
|
|
|
- git submodule update --init
|
|
|
+如果修改了 ``IDF_TOOLS_PATH`` 变量,请确保该变量在每次执行“安装脚本” (``install.bat``、``install.ps1`` 或 ``install.sh``) 和导出脚本 (``export.bat``、``export.ps1`` 或 ``export.sh``) 均保持一致。
|
|
|
|
|
|
-.. _get-started-setup-path:
|
|
|
.. _get-started-set-up-env:
|
|
|
|
|
|
-第三步:设置环境变量
|
|
|
-===========================
|
|
|
+第四步:设置环境变量
|
|
|
+=======================================
|
|
|
|
|
|
-请在您的 PC 上设置以下环境变量,否则无法编译工程。
|
|
|
+此时,您刚刚安装的工具尚未添加至 PATH 环境变量,无法通过“命令窗口”使用这些工具。因此,必须设置一些环境变量,这可以通过 ESP-IDF 提供的另一个脚本完成。
|
|
|
|
|
|
-- ``IDF_PATH`` 应设置为 ESP-IDF 根目录的路径。
|
|
|
-- ``PATH`` 应包括同一 ``IDF_PATH`` 目录下的 ``tools`` 目录路径。
|
|
|
+Windows 操作系统
|
|
|
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
-您可以在每次重启会话时手动设置,也可以在用户配置中进行永久设置,具体请前往 :doc:`add-idf_path-to-profile` 章节,查看 :ref:`Windows <add-paths-to-profile-windows>` 、:ref:`Linux 及 MacOS <add-idf_path-to-profile-linux-macos>` 操作系统的具体设置方式。
|
|
|
+Windows 安装器(:ref:`get-started-windows-tools-installer` )可在“开始”菜单创建一个 "ESP-IDF Command Prompt" 快捷方式。该快捷方式可以打开命令提示符窗口,并设置所有环境变量。您可以点击该快捷方式,然后继续下一步。
|
|
|
|
|
|
+此外,如果您希望在当下命令提示符窗口使用 ESP-IDF,请使用下方代码:
|
|
|
|
|
|
-.. _get-started-get-packages:
|
|
|
+.. code-block:: batch
|
|
|
|
|
|
-第四步:安装 Python 软件包
|
|
|
-=================================
|
|
|
+ %userprofile%\esp\esp-idf\export.bat
|
|
|
|
|
|
-ESP-IDF 所需的 Python 软件包位于 ``IDF_PATH/requirements.txt`` 中。您可以运行以下命令进行安装: ::
|
|
|
+或使用 Windows PowerShell
|
|
|
|
|
|
- python -m pip install --user -r $IDF_PATH/requirements.txt
|
|
|
+.. code-block:: powershell
|
|
|
|
|
|
-.. note::
|
|
|
+ .$HOME/esp/esp-idf/export.ps1
|
|
|
+
|
|
|
+Linux 和 MacOS 操作系统
|
|
|
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
+
|
|
|
+请在您需要运行 ESP-IDF 的“命令提示符”窗口运行以下命令:
|
|
|
|
|
|
- 请注意查询您所使用的 Python 解释器的版本(运行命令 ``python --version``),并根据查询结果将上方命令中的 ``python`` 替换为 ``python2``, ``python2.7``,例如:
|
|
|
+.. code-block:: bash
|
|
|
+
|
|
|
+ . $HOME/esp/esp-idf/export.sh
|
|
|
|
|
|
- ``python2.7 -m pip install --user -r $IDF_PATH/requirements.txt``
|
|
|
+注意,命令开始的 "." 与路径之间应有一个空格!
|
|
|
+
|
|
|
+此外,您也可以将这行代码增加至您的 ``.profile`` 或 ``.bash_profile`` 脚本中,这样您就可以在任何命令窗口使用 ESP-IDF 工具了。
|
|
|
|
|
|
.. _get-started-start-project:
|
|
|
|
|
|
第五步:开始创建工程
|
|
|
-=======================
|
|
|
+========================================
|
|
|
|
|
|
现在,您可以开始准备开发 ESP32 应用程序了。您可以从 ESP-IDF 中 :idf:`examples` 目录下的 :example:`get-started/hello_world` 工程开始。
|
|
|
|
|
|
将 :example:`get-started/hello_world` 复制至您本地的 ``~/esp`` 目录下:
|
|
|
|
|
|
Linux 和 MacOS 操作系统
|
|
|
-~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
@@ -228,7 +251,7 @@ Linux 和 MacOS 操作系统
|
|
|
cp -r $IDF_PATH/examples/get-started/hello_world .
|
|
|
|
|
|
Windows 操作系统
|
|
|
-~~~~~~~~~~~~~~~~~~~~~~
|
|
|
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
.. code-block:: batch
|
|
|
|
|
|
@@ -244,7 +267,7 @@ ESP-IDF 的 :idf:`examples` 目录下有一系列示例工程,都可以按照
|
|
|
.. _get-started-connect:
|
|
|
|
|
|
第六步:连接设备
|
|
|
-======================
|
|
|
+==========================================
|
|
|
|
|
|
现在,请将您的 ESP32 开发板连接到 PC,并查看开发板使用的串口。
|
|
|
|
|
|
@@ -264,34 +287,28 @@ ESP-IDF 的 :idf:`examples` 目录下有一系列示例工程,都可以按照
|
|
|
.. _get-started-configure:
|
|
|
|
|
|
第七步:配置
|
|
|
-=================
|
|
|
+=========================
|
|
|
|
|
|
请进入 :ref:`get-started-start-project` 中提到的 ``hello_world`` 目录,并运行工程配置工具 ``menuconfig``。
|
|
|
|
|
|
Linux 和 MacOS 操作系统
|
|
|
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
cd ~/esp/hello_world
|
|
|
idf.py menuconfig
|
|
|
|
|
|
-如果您的默认 Python 版本为 3.0 以上,可能需要运行 ``python2 idf.py`` 。
|
|
|
+如果您的默认 Python 版本为 3.0 及以上,可能需要运行 ``python2 $(which idf.py) menuconfig``。
|
|
|
|
|
|
Windows 操作系统
|
|
|
-~~~~~~~~~~~~~~~~~~~~~
|
|
|
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
.. code-block:: batch
|
|
|
|
|
|
cd %userprofile%\esp\hello_world
|
|
|
idf.py menuconfig
|
|
|
|
|
|
-Python 2.7 安装程序将尝试配置 Windows,将 ``.py`` 文件与 Python 2 关联起来。如果其他程序(比如 Visual Studio Python 工具)曾关联了其他版本 Python,则 ``idf.py`` 可能无法正常运行(文件将在 Visual Studio 中打开)。这种情况下,您可以选择每次都运行一遍 ``C:\Python27\python idf.py``,或更改 Windows 的 ``.py`` 关联文件设置。
|
|
|
-
|
|
|
-.. note::
|
|
|
-
|
|
|
- 如果出现 ``idf.py not found(无法找到 idf.py)`` 错误,请确保 ``PATH`` 环境变量设置无误,具体请参考 :ref:`get-started-setup-path`。如果 ``tools`` 目录下没有 ``idf.py`` 文件,请确保 CMake 预览的分支正确无误,具体请参考 :ref:`get-started-get-esp-idf`。
|
|
|
-
|
|
|
如果之前的步骤都正确,则会显示下面的菜单:
|
|
|
|
|
|
.. figure:: ../../_static/project-configuration.png
|
|
|
@@ -299,17 +316,17 @@ Python 2.7 安装程序将尝试配置 Windows,将 ``.py`` 文件与 Python 2
|
|
|
:alt: 工程配置 — 主窗口
|
|
|
:figclass: align-center
|
|
|
|
|
|
- 工程配置 — 主窗口
|
|
|
+工程配置 — 主窗口
|
|
|
|
|
|
``menuconfig`` 工具的常见操作见下。
|
|
|
|
|
|
-* ``上下箭头``:移动
|
|
|
+* 上下箭头:移动
|
|
|
* ``回车``:进入子菜单
|
|
|
* ``ESC 键``:返回上级菜单或退出
|
|
|
* ``英文问号``:调出帮助菜单(退出帮助菜单,请按回车键)。
|
|
|
-* ``空格``、``Y 键``或``N 键``:使能/禁用 ``[*]`` 配置选项
|
|
|
-* ``英文问号``:调出有关高亮选项的帮助菜单
|
|
|
-* ``/ 键``:寻找配置项目
|
|
|
+* ``空格``或 ``Y 键``:选择 ``[*]`` 配置选项;``N 键``:禁用 ``[*]`` 配置选项
|
|
|
+* ``英文问号`` (查询配置选项):调出有关该选项的帮助菜单
|
|
|
+* ``/ 键``:寻找配置工程
|
|
|
|
|
|
.. attention::
|
|
|
|
|
|
@@ -318,7 +335,7 @@ Python 2.7 安装程序将尝试配置 Windows,将 ``.py`` 文件与 Python 2
|
|
|
.. _get-started-build:
|
|
|
|
|
|
第八步:编译工程
|
|
|
-==================
|
|
|
+=========================
|
|
|
|
|
|
请使用以下命令,编译烧录工程:::
|
|
|
|
|
|
@@ -328,23 +345,23 @@ Python 2.7 安装程序将尝试配置 Windows,将 ``.py`` 文件与 Python 2
|
|
|
|
|
|
.. code-block:: none
|
|
|
|
|
|
- $ idf.py build
|
|
|
- Running cmake in directory /path/to/hello_world/build
|
|
|
- Executing "cmake -G Ninja --warn-uninitialized /path/to/hello_world"...
|
|
|
- Warn about uninitialized values.
|
|
|
- -- Found Git: /usr/bin/git (found version "2.17.0")
|
|
|
- -- Building empty aws_iot component due to configuration
|
|
|
- -- Component names: ...
|
|
|
- -- Component paths: ...
|
|
|
-
|
|
|
- ... (more lines of build system output)
|
|
|
-
|
|
|
- [527/527] Generating hello-world.bin
|
|
|
- esptool.py v2.3.1
|
|
|
-
|
|
|
- Project build complete. To flash, run this command:
|
|
|
- ../../../components/esptool_py/esptool/esptool.py -p (PORT) -b 921600 write_flash --flash_mode dio --flash_size detect --flash_freq 40m 0x10000 build/hello-world.bin build 0x1000 build/bootloader/bootloader.bin 0x8000 build/partition_table/partition-table.bin
|
|
|
- or run 'idf.py -p PORT flash'
|
|
|
+ $ idf.py build
|
|
|
+ Running cmake in directory /path/to/hello_world/build
|
|
|
+ Executing "cmake -G Ninja --warn-uninitialized /path/to/hello_world"...
|
|
|
+ Warn about uninitialized values.
|
|
|
+ -- Found Git:/usr/bin/git (found version "2.17.0")
|
|
|
+ -- Building empty aws_iot component due to configuration
|
|
|
+ -- Component names: ...
|
|
|
+ -- Component paths: ...
|
|
|
+
|
|
|
+ ... (more lines of build system output)
|
|
|
+
|
|
|
+ [527/527] Generating hello-world.bin
|
|
|
+ esptool.py v2.3.1
|
|
|
+
|
|
|
+ Project build complete. To flash, run this command:
|
|
|
+ ../../../components/esptool_py/esptool/esptool.py -p (PORT) -b 921600 write_flash --flash_mode dio --flash_size detect --flash_freq 40m 0x10000 build/hello-world.bin build 0x1000 build/bootloader/bootloader.bin 0x8000 build/partition_table/partition-table.bin
|
|
|
+ or run 'idf.py -p PORT flash'
|
|
|
|
|
|
如果一切正常,编译完成后将生成 .bin 文件。
|
|
|
|
|
|
@@ -352,15 +369,15 @@ Python 2.7 安装程序将尝试配置 Windows,将 ``.py`` 文件与 Python 2
|
|
|
.. _get-started-flash:
|
|
|
|
|
|
第九步:烧录到设备
|
|
|
-====================
|
|
|
+=============================
|
|
|
|
|
|
-请使用以下命令,将刚刚生成的二进制文件烧录至您的 ESP32 开发板: ::
|
|
|
+请使用以下命令,将刚刚生成的二进制文件烧录至您的 ESP32 开发板:
|
|
|
|
|
|
- idf.py -p PORT [-b BAUD] flash
|
|
|
+ ``idf.py -p PORT [-b BAUD] flash``
|
|
|
|
|
|
请将 PORT 替换为 ESP32 开发板的串口名称,具体可见 :ref:`get-started-connect`。
|
|
|
|
|
|
-您还可以将 BAUD 替换为您希望的烧录波特率。默认波特率为 ``460800``。
|
|
|
+您还可以将 BAUD 替换为您希望的烧录波特率。默认波特率为 ``460800``。
|
|
|
|
|
|
更多有关 idf.py 参数的详情,请见 :ref:`idf.py`。
|
|
|
|
|
|
@@ -409,11 +426,11 @@ Python 2.7 安装程序将尝试配置 Windows,将 ``.py`` 文件与 Python 2
|
|
|
.. _get-started-build-monitor:
|
|
|
|
|
|
第十步:监视器
|
|
|
-==================
|
|
|
+======================
|
|
|
|
|
|
您可以使用 ``make monitor`` 命令,监视 “hello_world” 的运行情况。注意,不要忘记将 PORT 替换为您的串口名称。
|
|
|
|
|
|
-运行该命令后,:doc:`IDF 监视器 <../api-guides/tools/idf-monitor>` 应用程序将启动: ::
|
|
|
+运行该命令后,:doc:`IDF 监视器 <../api-guides/tools/idf-monitor>` 应用程序将启动:::
|
|
|
|
|
|
$ idf.py -p /dev/ttyUSB0 monitor
|
|
|
Running idf_monitor in directory [...]/esp/hello_world/build
|
|
|
@@ -440,17 +457,17 @@ Python 2.7 安装程序将尝试配置 Windows,将 ``.py`` 文件与 Python 2
|
|
|
|
|
|
您可使用快捷键 ``Ctrl+]``,退出 IDF 监视器。
|
|
|
|
|
|
-如果 IDF 监视器在烧录后很快发生错误,或打印信息全是乱码(见下),很有可能是因为您的开发板选用了 26 MHz 晶振,而 ESP-IDF 默认支持大多数开发板使用的 40 MHz 晶振。
|
|
|
+如果 IDF 监视器在烧录后很快发生错误,或打印信息全是乱码(见下),很有可能是因为您的开发板采用了 26 MHz 晶振,而 ESP-IDF 默认支持大多数开发板使用的 40 MHz 晶振。
|
|
|
|
|
|
.. figure:: ../../_static/get-started-garbled-output.png
|
|
|
:align: center
|
|
|
:alt: 乱码输出
|
|
|
:figclass: align-center
|
|
|
|
|
|
-此时,请您:
|
|
|
+此时,您可以:
|
|
|
|
|
|
1. 退出监视器。
|
|
|
-2. 打开 :ref:`menuconfig <get-started-configure>`,
|
|
|
+2. 打开 :ref:`menuconfig <get-started-configure>`。
|
|
|
3. 进入 ``Component config`` --> ``ESP32-specific`` --> ``Main XTAL frequency`` 进行配置,将 :ref:`CONFIG_ESP32_XTAL_FREQ_SEL` 设置为 26 MHz。
|
|
|
4. 然后,请重新 :ref:`编译和烧录 <get-started-flash>` 应用程序。
|
|
|
|
|
|
@@ -458,7 +475,7 @@ Python 2.7 安装程序将尝试配置 Windows,将 ``.py`` 文件与 Python 2
|
|
|
|
|
|
您也可以运行以下命令,一次性执行构建、烧录和监视过程:
|
|
|
|
|
|
- ``idf.py -p PORT flash monitor``
|
|
|
+ ``idf.py -p PORT flash monitor``
|
|
|
|
|
|
此外,
|
|
|
|
|
|
@@ -470,21 +487,22 @@ Python 2.7 安装程序将尝试配置 Windows,将 ``.py`` 文件与 Python 2
|
|
|
现在,您可以尝试一些其他 :idf:`examples`,或者直接开发自己的应用程序。
|
|
|
|
|
|
更新 ESP-IDF
|
|
|
-=================
|
|
|
+================
|
|
|
|
|
|
乐鑫会不时推出更新版本的 ESP-IDF,修复 bug 或提出新的特性。因此,您在使用时,也应注意更新您本地的版本。最简单的方法是:直接删除您本地的 ``esp-idf`` 文件夹,然后按照 :ref:`get-started-get-esp-idf` 中的指示,重新完成克隆。
|
|
|
|
|
|
-如果您希望将 ESP-IDF 克隆到新的路径下,请务必 :doc:`重新设置 IDF_PATH <add-idf_path-to-profile>`。否则,工具链将无法找到 ESP-IDF。
|
|
|
-
|
|
|
此外,您可以仅更新变更部分。具体方式,请前往 :ref:`更新 <updating>` 章节查看。
|
|
|
|
|
|
+注意,更新完成后,请执行 ``install.sh`` (Windows 系统中为 ``install.bat``)脚本,避免新版 ESP-IDF 所需的工具也有所更新。具体请参考 :ref:`get-started-set-up-tools`。
|
|
|
+
|
|
|
+一旦重新安装好工具,请使用“导出脚本”更新环境,具体请参考 :ref:`get-started-set-up-env`。
|
|
|
+
|
|
|
相关文档
|
|
|
-===========
|
|
|
+=================
|
|
|
|
|
|
.. toctree::
|
|
|
:maxdepth: 1
|
|
|
|
|
|
- add-idf_path-to-profile
|
|
|
establish-serial-connection
|
|
|
eclipse-setup
|
|
|
../api-guides/tools/idf-monitor
|