docs: Make Getting Started (CMake) guides version-aware

Also clean up some changes in Chinese CMake guide which were not propagated from the English guide.
This commit is contained in:
Angus Gratton 2018-12-18 17:22:40 +11:00 committed by Angus Gratton
parent 3d03c2b7fd
commit 88150cb9bb
5 changed files with 116 additions and 176 deletions

View file

@ -10,6 +10,8 @@ Get Started (CMake)
This document is intended to help users set up the software environment for development of applications using hardware based on the Espressif ESP32. Through a simple example we would like to illustrate how to use ESP-IDF (Espressif IoT Development Framework), including the menu based configuration, compiling the ESP-IDF and firmware download to ESP32 boards.
.. include:: /_build/inc/version-note.inc
Introduction
============
@ -116,23 +118,24 @@ Besides the toolchain (that contains programs to compile and build the applicati
Linux and MacOS
~~~~~~~~~~~~~~~
.. code-block:: bash
To obtain a local copy: open terminal, navigate to the directory you want to put ESP-IDF, and clone the repository using ``git clone`` command:
mkdir -p ~/esp
cd ~/esp
git clone --recursive https://github.com/espressif/esp-idf.git
.. include:: /_build/inc/git-clone-bash.inc
ESP-IDF will be downloaded into ``~/esp/esp-idf``.
Consult :doc:`/versions` for information about which version of ESP-IDF to use in a given situation.
Windows Command Prompt
~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: batch
.. include:: /_build/inc/git-clone-windows.inc
mkdir %userprofile%\esp
cd %userprofile%\esp
git clone --recursive https://github.com/espressif/esp-idf.git
ESP-IDF will be downloaded into ``esp\esp-idf`` in the user's profile directory.
Consult :doc:`/versions` for information about which version of ESP-IDF to use in a given situation.
.. include:: /_build/inc/git-clone-notes.inc
.. highlight:: bash
.. note::
@ -201,7 +204,7 @@ You are almost there. To be able to proceed further, connect ESP32 board to PC,
Configure
=========
Naviagate to the directory of the ``hello_world`` application copy, and run the ``menuconfig`` project configuration utility:
Navigate to the directory of the ``hello_world`` application copy, and run the ``menuconfig`` project configuration utility:
Linux and MacOS
~~~~~~~~~~~~~~~
@ -395,60 +398,9 @@ Updating ESP-IDF
After some time of using ESP-IDF, you may want to update it to take advantage of new features or bug fixes. The simplest way to do so is by deleting existing ``esp-idf`` folder and cloning it again, exactly as when doing initial installation described in sections :ref:`get-started-get-esp-idf-cmake`.
Another solution is to update only what has changed. This method is useful if you have a slow connection to GitHub. To do the update run the following commands:
If downloading to a new path, remember to :doc:`add-idf_path-to-profile` so that the toolchain scripts know where to find the ESP-IDF in its release specific location.
Linux and MacOS
~~~~~~~~~~~~~~~
.. code-block:: bash
cd ~/esp/esp-idf
git pull
git submodule update --init --recursive
Windows Command Prompt
~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: batch
cd %userprofile%\esp\esp-idf
git pull
git submodule update --init --recursive
The ``git pull`` command is fetching and merging changes from ESP-IDF repository on GitHub. Then ``git submodule update --init --recursive`` is updating existing submodules or getting a fresh copy of new ones. On GitHub the submodules are represented as links to other repositories and require this additional command to get them onto your PC.
.. highlight:: bash
It is also possible to check out a specific release of ESP-IDF, e.g. `v2.1`.
Linux and MacOS
~~~~~~~~~~~~~~~
.. code-block:: bash
cd ~/esp
git clone https://github.com/espressif/esp-idf.git esp-idf-v2.1
cd esp-idf-v2.1/
git checkout v2.1
git submodule update --init --recursive
Windows Command Prompt
~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: batch
cd %userprofile%\esp
git clone https://github.com/espressif/esp-idf.git esp-idf-v2.1
cd esp-idf-v2.1/
git checkout v2.1
git submodule update --init --recursive
After that remember to :doc:`add-idf_path-to-profile`, so the toolchain scripts know where to find the ESP-IDF in it's release specific location.
.. note::
Different versions of ESP-IDF may have different setup or prerequisite requirements, or require different toolchain versions. If you experience any problems, carefully check the Getting Started documentation for the version you are switching to.
Another solution is to update only what has changed. :ref:`The update procedure depends on the version of ESP-IDF you are using <updating>`.
Related Documents
@ -462,3 +414,6 @@ Related Documents
eclipse-setup
idf-monitor
toolchain-setup-scratch
.. _Stable version: https://docs.espressif.com/projects/esp-idf/en/stable/
.. _Releases page: https://github.com/espressif/esp-idf/releases

View file

@ -117,18 +117,23 @@ Get ESP-IDF
Besides the toolchain (that contains programs to compile and build the application), you also need ESP32 specific API / libraries. They are provided by Espressif in `ESP-IDF repository <https://github.com/espressif/esp-idf>`_.
.. include:: /_build/inc/git-clone.inc
To obtain a local copy: open terminal, navigate to the directory you want to put ESP-IDF, and clone the repository using ``git clone`` command:
.. include:: /_build/inc/git-clone-bash.inc
ESP-IDF will be downloaded into ``~/esp/esp-idf``.
Consult :doc:`/versions` for information about which version of ESP-IDF to use in a given situation.
.. include:: /_build/inc/git-clone-notes.inc
.. note::
Do not miss the ``--recursive`` option. If you have already cloned ESP-IDF without this option, run another command to get all the submodules::
cd ~/esp/esp-idf
cd esp-idf
git submodule update --init --recursive
.. _get-started-setup-path:
Setup Path to ESP-IDF

View file

@ -14,15 +14,23 @@ import re
TEMPLATES = {
"en": {
"git-clone": {
"template": """
To obtain a local copy: open terminal, navigate to the directory you want to put ESP-IDF, and clone the repository using ``git clone`` command::
"git-clone-bash": """
.. code-block:: bash
cd ~/esp
git clone %(clone_args)s--recursive https://github.com/espressif/esp-idf.git
""",
ESP-IDF will be downloaded into ``~/esp/esp-idf``.
"git-clone-windows": """
.. code-block:: batch
mkdir %%userprofile%%\\esp
cd %%userprofile%%\\esp
git clone %(clone_args)s--recursive https://github.com/espressif/esp-idf.git
""",
"git-clone-notes": {
"template": """
.. note::
%(extra_note)s
@ -32,16 +40,16 @@ ESP-IDF will be downloaded into ``~/esp/esp-idf``.
%(zipfile_note)s
""",
"master": 'This command will clone the master branch, which has the latest development ("bleeding edge") '
'version of ESP-IDF. It is fully functional and updated on weekly basis with the most recent features and bugfixes.',
"branch": 'The ``git clone`` option ``-b %(clone_arg)s`` tells git to clone the %(ver_type)s in the ESP-IDF repository '
'corresponding to this version of the documentation.',
'version of ESP-IDF. It is fully functional and updated on weekly basis with the most recent features and bugfixes.',
"branch": 'The ``git clone`` option ``-b %(clone_arg)s`` tells git to clone the %(ver_type)s in the ESP-IDF repository ``git clone`` '
'corresponding to this version of the documentation.',
"zipfile": {
"stable": 'As a fallback, it is also possible to download a zip file of this stable release from the `Releases page`_. '
'Do not download the "Source code" zip file(s) generated automatically by GitHub, they do not work with ESP-IDF.',
"unstable": 'GitHub\'s "Download zip file" feature does not work with ESP-IDF, a ``git clone`` is required. As a fallback, '
'`Stable version`_ can be installed without Git.'
}, # zipfile
}, # git-clone
}, # git-clone-notes
"version-note": {
"master": """
.. note::
@ -59,15 +67,23 @@ ESP-IDF will be downloaded into ``~/esp/esp-idf``.
}, # version-note
}, # en
"zh_CN": {
"git-clone": {
"template": """
获取本地副本打开终端切换到你要存放 ESP-IDF 的工作目录使用 ``git clone`` 命令克隆远程仓库::
"git-clone-bash": """
.. code-block:: bash
cd ~/esp
git clone %(clone_args)s--recursive https://github.com/espressif/esp-idf.git
""",
ESP-IDF 将会被下载到 ``~/esp/esp-idf`` 目录下
"git-clone-windows": """
.. code-block:: batch
mkdir %%userprofile%%\\esp
cd %%userprofile%%\\esp
git clone %(clone_args)s--recursive https://github.com/espressif/esp-idf.git
""",
"git-clone-notes": {
"template": """
.. note::
%(extra_note)s
@ -119,29 +135,43 @@ def main():
version, ver_type, is_stable = get_version()
write_git_clone_inc(template["git-clone"], out_dir, version, ver_type, is_stable)
write_git_clone_inc_files(template, out_dir, version, ver_type, is_stable)
write_version_note(template["version-note"], out_dir, version, ver_type, is_stable)
print("Done")
def write_git_clone_inc(template, out_dir, version, ver_type, is_stable):
zipfile = template["zipfile"]
def write_git_clone_inc_files(templates, out_dir, version, ver_type, is_stable):
def out_file(basename):
p = os.path.join(out_dir, "%s.inc" % basename)
print("Writing %s..." % p)
return p
if version == "master":
args = {
"clone_args": "",
"extra_note": template["master"],
"zipfile_note": zipfile["unstable"]
}
clone_args = ""
else:
args = {
"clone_args": "-b %s " % version,
"extra_note": template["branch"] % {"clone_arg": version, "ver_type": ver_type},
"zipfile_note": zipfile["stable"] if is_stable else zipfile["unstable"]
}
out_file = os.path.join(out_dir, "git-clone.inc")
with open(out_file, "w", encoding='utf-8') as f:
f.write(template["template"] % args)
print("%s written" % out_file)
clone_args = "-b %s " % version
with open(out_file("git-clone-bash"), "w", encoding="utf-8") as f:
f.write(templates["git-clone-bash"] % locals())
with open(out_file("git-clone-windows"), "w", encoding="utf-8") as f:
f.write(templates["git-clone-windows"] % locals())
with open(out_file("git-clone-notes"), "w", encoding="utf-8") as f:
template = templates["git-clone-notes"]
zipfile = template["zipfile"]
if version == "master":
extra_note = template["master"],
zipfile_note = zipfile["unstable"]
else:
extra_note = template["branch"] % {"clone_arg": version, "ver_type": ver_type}
zipfile_note = zipfile["stable"] if is_stable else zipfile["unstable"]
f.write(template["template"] % locals())
print("Wrote git-clone-xxx.inc files")
def write_version_note(template, out_dir, version, ver_type, is_stable):

View file

@ -10,6 +10,8 @@
本文档旨在指导用户创建 ESP32 的软件环境。本文将通过一个简单的例子,说明 ESP-IDF (Espressif IoT Development Framework) 的使用方法,包括配置、编译、下载固件到开发板等步骤。
.. include:: /_build/inc/version-note.inc
概述
============
@ -116,23 +118,24 @@ ESP32 是一套 Wi-Fi (2.4 GHz) 和蓝牙 (4.2) 双模解决方案,集成了
Linux 和 MacOS
~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: bash
获取本地副本:打开终端,切换到你要存放 ESP-IDF 的工作目录,使用 ``git clone`` 命令克隆远程仓库:
mkdir -p ~/esp
cd ~/esp
git clone --recursive https://github.com/espressif/esp-idf.git
.. include:: /_build/inc/git-clone-bash.inc
ESP-IDF 将会被下载到 ``~/esp/esp-idf`` 目录下。
有关在给定情况下使用哪个 ESP-IDF 版本的信息,请参阅 :doc:`/versions`
Windows Command Prompt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: batch
.. include:: /_build/inc/git-clone-windows.inc
mkdir %userprofile%\esp
cd %userprofile%\esp
git clone --recursive https://github.com/espressif/esp-idf.git
ESP-IDF 将会被下载到用户的 ``esp\esp-idf`` 目录下。
有关在给定情况下使用哪个 ESP-IDF 版本的信息,请参阅 :doc:`/versions`
.. include:: /_build/inc/git-clone-notes.inc
.. highlight:: bash
.. note::
@ -142,13 +145,6 @@ Windows Command Prompt
cd esp-idf
git submodule update --init
.. note::
基于 CMake 的构建系统预览默认使用的 Git 分支是 ``feature/cmake``。如果你在克隆时没有带 ``--branch`` 选项,可通过以下命令行切换分支::
cd esp-idf
git checkout feature/cmake
.. _get-started-setup-path-cmake:
设置环境变量
@ -161,7 +157,7 @@ ESP-IDF 的正常运行需要设置两个环境变量:
你需在你的电脑中设置这两个变量,否则工程将不能编译。
你可以在每次 PC 重启时手动设置,你也可以在用户配置中进行永久设置,具体请参照 :doc:`add-idf_path-to-profile` 小节中的 :ref:`Windows <add-paths-to-profile-windows-cmake>`:ref:`Linux 和 MacOS <add-idf_path-to-profile-linux-macos-cmake>` 相关指导进行操作。
你可以在每次 PC 重启时手动设置,你也可以在用户配置中进行永久设置,具体请参照 :doc:`add-idf_path-to-profile` 小节中的 :ref:`Windows <add-paths-to-profile-windows-cmake>`:ref:`Linux 和 MacOS <add-idf_path-to-profile-linux-macos-cmake>` 相关指导进行操作。
.. _get-started-start-project-cmake:
@ -250,6 +246,10 @@ Windows Command Prompt
* 当光标在某个配置项上面高亮时,输入 ``?`` 可以直接查看该项的帮助信息
* 输入 ``/`` 搜索配置项
.. attention::
如果 ESP32-DevKitC 板载的是 ESP32-SOLO-1 模组,请务必在烧写示例程序之前在 menuconfig 中使能单核模式(:ref:`CONFIG_FREERTOS_UNICORE`)。
.. _get-started-build-cmake:
创建一个工程
@ -393,65 +393,13 @@ Windows Command Prompt
更新 ESP-IDF
=========================
=============
ESP-IDF 使用一段时间后,你可能想要进行升级来获得新的性能或者对 bug 进行修复。最简单的更新方式是删除已有的 ``esp-idf`` 文件夹然后再克隆一个,即重复 :ref:`get-started-get-esp-idf-cmake` 小节中所述的初始安装即可
使用 ESP-IDF 一段时间后,您可能想通过升级来获取新的功能或者修复 bug最简单的升级方式就是删除已有的 ``esp-idf`` 文件夹然后重新克隆一个,即重复 :ref:`get-started-get-esp-idf` 里的操作
另外一种方法是只更新有改动的部分,此方法适合连接 GitHub 比较缓慢的情况。你只需运行如下指令:
Linux 和 MacOS
~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: bash
cd ~/esp/esp-idf
git pull
git submodule update --init --recursive
Windows Command Prompt
~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: batch
cd %userprofile%\esp\esp-idf
git pull
git submodule update --init --recursive
``git pull`` 命令将获取和合并 GitHub 上对 ESP-IDF 仓库所做的更改。``git submodule update --init --recursive`` 命令会更新现有子模块或拷贝更新的子模块。GitHub 上的子模块是指向其他仓库的链接,需要以下额外命令将其指向你的电脑。
.. highlight:: bash
你还可以查看具体发布的 ESP-IDF 版本,如 `v2.1`
Linux 和 MacOS
~~~~~~~~~~~~~~~~~~~~
.. code-block:: bash
cd ~/esp
git clone https://github.com/espressif/esp-idf.git esp-idf-v2.1
cd esp-idf-v2.1/
git checkout v2.1
git submodule update --init --recursive
Windows Command Prompt
~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: batch
cd %userprofile%\esp
git clone https://github.com/espressif/esp-idf.git esp-idf-v2.1
cd esp-idf-v2.1/
git checkout v2.1
git submodule update --init --recursive
注意 :doc:`add-idf_path-to-profile`,这样工具链脚本就能够知道这一版本的 ESP-IDF 的具体位置。
.. note::
ESP-IDF 版本不同,其设置、必备要求或所需工具链版本也会有所不同。如果你有任何问题,请仔细对照快速入门文档查看你将使用版本的相应要求。
然后 :doc:`添加 IDF 到工作路径 <add-idf_path-to-profile>`,这样工具链脚本就能够知道这一版本的 ESP-IDF 的具体位置。
另外一种方法是只更新有改动的部分。:ref:`更新步骤取决于现在用的ESP-IDF版本 <updating>`
相关文档
=================
@ -464,3 +412,6 @@ Windows Command Prompt
eclipse-setup
idf-monitor
toolchain-setup-scratch
.. _Stable version: https://docs.espressif.com/projects/esp-idf/en/stable/
.. _Releases page: https://github.com/espressif/esp-idf/releases

View file

@ -3,8 +3,6 @@
***********
:link_to_translation:`en:[English]`
.. important:: 对不起CMake-based Build System Preview 还没有中文翻译。
本文档旨在指导用户创建 ESP32 的软件环境。本文将通过一个简单的例子来说明如何使用 ESP-IDF (Espressif IoT Development Framework),包括配置、编译、下载固件到开发板等步骤。
.. include:: /_build/inc/version-note.inc
@ -116,17 +114,22 @@ ESP32 是一套 Wi-Fi (2.4 GHz) 和蓝牙 (4.2) 双模解决方案,集成了
工具链(包括用于编译和构建应用程序的程序)安装完后,你还需要 ESP32 相关的 API/库。API/库在 `ESP-IDF 仓库 <https://github.com/espressif/esp-idf>`_ 中。
.. include:: /_build/inc/git-clone.inc
获取本地副本:打开终端,切换到你要存放 ESP-IDF 的工作目录,使用 ``git clone`` 命令克隆远程仓库:
查看 :doc:/versions 以获取不同情况下选择要使用的分支的帮助。
.. include:: /_build/inc/git-clone-bash.inc
ESP-IDF 将会被下载到 ``~/esp/esp-idf`` 目录下。
有关在给定情况下使用哪个 ESP-IDF 版本的信息,请参阅 :doc:`/versions`
.. note::
注意这里有个 ``--recursive`` 选项。如果你克隆 ESP-IDF 时没有带这个选项,你还需要运行额外的命令来获取子模块: ::
cd ~/esp/esp-idf
cd esp-idf
git submodule update --init
.. include:: /_build/inc/git-clone-notes.inc
.. _get-started-setup-path:
@ -212,13 +215,9 @@ ESP-IDF 的 :idf:`examples` 目录下有一系列示例工程,都可以按照
* 当光标在某个配置项上面高亮时,输入 ``?`` 可以直接查看该项的帮助信息
* 输入 ``/`` 搜索配置项
.. note::
如果你是 **Arch Linux** 用户,需要进入 ``SDK tool configuration````Python 2 interpreter````python`` 修改为 ``python2``
.. attention::
如果 ESP32-DevKitC 板载的是 ESP32-SOLO-1 模组,请务必在烧写示例程序之前在 menuconfig 中使能单核模式(:ref:CONFIG_FREERTOS_UNICORE
如果 ESP32-DevKitC 板载的是 ESP32-SOLO-1 模组,请务必在烧写示例程序之前在 menuconfig 中使能单核模式(:ref:`CONFIG_FREERTOS_UNICORE`)。
.. _get-started-build-flash: