Merge branch 'doc/versions_v3.0' into 'release/v3.0'

docs: Add version-specific include files, version documentation (backport v3.0)

See merge request idf/esp-idf!2975
This commit is contained in:
Angus Gratton 2018-08-22 13:36:36 +08:00
commit 04ce9050b6
8 changed files with 376 additions and 37 deletions

View file

@ -4,22 +4,27 @@
ESP-IDF is the official development framework for the [ESP32](https://espressif.com/en/products/hardware/esp32/overview) chip.
# Developing With the ESP-IDF
# Developing With ESP-IDF
## Setting Up ESP-IDF
See setup guides for detailed instructions to set up the ESP-IDF:
* [Windows Setup Guide](https://esp-idf.readthedocs.io/en/latest/get-started/windows-setup.html)
* [Mac OS Setup Guide](https://esp-idf.readthedocs.io/en/latest/get-started/macos-setup.html)
* [Linux Setup Guide](https://esp-idf.readthedocs.io/en/latest/get-started/linux-setup.html)
* [Getting Started Guide for the stable ESP-IDF version](https://docs.espressif.com/projects/esp-idf/en/stable/get-started/)
* [Getting Started Guide for the latest (master branch) ESP-IDF version](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/)
## Finding a Project
As well as the [esp-idf-template](https://github.com/espressif/esp-idf-template) project mentioned in the setup guide, ESP-IDF comes with some example projects in the [examples](examples) directory.
As well as the [esp-idf-template](https://github.com/espressif/esp-idf-template) project mentioned in Getting Started, ESP-IDF comes with some example projects in the [examples](examples) directory.
Once you've found the project you want to work with, change to its directory and you can configure and build it.
To start your own project based on an example, copy the example project directory outside of the ESP-IDF directory.
# Quick Reference
See the Getting Started guide links above for a detailed setup guide. This is a quick reference for common commands when working with ESP-IDF projects:
## Configuring the Project
`make menuconfig`
@ -36,15 +41,17 @@ Once done configuring, press Escape multiple times to exit and say "Yes" to save
## Compiling the Project
`make all`
`make -j4 all`
... will compile app, bootloader and generate a partition table based on the config.
NOTE: The `-j4` option causes `make` to run 4 parallel jobs. This is much faster than the default single job. The recommended number to pass to this option is `-j(number of CPUs + 1)`.
## Flashing the Project
When `make all` finishes, it will print a command line to use esptool.py to flash the chip. However you can also do this from make by running:
`make flash`
`make -j4 flash`
This will flash the entire project (app, bootloader and partition table) to a new chip. The settings for serial port flashing can be configured with `make menuconfig`.
@ -56,24 +63,24 @@ The `make monitor` target uses the [idf_monitor tool](https://esp-idf.readthedoc
Exit the monitor by typing Ctrl-].
To flash and monitor output in one pass, you can run:
To build, flash and monitor output in one pass, you can run:
`make flash monitor`
`make -j4 flash monitor`
## Compiling & Flashing Just the App
## Compiling & Flashing Only the App
After the initial flash, you may just want to build and flash just your app, not the bootloader and partition table:
* `make app` - build just the app.
* `make app-flash` - flash just the app.
`make app-flash` will automatically rebuild the app if it needs it.
`make app-flash` will automatically rebuild the app if any source files have changed.
(In normal development there's no downside to reflashing the bootloader and partition table each time, if they haven't changed.)
## Parallel Builds
ESP-IDF supports compiling multiple files in parallel, so all of the above commands can be run as `make -jN` where `N` is the number of parallel make processes to run (generally N should be equal to or one more than the number of CPU cores in your system.)
ESP-IDF supports compiling multiple files in parallel, so all of the above commands can be run as `make -jN` where `N` is the number of parallel make processes to run (generally N should be equal to the number of CPU cores in your system, plus one.)
Multiple make functions can be combined into one. For example: to build the app & bootloader using 5 jobs in parallel, then flash everything, and then display serial output from the ESP32 run:

View file

@ -1,6 +1,14 @@
# Makefile for Sphinx documentation
#
# ************ IMPORTANT *****************
#
# ReadTheDocs DOES NOT USE THIS MAKEFILE,
# so any behaviour additions must be
# done via Sphinx Config not here
#
# ****************************************
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
@ -9,7 +17,7 @@ BUILDDIR = _build
# User-friendly check for sphinx-build
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don\'t have Sphinx installed, grab it from http://sphinx-doc.org/)
endif
# Internal variables.
@ -19,10 +27,10 @@ ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) -w
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext dependencies version-specific-includes
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo "Please use \`make <target>\' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@ -44,7 +52,7 @@ help:
@echo " xml to make Docutils-native XML files"
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
@echo " doctest to run all doctests embedded in the documentation (if enabled) "
clean:
rm -rf $(BUILDDIR)/*

BIN
docs/_static/choose_version.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View file

@ -32,6 +32,15 @@ os.system("python gen-dxd.py")
# Generate 'kconfig.inc' file from components' Kconfig files
os.system("python gen-kconfig-doc.py > _build/inc/kconfig.inc")
# Generate version-related includes
#
# (Note: this is in a function as it needs to access configuration to get the language)
def generate_version_specific_includes(app):
print("Generating version-specific includes...")
if os.system('python gen-version-specific-includes.py en _build/inc'):
raise RuntimeError('gen-version-specific-includes.py failed')
# http://stackoverflow.com/questions/12772927/specifying-an-online-image-in-sphinx-restructuredtext-format
#
suppress_warnings = ['image.nonlocal_uri']
@ -314,3 +323,9 @@ if not on_rtd: # only import and set the theme if we're building docs locally
# otherwise, readthedocs.org uses their theme by default, so no need to specify it
# Override RTD CSS theme to introduce the theme corrections
# https://github.com/rtfd/sphinx_rtd_theme/pull/432
def setup(app):
app.add_stylesheet('theme_overrides.css')
generate_version_specific_includes(app)

View file

@ -0,0 +1,140 @@
#!/usr/bin/env python
#
# Python script to generate ReSTructured Text .inc snippets
# with version-based content for this IDF version
import subprocess
import os
import sys
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::
cd ~/esp
git clone %(clone_args)s--recursive https://github.com/espressif/esp-idf.git
ESP-IDF will be downloaded into ``~/esp/esp-idf``.
.. note::
%(extra_note)s
.. note::
%(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 %s`` tells git to clone the %s in the ESP-IDF repository 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
"version-note" : {
"master" : """
.. note::
This is documentation for the master branch (latest version) of ESP-IDF. This version is under continual development. `Stable version`_ documentation is available, as well as other :doc:`/versions`.
"""
,"stable" : """
.. note::
This is documentation for stable version %s of ESP-IDF. Other :doc:`/versions` are also available.
"""
,"branch" : """
.. note::
This is documentation for %s ``%s`` of ESP-IDF. Other :doc:`/versions` are also available.
"""
}, # version-note
}, # en
}
def main():
if len(sys.argv) != 3:
print("Usage: gen-git-clone.py <language> <output file path>")
sys.exit(1)
language = sys.argv[1]
out_dir = sys.argv[2]
if not os.path.exists(out_dir):
print("Creating directory %s" % out_dir)
os.mkdir(out_dir)
template = TEMPLATES[language]
version, ver_type, is_stable = get_version()
write_git_clone_inc(template["git-clone"], 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"]
if version == "master":
args = {
"clone_args" : "",
"extra_note" : template["master"],
"zipfile_note" : zipfile["unstable"]
}
else:
args = {
"clone_args" : "-b %s " % version,
"extra_note" : template["branch"] % (version, 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") as f:
f.write(template["template"] % args)
print("%s written" % out_file)
def write_version_note(template, out_dir, version, ver_type, is_stable):
if version == "master":
content = template["master"]
elif ver_type == "tag" and is_stable:
content = template["stable"] % version
else:
content = template["branch"] % (ver_type, version)
out_file = os.path.join(out_dir, "version-note.inc")
with open(out_file, "w") as f:
f.write(content)
print("%s written" % out_file)
def get_version():
"""
Returns a tuple of (name of branch/tag, type branch/tag, is_stable)
"""
# Trust what RTD says our version is, if it is set
version = os.environ.get("READTHEDOCS_VERSION", None)
if version == "latest":
return ("master", "branch", False)
# Otherwise, use git to look for a tag
try:
tag = subprocess.check_output(["git", "describe", "--tags", "--exact-match"]).strip()
is_stable = re.match(r"v[0-9\.]+$", tag) is not None
return (tag, "tag", is_stable)
except subprocess.CalledProcessError:
pass
# No tag, look for a branch
refs = subprocess.check_output(["git", "for-each-ref", "--points-at", "HEAD", "--format", "%(refname)"])
print("refs:\n%s" % refs)
refs = refs.split("\n")
# Note: this looks for branches in 'origin' because GitLab CI doesn't check out a local branch
branches = [ r.replace("refs/remotes/origin/","").strip() for r in refs if r.startswith("refs/remotes/origin/") ]
if len(branches) == 0:
# last resort, return the commit (may happen on Gitlab CI sometimes, unclear why)
return (subprocess.check_output(["git", "rev-parse", "--short", "HEAD"]).strip(), "commit", False)
if "master" in branches:
return ("master", "branch", False)
else:
return (branches[0], "branch", False) # take whatever the first branch is
if __name__ == "__main__":
main()

View file

@ -4,6 +4,7 @@ Get Started
This document is intended to help users set up the software environment for developement 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
============
@ -113,19 +114,18 @@ Get ESP-IDF
.. highlight:: bash
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>`_. To get it, open terminal, navigate to the directory you want to put ESP-IDF, and clone it using ``git clone`` command::
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>`_.
cd ~/esp
git clone --recursive https://github.com/espressif/esp-idf.git
.. include:: /_build/inc/git-clone.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.
.. 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
git submodule update --init
git submodule update --init --recursive
.. _get-started-setup-path:
@ -299,23 +299,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`.
Another solution is to update only what has changed. This method is useful if you have slow connection to the GiHub. 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.
cd ~/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.
If you would like to use specific release of ESP-IDF, e.g. `v2.1`, run::
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
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.
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
@ -330,3 +316,7 @@ 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

@ -41,6 +41,7 @@ This is the documentation for Espressif IoT Development Framework (`esp-idf <htt
H/W Reference <hw-reference/index>
API Guides <api-guides/index>
Contribute <contribute/index>
Versions <versions>
Resources <resources>
Copyrights <COPYRIGHT>
About <about>

178
docs/versions.rst Normal file
View file

@ -0,0 +1,178 @@
ESP-IDF Versions
================
The ESP-IDF GitHub repository is updated regularly, especially on the "master branch" where new development happens. There are also stable releases which are recommended for production use.
Releases
--------
Documentation for the current stable version can always be found at this URL:
https://docs.espressif.com/projects/esp-idf/en/stable/
Documentation for the latest version ("master branch") can always be found at this URL:
https://docs.espressif.com/projects/esp-idf/en/latest/
The full history of releases can be found on the GitHub repository `Releases page`_. There you can find release notes, links to each version of the documentation, and instructions for obtaining each version.
Documentation for all releases can also be found in the HTML documentation by clicking the "versions" pop up in the bottom-left corner of the page. You can use this popup to switch between versions of the documentation.
.. image:: _static/choose_version.png
Which Version Should I Start With?
----------------------------------
- For production purposes, use the `current stable version`_. Stable versions have been manually tested, and are updated with "bugfix releases" which fix bugs without changing other functionality (see `Versioning Scheme`_ for more details).
- For prototyping, experimentation or for developing new ESP-IDF features, use the `latest version (master branch in Git) <https://docs.espressif.com/projects/esp-idf/en/latest/>`_. The latest version in the master branch has all the latest features and has passed automated testing, but has not been completely manually tested ("bleeding edge").
- If a required feature is not yet available in a stable release, but you don't want to use the master branch, it is possible to check out a pre-release version or a release branch. It is recommended to start from a stable version and then follow the instructions for :ref:`updating-pre-release` or :ref:`updating-release-branch`.
See :ref:`updating` if you already have a local copy of ESP-IDF and wish to update it.
Versioning Scheme
-----------------
ESP-IDF uses `Semantic Versioning <http://semver.org/>`_. This means:
- Major Releases like ``v3.0`` add new functionality and may change functionality. This includes removing deprecated functionality.
When updating to a new major release (for example, from ``v2.1`` to ``v3.0``), some of your project's code may need updating and functionality will need to be re-tested. The release notes on the `Releases page`_ include lists of Breaking Changes to refer to.
- Minor Releases like ``v3.1`` add new functionality and fix bugs but will not change or remove documented functionality, or make incompatible changes to public APIs.
If updating to a new minor release (for example, from ``v3.0`` to ``v3.1``) then none of your project's code should need updating, but you should re-test your project. Pay particular attention to items mentioned in the release notes on the `Releases page`_.
- Bugfix Releases like ``v3.0.1`` only fix bugs and do not add new functionality.
If updating to a new bugfix release (for example, from ``v3.0`` to ``v3.0.1``), you should not need to change any code in your project and should only need to re-test functionality relating directly to bugs listed in the release notes on the `Releases page`_.
Checking The Current Version
----------------------------
The local ESP-IDF version can be checked using git::
cd $IDF_PATH
git describe --tags --dirty
The version is also compiled into the firmware and can be accessed (as a string) via the macro ``IDF_VER``. The default ESP-IDF bootloader will print the version on boot (these versions in code will not always update, it only changes if that particular source file is recompiled).
Examples of ESP-IDF versions:
============================ ==================================================
Version String Meaning
============================ ==================================================
``v3.2-dev-306-gbeb3611ca`` Master branch pre-release, in development for
version 3.2. 306 commits after v3.2 development
started. Commit identifier ``beb3611ca``.
``v3.0.2`` Stable release, tagged ``v3.0.2``.
``v3.1-beta1-75-g346d6b0ea`` Beta version in development (on a
:ref:`release branch <updating-release-branch>`).
75 commits after ``v3.1-beta1`` pre-release tag.
Commit identifier ``346d6b0ea``.
``v3.0.1-dirty`` Stable release, tagged ``v3.0.1``.
There are modifications in the local ESP-IDF
directory ("``dirty``").
============================ ==================================================
Git Workflow
------------
The development (Git) workflow of the Espressif ESP-IDF team is:
- New work is always added on the master branch (latest version) first. The ESP-IDF version on ``master`` is always tagged with ``-dev`` (for "in development"), for example ``v3.1-dev``.
- Changes are first added to an internal Git repository for code review and testing, but are pushed to GitHub after automated testing passes.
- When a new version (developed on ``master``) becomes feature complete and "beta" quality, a new branch is made for the release, for example ``release/v3.1``. A pre-release tag is also created, for example ``v3.1-beta1``. You can see a full `list of branches`_ and a `list of tags`_ on GitHub. Beta pre-releases have release notes which may include a significant number of Known Issues.
- As testing of the beta version progresses, bug fixes will be added to both the ``master`` branch and the release branch. New features (for the next release) may start being added to ``master`` at the same time.
- Once testing is nearly complete a new release candidate is tagged on the release branch, for example ``v3.1-rc1``. This is still a pre-release version.
- If no more significant bugs are found or reported then the final Major or Minor Version is tagged, for example ``v3.1``. This version appears on the `Releases page`_.
- As bugs are reported in released versions, the fixes will continue to be committed to the same release branch.
- Regular bugfix releases are made from the same release branch. After manual testing is complete, a bugfix release is tagged (i.e. ``v3.1.1``) and appears on the `Releases page`_.
.. _updating:
Updating ESP-IDF
----------------
Updating ESP-IDF depends on which version(s) you wish to follow:
- :ref:`updating-stable-releases` is recommended for production use.
- :ref:`updating-master` is recommended for latest features, development use, and testing.
- :ref:`updating-release-branch` is a compromise between these two.
.. note:: These guides assume you already have a local copy of ESP-IDF. To get one, follow the :doc:`Getting Started </get-started/index>` guide for any ESP-IDF version.
.. _`updating-stable-releases`:
Updating to Stable Release
^^^^^^^^^^^^^^^^^^^^^^^^^^
To update to new ESP-IDF releases (recommended for production use), this is the process to follow:
- Check the `Releases page`_ regularly for new releases.
- When a bugfix release for a version you are using is released (for example if using ``v3.0.1`` and ``v3.0.2`` is available), check out the new bugfix version into the existing ESP-IDF directory::
cd $IDF_PATH
git fetch
git checkout vX.Y.Z
git submodule update --init --recursive
- When major or minor updates are released, check the Release Notes on the releases page and decide if you would like to update or to stay with your existing release. Updating is via the same Git commands shown above.
.. note:: If you installed the stable release via zip file rather than using git, it may not be possible to change versions this way. In this case, update by downloading a new zip file and replacing the entire ``IDF_PATH`` directory with its contents.
.. _`updating-pre-release`:
Updating to a Pre-Release Version
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
It is also possible to ``git checkout`` a tag corresponding to a pre-release version or release candidate, the process is the same as :ref:`updating-stable-releases`.
Pre-release tags are not always found on the `Releases page`_. Consult the `list of tags`_ on GitHub for a full list. Caveats for using a pre-release are similar to :ref:`updating-release-branch`.
.. _`updating-master`:
Updating to Master Branch
^^^^^^^^^^^^^^^^^^^^^^^^^
.. note:: Using Master branch means living "on the bleeding edge" with the latest ESP-IDF code.
To use the latest version on the ESP-IDF master branch, this is the process to follow:
- Check out the master branch locally::
cd $IDF_PATH
git checkout master
git pull
git submodule update --init --recursive
- Periodically, re-run ``git pull`` to pull the latest version of master. Note that you may need to change your project or report bugs after updating master branch.
- To switch from ``master`` to a release branch or stable version, run ``git checkout`` as shown in the other sections.
.. important:: It is strongly recommended to regularly run ``git pull`` and then ``git submodule update --init --recursive`` so a local copy of ``master`` does not get too old. Arbitrary old master branch revisions are effectively unsupportable "snapshots" that may have undocumented bugs. For a semi-stable version, try :ref:`updating-release-branch` instead.
.. _`updating-release-branch`:
Updating to a Release Branch
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
In stability terms, using a release branch is part-way between using ``master`` branch and only using stable releases. A release branch is always beta quality or better, and receives bug fixes before they appear in each stable release.
You can find a `list of branches`_ on GitHub.
For example, to follow the branch for ESP-IDF v3.1, including any bugfixes for future releases like ``v3.1.1``, etc::
cd $IDF_PATH
git fetch
git checkout release/v3.1
git pull
git submodule --update --init --recursive
Each time you ``git pull`` this branch, ESP-IDF will be updated with fixes for this release.
.. note:: The is no dedicated documentation for release branches. It is recommended to use the documentation for the closest version to the branch which is currently checked out.
.. _`Releases page`: http://github.com/espressif/esp-idf/releases
.. _`list of branches`: https://github.com/espressif/esp-idf/branches
.. _`list of tags`: https://github.com/espressif/esp-idf/tags
.. _`current stable version`: https://docs.espressif.com/projects/esp-idf/en/stable/