Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
703 changes: 470 additions & 233 deletions tools/esptool_py/CHANGELOG.md

Large diffs are not rendered by default.

60 changes: 30 additions & 30 deletions tools/esptool_py/CONTRIBUTING.rst
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
Contributions Guide
===================

We welcome contributions to the ``esptool.py`` project!
We welcome contributions to the ``esptool`` project!

How to Contribute
-----------------

Contributions to ``esptool.py`` - fixing bugs, adding features, adding documentation - are welcome. We accept contributions via `Github Pull Requests <https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests>`_.
Contributions to ``esptool`` - fixing bugs, adding features, adding documentation - are welcome. We accept contributions via `Github Pull Requests <https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests>`_.

.. _development-setup:

Development Setup
-----------------

Development mode allows you to run the latest development version from the `esptool.py repository on GitHub <https://github.com/espressif/esptool>`_.
Development mode allows you to run the latest development version from the `esptool repository on GitHub <https://github.com/espressif/esptool>`_.

.. code-block:: sh

$ git clone https://github.com/espressif/esptool.git
$ cd esptool
$ pip install --user -e .

This will install ``esptool.py``’s dependencies and create some executable script wrappers in the users ``bin`` directory. The wrappers will run the scripts found in the git working directory directly, so any time the working directory contents change it will pick up the new versions.
This will install ``esptool``'s dependencies and create some executable script wrappers in the user's ``bin`` directory. The wrappers will run the scripts found in the git working directory directly, so any time the working directory contents change it will pick up the new versions.

Its also possible to run the scripts directly from the working directory with this Development Mode installation.
It's also possible to run the scripts directly from the working directory with this Development Mode installation.

To also install additional tools needed for actually developing and testing ``esptool.py``, run this command to install a development copy of ``esptool.py`` *plus* packages useful for development:
To also install additional tools needed for actually developing and testing ``esptool``, run this command to install a development copy of ``esptool`` *plus* packages useful for development:

::

Expand All @@ -36,14 +36,16 @@ To also install additional tools needed for actually developing and testing ``es
Reporting Issues
----------------

Please report bugs in ``esptool.py`` if you find them. However, before reporting a bug please check through the following:
Please report bugs in ``esptool`` if you find them. However, before reporting a bug please check through the following:

* `Troubleshooting Guide <https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.html>`_ - common problems and known issues.

* `Existing Open Issues <https://github.com/espressif/esptool/issues>`_ - someone might have already encountered this.

If you don’t find anything, please `open a new issue <https://github.com/espressif/esptool/issues/new/choose>`_.

.. _feature-requests:

Sending Feature Requests
------------------------

Expand All @@ -56,7 +58,7 @@ Before Contributing

Before sending us a Pull Request, please consider this list of points:

* Have you tried running ``esptool.py`` test suite locally?
* Have you tried running ``esptool`` test suite locally?

* Is the code adequately commented for people to understand how it is structured?

Expand All @@ -71,9 +73,9 @@ Before sending us a Pull Request, please consider this list of points:
Code Style & Static Analysis
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Please follow these coding standards when writing code for ``esptool.py``:
Please follow these coding standards when writing code for ``esptool``:

Pre-commit checks
Pre-Commit Checks
"""""""""""""""""

`pre-commit <https://pre-commit.com/>`_ is a framework for managing pre-commit hooks. These hooks help to identify simple issues before committing code for review.
Expand All @@ -90,27 +92,27 @@ On the first commit ``pre-commit`` will install the hooks, subsequent checks wil
Conventional Commits
""""""""""""""""""""

``esptool.py`` complies with the `Conventional Commits standard <https://www.conventionalcommits.org/en/v1.0.0/#specification>`_. Every commit message is checked with `Conventional Precommit Linter <https://github.com/espressif/conventional-precommit-linter>`_, ensuring it adheres to the standard.
``esptool`` complies with the `Conventional Commits standard <https://www.conventionalcommits.org/en/v1.0.0/#specification>`_. Every commit message is checked with `Conventional Precommit Linter <https://github.com/espressif/conventional-precommit-linter>`_, ensuring it adheres to the standard.


Ruff
""""

``esptool.py`` is `PEP8 <https://peps.python.org/pep-0008/>`_ compliant and enforces this style guide. For compliance checking, we use `ruff <https://docs.astral.sh/ruff/>`_.
``esptool`` is `PEP8 <https://peps.python.org/pep-0008/>`_ compliant and enforces this style guide. For compliance checking, we use `ruff <https://docs.astral.sh/ruff/>`_.
``Ruff`` also auto-format files in the same style as previously used ``black``.


``Ruff`` and ``Conventional Precommit Linter`` tools will be automatically run by ``pre-commit`` if that is configured. To check your code manually before submitting, run ``python -m ruff`` (this tool is installed as part of the development requirements shown at the beginning of this document).

When you submit a Pull Request, the GitHub Actions automated build system will run automated checks using these tools.

Shinx-lint
""""""""""
Sphinx-Lint
"""""""""""

The documentation is checked for stylistic and formal issues by ``sphinx-lint``.


Codespell check
Codespell Check
"""""""""""""""

This repository utilizes an automatic `spell checker <https://github.com/codespell-project/codespell>`_ integrated into the pre-commit process. If any spelling issues are detected, the recommended corrections will be applied automatically to the file, ready for commit.
Expand All @@ -120,46 +122,46 @@ In the event of false positives, you can adjust the configuration in the `.codes
Automated Integration Tests
^^^^^^^^^^^^^^^^^^^^^^^^^^^

The test directory contains a `pytest <https://docs.pytest.org/>`_ integration suite with some integration tests for ``esptool.py``, ``espefuse.py``, and ``espsecure.py``.
The test directory contains a `pytest <https://docs.pytest.org/>`_ integration suite with some integration tests for ``esptool``, ``espefuse``, and ``espsecure``.

It is necessary to have ``esptool.py`` installed (see `Development Setup`_) in your environment in order to run these tests.
It is necessary to have ``esptool`` installed (see `Development Setup`_) in your environment in order to run these tests.

The following tests run automatically by GitHub Actions for each Pull Request. You can run them locally to check for regressions in the respective functionality:

* ``test_imagegen.py`` tests the ``elf2image`` command
* ``test_image_info.py`` tests the ``image_info`` command
* ``test_mergebin.py`` tests the ``merge_bin`` command
* ``test_modules.py`` tests the modules used by ``esptool.py`` for regressions
* ``test_espsecure.py`` tests ``espsecure.py`` functionality
* ``test_espsecure_hsm.py`` tests support of external HSM signing in ``espsecure.py``. These tests require additional prerequisites, see ``SoftHSM2 setup`` in the `tests workflow definition <https://github.com/espressif/esptool/blob/master/.github/workflows/test_esptool.yml>`_ for more information.
* ``test_image_info.py`` tests the ``image-info`` command
* ``test_mergebin.py`` tests the ``merge-bin`` command
* ``test_modules.py`` tests the modules used by ``esptool`` for regressions
* ``test_espsecure.py`` tests ``espsecure`` functionality
* ``test_espsecure_hsm.py`` tests support of external HSM signing in ``espsecure``. These tests require additional prerequisites, see ``SoftHSM2 setup`` in the `tests workflow definition <https://github.com/espressif/esptool/blob/master/.github/workflows/test_esptool.yml>`_ for more information.

The following tests are not run automatically by GitHub Actions, because they need real connected hardware. Therefore, they need to be run locally in a command line:

* ``test_esptool.py`` contains integration tests for ``esptool.py`` and needs to be run against real Espressif hardware with the following format:
* ``test_esptool.py`` contains integration tests for ``esptool`` and needs to be run against real Espressif hardware with the following format:

``pytest test_esptool.py --port <serial port> --chip <name of chip> --baud <baud rate>``

For example, to run all tests on an ESP32 board connected to /dev/ttyUSB0, at 230400bps:

``pytest test_esptool.py --port /dev/ttyUSB0 --chip esp32 --baud 230400``

Or to run the TestFlashing suite only (using the pytest ``-k`` option to select tests based on their name) on an ESP8266 board connected to /dev/ttyUSB2, at 460800bps:
Or to run the ``TestFlashing`` suite only (using the pytest ``-k`` option to select tests based on their name) on an ESP8266 board connected to /dev/ttyUSB2, at 460800bps:

``pytest test_esptool.py --port /dev/ttyUSB2 --chip esp8266 --baud 460800 -k TestFlashing``

.. note::

Some tests might fail at higher baud rates on some hardware.

* ``test_esptool_sdm.py`` contains integration tests for ``esptool.py`` with chips in secure download mode. It needs to be run against real Espressif hardware (with active SDM). The command line format is the same as for ``test_esptool.py``.
* ``test_esptool_sdm.py`` contains integration tests for ``esptool`` with chips in secure download mode. It needs to be run against real Espressif hardware (with active SDM). The command line format is the same as for ``test_esptool.py``.

The following tests are not run automatically by GitHub Actions, but can be run locally in a command line:

* ``test_espefuse.py`` tests ``espefuse.py`` functionality. To run it:
* ``test_espefuse.py`` tests ``espefuse`` functionality. To run it:

``pytest test_espefuse.py --chip <name of chip>``

These test use the ``--virt`` virtual mode of ``espefuse.py`` to safely test the functionality without a connection to a chip and without the possibility of affecting the actual eFuses in a real hardware.
These test use the ``--virt`` virtual mode of ``espefuse`` to safely test the functionality without a connection to a chip and without the possibility of affecting the actual eFuses in a real hardware.

.. warning::

Expand All @@ -171,9 +173,7 @@ The whole test suite (without the tests needing an actual hardware or installati
Pull Request Process
--------------------

.. note::

If you are developing the stub flasher and plan to send a pull request, please use the latest toolchains available.
If you would like to contribute to the flasher stub, please see the `Flasher stub repository <https://github.com/espressif/esptool-legacy-flasher-stub>`_.

After you open the Pull Request, there will probably be some discussion in the comments field of the request itself.

Expand Down
2 changes: 1 addition & 1 deletion tools/esptool_py/MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ include LICENSE
include esptool/targets/stub_flasher/1/*
include esptool/targets/stub_flasher/2/*
include espefuse/efuse_defs/*.yaml
# sdist includes test/test*.py by default, but esptool.py tests
# sdist includes test/test*.py by default, but esptool tests
# are so far only intended to run from the git repo itself
prune test
prune .github
Expand Down
10 changes: 5 additions & 5 deletions tools/esptool_py/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# esptool.py
# esptool

A Python-based, open-source, platform-independent utility to communicate with the ROM bootloader in Espressif chips.
A Python-based, open-source, platform-independent serial utility for flashing, provisioning, and interacting with Espressif SoCs.

[![Test esptool](https://github.com/espressif/esptool/actions/workflows/test_esptool.yml/badge.svg?branch=master)](https://github.com/espressif/esptool/actions/workflows/test_esptool.yml) [![Build esptool](https://github.com/espressif/esptool/actions/workflows/build_esptool.yml/badge.svg?branch=master)](https://github.com/espressif/esptool/actions/workflows/build_esptool.yml)

## Documentation

Visit the [documentation](https://docs.espressif.com/projects/esptool/) or run `esptool.py -h`.
Visit the [documentation](https://docs.espressif.com/projects/esptool/) or run `esptool -h`.

## Contribute

If you're interested in contributing to esptool.py, please check the [contributions guide](https://docs.espressif.com/projects/esptool/en/latest/contributing.html).
If you're interested in contributing to esptool, please check the [contributions guide](https://docs.espressif.com/projects/esptool/en/latest/contributing.html).

## About

esptool.py was initially created by Fredrik Ahlberg (@[themadinventor](https://github.com/themadinventor/)), and later maintained by Angus Gratton (@[projectgus](https://github.com/projectgus/)). It is now supported by Espressif Systems. It has also received improvements from many members of the community.
esptool was initially created by Fredrik Ahlberg (@[themadinventor](https://github.com/themadinventor/)), and later maintained by Angus Gratton (@[projectgus](https://github.com/projectgus/)). It is now supported by Espressif Systems. It has also received improvements from many members of the community.

## License

Expand Down
34 changes: 18 additions & 16 deletions tools/esptool_py/ci/download_flasher_stubs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
# SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: GPL-2.0-or-later

import glob
Expand All @@ -12,42 +12,43 @@
"STUB_SET_VERSION": "1",
"DOWNLOAD_URL": "https://github.com/espressif/esptool-legacy-flasher-stub/releases/download",
"TAG_URL": "https://github.com/espressif/esptool-legacy-flasher-stub/releases/tag",
"VERSION": "v1.3.0",
"VERSION": "v1.6.0",
"FILE_LIST": (
"esp32",
"esp32c2",
"esp32c3",
"esp32c5",
"esp32c5beta3",
"esp32c6",
"esp32c61",
"esp32c6beta",
"esp32h2",
"esp32h2beta1",
"esp32h2beta2",
"esp32p4",
"esp32s2",
"esp32s3",
"esp32s3beta2",
"esp8266",
),
"LICENSE": "released as Free Software under GNU General Public License Version 2 or later",
"LICENSE": "released as Free Software under GNU General Public License "
"Version 2 or later",
},
{
"STUB_SET_VERSION": "2",
"DOWNLOAD_URL": "https://github.com/esp-rs/esp-flasher-stub/releases/download",
"TAG_URL": "https://github.com/esp-rs/esp-flasher-stub/releases/tag",
"VERSION": "v0.3.0",
"DOWNLOAD_URL": "https://github.com/espressif/esp-flasher-stub/releases/download",
"TAG_URL": "https://github.com/espressif/esp-flasher-stub/releases/tag",
"VERSION": "v0.1.0",
"FILE_LIST": (
"esp32",
"esp32c2",
"esp32c3",
"esp32c5",
"esp32c6",
"esp32c61",
"esp32h2",
"esp32p4",
"esp32s2",
"esp32s3",
"esp8266",
),
"LICENSE": "dual licensed under the Apache License Version 2.0 or the MIT license",
"LICENSE": "dual licensed under the Apache License Version 2.0 or the MIT "
"license",
},
)

Expand All @@ -56,16 +57,17 @@
README_TEMPLATE = """# Licensing

The binaries in JSON format distributed in this directory are {LICENSE}. They were released at {URL} from where the sources can be obtained.
"""
""" # noqa: E501


def main():
for stub_set in STUBS:
dest_sub_dir = os.path.join(DESTINATION_DIR, stub_set["STUB_SET_VERSION"])

""" The directory is cleaned up so we would detect if a stub was just committed into the repository but the
name was not added into the FILE_LIST of STUBS. This would be an unwanted state because the checker would not
detect any changes in that stub."""
""" The directory is cleaned up so we would detect if a stub was just committed
into the repository but the name was not added into the FILE_LIST of STUBS.
This would be an unwanted state because the checker would not detect any
changes in that stub."""
for old_file in glob.glob(os.path.join(dest_sub_dir, "*.json")):
print(f"Removing old file {old_file}")
os.remove(old_file)
Expand Down
9 changes: 7 additions & 2 deletions tools/esptool_py/docs/_static/esptool_versions.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
var DOCUMENTATION_VERSIONS = {
DEFAULTS: { has_targets: false,
DEFAULTS: { has_targets: true,
supported_targets: [ "esp32" ]
},
VERSIONS: [ ],
VERSIONS: [
{ name: "latest", old: false, pre_release: false, supported_targets: [ "esp8266", "esp32", "esp32s2", "esp32s3", "esp32c3", "esp32c2", "esp32c6", "esp32p4", "esp32h2", "esp32c5", "esp32c61" ] },
{ name: "release-v4", old: false, pre_release: false, supported_targets: [ "esp8266", "esp32", "esp32s2", "esp32s3", "esp32c3", "esp32c2", "esp32c6", "esp32p4", "esp32h2", "esp32c5", "esp32c61" ] },
],
IDF_TARGETS: [
{ text: "ESP8266", value: "esp8266" },
{ text: "ESP32", value: "esp32" },
Expand All @@ -13,5 +16,7 @@ var DOCUMENTATION_VERSIONS = {
{ text: "ESP32-C6", value: "esp32c6" },
{ text: "ESP32-H2", value: "esp32h2" },
{ text: "ESP32-P4", value: "esp32p4" },
{ text: "ESP32-C5", value: "esp32c5" },
{ text: "ESP32-C61", value: "esp32c61" },
]
};
17 changes: 16 additions & 1 deletion tools/esptool_py/docs/conf_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"esp32c6",
"esp32h2",
"esp32p4",
"esp32c5",
"esp32c61",
]

# link roles config
Expand All @@ -23,7 +25,14 @@
html_static_path = ["../_static"]

# Conditional content
extensions += ["esp_docs.esp_extensions.dummy_build_system"]
extensions += [
"esp_docs.esp_extensions.dummy_build_system",
"sphinx.ext.autodoc",
"sphinx.ext.napoleon",
"sphinx_tabs.tabs",
]

sphinx_tabs_disable_tab_closing = True

ESP8266_DOCS = []

Expand All @@ -42,9 +51,15 @@
"esp32c6": ESP32_DOCS,
"esp32h2": ESP32_DOCS,
"esp32p4": ESP32_DOCS,
"esp32c5": ESP32_DOCS,
"esp32c61": ESP32_DOCS,
}

# Extra options required by sphinx_idf_theme
project_slug = "esptool"

versions_url = "./_static/esptool_versions.js"


def conf_setup(app, config):
config.html_baseurl = f"https://docs.espressif.com/projects/esptool/{config.language}/stable/{config.idf_target}/"
Loading