SSL support in asyncio, sorted qstr pools, common machine module bindings #13277
dpgeorge
announced in
Announcements and news
Replies: 2 comments 1 reply
-
Matching stub-packages are now also available for the commonly used ports. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thank you @dpgeorge for all your work. Can you explain why io.TextIOWrapper was removed in this release? Thank you. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This release of MicroPython introduces SSL/TLS support to asyncio, for both the client and server sides. The interface matches CPython:
asyncio.open_connection()
andasyncio.start_serve()
now both accept anssl
argument to supply anSSLContext
object. As part of this, new methods were added toSSLContext
to load certificates, and certificate date/time validation was enabled on all ports that use mbedTLS.Qstr pools are now sorted, which provides a significant performance boost for
qstr_find_strn()
, which is called a lot during parsing and loading of .mpy files, as well as interning of string objects, which happens in most string methods that return new strings. The static pool (part of the .mpy ABI) isn't currently sorted, but could be in the future.There have been many internal changes to the
machine
module (and on some ports theos
module) to factor the Python bindings to a common location, reduce code duplication and make the API more consistent across all the ports. And a newboardgen.py
script has been added to factor pin generation and enable a more consistentmachine.Pin
across ports. For consistency, the following user-facing changes have been made:cc3200 port: The
machine
module gainssoft_reset()
,mem8
,mem16
,mem32
andSignal
; it losesPOWER_ON
(replaced byPWRON_RESET
).disable_irq()
now returns an (opaque) integer rather than a bool, andenable_irq(state)
must be passed an argument which is the return value ofdisable_irq()
, rather than a bool. In theos
module,dupterm()
has been converted to use the common implementation and has semantics the same as other ports, anduname()
is removed to save space (sys.version and sys.implementation can be used instead).esp32 port: In the
machine
module,lightsleep()
anddeepsleep()
no longer take thesleep
keyword argument, instead it's positional to match other ports. Also, passing 0 here will now do a 0ms sleep instead of acting like nothing was passed. Andreset_cause()
no longer accepts any arguments (before it would just ignore them).esp8266 port:
machine.idle()
now returns None instead of the time elapsed. Themachine.WDT()
constructor now takes keyword arguments, and accepts thetimeout
argument but raises an exception if it's not the default value (this port doesn't support changing the timeout).mimxrt port:
machine.freq()
now accepts an argument but raisesNotImplementedError
, andmachine.lightsleep()
has been added but also just raisesNotImplementedError
(this is to make these functions use an implementation common to the other ports).nrf port: The
machine
module gainsunique_id()
(returns an empty bytes object),freq()
(raisesNotImplementedError
) andSignal
.UART.sendbreak()
is removed, but this method previously did nothing. Theos.dupterm()
function has changed to match the semantics used by all other ports (except it's restricted to accept onlymachine.UART
objects).qemu-arm port: The
machine
module gainssoft_reset()
andidle()
.samd port: The
machine.deepsleep()
function now resets after sleeping.unix port: Gains
machine.soft_reset()
.zephyr port: The
machine
module gainssoft_reset()
,mem8
,mem16
, andmem32
. TheUART
class gains the following methods:init()
which supports settingtimeout
andtimeout_char
,deinit()
which does nothing,flush()
which raisesOSError(EINVAL)
because it's not implemented, andany()
andtxdone()
which both raiseNotImplementedError
.The teensy port has been removed in this release. This port was largely unmaintained, had limited features (the only hardware support was for GPIO and timer, and no
machine
module), and only supported a small number of Teensy boards.A new preview versioning scheme has been introduced, whereby non-release builds are a preview of the next, upcoming release. This scheme is compatible with semver and should help to eliminate confusion matching documentation and firmware version numbers, among other things.
Black has been replaced with ruff format as the Python code formatter. This required a few small changes to Python code, and now allows linting and formatting with ruff.
Bound method instances now support comparison and hashing, matching CPython semantics. The .mpy sub-version has been updated from 6.1 to 6.2 due to a change in the native .mpy ABI. A new option
MICROPY_PREVIEW_VERSION_2
has been added which provides a way to enable features and changes slated for MicroPython 2.x, by runningmake MICROPY_PREVIEW_VERSION_2=1
. This is an alternative to having a 2.x development branch, and any feature or change that needs to be "hidden" until 2.x will use this flag.LittleFS has been updated to v2.8.1. The associated MicroPython VfsLfs2 driver can read existing LFS2 filesystems, but any writes will update the filesystem to a newer LFS2 version that cannot be read by older drivers, so take this into account when updating, for example update mboot first.
The VFS sub-system has a new file ioctl to set the read-buffer size, which is used by mpremote to significantly increase performance of the "mpremote mount" feature. Manifest files now allow registering an external library path via
add_library(name, path)
.sys.stdout.buffer.write()
now returns the actual number of bytes written (although this is complicated when output goes to multiple destinations).The esp32 port has been updated to use IDF version 5.0.4, and the initial GC heap size tuned so that, after doubling the heap size, WiFi can still be started and an SSL connection made.
RMT.source_freq()
is now a class method, socket connect timeout has been implemented, RTC user memory is now preserved over most reset causes, andhashlib.md5
enabled.The mimxrt port has RTC alarm/wakeup functionality added, along with support for
machine.deepsleep()
.The rp2 port sees the introduction of a new
rp2.DMA
class for control over DMA transfers. It has switched to use the same math library as other ports to get more accurate floating point behaviour, and enabledos.dupterm_notify()
for WebREPL use. The TinyUSB stack is now scheduled to run from the IRQ handler (instead of polled in the VM) which slightly improves performance of the VM and USB. The port also makes better use of event scheduling and WFE to be more efficient. It also has added support for external ADC channels (for example when using the ninaw10 driver).The stm32 port has improved support for STM32H5xx MCUs, including Ethernet support, frequency scaling with HSI, sleep mode and SD card support. The NUCLEO_WL55 board now freezes in the LoRa driver, the I2S driver has improved accuracy of the clock frequency, and mboot now supports Microsoft WCID to set the USB driver.
New boards added in this release are: UM_TINYWATCHS3 (esp32 port), POLOLU_3PI_2040_ROBOT, POLOLU_ZUMO_2040_ROBOT and SIL_RP2040_SHIM (rp2 port), NUCLEO_H563ZI (stm32 port).
The change in code size since the previous release for various ports is (absolute and percentage change in the text section):
The changes that dominate these numbers are:
os.dupterm
implementationmachine.Signal
, asyncio SSL supportrp2.DMA
classWith the new sorted qstr pools, performance is significantly improved for qstr-heavy operations, between +50% and +200% improvement. Other areas have their performance unchanged since the last release.
Thanks to everyone who contributed to this release: Alessandro Gatti, Andrew Leech, Angus Gratton, Carlosgg, Christian Walther, Damien George, Daniël van de Giessen, Elias Wimmer, Glenn Moloney, iabdalkader, Ihor Nehrutsa, Jeff Epler, Jim Mussared, Kwabena W. Agyeman, Maarten van der Schrieck, Mark Blakeney, Mathieu Serandour, Matthias Urlichs, MikeTeachman, Ned Konz, Nicko van Someren, Pascal Brunot, Patrick Van Oosterwijck, Paul Grayson, Peter Züger, Rene Straub, robert-hh, Scott Zhao, Sebastian Romero, Seon Rozenblum, stijn, Thomas Ackermann, Thomas Wenrich, ThomHPL, Trent Piepho.
Contributions were made from the following timezones: -0800, -0700, -0600, -0500, +0000, +0100, +0200, +1000, +1100.
The work done in this release was funded in part through GitHub Sponsors, and in part by George Robotics, Planet Innovation, Espressif, Arduino, LEGO Education and OpenMV.
What follows is a detailed list of changes, generated from the git commit history, and organised into sections.
Main components
all:
py core:
extmod:
shared:
drivers:
mpy-cross: no changes specific to this component/port
lib:
Support components
docs:
examples:
tests:
tools:
ulimit -n
for unix CICI:
The ports
all ports:
bare-arm port:
cc3200 port:
embed port: no changes specific to this component/port
esp8266 port:
esp32 port:
mimxrt port:
minimal port: no changes specific to this component/port
nrf port:
pic16bit port: no changes specific to this component/port
powerpc port: no changes specific to this component/port
qemu-arm port: no changes specific to this component/port
renesas-ra port:
rp2 port:
samd port:
stm32 port:
teensy port:
unix port:
webassembly port: no changes specific to this component/port
windows port:
zephyr port: no changes specific to this component/port
This discussion was created from the release SSL support in asyncio, sorted qstr pools, common machine module bindings.
Beta Was this translation helpful? Give feedback.
All reactions