Skip to content

doc,esp32: Improve and de-duplicate the flashing instructions. #16535

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 17, 2025
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 69 additions & 80 deletions docs/esp32/tutorial/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,106 +36,95 @@ Getting the firmware

The first thing you need to do is download the most recent MicroPython firmware
.bin file to load onto your ESP32 device. You can download it from the
`MicroPython downloads page <https://micropython.org/download#esp32>`_.
From here, you have 3 main choices:
`MicroPython download page`_. Search for your particular board on this page.

* Stable firmware builds
* Daily firmware builds
* Daily firmware builds with SPIRAM support
.. note:: If you don't see your specific board on the download page, then it's
very likely that one of the generic firmwares will work. These are
listed at the top of the download page and have names matching the
onboard Espressif chip (i.e. `ESP32 / WROOM`_, `ESP32-C3`_,
`ESP32-S3`_, etc).

If you are just starting with MicroPython, the best bet is to go for the Stable
firmware builds. If you are an advanced, experienced MicroPython ESP32 user
who would like to follow development closely and help with testing new
features, there are daily builds. If your board has SPIRAM support you can
use either the standard firmware or the firmware with SPIRAM support, and in
the latter case you will have access to more RAM for Python objects.
However, you may need to double check with the vendor you purchased
the board from.

.. _esp32_flashing:

Deploying the firmware
----------------------

Once you have the MicroPython firmware you need to load it onto your ESP32 device.
There are two main steps to do this: first you need to put your device in
bootloader mode, and second you need to copy across the firmware. The exact
procedure for these steps is highly dependent on the particular board and you will
need to refer to its documentation for details.

Fortunately, most boards have a USB connector, a USB-serial converter, and the DTR
and RTS pins wired in a special way then deploying the firmware should be easy as
all steps can be done automatically. Boards that have such features
include the Adafruit Feather HUZZAH32, M5Stack, Wemos LOLIN32, and TinyPICO
boards, along with the Espressif DevKitC, PICO-KIT, WROVER-KIT dev-kits.
From here, you have a choice to make:

For best results it is recommended to first erase the entire flash of your
device before putting on new MicroPython firmware.
* Download a stable firmware release.
* Download a daily firmware "Preview" build.

Currently we only support esptool.py to copy across the firmware. You can find
this tool here: `<https://github.com/espressif/esptool/>`__, or install it
using pip::
If you are just starting with MicroPython, the best bet is to go for the stable
Release firmware builds. If you are an advanced, experienced MicroPython ESP32
user who would like to follow development closely and help with testing new
features, then you may find the Preview builds useful.

pip install esptool

Versions starting with 1.3 support both Python 2.7 and Python 3.4 (or newer).
An older version (at least 1.2.1 is needed) works fine but will require Python
2.7.
.. _esp32_flashing:

Using esptool.py you can erase the flash with the command::
Deploying the firmware
----------------------

esptool.py --port /dev/ttyUSB0 erase_flash
Once you have the MicroPython firmware you need to load it onto your ESP32
device. There are two main steps to do this: first you need to put your device
in bootloader mode, and second you need to copy across the firmware. The exact
procedure for these steps is highly dependent on the particular board.

And then deploy the new firmware using::
Detailed steps can be found on the same `MicroPython download page`_ for your
board. It's recommended that you follow the steps on the download page, as they
are customised for your particular board.

esptool.py --chip esp32 --port /dev/ttyUSB0 write_flash -z 0x1000 esp32-20180511-v1.9.4.bin
If the above commands run without error then MicroPython should be installed on
your board! Skip ahead to :ref:`esp32_serial_prompt`.

Notes:
.. _esp32_troubleshooting_install:

* You might need to change the "port" setting to something else relevant for your
PC
* You may need to reduce the baudrate if you get errors when flashing
(eg down to 115200 by adding ``--baud 115200`` into the command)
* For some boards with a particular FlashROM configuration you may need to
change the flash mode (eg by adding ``-fm dio`` into the command)
* The filename of the firmware should match the file that you have
Troubleshooting installation problems
-------------------------------------

If the above commands run without error then MicroPython should be installed on
your board!
If you experience problems during flashing or with running firmware immediately
after flashing, here are some troubleshooting recommendations:

* Esptool will try to detect the serial port where your ESP32 is connected. If
this doesn't work, or you have multiple serial ports, then you may need to
manually specify the port by adding the ``--port`` option to the start of the
``esptool.py`` command line. For example, ``esptool.py --port /dev/ttyUSB0
<rest of line>`` for Linux or ``esptool --port COM4 <rest of line>`` for
Windows.
* If the board isn't responding to esptool at all, it may need to be manually
reset into the bootloader download mode. Look for a button marked "BOOT" or
"IO0" on your board and a second button marked "RESET" or "RST". If you have
both buttons, try these steps:

1. Press "BOOT" (or "IO0") and hold it down.
2. Press "RESET" (or "RST") and immediately release it.
3. Release "BOOT" (or "IO0").
4. Re-run the flashing steps from the download page.

If your board doesn't have these buttons, consult the board manufacturer's
documentation about entering bootloader download mode.
* If you get errors part-way through the flashing process then try reducing the
speed of data transfer by removing the ``--baud 460800`` argument.
* Hardware problems can cause flashing to fail. There are two common problems:
bad power source quality, and defective hardware (especially very low cost
unbranded development boards). Speaking of power source, not just raw amperage
is important, but also low ripple and noise/EMI in general. The most reliable
and convenient power source is a USB port.
* If you still experience problems with flashing the firmware then please also
refer to the `esptool Troubleshooting documentation`_.

.. _esp32_serial_prompt:

Serial prompt
-------------

Once you have the firmware on the device you can access the REPL (Python prompt)
over UART0 (GPIO1=TX, GPIO3=RX), which might be connected to a USB-serial
converter, depending on your board. The baudrate is 115200.
over either UART0, which might be connected to a USB-serial converter depending
on your board, or the chip's built-in USB device. The baudrate is 115200.

From here you can now follow the ESP8266 tutorial, because these two Espressif chips
are very similar when it comes to using MicroPython on them. The ESP8266 tutorial
is found at :ref:`esp8266_tutorial` (but skip the Introduction section).

Troubleshooting installation problems
-------------------------------------

If you experience problems during flashing or with running firmware immediately
after it, here are troubleshooting recommendations:

* Be aware of and try to exclude hardware problems. There are 2 common
problems: bad power source quality, and worn-out/defective FlashROM.
Speaking of power source, not just raw amperage is important, but also low
ripple and noise/EMI in general. The most reliable and convenient power
source is a USB port.

* The flashing instructions above use flashing speed of 460800 baud, which is
good compromise between speed and stability. However, depending on your
module/board, USB-UART converter, cables, host OS, etc., the above baud
rate may be too high and lead to errors. Try a more common 115200 baud
rate instead in such cases.

* To catch incorrect flash content (e.g. from a defective sector on a chip),
add ``--verify`` switch to the commands above.

* If you still experience problems with flashing the firmware please
refer to esptool.py project page, https://github.com/espressif/esptool
for additional documentation and a bug tracker where you can report problems.

* If you are able to flash the firmware but the ``--verify`` option returns
errors even after multiple retries the you may have a defective FlashROM chip.
.. _esptool Troubleshooting documentation: https://docs.espressif.com/projects/esptool/en/latest/esp32/troubleshooting.html
.. _MicroPython download page: https://micropython.org/download/?port=esp32
.. _ESP32 / WROOM: https://micropython.org/download/ESP32_GENERIC
.. _ESP32-C3: https://micropython.org/download/ESP32_GENERIC_C3
.. _ESP32-S3: https://micropython.org/download/ESP32_GENERIC_S3
9 changes: 9 additions & 0 deletions ports/esp32/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,15 @@ files that configure ESP-IDF settings. Some standard `sdkconfig` files are
provided in the `boards/` directory, like `boards/sdkconfig.ble`. You can
also define custom ones in your board directory.

Deployment instructions usually invoke the `boards/deploy.md` file (for boards
with a USB/Serial converter connection), or the `boards/deploy_nativeusb.md`
file (for boards with only a native USB port connection). These files are
formatted for each board using template strings found in the `boards.json`
files. You can also include the common `boards/deploy_flashmode.md` file if you
have a board which requires manual resetting via the RESET and BOOT buttons.
Boards with unique flashing steps can include custom `deploy.md` file(s).
Existing `board.json` files contain examples of all of these combinations.

See existing board definitions for further examples of configuration.

Configuration
Expand Down
3 changes: 3 additions & 0 deletions ports/esp32/boards/ARDUINO_NANO_ESP32/board.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"deploy": [
"deploy.md"
],
"deploy_options": {
"flash_offset": "0"
},
"docs": "",
"features": [
"BLE",
Expand Down
2 changes: 2 additions & 0 deletions ports/esp32/boards/ARDUINO_NANO_ESP32/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ Please note that the DFU bootloader comes factory flashed. Should you for any re
entire flash, the DFU bootloader will have to be re-installed. Please follow the instructions
[here](https://support.arduino.cc/hc/en-us/articles/9810414060188-Reset-the-Arduino-bootloader-on-the-Nano-ESP32)
to do so.

**Important** From the options below, download the `.app-bin` file for your board.
3 changes: 3 additions & 0 deletions ports/esp32/boards/ESP32_GENERIC/board.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"deploy": [
"../deploy.md"
],
"deploy_options": {
"flash_offset": "0x1000"
},
"docs": "",
"features": [
"BLE",
Expand Down
19 changes: 14 additions & 5 deletions ports/esp32/boards/ESP32_GENERIC/board.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
The following files are firmware that should work on most ESP32-based boards
with 4MiB of flash, including WROOM WROVER, SOLO, PICO, and MINI modules.

If your board is based on a WROVER module, or otherwise has SPIRAM (also known
as PSRAM), then use the "spiram" variant.
This board has multiple variants available:

The "d2wd" variant is for ESP32-D2WD chips (with 2MiB flash), and "unicore" is
for single-core ESP32 chips (e.g. the "SOLO" modules). The "ota" variant sets
up the partition table to allow for Over-the-Air updates.
* If your board is based on a WROVER module, or otherwise has SPIRAM (also known
as PSRAM) then it's recommended to use the "spiram" variant. Look for heading
**Support for SPIRAM / WROVER)**.
* If your board has a ESP32-D2WD chip (with only 2MiB flash) then use the "d2wd"
variant. Look for heading **ESP32 D2WD**.
* If your board has a single-core ESP32 (e.g. the "SOLO" modules) then choose
the "unicore" variant. Look for heading **ESP32 Unicore**.
* If you'd like to perform Over-the-Air updates of the MicroPython firmware,
then choose the "ota" variant. This variant has less room in the flash for
Python files as a result of supporting OTA. Look for heading **Support for
OTA**.

Otherwise, download the generic variant (under the first heading below).
5 changes: 4 additions & 1 deletion ports/esp32/boards/ESP32_GENERIC_C3/board.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"deploy": [
"../deploy_c3.md"
"../deploy.md"
],
"deploy_options": {
"flash_offset": "0"
},
"docs": "",
"features": [
"BLE",
Expand Down
5 changes: 4 additions & 1 deletion ports/esp32/boards/ESP32_GENERIC_C6/board.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"deploy": [
"../deploy_c6.md"
"../deploy.md"
],
"deploy_options": {
"flash_offset": "0"
},
"docs": "",
"features": [
"BLE",
Expand Down
5 changes: 4 additions & 1 deletion ports/esp32/boards/ESP32_GENERIC_S2/board.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"deploy": [
"../deploy_s2.md"
"../deploy.md"
],
"deploy_options": {
"flash_offset": "0x1000"
},
"docs": "",
"features": [
"External Flash",
Expand Down
5 changes: 4 additions & 1 deletion ports/esp32/boards/ESP32_GENERIC_S3/board.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"deploy": [
"../deploy_s3.md"
"../deploy.md"
],
"deploy_options": {
"flash_offset": "0"
},
"docs": "",
"features": [
"BLE",
Expand Down
3 changes: 3 additions & 0 deletions ports/esp32/boards/LILYGO_TTGO_LORA32/board.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"deploy": [
"../deploy.md"
],
"deploy_options": {
"flash_offset": "0x1000"
},
"docs": "",
"features": [
"BLE",
Expand Down
5 changes: 4 additions & 1 deletion ports/esp32/boards/LOLIN_C3_MINI/board.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"deploy": [
"../deploy_c3.md"
"../deploy_nativeusb.md"
],
"deploy_options": {
"flash_offset": "0"
},
"docs": "",
"features": [
"BLE",
Expand Down
5 changes: 4 additions & 1 deletion ports/esp32/boards/LOLIN_S2_MINI/board.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"deploy": [
"../deploy_s2.md"
"../deploy_nativeusb.md"
],
"deploy_options": {
"flash_offset": "0x1000"
},
"docs": "",
"features": [
"External Flash",
Expand Down
5 changes: 4 additions & 1 deletion ports/esp32/boards/LOLIN_S2_PICO/board.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"deploy": [
"../deploy_s2.md"
"../deploy_nativeusb.md"
],
"deploy_options": {
"flash_offset": "0x1000"
},
"docs": "",
"features": [
"Display",
Expand Down
3 changes: 3 additions & 0 deletions ports/esp32/boards/M5STACK_ATOM/board.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"deploy": [
"../deploy.md"
],
"deploy_options": {
"flash_offset": "0x1000"
},
"docs": "",
"features": [
"External Flash",
Expand Down
5 changes: 4 additions & 1 deletion ports/esp32/boards/M5STACK_ATOMS3_LITE/board.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"deploy": [
"deploy.md"
"../deploy_nativeusb.md"
],
"deploy_options": {
"flash_offset": "0"
},
"docs": "https://docs.m5stack.com/en/core/AtomS3%20Lite",
"features": [
"BLE",
Expand Down
22 changes: 0 additions & 22 deletions ports/esp32/boards/M5STACK_ATOMS3_LITE/deploy.md

This file was deleted.

5 changes: 4 additions & 1 deletion ports/esp32/boards/M5STACK_NANOC6/board.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"deploy": [
"deploy_nanoc6.md"
"../deploy_nativeusb.md"
],
"deploy_options": {
"flash_offset": "0"
},
"docs": "",
"features": [
"BLE",
Expand Down
Loading
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy