Skip to content

Commit

Permalink
Merge branch 'micropython:master' into feature/mboot_version
Browse files Browse the repository at this point in the history
  • Loading branch information
victorallume authored Nov 20, 2024
2 parents d431d08 + 181800e commit e6d8eca
Show file tree
Hide file tree
Showing 106 changed files with 1,865 additions and 542 deletions.
1 change: 0 additions & 1 deletion .github/workflows/code_size.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Check code size

on:
push:
pull_request:
paths:
- '.github/workflows/*.yml'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/commit_formatting.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Check commit message formatting

on: [push, pull_request]
on: [pull_request]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -12,7 +12,7 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '100'
fetch-depth: 100
- uses: actions/setup-python@v5
- name: Check commit message formatting
run: source tools/ci.sh && ci_commit_formatting_run
11 changes: 7 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
"is_release": micropy_version != "latest",
}

# Authors used in various parts of the documentation.
micropy_authors = "MicroPython authors and contributors"


# -- General configuration ------------------------------------------------

Expand Down Expand Up @@ -68,7 +71,7 @@

# General information about the project.
project = "MicroPython"
copyright = "- The MicroPython Documentation is Copyright © 2014-2024, Damien P. George, Paul Sokolovsky, and contributors"
copyright = "- The MicroPython Documentation is Copyright © 2014-2024, " + micropy_authors

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -244,7 +247,7 @@
master_doc,
"MicroPython.tex",
"MicroPython Documentation",
"Damien P. George, Paul Sokolovsky, and contributors",
micropy_authors,
"manual",
),
]
Expand Down Expand Up @@ -281,7 +284,7 @@
"index",
"micropython",
"MicroPython Documentation",
["Damien P. George, Paul Sokolovsky, and contributors"],
[micropy_authors],
1,
),
]
Expand All @@ -300,7 +303,7 @@
master_doc,
"MicroPython",
"MicroPython Documentation",
"Damien P. George, Paul Sokolovsky, and contributors",
micropy_authors,
"MicroPython",
"One line description of project.",
"Miscellaneous",
Expand Down
2 changes: 1 addition & 1 deletion docs/develop/gettingstarted.rst
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ To run a selection of tests on a board/device connected over USB use:
.. code-block:: bash
$ cd tests
$ ./run-tests.py --target minimal --device /dev/ttyACM0
$ ./run-tests.py -t /dev/ttyACM0
See also :ref:`writingtests`.

Expand Down
2 changes: 1 addition & 1 deletion docs/develop/writingtests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Then to run on a board:

.. code-block:: bash
$ ./run-tests.py --target minimal --device /dev/ttyACM0
$ ./run-tests.py -t /dev/ttyACM0
And to run only a certain set of tests (eg a directory):

Expand Down
11 changes: 6 additions & 5 deletions docs/esp32/quickref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,19 @@ Networking
WLAN
^^^^

The :mod:`network` module::
The :class:`network.WLAN` class in the :mod:`network` module::

import network

wlan = network.WLAN(network.STA_IF) # create station interface
wlan = network.WLAN(network.WLAN.IF_STA) # create station interface
wlan.active(True) # activate the interface
wlan.scan() # scan for access points
wlan.isconnected() # check if the station is connected to an AP
wlan.connect('ssid', 'key') # connect to an AP
wlan.config('mac') # get the interface's MAC address
wlan.ipconfig('addr4') # get the interface's IPv4 addresses

ap = network.WLAN(network.AP_IF) # create access-point interface
ap = network.WLAN(network.WLAN.IF_AP) # create access-point interface
ap.config(ssid='ESP-AP') # set the SSID of the access point
ap.config(max_clients=10) # set how many clients can connect to the network
ap.active(True) # activate the interface
Expand All @@ -100,7 +100,7 @@ A useful function for connecting to your local WiFi network is::

def do_connect():
import network
wlan = network.WLAN(network.STA_IF)
wlan = network.WLAN(network.WLAN.IF_STA)
wlan.active(True)
if not wlan.isconnected():
print('connecting to network...')
Expand All @@ -124,7 +124,8 @@ to reconnect forever).
LAN
^^^

To use the wired interfaces one has to specify the pins and mode ::
To use the wired interfaces via :class:`network.LAN` one has to specify the pins
and mode ::

import network

Expand Down
1 change: 1 addition & 0 deletions docs/esp32/tutorial/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ to `<https://www.python.org>`__.
intro.rst
pwm.rst
peripheral_access.rst
reset.rst
2 changes: 2 additions & 0 deletions docs/esp32/tutorial/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ 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.

.. _esp32_flashing:

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

Expand Down
25 changes: 25 additions & 0 deletions docs/esp32/tutorial/reset.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Factory reset
=============

If something unexpected happens and your ESP32-based board no longer boots
MicroPython, then you may have to factory reset it. For more details, see
:ref:`soft_bricking`.

Factory resetting the MicroPython esp32 port involves fully erasing the flash
and resetting the flash memory, so you will need to re-flash the MicroPython
firmware afterwards and copy any Python files to the filesystem again.

1. You will need the Espressif `esptool`_ installed on your system. This is the
same tool that you may have used to initially install MicroPython on your
board (see :ref:`installation instructions <esp32_flashing>`).
2. Find the serial port name of your board, and then use esptool to erase the
entire flash contents::

esptool.py -p PORTNAME erase_flash

3. Use esptool to flash the MicroPython file to your board again. If needed,
this file and flashing instructions can be found on the `MicroPython
downloads page`_.

.. _esptool: https://github.com/espressif/esptool
.. _MicroPython downloads page: https://micropython.org/download/?port=esp32
35 changes: 1 addition & 34 deletions docs/esp8266/general.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,40 +74,7 @@ as possible after use.
Boot process
------------

On boot, MicroPython EPS8266 port executes ``_boot.py`` script from internal
frozen modules. It mounts filesystem in FlashROM, or if it's not available,
performs first-time setup of the module and creates the filesystem. This
part of the boot process is considered fixed, and not available for customization
for end users (even if you build from source, please refrain from changes to
it; customization of early boot process is available only to advanced users
and developers, who can diagnose themselves any issues arising from
modifying the standard process).

Once the filesystem is mounted, ``boot.py`` is executed from it. The standard
version of this file is created during first-time module set up and has
commands to start a WebREPL daemon (disabled by default, configurable
with ``webrepl_setup`` module), etc. This
file is customizable by end users (for example, you may want to set some
parameters or add other services which should be run on
a module start-up). But keep in mind that incorrect modifications to boot.py
may still lead to boot loops or lock ups, requiring to reflash a module
from scratch. (In particular, it's recommended that you use either
``webrepl_setup`` module or manual editing to configure WebREPL, but not
both).

As a final step of boot procedure, ``main.py`` is executed from filesystem,
if exists. This file is a hook to start up a user application each time
on boot (instead of going to REPL). For small test applications, you may
name them directly as ``main.py``, and upload to module, but instead it's
recommended to keep your application(s) in separate files, and have just
the following in ``main.py``::

import my_app
my_app.main()

This will allow to keep the structure of your application clear, as well as
allow to install multiple applications on a board, and switch among them.

See :doc:`/reference/reset_boot`.

Known Issues
------------
Expand Down
16 changes: 8 additions & 8 deletions docs/esp8266/quickref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,27 @@ The :mod:`esp` module::
Networking
----------

The :mod:`network` module::
The :class:`network.WLAN` class in the :mod:`network` module::

import network

wlan = network.WLAN(network.STA_IF) # create station interface
wlan = network.WLAN(network.WLAN.IF_STA) # create station interface
wlan.active(True) # activate the interface
wlan.scan() # scan for access points
wlan.isconnected() # check if the station is connected to an AP
wlan.connect('ssid', 'key') # connect to an AP
wlan.config('mac') # get the interface's MAC address
wlan.ipconfig('addr4') # get the interface's IPv4 addresses

ap = network.WLAN(network.AP_IF) # create access-point interface
ap = network.WLAN(network.WLAN.IF_AP) # create access-point interface
ap.active(True) # activate the interface
ap.config(ssid='ESP-AP') # set the SSID of the access point

A useful function for connecting to your local WiFi network is::

def do_connect():
import network
wlan = network.WLAN(network.STA_IF)
wlan = network.WLAN(network.WLAN.IF_STA)
wlan.active(True)
if not wlan.isconnected():
print('connecting to network...')
Expand Down Expand Up @@ -163,10 +163,10 @@ sys.stdin.read() if it's needed to read characters from the UART(0)
while it's also used for the REPL (or detach, read, then reattach).
When detached the UART(0) can be used for other purposes.

If there are no objects in any of the dupterm slots when the REPL is
started (on hard or soft reset) then UART(0) is automatically attached.
Without this, the only way to recover a board without a REPL would be to
completely erase and reflash (which would install the default boot.py which
If there are no objects in any of the dupterm slots when the REPL is started (on
:doc:`hard or soft reset </reference/reset_boot>`) then UART(0) is automatically
attached. Without this, the only way to recover a board without a REPL would be
to completely erase and reflash (which would install the default boot.py which
attaches the REPL).

To detach the REPL from UART0, use::
Expand Down
13 changes: 7 additions & 6 deletions docs/esp8266/tutorial/network_basics.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
Network basics
==============

The network module is used to configure the WiFi connection. There are two WiFi
interfaces, one for the station (when the ESP8266 connects to a router) and one
for the access point (for other devices to connect to the ESP8266). Create
The :class:`network.WLAN` class in the :mod:`network` module is used to
configure the WiFi connection. There are two WiFi interfaces, one for
the station (when the ESP8266 connects to a router) and one for the
access point (for other devices to connect to the ESP8266). Create
instances of these objects using::

>>> import network
>>> sta_if = network.WLAN(network.STA_IF)
>>> ap_if = network.WLAN(network.AP_IF)
>>> sta_if = network.WLAN(network.WLAN.IF_STA)
>>> ap_if = network.WLAN(network.WLAN.IF_AP)

You can check if the interfaces are active by::

Expand Down Expand Up @@ -57,7 +58,7 @@ connect to your WiFi network::

def do_connect():
import network
sta_if = network.WLAN(network.STA_IF)
sta_if = network.WLAN(network.WLAN.IF_STA)
if not sta_if.isconnected():
print('connecting to network...')
sta_if.active(True)
Expand Down
10 changes: 10 additions & 0 deletions docs/library/builtins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ Exceptions

.. exception:: KeyboardInterrupt

|see_cpython| `python:KeyboardInterrupt`.

See also in the context of :ref:`soft_bricking`.

.. exception:: KeyError

.. exception:: MemoryError
Expand All @@ -190,6 +194,12 @@ Exceptions

|see_cpython| `python:SystemExit`.

On non-embedded ports (i.e. Windows and Unix), an unhandled ``SystemExit``
exits the MicroPython process in a similar way to CPython.

On embedded ports, an unhandled ``SystemExit`` currently causes a
:ref:`soft_reset` of MicroPython.

.. exception:: TypeError

|see_cpython| `python:TypeError`.
Expand Down
24 changes: 12 additions & 12 deletions docs/library/espnow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ A simple example would be:
import espnow

# A WLAN interface must be active to send()/recv()
sta = network.WLAN(network.STA_IF) # Or network.AP_IF
sta = network.WLAN(network.WLAN.IF_STA) # Or network.WLAN.IF_AP
sta.active(True)
sta.disconnect() # For ESP8266

Expand All @@ -76,7 +76,7 @@ A simple example would be:
import espnow

# A WLAN interface must be active to send()/recv()
sta = network.WLAN(network.STA_IF)
sta = network.WLAN(network.WLAN.IF_STA)
sta.active(True)
sta.disconnect() # Because ESP8266 auto-connects to last Access Point

Expand Down Expand Up @@ -182,14 +182,14 @@ Configuration
Sending and Receiving Data
--------------------------

A wifi interface (``network.STA_IF`` or ``network.AP_IF``) must be
A wifi interface (``network.WLAN.IF_STA`` or ``network.WLAN.IF_AP``) must be
`active()<network.WLAN.active>` before messages can be sent or received,
but it is not necessary to connect or configure the WLAN interface.
For example::

import network

sta = network.WLAN(network.STA_IF)
sta = network.WLAN(network.WLAN.IF_STA)
sta.active(True)
sta.disconnect() # For ESP8266

Expand Down Expand Up @@ -445,8 +445,8 @@ must first register the sender and use the same encryption keys as the sender

- *ifidx*: (ESP32 only) Index of the wifi interface which will be
used to send data to this peer. Must be an integer set to
``network.STA_IF`` (=0) or ``network.AP_IF`` (=1).
(default=0/``network.STA_IF``). See `ESPNow and Wifi Operation`_
``network.WLAN.IF_STA`` (=0) or ``network.WLAN.IF_AP`` (=1).
(default=0/``network.WLAN.IF_STA``). See `ESPNow and Wifi Operation`_
below for more information.

- *encrypt*: (ESP32 only) If set to ``True`` data exchanged with
Expand Down Expand Up @@ -588,7 +588,7 @@ api-reference/network/esp_now.html#api-reference>`_. For example::
elif err.args[1] == 'ESP_ERR_ESPNOW_NOT_FOUND':
e.add_peer(peer)
elif err.args[1] == 'ESP_ERR_ESPNOW_IF':
network.WLAN(network.STA_IF).active(True)
network.WLAN(network.WLAN.IF_STA).active(True)
else:
raise err

Expand Down Expand Up @@ -645,7 +645,7 @@ A small async server example::
import asyncio

# A WLAN interface must be active to send()/recv()
network.WLAN(network.STA_IF).active(True)
network.WLAN(network.WLAN.IF_STA).active(True)

e = aioespnow.AIOESPNow() # Returns AIOESPNow enhanced with async support
e.active(True)
Expand Down Expand Up @@ -747,8 +747,8 @@ ESPNow and Wifi Operation
-------------------------

ESPNow messages may be sent and received on any `active()<network.WLAN.active>`
`WLAN<network.WLAN()>` interface (``network.STA_IF`` or ``network.AP_IF``), even
if that interface is also connected to a wifi network or configured as an access
`WLAN<network.WLAN()>` interface (``network.WLAN.IF_STA`` or ``network.WLAN.IF_AP``),
even if that interface is also connected to a wifi network or configured as an access
point. When an ESP32 or ESP8266 device connects to a Wifi Access Point (see
`ESP32 Quickref <../esp32/quickref.html#networking>`__) the following things
happen which affect ESPNow communications:
Expand Down Expand Up @@ -832,8 +832,8 @@ Other issues to take care with when using ESPNow with wifi are:
import network, time

def wifi_reset(): # Reset wifi to AP_IF off, STA_IF on and disconnected
sta = network.WLAN(network.STA_IF); sta.active(False)
ap = network.WLAN(network.AP_IF); ap.active(False)
sta = network.WLAN(network.WLAN.IF_STA); sta.active(False)
ap = network.WLAN(network.WLAN.IF_AP); ap.active(False)
sta.active(True)
while not sta.active():
time.sleep(0.1)
Expand Down
Loading

0 comments on commit e6d8eca

Please sign in to comment.