Micropython Versions Save

MicroPython - a lean and efficient Python implementation for microcontrollers and constrained systems

v1.22.2

2 months ago

This is a patch release containing the following commits:

  • py/compile: fix potential Py-stack overflow in try-finally with return
  • extmod/asyncio: support gather of tasks that finish early
  • extmod/modssl_mbedtls: fix cipher iteration in SSLContext.get_ciphers
  • extmod/btstack: reset pending_value_handle before calling write-done cb
  • extmod/btstack: reset pending_value_handle before calling read-done cb
  • esp32/mpnimbleport: release the GIL while doing NimBLE port deinit
  • esp32: increase NimBLE task stack size and overflow detection headroom
  • mimxrt/modmachine: fix deepsleep wakeup pin ifdef
  • renesas-ra/ra: fix SysTick clock source
  • renesas-ra/boards/ARDUINO_PORTENTA_C33: fix the RTC clock source
  • renesas-ra/ra/ra_i2c: fix 1 byte and 2 bytes read issue
  • rp2/rp2_dma: fix fetching 'write' buffers for writing not reading
  • rp2/machine_uart: fix event wait in uart.flush() and uart.read()
  • rp2: change machine.I2S and rp2.DMA to use shared DMA IRQ handlers

v1.22.1

4 months ago

This is a patch release to fix a race condition and potential deadlock in the rp2 port's mp_thread_begin_atomic_section() function, when the second core is in use.

v1.22.0

4 months ago

This release of MicroPython introduces SSL/TLS support to asyncio, for both the client and server sides. The interface matches CPython: asyncio.open_connection() and asyncio.start_serve() now both accept an ssl argument to supply an SSLContext object. As part of this, new methods were added to SSLContext 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 the os 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 new boardgen.py script has been added to factor pin generation and enable a more consistent machine.Pin across ports. For consistency, the following user-facing changes have been made:

  • cc3200 port: The machine module gains soft_reset(), mem8, mem16, mem32 and Signal; it loses POWER_ON (replaced by PWRON_RESET). disable_irq() now returns an (opaque) integer rather than a bool, and enable_irq(state) must be passed an argument which is the return value of disable_irq(), rather than a bool. In the os module, dupterm() has been converted to use the common implementation and has semantics the same as other ports, and uname() is removed to save space (sys.version and sys.implementation can be used instead).

  • esp32 port: In the machine module, lightsleep() and deepsleep() no longer take the sleep 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. And reset_cause() no longer accepts any arguments (before it would just ignore them).

  • esp8266 port: machine.idle() now returns None instead of the time elapsed. The machine.WDT() constructor now takes keyword arguments, and accepts the timeout 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 raises NotImplementedError, and machine.lightsleep() has been added but also just raises NotImplementedError (this is to make these functions use an implementation common to the other ports).

  • nrf port: The machine module gains unique_id() (returns an empty bytes object), freq() (raises NotImplementedError) and Signal. UART.sendbreak() is removed, but this method previously did nothing. The os.dupterm() function has changed to match the semantics used by all other ports (except it's restricted to accept only machine.UART objects).

  • qemu-arm port: The machine module gains soft_reset() and idle().

  • samd port: The machine.deepsleep() function now resets after sleeping.

  • unix port: Gains machine.soft_reset().

  • zephyr port: The machine module gains soft_reset(), mem8, mem16, and mem32. The UART class gains the following methods: init() which supports setting timeout and timeout_char, deinit() which does nothing, flush() which raises OSError(EINVAL) because it's not implemented, and any() and txdone() which both raise NotImplementedError.

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 running make 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, and hashlib.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 enabled os.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):

   bare-arm:   +216  +0.381%
minimal x86:   +624  +0.340%
   unix x64:  +8283  +1.050%
      stm32:  +1368  +0.350%
     cc3200:  +1184  +0.649%
    esp8266:   +800  +0.114%
      esp32: +35348  +2.100%
     mimxrt:  +2172  +0.602%
 renesas-ra:    +96  +0.015%
        nrf:  +1460  +0.785%
        rp2:  +6100  +1.880%
       samd:  +1476  +0.568%

The changes that dominate these numbers are:

  • bare-arm, minimal: comparing and hashing bound methods, sorted qstr pools
  • unix: updating LittleFS to 2.8.1, enabling certificate date/time validation, adding SSLContext certificate methods, asyncio SSL support
  • stm32: sorted qstrs, updating LittleFS to 2.8.1, I2S clock frequency improvements, asyncio SSL support
  • cc3200: sorted qstrs, more machine module functions, use of the common os.dupterm implementation
  • esp32: switching ESP-IDF from 5.0.2 to 5.0.4
  • esp8266: updating LittleFS to 2.8.1
  • mimxrt: adding RTC alarm/wakeup functionality, updating LittleFS to 2.8.1, asyncio SSL support
  • nrf: updating LittleFS to 2.8.1, enabling machine.Signal, asyncio SSL support
  • rp2: using locally-provided math library, adding new rp2.DMA class
  • samd: sorted qstrs, updating LittleFS to 2.8.1, asyncio SSL support

With 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:

  • switch to new preview build versioning scheme
  • replace "black" with "ruff format"
  • update Python formatting to ruff-format

py core:

  • vm: don't emit warning when using "raise ... from None"
  • builtinevex: handle invalid filenames for execfile
  • objboundmeth: support comparing and hashing bound methods
  • objboundmeth: optimise check for types in binary_op
  • obj: generalise mp_get_buffer so it can raise if a flag is set
  • dynruntime: add mp_get_buffer
  • persistentcode: bump .mpy sub-version
  • modthread: initialise nlr_jump_callback_top on threads
  • makeqstrdefs.py: print a nicer error when preprocessing stage fails
  • mkrules.mk: add MICROPY_PREVIEW_VERSION_2
  • asm: remove unused asm helper macros
  • qstr: add support for sorted qstr pools
  • mkrules.mk: add rule for compiling auto-generated source files
  • runtime: remove declaration of function from inside function
  • lexer: change token position for new lines
  • misc: change sizeof to offsetof for variable-length alloc
  • qstr: special case qstr_find_strn for empty string
  • obj: fix mp_obj_is_type compilation with C++
  • objslice: validate that the argument to indices() is an integer
  • mkrules: add support for custom manifest variables
  • modbuiltins: share vstr_add_char's implementation of utf8 encoding
  • mphal: move configuration of ATOMIC_SECTION macros to mphal.h
  • add port-agnostic inline functions for event handling
  • modsys: implement optional sys.intern
  • mkrules.mk: list hash files as byproducts
  • makeqstrdefs.py: don't skip output for stale hash file
  • makeqstrdefs.py: stop generating temporary intermediate file
  • gc: improve calculation of new heap size in split-heap-auto mode
  • mkrules.mk: fix dependency file generation for compiler wrappers

extmod:

  • moductypes: validate that uctypes.struct addr argument is an int
  • asyncio: emit errors to stderr, not stdout
  • modframebuf: validate FrameBuffer bounds against input buffer
  • modframebuf: fix FrameBuffer get-buffer implementation
  • modframebuf: remove FrameBuffer1 from natmod build
  • vfs_posix: fix relative root path
  • vfs_posix: fix accidentally passing tests
  • vfs_posix: fix relative paths on non-root VFS
  • vfs_posix: fix getcwd() on non-root VFS
  • vfs_posix: additional tests for coverage of error cases
  • network_ninaw10: raise an error if nina_ioctl fails
  • machine_wdt: factor ports' WDT Python bindings to common code
  • machine_pwm: remove header file and move decls to .c file
  • machine_i2s: factor ports' I2S Python bindings to common code
  • machine_i2s: factor stream and ring-buf code
  • machine_i2s: factor I2S.shift method
  • machine_i2s: factor I2S.irq method
  • machine_i2s: factor print function
  • machine_i2s: factor init_helper argument parsing
  • machine_i2s: factor comments, some enums and macros
  • machine_adc: factor ports' ADC Python bindings to common code
  • machine_uart: factor ports' UART Python bindings to common code
  • modmachine: clean up decls of machine types to use common ones
  • modmachine: consolidate simple machine headers into modmachine.h
  • modmachine: consolidate mem, i2c and spi headers to modmachine.h
  • network_ninaw10: fix select flags handling in socket poll
  • remove empty utime_mphal.h file
  • machine_adc_block: factor esp32 ADCBlock bindings to common code
  • machine_i2c: do a fast poll during I2C.scan()
  • vfs_reader: add file ioctl to set read buffer size
  • modbluetooth: initialise nlr_jump_callback_top for IRQ handlers
  • vfs_posix_file: make standard file objects non-const
  • extmod.mk: allow enabling lwip loopback support
  • modmachine: make I2C/SPI defns available when soft impl enabled
  • modmachine: factor ports' machine module dict to common code
  • modmachine: provide common Python bindings for machine.idle()
  • modmachine: add MICROPY_PY_MACHINE_PIN_BASE option
  • modmachine: provide common Python bindings for bootloader()
  • modmachine: provide common bindings for 6 bare-metal functions
  • modmachine: provide common implementation of disable/enable_irq
  • mbedtls: enable certificate time/date validation by default
  • modnetwork: add deinit function to NIC protocol
  • network_ninaw10: switch to using soft-timer for polling
  • switch to use new event functions
  • add lists of libm/libm_dbl source files for ports to use
  • modssl_mbedtls: add SSLContext certificate methods
  • modssl_mbedtls: make SSLSocket.getpeercert() optional
  • modssl_mbedtls: fix parsing of ciphers in set_ciphers method
  • asyncio: add ssl support with SSLContext
  • modonewire: adopt Maxim recommended read timings
  • modonewire: improve write timings for better reliability
  • modos: factor os.dupterm_notify() function to common extmod code
  • os_dupterm: prevent recursive execution of mp_os_dupterm_rx_chr
  • asyncio: remove non-working Stream aenter/aexit methods
  • modselect: handle growing the pollfds allocation correctly
  • modhashlib: support MD5 with mbedtls 3.x
  • os_dupterm: let mp_os_dupterm_tx_strn() return num bytes written
  • vfs_lfs: fix lfs cache_size calculation
  • nimble: do not set GAP device name after sync

shared:

  • libc/string0: don't deref args for n==0 case
  • tinyusb: schedule TinyUSB task function from dcd_event_handler
  • tinyusb: expose mp_usbd_task as a public function
  • tinyusb: add a helper for hex string conversion
  • runtime/softtimer: generalise soft_timer to work without SysTick

drivers:

  • ninaw10: add ioctl for reading analog pins
  • ninaw10: add support for external ADC channels

mpy-cross: no changes specific to this component/port

lib:

  • littlefs: update LittleFS to v2.8.1
  • uzlib: for matches of the same length, take the closest one
  • mbedtls_errors: update error list for latest esp32 mbedtls
  • micropython-lib: update submodule to latest

Support components

docs:

  • reference/mpyfiles: document change in .mpy sub-version
  • library/io: remove io.FileIO and io.TextIOWrapper
  • reference/micropython2_migration: add migration guide
  • mimxrt: change the examples which denote a Pin with a number
  • samd: fix the pinout for SAMD21 Itsy Bitsy Express M0
  • library/esp: correct the description of esp.osdebug()
  • esp32/quickref: add DAC example
  • library: document SSLContext cert methods and asyncio support

examples:

  • pins.py: remove this pins printing example

tests:

  • basics/boundmeth1.py: add tests for bound method equality/hash
  • perf_bench: add string/qstr/map tests
  • extmod/asyncio_as_uasyncio.py: fix qstr order dependency
  • net_hosted/asyncio_loopback.py: add loopback test
  • extmod/deflate_compress.py: add a test for optimal compression
  • float/inf_nan_arith.py: include -inf in argument combos
  • run-tests.py: skip Thumb2 tests if target doesn't support them
  • update SSL network tests to use SSLContext, and work on CPython

tools:

  • ci.sh: ensure enough commits are fetched for a common ancestor
  • boardgen.py: add initial implementation of a common make-pins.py
  • tinytest-codegen.py: externalise tests list
  • mpremote: add ioctl to specify large read buffer size
  • ci.sh: build ESP32_GENERIC-SPIRAM as part of esp32 CI
  • ci.sh: set ulimit -n for unix CI
  • manifestfile.py: add support for external libraries

CI:

  • workflows: pin ruff to 0.1.0 and change flags for new version
  • workflows: cache ESP-IDF checkout and installation
  • workflows: use build matrix for esp32 port
  • workflows: enable build matrix for stm32 port
  • workflows: enable ccache for esp32 build
  • workflows: bump actions/github-script from 6 to 7
  • workflows: bump actions/setup-python from 4 to 5
  • workflows: bump actions/upload-artifact from 3 to 4

The ports

all ports:

  • make all ports skip execution of main.py if boot.py fails
  • remove SRC_QSTR_AUTO_DEPS from all ports' Makefiles
  • standardise arguments and output for make-pins.py script
  • fix incorrect identifiers on Arduino boards
  • move definitions of ATOMIC_SECTION macros to mphalport.h
  • switch build to use common lib/libm list of source files
  • fix sys.stdout.buffer.write() return value

bare-arm port:

  • lib: add minimal strncmp implementation

cc3200 port:

  • boards/make-pins.py: don't generate qstrs
  • boards/make-pins.py: add a note about tools/boardgen.py
  • mods/modmachine: use common implementation of disable/enable_irq
  • convert dupterm to use common extmod implementation
  • convert os module to use extmod version
  • eliminate dependency on stm32's irq.h
  • application.mk: don't add stm32 to build include path

embed port: no changes specific to this component/port

esp8266 port:

  • rename MICROPY_ESPNOW to MICROPY_PY_ESPNOW
  • machine_spi: rename machine_hspi to machine_spi
  • esp_mphal: make atomic section more atomic
  • modmachine: use common implementation of disable/enable_irq
  • avoid including ep_mphal.h directly
  • update port to use new event functions

esp32 port:

  • rename MICROPY_ESPNOW to MICROPY_PY_ESPNOW
  • boards: update UM board image names for consistency
  • boards/UM_TINYWATCHS3: add new UM TinyWATCH S3 board
  • boards: update UM board settings to use custom PID/VID
  • network_ppp: allow building with IPv6 disabled
  • poll serial/JTAG for unread data to prevent blocking
  • mpconfigport: remove port-specific GAP name
  • machine_uart: add error checking for IDF API's
  • network_ppp: reduce PPP thread CPU usage
  • boards: disable ALPN support
  • network_lan: fix and simplify the code for ETH-SPI devices
  • network_lan: fix LAN.isconnected()
  • network_lan: register the hostname setting for Ethernet
  • modmachine: fix deepsleep() when previous sleep delay was set
  • boards: reduce size of D2WD and OTA firmware
  • use better build settings for ESP32-C3
  • mphalport: add function to wake main from separate FreeRTOS task
  • usb: wake main thread when USB receives data
  • machine_pin: make irq object a sub-field of pin object
  • esp32_rmt: change RMT.source_freq() to class method
  • esp32_rmt: add RMT.PULSE_MAX constant
  • modsocket: implement socket connect timeout
  • modsocket: try garbage collection if the socket limit is reached
  • boards/sdkconfig.base: fix increasing log level via esp.osdebug()
  • boards/ESP32_GENERIC: reduce size of D2WD variant to fit in flash
  • uart: preserve console UART clock, fix UART console with DFS
  • uart: make compatible with sclk type change in ESP-IDF 5.3
  • network_wlan: reduce RAM usage if SPIRAM fails to initialise
  • network_wlan: fix network.WLAN.status() to return better info
  • esp32_rmt: fix RMT looping
  • enable mbedtls cert time validation
  • boards: enable further IRAM saving opts to fit ESP32-SPIRAM fw
  • machine_rtc: preserve RTC user memory over most reset causes
  • boards/UM_TINYPICO: fix typo in baudrate instructions
  • boards/sdkconfig.base: disable unused mbedtls options
  • machine_i2c: use APB_CLK_FREQ instead of I2C_APB_CLK_FREQ
  • modnetwork: add WiFi AUTH_WPA3_ENT_192 authenticate mode
  • machine_dac: support one-shot mode of driver
  • modmachine: fix deprecated esp_pm_config_XXX_t
  • machine_i2s: fix deprecated fields and constants
  • mpconfigport: keep some funcs out of IRAM for ESP32-SPIRAM builds
  • boards/ESP32_GENERIC: disable network.LAN and VM-opt on D2WD
  • change minimum supported IDF version to v5.0.4
  • re-enable custom mbedtls error string tables
  • add MICROPY_GC_INITIAL_HEAP_SIZE option and tune it
  • mpconfigport: enable MICROPY_PY_HASHLIB_MD5

mimxrt port:

  • led: fix LED init call from main, and simplify led_init
  • boards: define missing SNVS pins for all processors
  • machine_rtc: add RTC alarm/wakeup functionality
  • modmachine: add support for machine.deepsleep
  • boards/make-pins.py: update to use tools/boardgen.py
  • modmachine: fix settings for the MIMXRT1170 board
  • boards/OLIMEX_RT1010: adjust the UART pin assignment

minimal port: no changes specific to this component/port

nrf port:

  • boards: automatically configure MICROPY_PY_MACHINE_PWM
  • modules/machine: use SPI Python bindings provided by extmod
  • boards/make-pins.py: don't generate qstrs
  • boards/make-pins.py: add a note about tools/boardgen.py
  • use MICROPY_PY_MACHINE_SPI instead of MICROPY_PY_MACHINE_HW_SPI
  • use dupterm_objs[0] instead of board_stdio_uart
  • convert os module to use extmod version
  • mpconfigport: enable MICROPY_PY_MACHINE_BOOTLOADER
  • boards/ARDUINO_NANO_33_BLE_SENSE: don't enable MICROPY_MBFS
  • main: add /flash and /flash/lib to sys.path

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:

  • boards/make-pins.py: don't generate qstrs
  • boards/make-pins.py: update to use tools/boardgen.py
  • boards/ARDUINO_PORTENTA_C33: fix incorrect I2C pins
  • consolidate MICROPY_PY_MACHINE_I2C option

rp2 port:

  • cyw43_configport: use m_tracked_calloc and m_tracked_free
  • machine_adc: add support for external ADC channels
  • boards/ARDUINO_NANO_RP2040_CONNECT: add external analog pins
  • boards/make-pins.py: don't generate qstrs
  • machine_uart: fix handling of serial break condition
  • machine_adc: refactor channel/pin validation code
  • remove 1ms timeout to make idle waiting tickless
  • change to use TinyUSB dcd_event_handler hook
  • mphalport: run TinyUSB stack while waiting for CDC input/output
  • integrate soft_timer using the alarm pool
  • mpbthciport: rework HCI polling timer to use soft_timer
  • mpnetworkport: rework lwIP polling to use soft_timer
  • mphalport: optimise exit of mp_hal_delay_ms loop
  • cyw43_configport: implement cyw43_delay_ms as mp_hal_delay_ms
  • switch to locally provided math library
  • switch rp2 and drivers to use new event functions
  • main: enable SEVONPEND CPU interrupt bit
  • mpconfigport: enable MICROPY_PY_OS_DUPTERM_NOTIFY
  • add new NO_DEFAULT_PINS config options for i2c, spi, and uart
  • boards: add support for Pololu 3pi+ and Zumo robots
  • boards: add SIL_RP2040_SHIM board by Silicognition LLC
  • rp2_dma: introduce a new rp2.DMA class for control over DMA xfers

samd port:

  • boards/make-pins.py: update to use tools/boardgen.py
  • mpconfigport: set MICROPY_USE_INTERNAL_ERRNO to 1
  • machine_uart: add machine_uart_set_baudrate() function
  • pin_af: fix a typo in a conditional compile
  • switch TinyUSB to run via a scheduled task
  • mphalport: run TinyUSB stack while waiting for CDC input/output
  • switch to shared TinyUSB implementation
  • use unique id for USB serial number

stm32 port:

  • boards/ARDUINO_GIGA: add QSPI fix/workaround to early init
  • boards/ARDUINO_GIGA: fix name of pins in board init
  • eth: add Ethernet support for H5 MCUs
  • boards/STM32H573I_DK: enable ETH and DAC peripherals
  • powerctrl: add support for frequency scaling with HSI on H5 MCUs
  • boards/make-pins.py: don't generate qstrs
  • boards: fix errors in pins.csv and af.csv
  • boards: format stm32 alternate function csv files
  • rename pin_obj_t to machine_pin_obj_t
  • boards/make-pins.py: update to use tools/boardgen.py
  • boards/make-pins.py: add initial support for H7 dual-pad pins
  • add configuration options for analog switches
  • add STM32H5 support for sleep mode
  • boards/make-pins.py: fix H7 ADC generation
  • boards/stm32f4x9_af.csv: fix DCMI_VSYNC
  • boards/stm32g474_af.csv: fix final row ADC column
  • boards/make-pins.py: only support ADC1-3
  • boards/NUCLEO_WL55: freeze LoRa driver
  • mpu: enable STM32WB mpu use to support qspi flash
  • add optional lwip loopback support
  • boards/NUCLEO_F446RE: add UARTs 1, 3 and 4
  • boards/NUCLEO_H563ZI: add new NUCLEO-H563ZI board definition
  • sdcard: add SD card support for H5 MCUs
  • boards/STM32H573I_DK: enable the SD card
  • add missing header include for debug builds
  • modmachine: only enable machine.I2C if hardware I2C is enabled
  • usbd_cdc_interface: include header to get machine_bootloader decl
  • machine_i2s: improve accuracy of SCK frequency
  • usbdev: optionally pass through vendor requests to Setup function
  • mboot: guard use of tx_pending with USE_USB_POLLING option
  • mboot: expand device descriptor to make it easier to understand
  • mboot: add support for Microsoft WCID

teensy port:

  • remove the teensy port

unix port:

  • mbedtls: enable mbedtls cert time validation
  • update port to use the new event functions

webassembly port: no changes specific to this component/port

windows port:

  • use the MicroPython logo as application icon
  • implement MICROPY_INTERNAL_WFE() macro

zephyr port: no changes specific to this component/port

v1.21.0

7 months ago

This release of MicroPython sees the renaming of built-in modules to remove the u-prefix, a new deflate module with optional compression support, the introduction of board variants, switching of the esp32 port to use IDF 5 together with improved heap management, support for BLE on RPi Pico W boards, and STM32H5xx support. The project is also now using codespell and ruff to improve code quality. New boards added in this release are: ARDUINO_NANO_ESP32 and UM_NANOS3 (esp32 port), ADAFRUIT_METRO_M7 (mimxrt port), ARDUINO_PORTENTA_C33 and VK_RA6M5 (renesas-ra port), ADAFRUIT_METRO_M4_EXPRESS (samd port), NUCLEO_L4A6ZG and STM32H573I_DK (stm32 port).

The renaming of built-in modules to remove the u-prefix -- for example utime becomes time, uasyncio becomes asyncio -- is done to improve compatibility with CPython and eliminate confusion about whether to import the u-version or the non-u-version of the name. Now, one should just always import the non-u-version and no longer think about u-naming. The only remaining module with a u-prefix is uctypes because it is not compatible with the CPython ctypes modules. The following modules are still available via their u-names for backwards compatibility: array, asyncio, binascii, bluetooth, collections, cryptolib, errno, hashlib, heapq, io, json, machine, os, platform, random, re, select, socket, ssl, struct, time, websocket. These modules (except for asyncio) are also extensible and can be overridden by a file with the same name, eg time.py. To force the import of a built-in, one must first clear (and subsequently restore) sys.path; the ability to write to the sys.path attribute has also been implemented in this release. For further information see the discussion at https://github.com/micropython/micropython/issues/9018.

Furthermore, importing itself has been tweaked and optimised, and importing of built-ins no longer touch the filesystem, which makes a typical built-in import take ~0.15ms rather than 3-5ms. For modules that fail to import, they are now removed from sys.modules, allowing the import to be attempted again. This required adding "NLR jump callbacks" to efficiently run some code if an exception is raised.

Additional improvements to the core runtime include support for conversion specifiers in f-strings (e.g. !r), speeding up of incremental GC cycles by tracking the last used block, addition of a new MICROPY_GC_SPLIT_HEAP_AUTO "auto grow heap" mode and support for pad bytes in struct format. The documentation, examples and test have also seen general improvements and additions.

For the extended modules, the zlib C module has been removed and replaced with a new MicroPython-specific deflate module and DeflateIO class that is optimised to provide efficient streaming compression and decompression. The zlib (and gzip) modules are now implemented in pure Python on top of the deflate module. The timeq module has been removed, it existed only for a previous version of (u)asyncio and is no longer used. In the ssl module, SSLContext has been added to be more compatible with CPython. The select module now supports using system/POSIX poll when possible and the unix port now uses this implementation instead of its own one. That means the unix port can now select/poll on custom Python objects that implement the appropriate ioctl. The socket module now supports SO_BROADCAST, and sys.std*.buffer objects now exist on unix. There is also a new esp-hosted network driver for external ESP32-based network coprocessors.

mpy-cross now allows reading source files from stdin and writing compiled code to stdout.

The esp8266 and esp32 ports add support for the Espressif ESP-NOW protocol, and the ability to set/get the power saving mode of the WLAN hardware. The esp8266 port adds board-variant support, combining all boards into a single ESP8266_GENERIC with FLASH_512K, FLASH_1M and OTA variants.

The esp32 port has now switched exclusively to ESP-IDF 5, and all existing components have been updated to work with this new IDF (except esp32.hall_sensor() which has been removed). The FSM ULP has been enabled for S2 and S3 chips, sockets now support SO_BINDTODEVICE, and board-named pins and the Pin.board dict have been implemented. The MicroPython heap has been reworked on this port to support the large variety of memory configurations: it now starts at 64kbytes and automatically grows as needed, with new segments allocated from the IDF heap. This means that boards with SPIRAM have much faster GC collection times if only a small amount of RAM is used, all available RAM can be used if needed, and the IDF has access to enough RAM for things like SSL sockets. For more information see https://github.com/micropython/micropython/pull/12141. The esp32 port has also had its generic boards consolidated and renamed to ESP32_GENERIC, ESP32_GENERIC_C3, ESP32_GENERIC_S2 and ESP32_GENERIC_S3, and some now have variants such as SPIRAM.

The mimxrt port has fixes and improvements to PWM and Pin.irq, as well as support for UART hardware flow control and UART.deinit. It has also seen integration of WiFi via the CYW43 driver, and Bluetooth via NimBLE. The mbedTLS bindings have enabled time validation of certificates.

The renesas-ra port has changed board names to match the product name, updated to use FSP v4.4.0, added support for: RA6M5 MCUs, machine PWM, DAC, RNG and SDCard classes, TinyUSB, Bluetooth via NimBLE, networking via lwIP, and mbedTLS.

Bluetooth support has also been added to the rp2 port for the Pico W board. And the RPi boards have been renamed from PICO to RPI_PICO, and PICO_W to RPI_PICO_W. Lightsleep has been fixed on this port so it works while WiFi is powered off, and time.time_ns() now has microsecond resolution.

The samd port sees the addition of SPI and QSPI flash drivers to support filesystems on external flash.

The stm32 port add support for STM32H5xx MCUs, basic support for the OCTOSPI peripheral, and USB support for STM32L1xx MCUs. New functions have been added to the stm module to support the sub-GHz radio on STM32WL55.

In micropython-lib, an extensive LoRa module has been added along with drivers for SX126x and SX127x chipsets, and the STM32WL55. This module supports both synchronous and asynchronous (asyncio) mode. Also, as part of the u-module renaming, urequests has been renamed to requests (but for backwards compatibility "import urequests" still works for now).

The change in code size since the previous release for various ports is (absolute and percentage change in the text section):

   bare-arm:    +192  +0.340%
minimal x86:    +310  +0.169%
   unix x64:   +4784  +0.610%
      stm32:    -524  -0.134%
     cc3200:    +280  +0.154%
    esp8266:   +8016  +1.151%
      esp32: +112133  +7.293%
     mimxrt:   +3624  +1.015%
 renesas-ra:   -2184  -0.348%
        nrf:    +616  +0.332%
        rp2:   +1920  +0.595%
       samd:   -7904  -2.953%

The changes that dominate these numbers are:

  • bare-arm, minimal, cc3200, nrf: NLR jump callbacks and support for extensible modules
  • unix: update of mbedTLS to v2.28.1, support for polling Python objects in select module
  • stm32: removal of the timeq module
  • esp8266: addition of the espnow module
  • esp32: switching to ESP-IDF 5
  • mimxrt: UART features, time validation of SSL certificates
  • renesas-ra: move to FSP v4.4.0, remove timeq module
  • rp2: machine.PWM enhancements
  • samd: drop support for VfsLfs1

Performance is effectively unchanged since the previous release.

Note that this is the last release to use the current versioning scheme for nightly/unstable builds, whereby a build between releases is versioned as v1.20.0--g (following the release of v1.20.0). Moving forward, nightly builds will now be called preview builds and be versioned with the next release number. For example, if the last release was v1.21.0 then preview releases will be of the form v1.22.0-preview..g. For discussion see https://github.com/micropython/micropython/issues/12127.

Thanks to everyone who contributed to this release: Adam Green, Alexander Wilde, algonell, Andrew Leech, Andy Piper, Angus Gratton, Armin Brauns, brave ulysses, Brett Cannon, Brian 'redbeard' Harrington, Carlosgg, Chris Wilson, Christian Clauss, Damien George, Damien Tournoud, Daniël van de Giessen, David Grayson, David Lechner, David Yang, dotnfc, Duncan Lowther, Elecia White, elibdev, Elvis Pfutzenreuter, Felix Dörre, Francis Dela Cruz, Glenn Moloney, glenn20, iabdalkader, Ihor Nehrutsa, Jared Hancock, Jim Lipsey, Jim Mussared, Jon Nordby, Jonas Scharpf, Jos Verlinde, Kwabena W. Agyeman, Luca Burelli, marble, Mark Grosen, mbedNoobNinja, mcskatkat, Mingjie Shen, Mirko Vogt, Nicholas H. Tollervey, Oliver Joos, Ondrej Wisniewski, patrick, Peter Harper, Phil Howard, Philipp Ebensberger, Rene Straub, robert-hh, Sebastian Romero, Seon Rozenblum, stephanelsmith, stijn, Takeo Takahashi, Thomas, Tobias Thyrrestrup, UnexpectedMaker, Victor Rajewski, vsfos, Wang Xuancong, Wanlin Wang, Wilko Nienhaus, Wind-stormger, Yaroslav Halchenko, Yilin Sun, Yuuki NAGAO.

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:

  • fix spelling mistakes based on codespell check
  • fix strings with backslash by using raw string literals
  • fix various Python coding inconsistencies found by ruff
  • fix cases of Python variable assigned but never used
  • rename MP_QSTR_umodule to MP_QSTR_module everywhere
  • rename mp_umodule*, mp_module_umodule* to remove the "u" prefix
  • rename mod_umodule*, ^umodule* to remove the "u" prefix
  • rename UMODULE to MODULE in preprocessor/Makefile vars
  • rename umodule.h to remove the "u" prefix
  • rename umodule.c to remove the "u" prefix
  • use MP_REGISTER_EXTENSIBLE_MODULE for overrideable built-ins
  • replace all uses of umodule in Python code
  • remove the zlib module
  • remove query-variants make target
  • add missing imports for micropython.const
  • add Black configuration section to pyproject.toml
  • add ruff to pre-commit
  • CODECONVENTIONS: require that commits be signed-off by the author

py core:

  • ringbuf: implement put_bytes/get_bytes functions
  • parse: fix build when COMP_CONST_FOLDING=0 and COMP_MODULE_CONST=1
  • compile: remove over-eager optimisation of tuples as if condition
  • stackctrl: add gcc pragmas to ignore dangling-pointer warning
  • gc: make improvements to MICROPY_GC_HOOK_LOOP
  • obj: remove mp_generic_unary_op()
  • objslice: ensure slice is not hashable
  • objdict: fix hash for dict_view types
  • objarray: disallow memoryview addition
  • objstr: return unsupported binop instead of raising TypeError
  • runtime: if inplace binop fails then try corresponding normal binop
  • change MP_UNARY_OP_INT to MP_UNARY_OP_INT_MAYBE
  • obj: accept user types in mp_obj_get_int_maybe
  • objint: allow int() to parse anything with the buffer protocol
  • builtinimport: handle empty sys.path correctly
  • builtinimport: optimise sub-package loading
  • builtinimport: allow builtin modules to be packages
  • objmodule: don't use sys.modules to track a builtin init
  • nlrsetjmp: use MP_NLR_JUMP_HEAD macro to simplify code
  • nlr: remove commented-out debugging code
  • nlr: implement jump callbacks
  • use nlr jump callbacks to optimise compile/execute functions
  • builtinimport: remove partially-loaded modules from sys.modules
  • builtinimport: remove weak links
  • makemoduledefs.py: add a way to register extensible built-in modules
  • objmodule: add a table of built-in modules with delegation
  • objmodule: workaround for MSVC with no module delegation
  • mpconfig: enable module delegation if sys needs it
  • modsys: allow sys.path to be assigned to
  • mkrules.mk: automatically configure frozen options when manifest set
  • parsenum: fix typo in #endif comment
  • nlraarch64: fix dangerous use of input register
  • makemoduledefs.py: fix declaring multiple module delegations
  • makemoduledefs.py: automatically declare delegation attr functions
  • lexer: allow conversion specifiers in f-strings (e.g. !r)
  • mkrules.mk: allow $(AFLAGS) to set flags to $(AS)
  • compile: fix async for's stack handling of iterator expression
  • builtinimport: fix built-in imports when external import is disabled
  • stream: add mp_stream___exit___obj that calls mp_stream_close
  • runtime: always initialise sched_state in mp_init
  • mpconfig: add MICROPY_PY_PLATFORM, enabled at extra features level
  • gc: speed up incremental GC cycles by tracking the last used block
  • gc: apply some code formatting cleanup
  • gc: add new MICROPY_GC_SPLIT_HEAP_AUTO "auto grow heap" mode
  • profile: remove the requirement to disable MICROPY_COMP_CONST
  • mpconfig: enable SSL finalizers if finalizers are enabled
  • objstr: fix str % {} edge case
  • modstruct: support pad bytes in struct format
  • dynruntime.h: implement MP_OBJ_NEW_QSTR
  • modthread: return thread id from start_new_thread()
  • malloc: fix DEBUG_print() args in m_realloc_maybe
  • runtime: add helpers to call a general function on nlr jump callback
  • parse: always free lexer even if an exception is raised
  • persistentcode: always close reader even if an exception is raised
  • gc: add "max new split" value in result of gc.mem_free()
  • nlrx64: mark nlr_push() as naked function when possible
  • mkrules.mk: don't strip binary if STRIP variable is unset
  • change ifdef DEBUG_PRINT to if DEBUG_PRINT
  • lexer: add missing initialisation for fstring_args_idx

extmod:

  • utime_mphal: provide a general mktime function
  • modutime: provide a generic time module
  • machine_pwm: remove PWM_INIT and PWM_DUTY_U16_NS config options
  • network_cyw43: add power management constants
  • vfs_lfsx: fix offset used before range check
  • extmod.mk: suppress deprecated-non-prototype warning
  • moduos: move os.sync() into extmod/moduos.c
  • modtimeq: remove timeq module
  • btstack: add cmake support for BTstack
  • btstack: fix marking of static addresses in set_random_address
  • asyncio: rename uasyncio to asyncio
  • asyncio/uasyncio.py: add backwards-compatible uasyncio alias
  • modbinascii: fix buffer length error
  • update to support mbedtls 3.x
  • modplatform: set MICROPY_PLATFORM_ARCH on riscv platforms
  • modbtree: undefine queue macros before including berkeley-db
  • modssl: add SSLContext class
  • moddeflate: add deflate module providing the DeflateIO class
  • modssl_mbedtls: reference SSLContext from SSLSocket
  • vfs_posix_file: add poll support for missing ERR,HUP,NVAL values
  • modselect: abstract out a poll_set_t struct and functions
  • modselect: factor low-level polling code into common function
  • modselect: add optimisation to use system poll when possible
  • modselect: remove undocumented support for flags arg to poll
  • modssl_mbedtls: reject ioctls that are not supported
  • modssl_mbedtls: fix ioctl of a socket in closed/error state
  • modselect: properly track number of poll objects that are fd's
  • modssl_mbedtls: clear sock member if error creating SSLSocket
  • moddeflate: change default window size
  • vfs_posix_file: fix flush handling on macOS
  • vfs_posix_file: implement sys.std*.buffer objects
  • modlwip: add support for SO_BROADCAST socket option
  • modsocket: add support for SO_BROADCAST socket option
  • modssl_mbedtls: call func psa_crypto_init if PSA is used
  • modssl_mbedtls: ignore err ERR_SSL_RECEIVED_NEW_SESSION_TICKET
  • modlwip: fix setting of IP option SOF_BROADCAST
  • network_esp_hosted: add ESP-Hosted networking interface
  • modssl_axtls: only close underlying socket once if it was used
  • asyncio/event.py: fix ThreadSafeFlag.ioctl return
  • btstack/btstack_hci_uart: trigger a poll after UART data is sent
  • asyncio/stream.py: fix cancellation handling of start_server
  • modnetwork: increase max hostname length to 32
  • modnetwork: forward if.config(hostname) to network.hostname
  • vfs_posix_file: fix flush handling in msvc builds

shared:

  • upytesthelper: fix spelling of "default"
  • libc/printf: fix stdout destination for putchar and puts
  • tinyusb: avoid symbol clash on targets with external TinyUSB
  • tinyusb: support HS endpoint sizes
  • netutils/dhcpserver: reply on correct netif

drivers:

  • cyw43: make the CYW43 Bluetooth HCI driver more portable
  • esp-hosted: add host driver for ESP-Hosted firmware
  • ninaw10/nina_bt_hci: make some minor fixes to HCI driver
  • esp-hosted: fix pin IRQ
  • esp-hosted: fix MTU size
  • esp-hosted: add support for WiFI LED activity indicator

mpy-cross:

  • allow specifying source files starting with -
  • allow reading from stdin and writing to stdout
  • when reading from stdin, write output to stdout
  • allow specifying stdin as input without --
  • fix source file name in file-not-found error

lib:

  • mbedtls_errors: update error list for current version of mbedtls
  • mbedtls: update to mbedtls v2.28.1
  • mbedtls_errors: add esp32-specific mbedtls error file
  • mbedtls_errors: update patch and error list for new mbedtls
  • mbedtls: update to mbedtls v2.28.3
  • fsp: update FSP for renesas-ra to the latest version v4.4.0
  • cyw43-driver: update driver to latest version v1.0.1
  • btstack: update to v1.5.6.2
  • pico-sdk: update to version 1.5.1
  • stm32lib: update library for H5 v1.0.0
  • oofatfs: fix speculative read in create_name
  • uzlib: add memory-efficient, streaming LZ77 compression support
  • uzlib/lz77: always use separate history buffer
  • uzlib/defl_static: implement some code size improvements
  • uzlib: clean up tinf -> uzlib rename
  • uzlib: combine zlib/gzip header parsing to allow auto-detect
  • uzlib/tinflate: implement more compact lookup tables
  • uzlib/defl_static: optimize zlib_start/finish_block
  • uzlib: add a source_read_data var to pass to source_read_cb
  • tinyusb: update to the most recent master
  • protobuf-c: add protobuf-c library
  • cyw43-driver: update driver to latest version v1.0.2
  • micropython-lib: update submodule to latest

Support components

docs:

  • reference: remove double 'are' in glossary
  • update the PWM examples based on recent API improvements
  • samd: make use of pin names more consistent in examples
  • reference/mpyfiles: add release info on v6.1
  • library/espnow: update espnow docs for WLAN.config(pm=x) options
  • develop/porting: add missing code to example main.c and Makefile
  • reference/speed_python: remove 4-arg limit for viper
  • mimxrt: add the pin-out for the Adafruit Metro M7 board
  • samd: add the pin-out for the Adafruit Metro M4 Airlift board
  • library/index: update built-in extension docs
  • reference/packages: add GitHub repo to package example dependency
  • reference/mpremote.rst: extend the mpremote guide
  • library/index: update docs after umodule rename
  • rename uasyncio to asyncio
  • esp32: update esp32 docs based on IDF v5 changes
  • library/ssl: add documentation for SSLContext
  • esp32/quickref: add LAN example for WT32-ETH01 version 1.4
  • library/deflate: add docs for deflate.DeflateIO
  • develop/gettingstarted: clarify submodule initialization
  • develop/gettingstarted: update ARM package list
  • library/neopixel: change link to a micropython-lib reference
  • library/platform: add docs for the platform library
  • library/network: clarify network.hostname() behaviour
  • esp32/tutorial: add example for pin access via registers
  • library/esp32: update ESP32 idf_heap_info docs to match behaviour
  • library/gc: clarify mem_alloc and mem_free only for Python heap
  • conf.py: add sphinxcontrib.jquery to extensions
  • add requirements.txt file with dependencies for Sphinx
  • change remaining "urequests" references to "requests"

examples:

  • usercmodule: add a sub-package example
  • natmod: rename umodule to module
  • hwapi: rename uasyncio to asyncio
  • natmod/deflate: add deflate as a dynamic native module
  • mark asm, pio, etc. as noqa: F821 (undefined-name)
  • hwapi: add missing import for 96Boards Carbon example
  • bluetooth: raise ValueError when advertising data is too large
  • bluetooth: link to aioble in BLE examples
  • natmod: add features4 as a class definition example
  • unix/machine_bios.py: fix typo

tests:

  • run-tests.py: ensure correct cwd for mpy tests
  • basics: add more tests for hashing of various types
  • basics: remove index and inv from special methods tests
  • import/builtin_ext.py: add test for built-in module override
  • import/import_pkg9.py: add test for subpackage attribute
  • replace umodule with module everywhere
  • run-multitests.py: don't allow imports from the cwd
  • run-perfbench.py: don't allow imports from the cwd
  • run-natmodtests.py: don't allow imports from the cwd
  • float: test domain errors for more combos of args to math funcs
  • rename uasyncio to asyncio
  • extmod/uctypes_array_assign_le: fix buffer
  • extmod/framebuf: fix buffer size issues
  • extmod: add tests for ssl.SSLContext
  • extmod: add test for passing cadata into ssl.wrap_socket()
  • extmod: add deflate.DeflateIO tests
  • extmod: add coverage tests for select module
  • extmod: skip select/socket tests if they can't create UDP socket
  • extmod/select_poll_eintr.py: improve robustness of test
  • misc/sys_settrace_features.py: fix to run on newer CPython
  • unix/mod_os: make os.system() test work on windows
  • run-tests.py: capture output of stderr when running on CPython
  • multi_net: increase asyncio tests timeouts
  • stress/bytecode_limit.py: reverse order of cases
  • float/float_format_ints.py: put power-of-10 test in separate file
  • extmod/deflate_decompress.py: skip test when not enough memory
  • extmod/ssl_cadata.py: skip test on axtls
  • float/math_domain.py: tweak test to also pass with obj-repr-C
  • extmod/vfs_fat_finaliser.py: tweak test so files are collected
  • README: document ./run-internalbench.py
  • run-internalbench.py: remove old CPython reference
  • multi_net/ssl_cert_rsa.py: update test certificate
  • extmod/asyncio_threadsafeflag.py: update for unix select

tools:

  • pyboard.py: rename ProcessPtyToTerminal member "ser" to "serial"
  • mpremote: remove unused import of serial
  • pyboard.py: import serial.tools.list_ports
  • pyboard.py: import errno to fix undefined name in PyboardError
  • manifestfile.py: fix license capturing
  • mpremote: add repl option to escape non-printable characters
  • pydfu.py: use getattr to retrieve getargspec function
  • mpremote: add sleep command
  • mpremote: allow terminator for shortcut commands
  • mpremote: add rtc commands to get and set the RTC
  • mpremote: handle cp without destination
  • mpremote: detach mpremote from pyboard.py
  • mpremote: fix use of stdout_write_bytes function
  • mpremote: fix exec_ -> exec in commands.py
  • autobuild: update auto-build code to build esp32 port with IDF v5
  • autobuild: add support for application .bin files for esp32
  • mpy-tool.py: use isinstance() for type checking
  • codeformat.py: skip formatting ESP-IDF managed components
  • codeformat.py: use pyproject.toml for black config
  • mpremote: make soft-reset count as an action
  • autobuild: automatically build all variants for each board
  • mpy_ld.py: pre-declare some local variables to appease linter
  • mpy-tool.py: ignore linter failure in Python 2 compatibility code
  • mpy_ld.py: support more complex rodata sections
  • metrics.py: fix nrf and rp2 board names after renaming
  • autobuild: include .bin firmware in renesas-ra build output
  • autobuild/build-downloads.py: verify standard features
  • mpremote: add support for rfc2217, serial over TCP
  • metrics.py: fix esp32 and esp8266 board names after renaming
  • change remaining "urequests" references to "requests"

CI:

  • ci.sh: build both SAMD21 and SAMD51 boards as part of samd CI
  • ci.sh: add functions to check code spelling using codespell
  • ci.sh: add mimxrt and samd ports to code size build
  • ci.sh: build PICO_W board as part of rp2 CI
  • ci.sh: add a H5 board to stm32 CI build
  • ci.sh: add ARDUINO_PORTENTA_C33 to RA CI build
  • workflows: fetch full history for mpremote workflow
  • workflows: add spell check to code formatting workflow
  • workflows: add GitHub Action to lint Python code with ruff
  • workflows: force use of Ubuntu-20.04 for unix 32-bit builds
  • workflows: update esp32 CI to use IDF v5.0
  • workflows: bump actions/checkout from 3 to 4

The ports

all ports:

  • use extmod version of mktime instead of port-specific one
  • remove os.sync() implementation from stm32 and renesas-ra
  • enable os.sync() for esp32, esp8266, rp2, mimxrt, samd51
  • standardise docs link in help text
  • in machine_i2s.c, rename uasyncio to asyncio
  • simplify board feature tags in board.json
  • /boards//board.json: remove "id" field
  • restrict board.json to standard features
  • rename Arduino board LED pins to be consistent

bare-arm port: no changes specific to this component/port

cc3200 port:

  • mods/modutime: use extmod version of time module
  • tools: fix exception raised on process failure
  • Makefile: build firmware.zip

embed port: no changes specific to this component/port

esp8266 port:

  • modutime: use extmod version of time module
  • add support for the Espressif ESP-NOW protocol
  • machine_pwm: implement duty_u16() and duty_ns() for consistency
  • add support to set/get power saving mode of WLAN
  • change network.WLAN from a function to a type
  • allow Ctrl-C to interrupt the corrupt-fs while loop
  • machine_pin: accept an integer argument to mp_obj_get_pin_obj
  • add board variant support
  • boards/ESP8266_GENERIC: add image filename
  • boards: make sure modespnow.o is placed in irom0
  • boards/ESP8266_GENERIC: remove urllib from the 2MiB manifest

esp32 port:

  • modutime: use extmod version of time module
  • add support for the Espressif ESP-NOW protocol
  • add support to set/get power saving mode of WLAN
  • change network.WLAN from a function to a type
  • boards: add some missing board configs for two UM boards
  • esp32_ulp: enable FSM ULP for S2 and S3 chips
  • uart: use xtal as UART clock source on S3 and C3
  • modespnow: change name of buffer size config option to "rxbuf"
  • CMake: change PROJECT_DIR to CMAKE_CURRENT_LIST_DIR
  • esp32_ulp: fix ULP (FSM) support for S2 and S3
  • allow Ctrl-C to interrupt the corrupt-fs while loop
  • switch from UART driver to UART HAL
  • ppp_set_auth: add pppapi_set_auth from ESP-IDF
  • modesp32: remove esp32.hall_sensor function
  • update port to support IDF v5.0.2
  • in recv_cb, get espnow rssi from recv_info->rx_ctrl
  • network_wlan: wait for WIFI_EVENT_STA_START after activating
  • Makefile: provide more IDF shortcuts
  • boards: change SDK config parameters from deprecated to new ones
  • modules/inisetup.py: format partition as FAT if its label is ffat
  • machine_uart: always select a source_clk value in UART config
  • re-enable mDNS after move to IDF v5.0.2
  • boards/GENERIC_OTA: enable silent checks to reduce firmware size
  • network_wlan: wait for STA/AP START/STOP event in wlan.active
  • machine_timer: switch from legacy driver to timer HAL
  • machine_pin: add a pin-find func and use it in machine_pin_get_id
  • use always machine_pin_get_id for getting a Pin id
  • add support for board-named pins and the Pin.board dict
  • collect properties from IDF-managed components as well
  • modmachine: add generic machine.bootloader()
  • usb: add custom TinyUSB callback support
  • boards/ARDUINO_NANO_ESP32: add support for Arduino Nano ESP32
  • CMakeLists: enable multiple extra component directories in build
  • boards/ARDUINO_NANO_ESP32: fix deploy instructions
  • main: remove unused mbedtls debug function
  • machine_wdt: allow feeding WDT from threads
  • machine_hw_spi: fix access of SPI(2)
  • machine_hw_spi: remove unnecessary duplicate SPI pin defaults
  • machine_hw_spi: remove SPI host renaming for C3 and S3 variants
  • machine_hw_spi: check for valid SPI id in constructor, not init
  • boards: remove references to the IDF version in board.md files
  • README: specify that only IDF v5.0.2 is supported
  • allow malloc() to allocate from SPIRAM
  • enable automatic Python heap growth
  • gccollect: make level arg volatile to force recursive function
  • Makefile: implement make submodules to match other ports
  • boards/GENERIC: merge with GENERIC_{SPIRAM,OTA,D2WD,UNICORE}
  • boards/GENERIC_C3: merge with GENERIC_C3_USB
  • boards/GENERIC_S2: merge with ESP32_S2_WROVER
  • boards/GENERIC_S3: merge with GENERIC_S3_{SPIRAM,SPIRAM_OCT}
  • partitions.csv: rename to partitions-4MiB.csv
  • use uppercase variant names
  • Makefile: append board variant to BUILD
  • rename GENERIC* boards to ESP32_GENERIC*
  • boards/ESP32_GENERIC_C3: enable UART REPL
  • modsocket: add support for SO_BROADCAST socket option
  • modnetwork: add support for SO_BINDTODEVICE socket option
  • support JTAG console, free up UART
  • machine_uart: release GIL for blocking reads
  • boards: add pins.csv to UM boards and other minor changes
  • boards/UM_NANOS3: add new UM NanoS3 board
  • network_ppp: block after deleting task
  • boards/ARDUINO_NANO_ESP32: clarify recovery instructions
  • boards/UM_FEATHERS3: fix I2C pins in pins.csv
  • skip validation of image on boot from deepsleep
  • machine_pin: fix null pointer access in machine_pin_find
  • mphalport: add function/line/file info to check_esp_err exception
  • fix Partition.writeblocks() partial write corruption
  • boards: fix VBAT voltage calculation for UM S3 boards
  • boards: add bootloader rollback support for all builds
  • main: allow a board to override the MicroPython task stack size
  • boards/ARDUINO_NANO_ESP32: use Arduino USB IDs
  • boards/manifest.py: freeze aioespnow into firmware by default

mimxrt port:

  • modutime: use extmod version of time module
  • machine_pwm: start PWM only if freq and duty are set
  • flash: separate low level driver code from flash object
  • mpconfigport: add back lost uos.urandom()
  • add missing UART defintion and remove obsolete config
  • machine_spi: ignore transfers with len=0
  • machine_pin: perform full configuration in machine_pin_set_mode
  • sdcard: fix GCC 13 build error with sdcard_cmd_set_bus_width
  • led: add support for up to four LEDs
  • boards/ADAFRUIT_METRO_M7: add Adafruit Metro M7 board definition
  • machine_pwm: fix freq change, PWM print, and error checks
  • Makefile: use a specific fsl_flexspi_nor_boot.c for mimxrt1062
  • machine_pin: fix bug when Pin.irq is called without a handler
  • hal/pwm_backport: fix 0 and 65536 edge cases of PWM's duty_u16
  • machine_uart: add uart.deinit method and machine_uart_deinit_all
  • machine_uart: add support for UART hardware flow control
  • boards: add support for GPIO control of SNVS pins
  • hal: make flash clock frequency configurable
  • fix UART RTS/CTS assignments for the OLIMEX and Adafruit boards
  • machine_pin: extend pin configuration functions
  • sdio: add SDIO driver
  • integrate support for WiFi via the CYW43 driver
  • integrate Bluetooth support with NimBLE bindings
  • irq: move all IRQ related definitions to dedicated header
  • machine_uart: fix and complete UART.deinit and uart_deinit_all
  • boards: fix use of MICROPY_HW_SDRAM_AVAIL in MIMXRT1176.ld
  • machine_uart: support slow baud rates for UART
  • machine_uart: add a helper function to change the baudrate
  • sdio: move config guard so headers are only included if used
  • Makefile: update to work with latest TinyUSB
  • mpconfigport: don't override parse chunk alloc
  • sdio: add support for the 117x series
  • mimxrt_sdram: allow boards to override the default SDRAM config
  • Makefile: enable the FSL USDHC for supported MCU series
  • remove SDCARD Makefile config option
  • mpbthciport: enable flow control for BT HCI UART
  • mbedtls: enable certificate validity time validation
  • machine_uart: set the UART clock to a fixed 40MHz value
  • boards/MIMXRT1176_clock_config: fix comments about UART clocks
  • boards: fix naming of SD-card config option
  • mpbthciport: allow disabling UART flow control for BLE
  • machine_rtc: improve the RTC init at boot

minimal port: no changes specific to this component/port

nrf port:

  • modules/utime: use extmod version of time module
  • boards: rename all nRF boards to use uppercase

pic16bit port: no changes specific to this component/port

powerpc port:

  • mpconfigport: don't override parse chunk alloc

qemu-arm port: no changes specific to this component/port

renesas-ra port:

  • change MICROPY_HW_BOARD_NAME definition to product name
  • modutime: use extmod version of time module
  • update boards and ra directory files to support FSP v4.4.0
  • add a macro definition to avoid compile error of FSP v4.4.0
  • irq: fix typo in comment about IRQ priorities
  • consolidate hal_entry.c code and remove hal_entry() func
  • boards/make-pins.py: fix PA/PB pins support
  • consolidate all fsp_cfg header files to one location
  • support changing baudrate for UART
  • add support for RA6M5, and add machine PWM, DAC, SDCard
  • boards/VK_RA6M5: add new board definition
  • remove duplicate machine module from constants list
  • machine_spi: consistently use machine_pin_find to get pin
  • boards: remove unreachable code in make-pins.py
  • Makefile: generate binary firmware output
  • add TinyUSB support
  • add Bluetooth support using NimBLE
  • add RNG driver
  • add networking support using lwIP
  • add mbedTLS support
  • fsp_cfg: add common FSP config files
  • boards/ARDUINO_PORTENTA_C33: add support for Portenta C33
  • boards/ARDUINO_PORTENTA_C33: update WiFi config
  • tune lwip buffers and timing to improve network performance

rp2 port:

  • modutime: use extmod version of time module
  • machine_pwm: enable keyword args in constructor and add init method
  • machine_pwm: add support for inverting a PWM channel output
  • machine_pwm: add duty_x() checks and return 0 if PWM is not started
  • make rp2_state_machine_exec accept integers
  • CMakeLists: allow relative MICROPY_BOARD_DIR when invoking cmake
  • mphalport: only use CYW43 MAC for WLAN0 interface
  • CMake: normalize MICROPY_PORT_DIR
  • add Bluetooth support via cyw43
  • mpbthciport: cancel existing alarms
  • boards/PICO_W: enable Bluetooth Low Energy support
  • machine_pin: factor out pin-find code from machine_pin_make_new
  • use uppercase variant names
  • Makefile: append board variant to BUILD
  • rename PICO, PICO_W to RPI_PICO, RPI_PICO_W
  • machine_timer: fix printing of timer period
  • mpbthciport: switch to static scheduler nodes
  • mpbthciport: fix HCI UART config
  • mpconfigport: disable BLE locking when MICROPY_PY_BLUETOOTH enabled
  • boards/ARDUINO_NANO_RP2040_CONNECT: use standard HCI UART baudrate
  • modmachine: fix lightsleep while wifi is powered off
  • msc_disk: allow configuring the USB MSC inquiry response
  • README: fix name of RPI_PICO_W board
  • CMakeLists: enable debug symbols in all builds
  • implement time.time_ns with time_us_64 so it has us resolution

samd port:

  • modutime: use extmod version of time module
  • machine_pwm: add init() method to PWM and simplify the PWM code
  • mpconfigport: drop support for SoftSPI max speed
  • boards/MINISAM_M4: update pins.csv for the Mini SAM M4 board
  • rearrange the MCU-specific loader files
  • mcu/samd51: enable MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF
  • boards: add default deploy instructions
  • main: fix sercom deinit ordering in soft-reset
  • modmachine: add machine.deepsleep as alias of machine.lightsleep
  • modmachine: make some machine classes configurable by #defines
  • boards/SEEED_WIO_TERMINAL: rename two pins starting with a digit
  • mcu: reduce the startup time after hard reset
  • machine_uart: add support for UART hardware flow control
  • boards/ADAFRUIT_METRO_M4_EXPRESS: add Metro M4 Express Airlift
  • boards: rename flash pins consistently for QSPI and SPI
  • samd_spiflash: add SPI flash driver and configure it accordingly
  • samd_qspiflash: add QSPI flash driver and configure it accordingly
  • adapt existing samd.Flash and integrate with (Q)SPI flash in boot
  • boards: extend the code size limit for boards with external flash
  • set the LFS type in mpconfigmcu.mk instead of mpconfigboard.mk
  • Makefile: move the math lib files from mpconfigmcu.mk to Makefile
  • Makefile: print memory region usage instead of totals
  • mpconfigport: enable DHT and onewire drivers on all MCUs/boards
  • mpconfigport: provide the platform module
  • modules/_boot.py: add /lib to sys.path
  • mpconfigport: don't override parse chunk alloc

stm32 port:

  • modutime: use extmod version of time module
  • boards/ARDUINO_PORTENTA_H7: enable FDCAN
  • boards/stm32h723_af.csv: fix ADC AF definitions
  • mboot: fix alignment of packed final buffer
  • irq: fix typo in comment about priorities
  • usb: fix USB support on STM32G4
  • boards/NUCLEO_G474RE: make it easier to enable USB
  • adc: add support for STM32L4A6 MCUs
  • boards/NUCLEO_L4A6ZG: add new board definition
  • help: don't include unavailable features in help()
  • help: exclude legacy entries from help, and adjust constant names
  • mpconfigboard_common: provide default spidev config
  • boards: use default spibdev config where appropriate
  • Makefile: pass relevant CPU flags to assembler
  • make-stmconst.py: support structs with names ending in _t
  • main: start UART REPL as early as possible
  • usbd_conf: treat G0 USB periph as MICROPY_HW_USB_IS_MULTI_OTG=0
  • machine_adc: handle ADC resolution less than 8 bits on all MCUs
  • add initial support for H5 MCUs
  • boards: add ld, af.csv and hal_conf_base.h files for H5 MCUs
  • octospi: add preliminary support for OCTOSPI peripheral
  • boards/STM32H573I_DK: add H5 board definition files
  • add USB support for STM32L1 MCUs
  • modify RCC->APB2ENR directly instead of HAL API
  • modmachine: remove duplicate machine_timer_type declaration
  • modmachine: make machine_reset_cause_obj public
  • dac: fix dac.write_timed on G4 MCUs to use 32-bit DMA access
  • adc: fix ADC clock prescaler for G4 MCUs
  • adc: fix pyb.ADCAll.read_core_temp for G4 MCUs
  • adc: fix reading internal ADC channels on G4 MCUs
  • machine_adc: fix machine.ADC to work on G4 MCUs
  • adc: add workaround for ADC errata with G4 MCUs
  • adc: fix pyb.ADCAll.read_core_bat on G4 and L4 MCUs
  • qspi: allow qspi_write_cmd_data to write cmd with 1 data byte
  • mpconfigport: always define MICROPY_SOFT_TIMER_TICKS_MS
  • remove duplicate machine module from constants list
  • boards/B_L072Z_LRWAN1: add pin definitions for internal SX1262
  • boards/B_L072Z_LRWAN1: lower default ROM level to "Core"
  • spi: add STM32WL5 SUBGHZ SPI peripheral
  • powerctrlboot: support STM32WL system clock from HSE+PLL
  • dma: fix DMA completion on WL55 boards
  • subghz: add STM32WL55 subghz radio interface to stm module
  • modstm: add MICROPY_PY_STM_CONST flag, clear it for STM32WL5
  • use uppercase variant names
  • Makefile: append board variant to BUILD
  • mboot: fix fwupdate by replacing zlib with new deflate module
  • uart: fix UART timeout issue with low baudrate on G4 MCUs
  • timer: fix deadtime config on Advanced Timer peripherals
  • dma: add support for SPI1 DMA on H5 MCU's
  • octospi: add support for dual-line SPI interface
  • powerctrlboot: allow using PLL3 for USB clock on H5 MCU's
  • timer: fix use of TIM8 on H5 MCU's
  • uart: add support for UART10 when it's a USART
  • powerctrlboot: allow PLL1 Q and R outputs to be enabled on H5
  • adc: fix STM32H5 support
  • adc: add support for STM32H5 ADC2 inputs
  • adc: optimize sampling time for G4, H5, L4 and WB MCUs
  • machine_adc: fix and improve STM32H5 support
  • dac: add STM32H5 DAC support, with dma_nohal implementation
  • boards: move includes to after defines in all hal_conf.h files
  • uart: generalise UART source clock calculation for H5 and H7 MCUs
  • dma: remove unbalanced )
  • usbd_msc_interface: allow configuring the MSC inquiry response
  • boards/ARDUINO_GIGA: update board config
  • i2c: add support for I2C4 on H7 MCUs

teensy port: no changes specific to this component/port

unix port:

  • modutime: use extmod version of time module
  • Makefile: allow variants to add QSTR_DEFS
  • main: add NLR scope for checking module path
  • README: fix Markdown link markup
  • modsocket: add poll support for missing ERR,HUP,NVAL poll values
  • modselect: remove unix-specific implementation of select module
  • modjni: fix build errors with type definitions and error strings
  • main: fix memory leakage if MICROPY_USE_READLINE is disabled

webassembly port:

  • modutime: use extmod version of time module
  • make mp_js_do_str asynchronous
  • make mp_js_process_char asynchronous
  • replace typeof window check with ENVIRONMENT_IS_NODE flag

windows port:

  • Makefile: allow variants to add QSTR_DEFS

zephyr port:

  • modutime: use extmod version of time module

v1.20.0

1 year ago

v1.19

1 year ago

In this release of MicroPython the .mpy file format has been significantly reworked and bumped to version 6. The new format now contains data and bytecode organised to be mostly static and ready to run in-place. To achieve this, qstr references from bytecode (and native machine code) now go through a lookup table, to convert from local qstr number in the module to global qstr number in the runtime that the module executes within. This means bytecode (and most native code) does not need rewriting when it is imported. Along with this change, the jump opcodes have been optimised to emit 1-byte jump offsets when possible, which gives a good reduction in bytecode size, saving RAM and reducing the size of .mpy files.

The change to the bytecode means that code constants (like long strings, bytes objects and floats) are now shared and de-duplicated across the whole module, rather than each code object having a separate constant table. The parser can also now turn a tuple of constants into a constant object, so the tuple doesn't need to be built at runtime each time it is used. Furthermore, any constant object can now be used in "X = const(obj)" statements.

With these bytecode changes, .mpy files see around a 10% reduction in size and frozen .mpy code sees about a 5% size reduction. Heap memory use after import is also down by around 5% (more savings are seen if the code uses lots of constants). Due to the qstr indirection performance of the VM is slightly reduced on some benchmarks by a few percent, but the benefits of smaller code and reduced RAM usage are deemed to outweigh this. See commit f2040bfc7ee033e48acef9f289790f3b4e6b74e5 for more details.

In the runtime, support has been added for multiple *args and **args in a function call, following PEP 448. Built-in modules can now have (optional) mutable attributes, and this is used to implement sys.ps1/sys.ps2 which allow the user to customise the REPL prompt. This can be useful, for example, to configure a different REPL for different boards so they can be easily distinguished. The sys module has also had the MicroPython git version and build date appended to sys.version, sys.implementation._machine has been added, and sys.implementation.mpy renamed to sys.implementation._mpy. The sys module can now be used to fully identify the MicroPython version and target it is running on (and the platform module provides additional information when it's available).

The MP_REGISTER_MODULE macro is now used to register all built-in C modules and the third argument to this macro has been removed. Any user-C-modules will need to be updated. Also support for MICROPY_PORT_BUILTIN_MODULES is removed because this is no longer needed, and should be replaced by usage of MP_REGISTER_MODULE (see commit 0a92469c10542d57ef0ea6b6cf2ed0cae9491dbe for example).

mpy-cross now supports the -march=armv6m option, which can be used with the rp2 port. The -mno-unicode has been removed.

The littlefs2 library has been updated to v2.5.0 which includes some performance improvements and minor fixes.

At the REPL, a tab will now insert an indent when it follows whitespace, and auto-indent is automatically disabled if a space or tab follows an auto-indent. This means that Python code can be pasted into the standard REPL without messing up the indentation.

mpremote is now at version 0.3.0, with a progress indicator shown when copying large files, and recursive copy fixed on Windows. It also has the following commands added: --help, --version, version, resume, soft-reset, umount.

The esp32 port has a new machine.ADCBlock class and updated ADC class. Fixes have been made to ADC2 channel mapping, low PWM frequencies, UART initialisation of unspecified parameters, and RMT channel on S2/S3/C3 variants. The Pin.PULL_HOLD constant has been replaced by a "hold" keyword argument to the Pic constructor, and it's now possible to configure pin drive strength. I2C write-then-read transfers have been optimised to be faster. WLAN.config() now supports setting/getting the txpower. New boards include LOLIN C3 MINI ESP32-C3, LilyGO LoRa32, and UM ESP32-S3 based boards.

The mimxrt port has updated the nxp_driver to v2.10 and fixed USB CDC RX handling to not block. Pin drive constants have been renamed to DRIVE_x to match other ports, and the machine.I2S class has been added. New boards include Olimex RT1010 and MIMXRT1015_EVK.

The nrf port now includes uasyncio in the default board manifest, and additional features have been enabled on nrf52840 and nrf9160 boards to match the features on stm32, rp2 and esp32. This includes enabling the json, re, zlib and framebuf modules.

There is a new renesas-ra port which targets Renesas RA4M1, RA4W1, RA6M1 and RA6M2 MCUs, with board definitions for evaluation kits for these MCUs, along with RA4M1 clicker. This port currently supports Pin, ADC, SoftI2C, I2C, SoftSPI, SPI, UART, Timer and RTC classes in the machine module, along with the VFS and an internal flash filesystem.

The rp2 port now has optional USB MSC support, and optional dupterm support. The machine.UART class has init and deinit methods added, and the ucryptolib module is now available. The lwIP network stack has been integrated, along with mbedtls for the ssl module, and these can be used with the new Wiznet driver to provide Ethernet support. The Wiznet W5100S-EVB-Pico board has been added which makes use of this driver. The day-of-week value reported by time.localtime() has been fixed, memory corruption when a thread is created on core1 has been fixed, and the UART now uses a mutex when reading/writing to prevent character duplication in code that uses both cores.

The stm32 port has added support for G0, G4 and WL MCUs. The new boards for these MCUs are NUCLEO_G0B1RE, NUCLEO_G474RE and NUCLEO_WL55. The ARDUINO_PORTENTA_H7 board has also been added, with full WiFi and BLE support. The rfcore on WB55 MCUs has been improved by removing an extra layer of buffering, and the restriction on the use of address resolution has been removed, meaning that the rfcore WS firmware should be updated to v1.12.0 or later; see commit 26b1d31eda292d9cd5cfc68f14ce8055256fade8. The board-level configuration of mboot has been significantly improved to allow more control over system clocks, more hooks into the start up process, and a hook for state change. And the CRC32 of DFU files is now verified before writing them.

The pyb.CAN class has been improved to support FD frames and buses with mixed classic/extended-ID nodes, allowing extended IDs to be specified on a per-message basis. CAN.recv also now returns a value indicating if the received message had an extended ID or not. And CAN.initfilterbanks has been removed, replaced with the num_filter_banks keyword argument to CAN.init. These are all breaking changes to the pyb.CAN class API and code will need to be updated accordingly; see commit 5cdf9645711cc12b45e602ef5795c33895116fc4 for details.

The unix port now shows compiler information in the REPL banner to make it consistent with how bare-metal ports work, and the "-X realtime" command-line option has been added for macOS to get improved timing. All variants have switched to use the VFS subsystem, and use the VfsPosix class for mounting the host's filesystem. The os module has been consolidated with all other ports and the minimal and standard variants gain the unlink, chdir, getcwd and listdir functions.

The windows port has also switched to the VFS subsystem and VfsPosix. It adds support for micropython.schedule and uasyncio on the dev variant. And BCryptGenRandom has been used to implement os.urandom.

The zephyr port upgraded Zephyr to v3.0.0.

The change in code size since the previous release for various ports is (absolute and percentage change in the text section):

   bare-arm:   +792  +1.394%
minimal x86:  +2091  +1.286%
   unix x64: +10231  +1.995%
unix nanbox:  +9777  +2.162%
      stm32:   +184  +0.047% PYBV10
     cc3200:   +904  +0.493%
    esp8266:  -1240  -0.177% GENERIC
      esp32:  +6464  +0.425% GENERIC
        nrf: +11288  +6.472% pca10040
        rp2: +14432  +2.929% PICO
       samd:  +1352  +0.970% ADAFRUIT_ITSYBITSY_M4_EXPRESS

The changes that dominate these numbers are:

  • bare-arm, minimal, cc3200, samd: reworked bytecode and mpy format, optimisation of jump opcodes to use 1-byte offsets, de-duplication of constants at the module level, and PEP 448 support
  • unix: switching to use VFS, and new mpy format and related changes
  • esp8266: removal of esp.info and machine.WDT.deinit
  • esp32: addition of machine.ADCBlock, and new mpy format changes
  • nrf: enabling uasyncio, enabling MICROPY_PY_IO
  • rp2: enabling ucryptolib with mbedtls

Note that the stm32 port's size remained roughly unchanged. This is because it has a decent amount of frozen Python code and the reduction in frozen code size due to the reworked bytecode has offset the increase in runtime/VM size due to this change. Ports like bare-arm, minimal, cc3200 and samd do not have any frozen code so only see the increase in runtime/VM size. Production-level projects that have a significant amount of frozen code have seen around a 4% overall reduction in their firmware size.

Thanks to everyone who contributed to this release: Algy Tynan, Andrew Leech, Andrew Scheller, Artyom Skrobov, Asensio Lorenzo Sempere, Bradley Wogsland, Cem Eliguzel, Chris Wilson, Christian Decker, Christian Zietz, Christophe Priouzeau, Clayton Mills, Damien George, Daniel Jour, Daniël van de Giessen, Dave Hylands, David Lechner, Emil Kondayan, Herwin Grobben, iabdalkader, IhorNehrutsa, Jan, Jared Hancock, jason, Jeff Epler, Jeremy Herbert, Jim Mussared, Jon Bjarni Bjarnason, Jonathan Hogg, Jos Verlinde, Kattni Rembor, Lars Kellogg-Stedman, Luiz Brandao, marcidy, Martin Fischer, Maureen Helm, Meriç SARIIŞIK, Michael Himing, Michael O'Cleirigh, MikeTeachman, Peter D. Gray, Peter Hinch, Peter Züger, Phil Howard, Philipp Ebensberger, Rob Knegjens, robert-hh, Sean Coates, Seon Rozenblum, Stephane Smith, stijn, Takeo Takahashi, ubi de feo, Waterlens, wemos, YoungJoon Chun, Yukai Li.

What follows is a detailed list of changes, generated from the git commit history, and organised into sections.

Main components

all:

  • fix MICROPY_OBJ_REPR_D compilation with msvc
  • update Python formatting to latest Black version 22.1.0
  • use mp_obj_malloc everywhere it's applicable
  • reformat remaining C code that doesn't have a space after a comma
  • remove third argument to MP_REGISTER_MODULE
  • rename MICROPY_PY_WIZNET5K to MICROPY_PY_NETWORK_WIZNET5K

py core:

  • objstr: support '{:08}'.format("Jan") like Python 3.10
  • modmath: add math.tau, math.nan and math.inf constants
  • qstr: separate hash and len from string data
  • qstr: use const consistently to avoid a cast
  • gc: update debug code to compile with changes to qstr pool types
  • rework bytecode and .mpy file format to be mostly static data
  • bc.h: fix C++ compilation of public API
  • objmodule: support delegating failed attr lookups
  • modsys: add optional attribute delegation
  • modsys: add optional sys.tracebacklimit attribute
  • modsys: add optional mutable attributes sys.ps1/ps2 and use them
  • parse: simplify handling of const int parse nodes
  • parse: put const bytes objects in parse tree as const object
  • parse: handle check for target small-int size in parser
  • showbc: remove global variables and make DECODE_PTR work correctly
  • smallint: introduce MP_SMALL_INT_BITS macro
  • objgenerator: fix unused variables when native gen extracts prelude
  • change jump opcodes to emit 1-byte jump offset when possible
  • emitbc: add check for bytecode jump offset overflow
  • change jump-if-x-or-pop opcodes to have unsigned offset argument
  • builtinimport: alias sys to usys if import weak links aren't enabled
  • bc.h: fix C++20 compilation with "volatile"
  • compile: only show raw code that is bytecode
  • asmxtensa: fix use of l32i/s32i when offset won't fit in encoding
  • emitnative: don't store prelude at end of machine code if not needed
  • vm: prevent array bound warning when using -MP_OBJ_ITER_BUF_NSLOTS
  • runtime: allow multiple **args in a function call
  • runtime: allow multiple *args in a function call
  • runtime: do not overallocate when len is known
  • runtime: drop new_alloc < 4 check
  • runtime: use size_t/ssize_t instead of uint/int
  • emitbc: assert that a small int fits its encoding when emitting one
  • fix compiling and decoding of *args at large arg positions
  • runtime: remove unnecessary check for kw_value == MP_OBJ_NULL
  • makeqstrdefs: cleanup and extend source file classification
  • emitinlinethumb: use 16 bit encodings for PUSH LR and POP PC
  • scheduler: add support for scheduling static C-based callbacks
  • emitnative: revert "don't store prelude at end of machine code if..."
  • persistentcode: define enum values for obj types instead of letters
  • parse: factor obj extract code to mp_parse_node_extract_const_object
  • parse: print const object value in mp_parse_node_print
  • parse: add MICROPY_COMP_CONST_TUPLE option to build const tuples
  • persistentcode: support loading and saving tuples in .mpy files
  • objtype: convert result of user contains method to bool
  • modsys: append MicroPython git version and build date to sys.version
  • modsys: rename sys.implementation.mpy to sys.implementation._mpy
  • modsys: introduce sys.implementation._machine constant
  • emitcommon: don't implicitly close class vars that are assigned to
  • obj: introduce mp_obj_malloc macro to allocate, and set object type
  • objfloat: explain why mp_obj_malloc isn't used
  • malloc: introduce m_tracked_calloc, m_tracked_free functions
  • objmodule: move stray #include to top of file
  • persistentcode: remove obsolete comment about qstr window size
  • persistentcode: remove unicode feature flag from .mpy file
  • asmx64: support full range of regs in asm_x64_lea_disp_to_r64
  • bc: provide separate code-state setup funcs for bytecode and native
  • emitnative: put a pointer to the native prelude in child_table array
  • compile: allow new qstrs to be allocated at all compiler passes
  • compile: de-duplicate constant objects in module's constant table
  • parse: allow all constant objects to be used in "X = const(o)"
  • makemoduledefs.py: allow multiple ways to register a module
  • make builtin modules use MP_REGISTER_MODULE
  • remove support for MICROPY_PORT_BUILTIN_MODULES
  • asmthumb: fix PC relative load by sign extending the constant
  • emitnative: simplify generation of code that loads prelude pointer
  • emitnative: provide dedicated local for exception unwind handler ptr
  • asmthumb: fix offset variable name in ldr, ldrh and strh functions
  • asmthumb: add asm_thumb_ldrh_reg_reg_i12_optimised() helper func
  • asmarm: add asm_arm_ldrh_reg_reg_offset() helper func
  • asm: add ASM_LOAD16_REG_REG_OFFSET macro for load-u16 with offset
  • emitnative: access qstr values using indirection table qstr_table
  • asmthumb: make ARMv7-M instruction use dynamically selectable
  • persistentcode: select ARMV6M as maximum when thumb2 not defined
  • dynruntime.mk: add basic support for armv6m architecture
  • asmthumb: provide implementations of clz/ctz for msvc
  • builtin: clean up and simplify import_stat and builtin_open config
  • emitinlinethumb: make ARMv7-M instruction use dynamically selectable
  • emitinlinethumb: make float instruction use dynamically selectable
  • change makemoduledefs process so it uses output of qstr extraction
  • persistentcode: remove remaining native qstr linking support
  • bc: remove unused mp_opcode_format function
  • compile: give the compiler a hint about num nodes being non-zero
  • makemoduledefs.py: remove shebang line and adjust style of comment
  • parse: work around xtensa esp-2020r3 compiler bug
  • dynruntime: add macros to create a new dict and store to dicts
  • dynruntime: add macros to access more types and mp_const_empty_bytes
  • makemoduledefs.py: emit useful error for legacy MP_REGISTER_MODULE

extmod:

  • network_ninaw10: implement MP_STREAM_POLL in ioctl
  • modusocket: make setsockopt return if NIC is not connected
  • modusocket: add makefile() method and common socket options
  • modusocket: create new sockets in blocking mode
  • modusocket: support additional args to getaddrinfo
  • machine_i2c: increase default SoftI2C timeout to 50ms
  • modubinascii: add newline keyword to b2a_base64 function
  • moduplatform: move platform PP definitions into a header
  • moduzlib: fix parsing zlib header dict size
  • moduos: create general uos module to be used by all ports
  • modure: set subject begin_line so ^ doesn't match interior
  • uasyncio: allow task state to be a callable
  • uasyncio: fix gather cancelling and handling of exceptions
  • extmod.cmake: add micropy_lib_mbedtls component
  • modusocket: implement optional socket.listen backlog argument
  • modusocket: provide config macro for socket.listen backlog deflt
  • uasyncio: make Python Task match C version with use of asserts
  • uasyncio: fix bug with task ending just after gather is cancel'd
  • uasyncio: rename and merge TaskQueue push/pop methods
  • move font_petme128_8x8.h from ports/stm32 to extmod
  • make extmod modules use MP_REGISTER_MODULE
  • make port-included extmod modules use MP_REGISTER_MODULES
  • revert accidental usocket->socket rename
  • webrepl: fix setting password in foreground mode and factor code
  • modusocket: fix polling of a new socket
  • modusocket: bind unconnected socket to default NIC in setsockopt
  • modusocket: fix errcode returned from socket read/write
  • modusocket: add socket type print function
  • modusocket: add support for socket events callback
  • modusocket: fix socket_make_new argument parsing
  • modusocket: add timeout and callback to socket object
  • modusocket: add sendall function
  • network_ninaw10: add support for socket events callback
  • machine_i2c: add optional support for write-then-read transfers
  • uasyncio: fix edge case for cancellation of wait_for
  • nimble: add support for reading whole HCI UART packets
  • network_wiznet5k: add Wiznet Ethernet network interface
  • modussl_mbedtls: poll EVENT_POLL_HOOK in ssl handshake loop
  • modurandom: fix missing void in empty argument list
  • extmod.cmake: require components to be explicitly enabled
  • modusocket: add socket state to track new/listening/conn/closed
  • modusocket: fix polling of closed sockets
  • extmod.cmake: fix hard-coded mbedtls config file path

shared:

  • readline: make tab insert an indent when it follows whitespace
  • readline: disable auto-indent if space/tab follows added indent

drivers:

  • ninaw10: add function to check socket state/data availability
  • ninaw10: fix timeout handling to match modusocket
  • ninaw10: return standard error numbers
  • ninaw10: add NIC-level ioctl function
  • sdcard: allow setting the final SPI baudrate
  • codec: add driver for the WM8960 codec
  • ninaw10: fix isconnected to return False when inactive
  • dht/dht.py: change default import module as machine
  • ninaw10: update driver to support firmware 1.5.0
  • bus: rename MP_SPI_ADDR_IS_32B to MICROPY_HW_SPI_ADDR_IS_32BIT
  • lsm6dsox: add support for SPI mode
  • sdcard: fix CSD version 1.0 device size calculation
  • sdcard: make ioctl(4), ioctl(5) return num blocks, block size
  • sdcard: fix address calculation on v2 SDSC cards

mpy-cross:

  • add armv6m architecture option

lib:

  • re1.5: distinguish between subject start-of-line and start-of-srch
  • stm32lib: update library for G0 v1.5.1
  • fsp: add renesas fsp git repository as submodule
  • littlefs: update littlefs2 to v2.5.0
  • littlefs: guard lfs2_file_rawopen with LFS2_NO_MALLOC
  • littlefs: remove assignment of variables to themselves
  • nxp_driver: update nxp_driver to v2.10
  • wiznet5k: add submodule for Wiznet Ethernet drivers

Support components

docs:

  • library: specify additional ADC methods and new ADCBlock class
  • esp32: document expanded ADC API in quickref
  • differences: update differences now that math.tau/inf/nan exist
  • differences: update python_36 now that b2a_base64 accepts newline
  • remove reference to obsolete neopixel_write function
  • develop/porting.rst: fix build and import problems in the example
  • reference/isr_rules.rst: fix inconsistent variable name in example
  • esp32/quickref: update ADC documentation
  • reference/isr_rules.rst: describe uasyncio-IRQ interface
  • library/collections.rst: use class for deque and OrderedDict
  • use the correct * keyword-only notation
  • library/socket.rst: document socket as a class
  • library/pyb.Timer.rst: add pyb.Timer class constants
  • library/pyb.rst: add pyb.hid_mouse and pyb.hid_keyboard constants
  • library/pyb.DAC.rst: add DAC class constants
  • library/machine.SPI.rst: add class constant SoftSPI.MSB and .LSB
  • library/machine.WDT.rst: use correct case for WDT.feed
  • library/esp.rst: document the osdebug function
  • library/pyb.SPI.rst: document default for prescaler argument
  • library/machine.Pin.rst: document defaults for Pin.init
  • library/uasyncio.rst: fix description of ThreadSafeFlag.wait
  • library/machine.UART.rst: add details for invert parameter
  • differences/python_35: mark PEP 486 as not applicable
  • library/esp32.rst: mark esp32.Partition as not taking kw args
  • esp32/quickref: document GPIO drive strength
  • library/machine.Pin: update to use preferred DRIVE_x constants
  • esp32/quickref: refine deep-sleep power-saving notes
  • library/machine.I2S: clarify what rate refers to
  • library/pyb.CAN: update CAN docs to match revised API
  • add quickref and docs for mimxrt, including network.LAN docs
  • reference/mpremote: add details about mount usage over soft reboot
  • differences: update Python 3.5 diff, with optional listen backlog
  • reference: update constrained docs now that tuples can be const
  • library/network.WLAN: add "txpower" to list of known WLAN configs
  • renesas-ra: add renesas-ra docs files
  • update files for renesas-ra port
  • renesas-ra: remove unused image files
  • reference/mpyfiles: remove docs about mpy flags and qstr win size
  • mimxrt: add i.MX RT1015 to general.rst, and a few clarifications
  • mimxrt: move the pinout tables to a separate document
  • reference/manifest: add link to details about opt-level for freeze
  • reference/mpyfiles: update .mpy description to match latest format
  • update Raspberry Pi URLs from .org to .com

examples:

  • embedding: fix build with updated sys and os modules
  • natmod/features3: add example to test more natmod features

tests:

  • run-multitests.py: ignore lld_pdu_get_tx_flush_nb msgs from IDF
  • run-multitests.py: set HOST_IP so tests work between PC and board
  • multi_net: add testing key/cert to SSL server/client test
  • multi_net: close accepted sockets when tests are done
  • multi_net/udp_data.py: allow reusing port before bind
  • multi_net/udp_data.py: make UDP test more reliable
  • run-perfbench.py: allow a test to SKIP, and to have a .exp file
  • perf_bench: add perf tests for qstr interning and importing .mpy
  • perf_bench: add perf test for yield-from execution
  • run-perfbench.py: use SKIP consistently, and increase print width
  • extmod/vfs_fat_finaliser.py: make finalisation more robust
  • run-tests.py: skip repl tests when running windows underneath
  • perf_bench: skip bm_chaos test if random.randrange is unavailable
  • unix: add coverage test for freezing various objects
  • basics: add test for creating small-ints in nan-box builds
  • run-tests.py: include test files ending in _set as set tests
  • micropython: switch from set.pop to raise-0 to test exc strings
  • extmod/vfs_posix.py: only test statvfs if it exists
  • cmdline/cmd_showbc: fix spelling of sequence
  • extmod: add test for machine.I2S data rate
  • extmod: update I2S rate test to work on mimxrt
  • basics/fun_callstardblstar: add coverage test
  • basics/fun_callstardblstar: add test for large arg allocation
  • pyb: update CAN tests to match revised CAN API
  • inlineasm: add test for PUSH LR and POP PC
  • perf_bench: update import tests for changes to .mpy consts
  • micropython: add tests that const tuples don't use the heap
  • extmod/uasyncio_gather: make double-raise gather test reliable
  • run-tests.py: add timeout for running PC-based MicroPython test
  • cmdline: add test for REPL auto-indent
  • renesas-ra: add tests for renesas-ra port
  • run-tests.py: update for renesas-ra port
  • renesas-ra: remove unsupported feature test of Pin
  • extmod: increase timing on uasyncio tests to make more reliable
  • fix tests to use sys.implementation._mpy
  • perf_bench: update .mpy file header to remove old unicode flag
  • run-perfbench.py: return error code if any test fails on target
  • thread: use less resources for stress_aes if settrace enabled
  • run-tests.py: exclude settrace tests when using native emitter
  • multi_net: skip SSL test if relevant modules aren't available
  • micropython: fully unlink nested list in extreme exc test
  • extmod: use bytearray instead of bytes for uctypes test
  • micropython: add more test cases for native generators
  • run-tests.py: allow running tests via mpy-cross on remote targets
  • run-perfbench.py: allow running tests via mpy and native emitter
  • basics: unlock heap if skipping nanbox small-int test
  • run-tests.py: handle case where mpy-cross fails to compile script
  • run-tests.py: enable -X realtime option for macOS tests
  • extmod: change expected errno code from 36 to 30 in VfsLfs2 test
  • multi_net: fix TCP accept test when using system error numbers
  • run-multitests.py: use LAN for IP address if WLAN doesn't exist
  • micropython: make import_mpy_native_gc run on ARMv6-M and above
  • micropython: make import_mpy_native test run on all architectures
  • run-tests.py: add rp2 test target
  • move native while test from pybnative to micropython
  • net_inet: remove broken api.telegram.org from tests
  • run-multitests.py: read IP address from boot nic if available
  • basics: add .exp file for sys.tracebacklimit test
  • stress: adjust bytecode_limit test so it can SKIP if no memory

tools:

  • mpremote: use machine instead of umachine in commands
  • ci: test math constants with MICROPY_OBJ_REPR_D
  • uf2conv.py: update to latest version
  • autobuild: provide .uf2 images for esp32 builds when available
  • mpremote: fix "fs cp -r" on Windows
  • mpremote: make ConsolePosix work without .raw attribute
  • mpremote: during soft reboot wait long enough for 115200 data
  • mpremote: accept both --help and help to show usage
  • mpremote: correctly manage mounted flag during soft-reset
  • mpremote: fix special handling of ctrl-D when host FS is mounted
  • verifygitlog.py: ignore line length in body if it's a URL
  • ci.sh: update IDF v4.4 build to use v4.4 tag
  • ci.sh: run urandom test scripts as part of native module tests
  • mpremote: add "resume" and "soft-reset" commands
  • mpremote: add "umount" command
  • upip.py: remove unused op_basename() function
  • mpy-tool.py: fix frozen comment generation to escape chars
  • ci.sh: run performance benchmark as part of all unix test runs
  • mpremote: bump version to 0.2.0
  • gen-cpydiff: skip Black fmt comments
  • mpremote: support any prompt string when detecting soft reset
  • mpremote: allow running mpremote with python -m
  • mpremote: improve reliability of mount after soft reboot
  • mpremote: show progress indicator when copying large files
  • mpremote: add option to mount cmd to allow "unsafe" symlinks
  • mpy-tool.py: support loading tuples from .mpy files
  • mpy-tool.py: support freezing tuples and other consts
  • mpy-tool.py: optimise freezing of ints that can fit a small int
  • mpy-tool.py: optimise freezing of empty str and bytes objects
  • mpy-tool.py: make global qstr list a dedicated class
  • mpy-tool.py: optimise freezing of str when str data is a qstr
  • mpy-tool.py: intern more strings when freezing
  • codeformat.py: remove ports/unix/*.py from exclusion list
  • codeformat.py: include more ports .c/.h files in formatting
  • ci.sh: don't run uasyncio_gather test on macOS
  • ci.sh: update for ports/renesas-ra
  • uncrustify: make sure a space exists after a comma
  • autobuild: update for ports/renesas-ra
  • mpy_ld.py: remove obsolete QSTR_WINDOW_SIZE constant
  • ci.sh: run full test suite on stackless and settrace builds
  • ci.sh: for esp8266 CI install esptool 3.3.1
  • mpy-tool.py: remove obsolete unicode flag in .mpy header
  • ci.sh: add build of W5100S_EVB_PICO board to rp2 CI
  • mpy-tool.py: rework .mpy merging feature
  • ci.sh: add test for mpy-tool's merging feature
  • mpy-tool.py: improve generated frozen identifiers
  • mpremote: add command to print the version
  • mpremote: bump version to 0.3.0
  • ci.sh: build NUCLEO_H743ZI with -O2 optimisation level
  • mpy_ld.py: support R_XTENSA_PDIFF32 relocation
  • ci.sh: build native .mpy examples for armv7emsp, xtensawin in CI
  • mpy_ld.py: support GOT entries that reference inside mp_fun_table

CI:

  • workflows: show context for qemu-arm test failures
  • workflows: add new workflow to test .mpy file format and tools
  • workflows: add new workflow to test embedding example
  • workflows: add workflow for renesas-ra port

The ports

all ports:

  • consolidate inclusion of umachine module in built-ins
  • recompile bytecode tests now that .mpy format changed
  • allow boards to define additional network interfaces
  • recompile bytecode tests now that .mpy format changed
  • reformat more C and Python source code
  • rename thread_t to mp_thread_t
  • use default VFS config for import_stat and builtin_open

bare-arm port: no changes specific to this component/port

cc3200 port:

  • make port-specific modules use MP_REGISTER_MODULE

esp8266 port:

  • moduos: convert module to use extmod version
  • mpconfigport.h: remove config values that are the defaults
  • modesp: remove esp.info() function
  • make port-specific modules use MP_REGISTER_MODULE
  • machine_wdt: remove deinit method for watchdog
  • etshal.h: remove unneeded function declaration

esp32 port:

  • machine_adcblock: add new machine.ADCBlock class and update ADC
  • pin MicroPython to core 1 again
  • esp32_rmt: call rmt_driver_install directly if running on core 1
  • main: allocate at most 1/2 of available IDF heap for MP heap
  • README.md: fix URL for esp-idf installation
  • modnetwork: fix test for WIFI_AUTH_MAX for IDF v4.3.0
  • main: use heap_caps_get_info on IDF <4.1 to compute total heap
  • boards: provide custom deploy_c3.md for ESP32-C3 boards
  • partitions: increase size of app-part from 0x180000 to 0x1F0000
  • machine_pwm: fix PWM not allowing frequencies < 611 Hz
  • machine_pwm: clean up macro names and their use
  • esp32_rmt: select correct last RMT channel on S2, S3, C3 variants
  • main: automatically size SPIRAM heap when allocated using malloc
  • adc: fix wrong mapping between ADC2 channel and GPIO number
  • remove unneeded modesp.h
  • create .uf2 binaries for S2 and S3 chips
  • partitions-16MiB.csv: increase 14MiB filesystem to maximum size
  • machine_adcblock: fix ADC bit width for ESP32-S3
  • machine_adc: fix configuration of default ADC atten value
  • boards: add three UM ESP32-S3 based boards
  • mpconfigport.h: use the "extra" feature level
  • mpconfigport.h: enable remaining features to get to "extra" level
  • esp32_partition: add support for specifying block_size
  • modules: create ffat partition object with block_size=512
  • README.md: update list of supported IDF versions
  • boards: add specific deploy instructions for S3 variant
  • uart: correctly init low-level UART driver for REPL
  • machine_uart: allow limited configuration of REPL UART
  • sleep one tick in MICROPY_EVENT_POLL_HOOK
  • machine_pwm: always set the duty cycle when setting the frequency
  • machine_uart: make UART.init preserve unspecified parameters
  • machine_pin: add support for pin drive strength
  • moduos: convert module to use extmod version
  • machine_pin: add new hold keyword argument and remove PULL_HOLD
  • modesp32: add new gpio_deep_sleep_hold function
  • boards/UM_TINYPICO: remove use of PULL_HOLD
  • boards: add LOLIN C3 MINI ESP32-C3 based board
  • machine_hw_spi: use automatic DMA channel selection for SPI on C3
  • boards: add support for LilyGO LoRa32 boards
  • machine_pin: expose pin 20 for ESP32
  • allow overriding cmake frozen manifest from the command line
  • boards: add test manifest to test freezing during build
  • add MICROPY_HW_ENABLE_UART_REPL and enable on generic S2/S3
  • boards: compile GENERIC_SPIRAM and UM_TINYPICO with -Os
  • machine_pin: don't expose pins 33-37 when octal SPIRAM is enabled
  • modesp32: properly define RTC_VALID_EXT_PINS on S2/S3 variants
  • network_wlan: support setting/getting txpower in WLAN.config()
  • modnetwork: fix build when MICROPY_PY_NETWORK_WLAN is disabled
  • make port-specific modules use MP_REGISTER_MODULE
  • boards/UM_FEATHERS3: use correct sdkconfig.board
  • boards/LILYGO_TTGO_LORA32: remove ID from TTGO Lora32 board json
  • machine_pin: fix ESP32C3 IDFv4.4.1 build
  • track allocated iRAM and free it on soft reset
  • machine_i2c: implement write-then-read I2C transfers
  • machine_pin: only expose IO20 on esp32 for IDF 4.3.2 and above

javascript port:

  • make port-specific modules use MP_REGISTER_MODULE

mimxrt port:

  • support gaps in the SPI an I2C device numbers
  • allow for board-specific flash driver files
  • compensate for a bug in the fsl_lpspi.c file
  • remove two files from the Seeed Arch Mix directory
  • replace Pin-config constants by a function call
  • allow to select cs0 or cs1 for SPI
  • add USB ID elements
  • add support for the Olimex RT1010 board
  • simplify Makefile in selection of flash type
  • machine_pin: change pin drive constants to DRIVE_x naming
  • machine_spi: add omitted GPIO config
  • boards: add board files for MIMXRT1015 and MIMXRT1015_EVK
  • eth: fix an Ethernet transmit error
  • boards/TEENSY41: use the same SPI1 pins for Teensy 4.0 and 4.1
  • boards: support using an optional board-specific manifest.py
  • eth: avoid a race condition for Ethernet
  • hal/pwm_backport: make PWM symmetric, and round division calcs
  • moduos: convert module to use extmod version
  • mbedtls: add NULL pointer check in m_free_mbedtls
  • machine_i2s: add I2S protocol support
  • boards: add board.json file for OLIMEX RT1010Py
  • modules: append /flash/lib to the default sys.path
  • machine_rtc: start RTC at boot and set datetime if not set
  • machine_spi: improve handling of busy SPI peripheral
  • mphalport: fix USB CDC RX handling to not block when unprocessed
  • mbedtls: use core-provided tracked alloc instead of custom funcs
  • make port-specific modules use MP_REGISTER_MODULE
  • boards/OLIMEX_RT1010: document the initial deploy procedure
  • boards: extend the deploy_teensy.md instructions
  • mphalport: fix strict aliasing error with unique id
  • update port to work with new nxp_driver v2.10
  • machine_uart: fix an inconsistency for UART.init() arg handling

minimal port: no changes specific to this component/port

nrf port:

  • drivers/usb: fix background events/scheduling while at USB REPL
  • drivers/usb: fix MP_STREAM_POLL_RD support on USB CDC
  • modules: include uasyncio in default board manifest
  • make port-specific modules use MP_REGISTER_MODULE
  • mpconfigport: set MICROPY_CONFIG_ROM_LEVEL defines for each MCU
  • mpconfigport: enable extra features as defined by ROM levels
  • mpconfigport: fix MICROPY_VFS IO build support
  • modules/uos/microbitfs: fix MICROPY_MBFS build to use mp_obj_malloc

pic16bit port:

  • make port-specific modules use MP_REGISTER_MODULE
  • use 1 byte for qstr hash len and include header to fix build

powerpc port: no changes specific to this component/port

qemu-arm port:

  • add tests for freezing viper and asm_thumb code
  • moduos: convert module to use extmod version
  • test-frzmpy: add test for freezing constant tuples
  • mpconfigport: define MICROPY_PY_SYS_PLATFORM

renesas-ra port:

  • add new port to Renesas RA
  • boards: change device name information to show properly
  • rename pyb_uart_ to machine_uart_
  • rename pyb_rtc_ to machine_rtc_
  • make port-specific modules use MP_REGISTER_MODULE
  • modmachine: add missing MP_REGISTER_MODULE for umachine
  • machine_pin: remove code for unsupported Pin features

rp2 port:

  • machine_i2c: provide more specific error codes from I2C transfer
  • mpconfigport.h: use internal error numbers
  • mphalport: add optional dupterm support
  • machine_uart: add machine.UART init/deinit methods
  • machine_i2c: use soft I2C only for len=0, and increase timeout
  • modutime: fix time.localtime day-of-week value
  • machine_uart: fix UART RTS behaviour so RTS is deasserted
  • Makefile: add FROZEN_MANIFEST Makefile option, to override default
  • mpthreadport: fix memory corruption when thread is created in core1
  • add USB MSC support
  • allow Overriding cmake frozen manifest from the command line
  • enable ucryptolib, using mbedtls for backend functions
  • mphalport: fix USB CDC RX handling to not block when unprocessed
  • Makefile: add mbedtls to GIT_SUBMODULES list and use it in CI func
  • machine_uart: use read/write mutex to prevent char duplication
  • mpconfigport: enable execfile, NotImplemented and REPL EMACS keys
  • make port-specific modules use MP_REGISTER_MODULE
  • mpconfigport.h: enable static scheduler nodes
  • mpconfigport.h: allow boards to override internal errno config
  • boards/ARDUINO_NANO_RP2040_CONNECT: disable internal errno
  • boards/ARDUINO_NANO_RP2040_CONNECT: enable webrepl
  • mbedtls: add support for ssl module with MICROPY_SSL_MBEDTLS
  • machine_pin: add mp_hal_pin_interrupt C interface
  • Makefile: use cmake for "make submodules" task when needed
  • integrate lwIP network stack
  • add support for using Wiznet hardware as an Ethernet NIC
  • boards/W5100S_EVB_PICO: add Wiznet W5100S-EVB-Pico board
  • Makefile: build in debug mode with "make DEBUG=1"
  • boards/ARDUINO_NANO_RP2040_CONNECT: update USB PID
  • mpnetworkport: fix lwip alarm callback timing to use microseconds
  • CMakeLists: simplify qstr sources when enabling extmod components

samd port:

  • moduos: convert module to use extmod version
  • make port-specific modules use MP_REGISTER_MODULE

stm32 port:

  • mbedtls: enable MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE
  • mboot: remove custom HAL_RCC_GetHCLKFreq and use HAL provided one
  • pin: change remaining uses of "af" to "alt"
  • dac: deinit all DACs on soft reset
  • fdcan: fix FIFO1 usage and handling of error interrupts
  • fdcan: fix naming with regards to G4 series
  • usbd_conf: set lpm_enable and battery_charging_enable on all MCUs
  • powerctrlboot: set HAL uwTickPrio variable when needed
  • powerctrl: write bootloader-state as 64-bit word to work on H7
  • mboot: use PLL3 for USB clock source on H7 MCUs
  • mboot: include hal_rcc_ex.c in source file list
  • mboot: support H7 MCUs in fwupdate.py
  • mboot: compute and check CRC32 of dfu file in fwupdate.py
  • add support for G4 MCUs, and add NUCLEO_G474RE board defn
  • mboot: allow HSI to be used as the main clock source
  • mboot: add MBOOT_BOARD_ENTRY_INIT for a board to add entry code
  • mboot: add support for F469/479 MCUs in fwupdate.py
  • rtc: use LL_RTC functions to simplify some MCU-specific code
  • Makefile: make stm32lib configurable
  • add initial support for STM32WL MCUs
  • boards/NUCLEO_WL55: add new board definition
  • system_stm32: make SystemClock_Config() a weak symbol
  • adc: fix L4 ADC channel numbers
  • adc: remove obsolete FIRST/LAST GPIO channel macros
  • boards/NUCLEO_L432KC: disable MICROPY_OPT_COMPUTED_GOTO
  • boards/NUCLEO_WB55: add Arduino pin alias definitions
  • mboot: allow a board to fully configure system clocks
  • mboot: allow a board more control over entry initialisation
  • moduos: convert module to use extmod version
  • boards: convert F4xx and F7xx to new flash FS config
  • mbedtls: add NULL pointer check in m_free_mbedtls
  • sdcard: use mp_hal_pin_input instead of HAL function
  • sdcard: add sdcard_select_sd/mmc functions
  • main: support SD cards without a partition table
  • dma: add option to disable auto-DMA-turn-off
  • mboot: add pragma for GCC to ignore array bounds warning
  • mboot: always check the magic number to enter filesystem loading
  • mboot: add support for 64-bit mboot address space for reads
  • mboot: add support for reading from SD card
  • boards/PYBD_SF2: turn on SD card in mboot init if SD enabled
  • mboot/fwupdate.py: simplify calculation of CRC32
  • mboot: verify signature of fsload packed DFU files before writing
  • mboot: verify CRC32 of fsload DFU files before writing
  • support building for STM32F745
  • machine_i2s: set FullDuplexMode to disabled on F4
  • machine_i2s: allow I2S.deinit to be called multiple times
  • machine_i2s: fix 16-bit stereo i2s_frame_map
  • sdio: use runtime calculation for clock divider of sdio on H7
  • modmachine: add deepsleep support to reset_cause() for WB55
  • pyb_can: enable CAN FD frame support and BRS
  • pyb_can: add support for CAN FD extended frame ID
  • pyb_can: add support for bus with mixed Classic/FD nodes
  • pyb_can: return the filter ID and type of received messages
  • pyb_can: define the maximum bit timing parameters
  • pyb_can: replace CAN.initfilterbanks with CAN.init keyword arg
  • Makefile: allow overriding COPT in Makefile
  • mpconfigport.h: let MICROPY_PY_IO_FILEIO take its default value
  • machine_bitstream: include all clobbered regs in Cortex-M0 impl
  • mboot: consolidate all UI and add general state change hooks
  • mboot: add macros for use in led_state_all()
  • sdram: add function to enable SDRAM power-down mode
  • Makefile: add H747 to Makefile's MCU flags
  • system_stm32: add H7 switched-mode-power-supply support
  • system_stm32: set voltage scaling level 0 for H7 Rev-V devices
  • system_stm32: allow boards to configure PLL VCI, VCO and FRACN
  • system_stm32: improve H7 PLL and OSC configuration
  • boards/PYBD_SFx: allow FROZEN_MANIFEST to be overridden
  • mpbthciport: switch scheduling callback to use node scheduler
  • boards/SPARKFUN_MICROMOD_STM32: fix incorrect UART and I2C config
  • mphalport: fix I/O glitches when switching GPIO mode to alt-func
  • boards/ADAFRUIT_F405_EXPRESS: use external SPI flash for storage
  • boards/LEGO_HUB_NO6: exclude BTstack code from formatting
  • qspi: support common flash sizes in MPU configuration
  • qspi: wait for a free FIFO location before writing to DR
  • qspi: workaround for SR set immediately after setting AR
  • ulpi: add USB3320 ULPI low-power functions
  • ulpi: include missing py/mperrno.h header
  • boards/ARDUINO_PORTENTA_H7: add support for Arduino Portenta H7
  • storage: add support for internal storage on Cortex-M0 MCUs
  • add support for G0 MCUs
  • boards/NUCLEO_G0B1RE: add NUCLEO_G0B1RE board definition
  • mbedtls: use core-provided tracked alloc instead of custom funcs
  • make port-specific modules use MP_REGISTER_MODULE
  • rfcore: revert "intercept addr-resolution HCI cmd to work arou..."
  • mboot: move remaining led_state_all call into mboot_state_change
  • mboot: add update_app_elements to return mboot fsload elements
  • mboot: make 0x70ad0000 values named constants with macros
  • mboot: pass initial_r0 to early-init and get-reset-mode funcs
  • boards/LEGO_HUB_NO6: make all SPI flash transfers use 32-bit addr
  • boards/LEGO_HUB_NO6: add support for mboot to access SPI flash
  • boards/LEGO_HUB_NO6: use multi-colour LED for mboot status
  • boards/LEGO_HUB_NO6: implement robust filesystem-load updates
  • boards/LEGO_HUB_NO6: add helper scripts to update app firmware
  • rfcore: remove extra layer of buffering on BLE IPCC
  • flash: remove FLASH_OPTR_DBANK condition in L4, H7 get_bank func
  • machine_i2c: enable timingr constructor keyword on H7 MCUs
  • powerctrl: disable sys tick interrupt in stop mode on some STM32s
  • usbd_conf: remove disable of SYSCFG clock
  • mboot: add board-configurable SysTick hook
  • mboot: remove MP_WEAK on led funcs and make some of them static
  • boards/LEGO_HUB_NO6: add comment to readme about powering off
  • mboot: only include UI code if at least one board LED is defined

teensy port:

  • make port-specific modules use MP_REGISTER_MODULE
  • mpconfigport.h: remove obsolete macros

unix port:

  • Makefile: remove explicit addition of -std=c++ flag
  • show compiler info in REPL banner
  • .gitignore: remove *.py from ignore list
  • moduos: convert module to use extmod version
  • mpconfigport.h: collect together config options from extra level
  • variants: use rom feature config for standard, dev, coverage
  • variants: enable a few optimisations and features on dev, coverage
  • make port-specific modules use MP_REGISTER_MODULE
  • implement -X realtime command-line option on macOS
  • factor out code that generates random bytes to a new func
  • variants: enable seeding random module on import in dev, coverage

windows port:

  • README.md: fix broken mingw link
  • add micropython.schedule support
  • mingw: include extmod/shared/lib sources properly
  • uselect: enable micropython select in dev variant
  • uasyncio: add support for uasyncio to windows dev variant
  • appveyor: fix printing of test failures
  • Makefile: specify CXXFLAGS in the Makefile
  • unify project file headers
  • switch to VFS subsystem and use VfsPosix
  • consolidate all sleep-related functions into windows_mphal.c
  • avoid busy loop when using scheduler
  • use BCryptGenRandom to implement os.urandom
  • factor out code that generates random bytes to a new func

zephyr port:

  • update include path to disk_access.h
  • upgrade to Zephyr v3.0.0
  • prj.conf: enable CONFIG_BUILD_OUTPUT_HEX to generate .hex output
  • moduos: convert module to use extmod version
  • make port-specific modules use MP_REGISTER_MODULE
  • modusocket: fix function object wrapper for listen method

v1.18

2 years ago

This release of MicroPython sees a boost to the overall performance of the VM and runtime. This is achieved by the addition of an optional cache to speed up general hash table lookups, as well as a fast path in the VM for the LOAD_ATTR opcode on instance types. The new configuration options are MICROPY_OPT_MAP_LOOKUP_CACHE and MICROPY_OPT_LOAD_ATTR_FAST_PATH. As part of this improvement the MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE option has been removed, which provided a similar map caching mechanism but with the cache stored in the bytecode, which made it not useful on bare metal ports. The new mechanism is measured to be at least as good as the old one, applies to more map lookups, has a constant RAM overhead, and applies to native code as well as bytecode.

These performance options are enabled on the esp32, mimxrt, rp2, stm32 and unix ports. For esp32 and mimxrt some code is also moved to RAM to further boost performance. On stm32, performance increases by about 20% for benchmarks that are heavy on name lookups, like misc_pystone.py and misc_raytrace.py. On esp32 performance can increase by 2-3x, and on mimxrt it is up to 6x.

All boards in all ports now have a board.json metadata file, which is used to automatically build firmware and generate a webpage for that board (among other possibilities). Auto-build scripts have been added for this purpose and they build all esp32, mimxrt, rp2, samd and stm32 boards. The generated output is available at https://micropython.org/download.

Support for FROZEN_DIR and FROZEN_MPY_DIR has been deprecated for some time and was finally removed in this release. Instead of these, FROZEN_MANIFEST can be used. The io.resource_stream() function is also removed, replaced by the pure Python version in micropython-lib.

The search order for importing frozen Python modules is now controlled by the ".frozen" entry in sys.path. This string is added by default in the second position in sys.path. User code should adjust sys.path depending on the desired behaviour. Putting ".frozen" first in sys.path will speed up importing frozen modules.

A bug in multiple precision integers with bitwise of -0 was fixed in commit 2c139bbf4e5724ab253b5b034ce925e04267a9c4.

The platform module has been added to allow querying the compiler and underlying SDK/HAL/libc version. This is enabled on esp32, mimxrt and stm32 ports.

The mpremote tool now supports seek, flush, mkdir and rmdir on PC-mounted filesystems. And a help command has been added.

The documentation has seen many additions and improvements thanks (for a second time) to the Google Season of Docs project. The rp2 documentation now includes a reference for PIO assembly instructions, a PIO quick reference and a PIO tutorial. The random and stm modules have been documented, along with sys.settrace, manifest.py files and mpremote. There is also now more detail about the differences between MicroPython and standard Python 3.5 and above.

The esp32 port sees support for ESP32-S3 SoCs, and new boards GENERIC_S3, ESP32_S2_WROVER, LOLIN_S2_MINI, LOLIN_S2_PICO and UM_FEATHERS2NEO. The PWM driver has been improved and now supports all PWM timers and channels, and the duty_u16() and duty_ns() methods, and it keeps the duty constant when changing frequency. The machine.bitstream() function has been improved to use RMT, with an option to select the original bit-banging implementation.

The mimxrt port gained new hardware features: SDRAM and SD card support, as well as network integration with a LAN driver. The machine.WDT class was added along with the machine.reset_cause(), machine.soft_reset(), machine.unique_id() add machine.bitstream() functions. DHT sensor support was added, and f-strings were enabled.

The rp2 port now has support for networking, and bluetooth using NimBLE. The Nina-W10 WiFi/BT driver is fully integrated and supported by the new Arduino Nano RP2040 connect board. I2S protocol support is added along with a machine.bitstream() driver and DHT sensor support. The PWM driver had a bug fix with the accuracy of setting/getting the frequency, and the duty value is now retained when changing the frequency.

On the samd port there is now support for the internal flash being a block device, and for filesystems and the os module. Pin and LED classes have been implemented. There are more time functions, more Python features enabled, and the help() function is added. SEEED_WIO_TERMINAL and SEEED_XIAO board definitions are now available.

The stm32 port now has support for F427, F479 and H7A3(Q)/H7B3(Q) MCUs, and new board definitions for VCC_GND_H743VI, OLIMEX_H407, MIKROE_QUAIL, GARATRONIC_PYBSTICK26_F411, STM32H73B3I_DK. A bug was fixed in the SPI driver where a SPI transfer could fail if the CYW43 WiFi driver was also active at the same time.

On the windows port the help() function has been enabled, and support for build variants added, to match the unix port.

The zephyr port upgraded Zephyr to v2.7.0.

The change in code size since the previous release for various ports is (absolute and percentage change in the text section):

   bare-arm:  -1520  -2.605%
minimal x86:  -2256  -1.531%
   unix x64:   -457  -0.089%
unix nanbox:   -925  -0.204%
      stm32:   +312  +0.079% PYBV10
     cc3200:   -176  -0.096%
    esp8266:   +532  +0.076% GENERIC
      esp32: +27096  +1.820% GENERIC
        nrf:   -212  -0.121% pca10040
        rp2:  +9904  +2.051% PICO
       samd: +35332 +33.969% ADAFRUIT_ITSYBITSY_M4_EXPRESS

The changes that dominate these numbers are:

  • bare-arm, minimal: use of new MICROPY_CONFIG_ROM_LEVEL_MINIMUM option and subsequent disabling of remaining optional features
  • unix, cc3200, nrf: general code size reductions of the core
  • stm32: performance improvements, addition of platform module
  • esp8266: enabling f-strings
  • esp32: use of -O2 instead of -Os
  • rp2: machine.I2S and other new hardware features
  • samd: filesystem support and other new hardware features

Thanks to everyone who contributed to this release: Alan Dragomirecký, Alexey Shvetsov, Andrew Leech, Andrew Scheller, Antoine Aubert, Boris Vinogradov, Chris Boudacoff, Chris Fiege, Christian Decker, Damien George, Daniel Gorny, Dave Hylands, David Michieli, Emilie Feral, Frédéric Pierson, gibbonsc, Henk Vergonet, iabdalkader, Ihor Nehrutsa, Jan Hrudka, Jan Staal, jc_.kim, Jim Mussared, Jonathan Hogg, Laurens Valk, leo chung, Lorenzo Cappelletti, Magnus von Wachenfeldt, Matt Trentini, Matt van de Werken, Maureen Helm, Michael Bentley, Michael Buesch, Mike Causer, Mike Teachman, Mike Wadsten, Ned Konz, NitiKaur, oli, patrick, Patrick Van Oosterwijck, Peter Boin, Peter Hinch, Peter van der Burg, Philipp Ebensberger, Pooya Moradi, retsyo, robert-hh, roland van straten, Scott Armitage, Sebastian Wicki, Seon Rozenblum, Sergei Silnov, Simon Baatz, Stewart Bonnick, stijn, Tobias Thyrrestrup, Tomas Vanek, YoungJoon Chun.

What follows is a detailed list of changes, generated from the git commit history, and organised into sections.

Main components

all:

  • remove MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE
  • update Python formatting to latest Black version 21.12b0
  • remove support for FROZEN_DIR and FROZEN_MPY_DIR

py core:

  • parse: simplify parse nodes representing a list
  • emitnative: ensure load_subscr does not clobber existing REG_RET
  • mpconfig.h: define initial templates for "feature levels"
  • vm: add a fast path for LOAD_ATTR on instance types
  • map: add an optional cache of (map+index) to speed up map lookups
  • builtinimport: forward all debug printing to MICROPY_DEBUG_PRINTER
  • add wrapper macros so hot VM functions can go in fast code location
  • runtime: fix crash when exc new doesn't return an exc instance
  • mpconfig.h: define the "extra" feature level
  • mpconfig.h: revert MICROPY_REPL_INFO to disabled at all levels
  • gc: add hook to run code during time consuming GC operations
  • showbc: print unary-op string when dumping bytecode
  • modsys: replace non-ASCII quote char with ASCII char
  • runtime: allow types to use both .attr and .locals_dict
  • lexer: support nested [] and {} characters within f-string params
  • objfun.h: remove obsolete comments about entries in extra_args
  • builtinimport: refactor module importing
  • showbc: fix printing of raw bytecode header on nanbox builds
  • modio: remove io.resource_stream function
  • only search frozen modules when '.frozen' is found in sys.path
  • mkrules.cmake: set frozen preprocessor defs early
  • runtime: allow initialising sys.path/argv with defaults
  • mpstate.h: only include sys.path/argv objects in state when enabled
  • mpz: fix bugs with bitwise of -0 by ensuring all 0's are positive
  • qstr: reset mpstate.qstr_last_chunk before raising an error
  • modbuiltins: add additional macro for extending builtins
  • mpconfig.h: define MICROPY_PY_USSL_FINALISER only if not defined

extmod:

  • machine_i2c: make SoftI2C configurable via macro option
  • machine_spi: make SoftSPI configurable via macro option
  • modonewire: make _onewire module configurable via macro option
  • machine_pwm: factor out machine.PWM bindings to common code
  • move modnetwork and modusocket from stm32 to extmod
  • modnetwork: add STA_IF and AP_IF constants
  • modnetwork: add extended socket state
  • modusocket: add read/write stream methods to socket object
  • modnetwork: define network interfaces in port config files
  • network_cyw43: make consistent use of STA and AP constants
  • modnetwork: remove STM32 references
  • modnetwork: remove modnetwork socket u_state member
  • mpbthci.h: add mp_bluetooth_hci_uart_any prototype
  • nimble: add nimble CMake fragment file
  • add platform module
  • moduplatform: improve implementation for PC ports
  • vfs_posix_file: support MP_STREAM_POLL in vfs_posix_file_ioctl
  • modbluetooth: add connection interval to gap_connect
  • nimble: update to NimBLE v1.4
  • nimble: remove workaround for OS_ENOMEM
  • uasyncio: fix gather returning exceptions from a cancelled task
  • uplatform: remove unused definitions
  • uplatform: use generic custom platform string
  • network_ninaw10: fix scan list order to match other NICs
  • modbluetooth: support gap_connect(None) to cancel a connection
  • modure: redirect regex debug printing to mp_printf
  • network_ninaw10: fix config of AP mode
  • network_ninaw10: disable active connections before connecting
  • network_ninaw10: make NIC state persistent
  • network_ninaw10: return -1 on timeout from recv/send
  • network_ninaw10: make recv/recvfrom interchangeable
  • moduplatform: detect xtensa arch
  • modusocket: allow setting timeout on unbound sockets
  • modusocket: initialise accepted socket state
  • network_ninaw10: use socket timeout preset in modusocket
  • modbluetooth: fix conditional compilation of ringbuf_put_uuid
  • modbluetooth: put declaration of connect_cancel in correct place

shared:

  • libc/string0: don't include string.h, and provide __memcpy_chk
  • runtime/pyexec: cleanup EXEC_FLAG flag constants

drivers:

  • ninaw10: add ublox Nina-W10 WiFi/BT module driver
  • lsm6dsox: add LSM6DSOX driver and examples
  • neopixel: avoid heap alloc in fill()
  • ninaw10: fix BSSID byte order, and add null byte to ESSID
  • ninaw10/nina_wifi_drv: fix DNS resolution

mpy-cross: no changes specific to this component/port

lib:

  • mynewt-nimble: switch to the MicroPython fork of NimBLE
  • asf4: point submodule to latest commit on circuitpython branch
  • update pico-sdk to 1.3.0 and tinyusb to 0.12.0
  • stm32lib: update library for L4 v1.17.0, new G4, WL, and MMC fixes
  • stm32lib: update library for fix to F7 USB HS

Support components

docs:

  • library/os.rst: clarify littlefs requirements for block erase
  • library/bluetooth.rst: update incorrect link to gatts_write
  • make.bat: change Windows output dir from '_build' to 'build'
  • library/machine.I2S.rst: specify that I2S.shift args are kw-only
  • esp32: explain ESP32 PWM modes, timers, and channels
  • rp2: add reference for PIO assembly instructions, and PIO tutorial
  • library/random.rst: document the random module
  • reference/mpremote.rst: add docs for mpremote
  • reference/manifest.rst: add docs for manifest.py files
  • library/stm.rst: document the stm module
  • esp32/tutorial: add an example of peripheral control via regs
  • rp2/general.rst: fix typo with missing spaces
  • library/framebuf.rst: adjust dimensions in example
  • library/rp2.rst: update function asm_pio_encode to add sideset_opt
  • reference/filesystem.rst: add detail on how to use littlefs fuse
  • rp2/quickref.rst: add section on PIO
  • library/sys.rst: add docs for sys.settrace
  • esp8266/tutorial: fix comments of FrameBuffer examples
  • library/uasyncio.rst: detail exception behaviour in cancel/timeout
  • library/machine.Timer.rst: document 'id' as positional-only arg
  • library/machine.SPI.rst: add example SPI usage
  • library/machine.Timer.rst: document period and callback args
  • library/machine.Pin.rst: add Pin.ANALOG mode constant
  • remove trailing spaces and convert tabs to spaces
  • library/sys.rst: add note about '.frozen' as an entry in sys.path
  • differences: document details of new PEPs/features in Python 3.5+
  • update copyright year range to include 2022
  • esp32: update RMT quickref example to match latest code

examples: no changes specific to this component/port

tests:

  • perf_bench: use math.log instead of math.log2
  • basics: add tests for type-checking subclassed exc instances
  • micropython/const.py: add comment about required config for test
  • cpydiff: clarify f-string diffs regarding concatenation
  • basics/int_big_cmp.py: add more tests for big-int comparison
  • extmod: skip uselect_poll_udp when poll() is not available

tools:

  • autobuild: add auto build for GENERIC_C3_USB
  • ci.sh: use IDF v4.4 as part of esp32 CI and build GENERIC_S3
  • autobuild: add the MIMXRT1010_EVK board to autobuild
  • ci.sh: use a specific ESP IDF v4.4 commit
  • autobuild: add script to generate website board metadata
  • dfu.py: make tool work with python3 when parsing DFU files
  • autobuild: automatically build all mimxrt, rp2 and samd boards
  • autobuild: automatically build all stm32 boards
  • mpremote: implement seek and flush in ioctl method
  • autobuild: automatically build all esp32 boards
  • upip.py: support == to specify exact package version
  • makemanifest.py: make str conversion compatible with Python 2
  • makemanifest.py: merge make-frozen.py
  • mpremote: add mkdir and rmdir to RemoteFS
  • mpremote: add help command
  • mpremote: add link to mpremote docs URL in help message
  • upip.py: skip '.frozen' entry in sys.path for install path
  • autobuild: build esp8266 OTA image with GENERIC_1M board
  • ci.sh: upgrade Zephyr docker image to v0.21.0
  • ci.sh: build zephyr nucleo_wb55rg to test zephyr bluetooth build

CI:

  • workflows: use Python 3.8 for macos workflow
  • workflows: add new workflow to build ports download metadata

The ports

all ports:

  • add board.json for all boards
  • add images, features and urls to board.json
  • add '.frozen' as the first entry in sys.path
  • move '.frozen' to second entry in sys.path

bare-arm port:

  • mpconfigport.h: use MICROPY_CONFIG_ROM_LEVEL_MINIMUM
  • mpconfigport.h: disable remaining optional features

cc3200 port: no changes specific to this component/port

esp8266 port:

  • boards/GENERIC: enable f-strings
  • extract qstr from object when comparing keys in config()
  • etshal.h: remove unneeded function declarations
  • allow building a board to any dest directory

esp32 port:

  • boards: add new FeatherS2-Neo board definition
  • machine_timer: use tx_update member for IDF 4.4 and above
  • add support for ESP32-S3 SoCs
  • boards: add new GENERIC_S3 board definition
  • machine_hw_spi: fix hardware SPI DMA channels for S2/S3
  • boards: add board definition for ESP32-S2-WROVER module
  • boards: add LOLIN_S2_MINI ESP32-S2 board
  • machine_pwm: add support for all PWM timers and channels
  • README: updated readme with req IDF vers for ESP32-S2, C3 and S3
  • usb: add USB host connection detection for CDC serial output
  • machine_pin: block out IO16 and IO17 when using SPIRAM on ESP32
  • mpthreadport: fix TCB cleanup function so thread_mutex is ready
  • main: add option for a board to hook code into startup sequence
  • split out WLAN code from modnetwork.c to network_wlan.c
  • enable optimisations and move code to iRAM to boost performance
  • usb: improve speed of USB CDC output
  • add specific deploy_s2.md instructions for esp32-s2
  • boards/LOLIN_S2_MINI: add image to board.json
  • boards: update board and deploy metadata for UM_xxx boards
  • usb: further improve speed of USB CDC output
  • boards/LOLIN_S2_PICO: add LOLIN_S2_PICO board definition files
  • boards/ESP32_S2_WROVER: link to specific deploy_s2 instructions
  • support building with latest IDF v5
  • in machine_i2s, send null samples in underflow situations
  • in machine_i2s, make object reference arrays root pointers
  • add SDCard support for S3, and a GENERIC_S3_SPIRAM board
  • boards/GENERIC_S3: enable BLE on ESP32 S3
  • machine_pwm: implement duty_u16() and duty_ns() PWM methods
  • extract qstr from object when comparing keys in config()
  • machine_pin: make GPIO 26 usable for S2,S3 if SPIRAM not config'd
  • machine_hw_spi: fix SPI default pins reordering on ESP32-S2/S3
  • machine_hw_spi: set proper default SPI(id=1) pins on S2,S3 and C3
  • machine_hw_spi: set proper default SPI(id=2) pins on S2 and S3
  • boards: remove SPI pin defaults from GENERIC S2/S3 boards
  • modnetwork: synchronize WiFi AUTH_xxx constants with IDF values
  • machine_pwm: keep duty constant when changing frequency
  • machine_bitstream: replace bit-bang code with RMT-based driver
  • machine_i2s: add support for ESP-IDF 4.4
  • machine_bitstream: fix signal duplication on output pins
  • esp32: enable platform module with IDF version
  • boards/GENERIC_D2WD: build with -Os optimisation
  • esp32_rmt: install RMT driver on core 1
  • machine_bitstream: reinstate bitstream bit-bang implementation

javascript port: no changes specific to this component/port

mimxrt port:

  • sdcard: implement SDCard driver
  • machine_bitstream: add bitstream function to machine module
  • rework flash configuration
  • sdram: add SDRAM support
  • eth: add LAN support and integrate the network module
  • modmachine: implement machine.WDT() and machine.reset_cause()
  • boards: fix the D14/D15 pin assignment of MIMXRT1050/60/64_EVK
  • hal: remove duplicate definitions from flexspi_hyper_flash.h
  • dma_channel: fix the DMA channel management
  • fix cycle counter for time.ticks_cpu() and machine.bitstream()
  • add dht_readinto() to the mimxrt module, and freeze dht.py
  • extend the help() message and README.md
  • mpconfigport.h: enable f-strings
  • modmachine: implement soft_reset() and unique_id() functions
  • boards/make-pins.py: allow empty lines and comments in pins.csv
  • optimize the runtime speed
  • enable the platform module
  • boards: add the Seeed ARCH MIX board
  • boards: update the board.json files and add deploy_xx.md files
  • fix mp_hal_quiet_timing_enter()/exit() so timer still runs
  • support PWM using the FLEXPWM and QTMR modules
  • define UART 0 on MIMXRT boards
  • support selection of PHY type and address
  • re-enable eth checksum creation by HW
  • fix a tiny unnoticed bug in sdcard.c
  • add a driver for the DP83848 PHY device
  • refactor the reading of the machine id
  • enable ticks_cpu at boot time for NDEBUG builds only
  • use -Og instead of -O0 for DEBUG builds
  • tidy up the board flash related files
  • hal: allow readSampleClkSrc to be configured by a board
  • enable MICROPY_PY_USSL_FINALISER

minimal port:

  • mpconfigport.h: use MICROPY_CONFIG_ROM_LEVEL_MINIMUM
  • Makefile: don't force a 32-bit build
  • mpconfigport.h: disable features that are not needed

nrf port:

  • Makefile: improve Black Magic Probe commands
  • main: use VFS helper function to mount fs and chdir

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

rp2 port:

  • mpconfigport.h: enable heapq module
  • add support for bluetooth module using NimBLE
  • add framework for networking
  • mpconfigport.h: use the "extra" feature level
  • enable optimisations (comp goto, map cache, fast attr)
  • machine_i2s: add I2S protocol support
  • add support for Nina-W10 WiFi/BT module
  • boards: add support for Arduino Nano RP2040
  • machine_bitstream: implement the machine.bitstream driver
  • boards: add neopixel.py to manifest.py
  • rp2_pio: support exec with sideset
  • boards/PIMORONI_PICOLIPO_16MB: fix 16MB flash size
  • boards: add PYBSTICK26 RP2040 board definition
  • machine_uart: handle and clear UART RX timeout IRQ
  • boards/ARDUINO_NANO_RP2040_CONNECT: set default I2C pins
  • machine_pwm: fix PWM frequency setting
  • machine_pwm: keep duty value when changing the frequency
  • add support for DHT11 and DHT22 sensors
  • CMakeLists.txt: allow a board to override PICO_BOARD
  • boards/GARATRONIC_PYBSTICK26_RP2040: use correct pico-sdk board cfg

samd port:

  • integrate latest asf4, add help, more time funcs and uPy features
  • samd_soc: allow a board to configure the low-level MCU config
  • add internal flash block device, filesystem and uos support
  • add Pin and LED classes, and machine.unique_id
  • boards/ADAFRUIT_FEATHER_M0_EXPRESS: update for flash and pins
  • boards/ADAFRUIT_ITSYBITSY_M4_EXPRESS: update for flash and pins
  • boards/MINISAM_M4: update for flash and pins
  • boards/ADAFRUIT_TRINKET_M0: update for flash and pins
  • boards/SAMD21_XPLAINED_PRO: update for flash and pins
  • boards/SEEED_WIO_TERMINAL: add new board definition
  • boards/SEEED_XIAO: add new board definition
  • README.md: update README to reflect new features and boards

stm32 port:

  • pin: enable GPIO clock of pin if it's constructed without init
  • main: don't unconditionally enable GPIO A,B,C,D clocks
  • boards/VCC_GND_H743VI: add board definition for VCC_GND_H743VI
  • boards/OLIMEX_E407: add Ethernet RMII support
  • boards/LEGO_HUB_NO6: remove user paths from cc2564 init file
  • boards: remove trailing spaces, and add newline at end of file
  • add basic support for STM32H750
  • add support for H7A3(Q)/H7B3(Q), and STM32H73B3I_DK board defn
  • suggest putting code in main.py not boot.py
  • boards/make-pins.py: allow a CPU pin to be hidden
  • boards/make-pins.py: allow empty lines and comments in pins.csv
  • dma: add functions for external users of DMA to enable clock
  • enable LOAD_ATTR fast path, and map lookup caching on >M0
  • boards: add OLIMEX H407 board definition
  • enable platform module
  • extended flash filesystem space to 512K on H743 boards
  • boards/NUCLEO_H743ZI: enable VfsLfs2 on NUCLEO_H743ZI(2) boards
  • boards: add PF11-BOOT0 to stm32f091_af.csv
  • machine_i2c: use hardware I2C for STM32H7
  • sdram: enforce gcc opt, and use volatile and DSB in sdram_test
  • usbd_cdc_interface: allow a board to hook into USBD CDC RX events
  • mpbthciport: allow a board to hook BT HCI poll functions
  • pendsv: allow a board to add entries for pendsv_schedule_dispatch
  • boards: add images to board.json for Adafruit and VCC_GND boards
  • uart: fix race conditions and clearing status in IRQ handler
  • mpconfigport.h: use the "extra" feature level
  • in machine_i2s, send null samples in underflow situations
  • in machine_i2s, make object reference arrays root pointers
  • led: support an extra 2 LEDs in board configuration
  • boards/MIKROE_CLICKER2_STM32: add more detail to board.json
  • boards: add new board MikroElektronika Quail, and F427 support
  • main: run optional frozen module at boot
  • sdio: don't explicitly disable DMA2 on deinit of SDIO
  • dma: make DMA2_Stream3 exclusive to SDIO when CYW43 enabled
  • boards: build NUCLEO_WB55 and STM32F769DISC without mboot enabled
  • boards: add PYBSTICK26 F411 board definition
  • boards/NADHAT_PYBF405: rename board to GARATRONIC_NADHAT_F405
  • usb: use a table of allowed values to simplify usb_mode get/set
  • boards/NUCLEO_WB55: update rfcore_firmwre for new WS
  • flashbdev: support generic flash storage config via link symbols
  • boards: convert F413,F439,H743,L4xx,WB55 to new flash FS config
  • add support for F479 MCUs
  • include HAL MMC code in F4 builds
  • boards/make-pins.py: use cpu pins to define static alt-fun macros
  • boards/NUCLEO_WB55: fix LED ordering
  • boards/LEGO_HUB_NO6: set filesystem label as HUB_NO6
  • boards: remove stray '+' characters at start of lines in ld files
  • boards: remove unused MICROPY_HW_ENABLE_TIMER config
  • boards: enable MICROPY_HW_ENABLE_SERVO on various boards
  • update L4 code to build with latest stm32lib and L4 HAL 1.17.0
  • main: call sdcard_init when only MICROPY_HW_ENABLE_MMCARD enabled
  • sdcard: support 8-bit wide SDIO bus
  • sdcard: add config option to force MM card capacity
  • factoryreset: init vfs flags before calling pyb_flash_init_vfs
  • qspi: fix typo in address comment
  • boards/make-pins.py: generate empty ADC table if needed
  • boards/OLIMEX_H407: fix typo in OLIMEX H407 board.json
  • network_wiznet5k: fix build error with wiznet5k and lwip enabled
  • enable MICROPY_PY_USSL_FINALISER

teensy port:

  • switch to use manifest.py instead of FROZEN_DIR

unix port:

  • enable LOAD_ATTR fast path, and map lookup caching
  • modusocket: support MP_STREAM_POLL in unix socket_ioctl
  • modos: add support for uos.urandom(n)
  • coverage: change remaining printf to mp_printf
  • Makefile: use -Og instead of -O0 for debug builds

windows port:

  • README: remove unsupported Python instructions for Cygwin
  • mpconfigport.h: enable help and help("modules")
  • add support for build variants to windows port
  • run tests via Makefile
  • appveyor: build both standard and dev variants
  • appveyor: build mpy-cross only once for mingw-w64
  • msvc: run qstr preprocessing phase in parallel

zephyr port:

  • mphalport.h: remove unused and unimplemented C-level pin API
  • increase minimum CMake version to 3.20.0
  • update include path to reboot.h
  • get UART console device from devicetree instead of Kconfig
  • use CONFIG_USB_DEVICE_STACK for conditional USB device support
  • upgrade to Zephyr v2.7.0
  • modbluetooth_zephyr: provide dummy connect_cancel function

v1.17

2 years ago

This release of MicroPython adds support for f-strings (PEP-498), with a few limitations compared to normal Python. F-strings are essentially syntactic sugar for "".format() and make formatting strings a lot more convenient. Other improvements to the core runtime include pretty printing OSError when it has two arguments (an errno code and a string), scheduling of KeyboardInterrupt on the main thread, and support for a single argument to the optimised form of StopIteration.

In the machine module a new I2S class has been added, with support for esp32 and stm32 ports. This provides a consistent API for transmit and receive of audio data in blocking, non-blocking and asyncio-based operation. Also, the json module has support for the "separators" argument in the dump and dumps functions, and framebuf now includes a way to blit between frame buffers of different formats using a palette. A new, portable machine.bitstream function is also added which can output a stream of bits with configurable timing, and is used as the basis for driving WS2812 LEDs in a common way across ports.

There has been some restructuring of the repository directory layout, with all third-party code now in the lib/ directory. And a new top-level directory shared/ has been added with first-party code that was previously in lib/ moved there.

The docs have seen further improvement with enhancements and additions to the rp2 parts, as well as a new quick reference for the zephyr port. The terms master/slave have been replaced with controller/peripheral, mainly relating to I2C and SPI usage. And u-module references have been replaced with just the module name without the u-prefix to help clear up the intended usage of modules in MicroPython.

For the esp8266 and esp32 ports, hidden networks are now included in WLAN scan results. On the esp32 the RMT class is enhanced with idle_level and write_pulses modes. There is initial support for ESP32-C3 chips with GENERIC_C3 and GENERIC_C3_USB boards.

The javascript port has had its Makefile and garbage collector implementation reworked so it compiles and runs with latest the Emscripten using asyncify.

The mimxrt port sees the addition of hardware I2C and SPI support, as well as some additional methods to the machine module. There is also support for Hyperflash chips.

The nrf port now has full VFS storage support, enables source-line on traceback, and has .mpy features consistent with other ports.

For the rp2 port there is now more configurability for boards, and more boards added.

The stm32 port has a new LEGO_HUB_NO6 board definition with detailed information how to get this LEGO Hub running stock MicroPython. There is also now support to change the CPU frequency on STM32WB MCUs. And USBD_xxx descriptor options have been renamed to MICROPY_HW_USB_xxx.

Thanks to everyone who contributed to this release: Amir Gonnen, Andrew Scheller, Bryan Tong Minh, Chris Wilson, Damien George, Daniel Mizyrycki, David Lechner, David P, Fernando, finefoot, Frank Pilhofer, Glenn Ruben Bakke, iabdalkader, Jeff Epler, Jim Mussared, Jonathan Hogg, Josh Klar, Josh Lloyd, Julia Hathaway, Krzysztof Adamski, Matúš Olekšák, Michael Weiss, Michel Bouwmans, Mike Causer, Mike Teachman, Ned Konz, NitiKaur, oclyke, Patrick Van Oosterwijck, Peter Hinch, Peter Züger, Philipp Ebensberger, robert-hh, Roberto Colistete Jr, Sashkoiv, Seon Rozenblum, Tobias Thyrrestrup, Tom McDermott, Will Sowerbutts, Yonatan Goldschmidt.

What follows is a detailed list of changes, generated from the git commit history, and organised into sections.

Main components

all:

  • fix signed shifts and NULL access errors from -fsanitize=undefined
  • update to point to files in new shared/ directory

py core:

  • mpstate: make exceptions thread-local
  • mpstate: schedule KeyboardInterrupt on main thread
  • mperrno: add MP_ECANCELED error code
  • makeqstrdefs.py: don't include .h files explicitly in preprocessing
  • mark unused arguments from bytecode decoding macros
  • objexcept: pretty print OSError also when it has 2 arguments
  • makeversionhdr: add --tags arg to git describe
  • vm: simplify handling of MP_OBJ_STOP_ITERATION in yield-from opcode
  • objexcept: make mp_obj_exception_get_value support subclassed excs
  • support single argument to optimised MP_OBJ_STOP_ITERATION
  • introduce and use mp_raise_type_arg helper
  • modsys: optimise sys.exit for code size by using exception helpers
  • objexcept: make mp_obj_new_exception_arg1 inline
  • obj: fix formatting of comment for mp_obj_is_integer
  • emitnative: reuse need_reg_all func in need_stack_settled
  • emitnative: ensure stack settling is safe mid-branch
  • runtime: fix bool unary op for subclasses of native types
  • builtinimport: fix condition for including do_execute_raw_code()
  • mkrules: automatically build mpy-cross if it doesn't exist
  • implement partial PEP-498 (f-string) support
  • lexer: clear fstring_args vstr on lexer free
  • mkrules.mk: do submodule sync in "make submodules"

extmod:

  • btstack: add missing call to mp_bluetooth_hci_uart_deinit
  • btstack: check that BLE is active before performing operations
  • uasyncio: get addr and bind server socket before creating task
  • axtls-include: add axtls_os_port.h to customise axTLS
  • update for move of crypto-algorithms, re1.5, uzlib to lib
  • moduselect: conditionally compile select()
  • nimble: fix leak in l2cap_send if send-while-stalled
  • btstack/btstack.mk: use -Wno-implicit-fallthrough, not =0
  • utime: always invoke mp_hal_delay_ms when >= to 0ms
  • modbluetooth: clamp MTU values to 32->UINT16_MAX
  • nimble: allow modbluetooth binding to hook "sent HCI packet"
  • nimble: add "memory stalling" mechanism for l2cap_send
  • uasyncio: in open_connection use address info in socket creation
  • modujson: add support for dump/dumps separators keyword-argument
  • modlwip: fix close and clean up of UDP and raw sockets
  • modbluetooth: add send_update arg to gatts_write
  • add machine.bitstream
  • modframebuf: enable blit between different formats via a palette

lib:

  • tinyusb: update to version 0.10.1
  • pico-sdk: update to version 1.2.0
  • utils/stdout_helpers: make mp_hal_stdout_tx_strn_cooked efficient
  • axtls: switch to repo at micropython/axtls
  • axtls: update to latest axtls 2.1.5 wih additional commits
  • re1.5: move re1.5 code from extmod to lib
  • uzlib: move uzlib code from extmod to lib
  • crypto-algorithms: move crypto-algorithms code from extmod to lib
  • update README's based on contents of these dirs

drivers:

  • neopixel: add common machine.bitstream-based neopixel module
  • neopixel: optimize fill() for speed
  • neopixel: reduce code size of driver
  • cyw43: fix cyw43_deinit so it can be called many times in a row
  • cyw43: make wifi join fail if interface is not active

mpy-cross:

  • disable stack check when building with Emscripten

Support components

docs:

  • library: document new esp32.RMT features and fix wait_done
  • library: warn that ustruct doesn't handle spaces in format strings
  • esp8266/tutorial: change flash mode from dio to dout
  • replace master/slave with controller/peripheral in I2C and SPI
  • rp2: enhance quickref and change image to Pico pinout
  • rp2: update general section to give a brief technical overview
  • library/utime.rst: clarify behaviour and precision of sleep ms/us
  • library/uasyncio.rst: document stream readexactly() method
  • library/machine.I2S.rst: fix use of sd pin in examples
  • zephyr: add quick reference for the Zephyr port
  • library/zephyr: add libraries specific to the Zephyr port
  • templates: add unix and zephyr quickref links to top-index
  • rename ufoo.rst to foo.rst
  • replace ufoo with foo in all docs
  • library/index.rst: clarify module naming and purpose
  • library/builtins.rst: add module title
  • library/network.rst: simplify socket import
  • add docs for machine.bitstream and neopixel module
  • library: fix usage of :term: for frozen module reference
  • esp8266: use monospace for software tools
  • reference: mention that slicing a memoryview causes allocation

examples: no changes specific to this component/port

tests:

  • extmod: make uasyncio_heaplock test more deterministic
  • cpydiff/modules_struct_whitespace_in_format: run black
  • extmod/ujson: add tests for dump/dumps separators argument
  • run-multitests.py: add broadcast and wait facility
  • multi_bluetooth/ble_subscribe.py: add test for subscription
  • extmod/vfs_fat_finaliser.py: ensure alloc at never-used GC blocks
  • basics: split f-string debug printing to separate file with .exp
  • pybnative: make while.py test run on boards without pyb.delay

tools:

  • autobuild: add scripts to build release firmware
  • remove obsolete build-stm-latest.sh script
  • ci.sh: run apt-get update in ci_powerpc_setup
  • makemanifest.py: allow passing flags to mpy-tool.py
  • autobuild: add mimxrt port to build scripts for nightly builds
  • pyboard.py: add cmd-line option to make soft reset configurable
  • mpremote: swap order of PID and VID in connect-list output
  • ci.sh: build unix dev variant as part of macOS CI
  • ci.sh: build GENERIC_C3 board as part of esp32 CI
  • autobuild: use separate IDF version to build newer esp32 SoCs
  • autobuild: add FeatherS2 and TinyS2 to esp32 auto builds
  • mpremote: add seek whence for mounted files
  • mpremote: raise OSError on unsupported RemoteFile.seek
  • autobuild: add the MIMXRT1050_EVKB board to the daily builds
  • ci.sh: add mpy-cross build to nrf port
  • codeformat.py: include ports/nrf/modules/nrf in code formatting
  • gen-cpydiff.py: don't rename foo to ufoo in diff output
  • autobuild: add auto build for Silicognition wESP32
  • mpremote: fix connect-list in case VID/PID are None
  • mpremote: add "devs" shortcut for "connect list"
  • mpremote: remove support for pyb.USB_VCP in/out specialisation
  • autobuild: don't use "-B" for make, it's already a fresh build
  • pyboard.py: move --no-exclusive/--soft-reset out of mutex group
  • pyboard.py: make --no-follow use same variable as --follow
  • pyboard.py: add --exclusive to match --no-exclusive
  • pyboard.py: make --no-soft-reset consistent with other args
  • uncrustify: force 1 newline at end of file
  • mpremote: bump version to 0.0.6

CI:

  • workflows: add workflow to build and test javascript port
  • workflows: switch from Coveralls to Codecov
  • workflows: switch from lcov to gcov
  • workflows: add workflow to build and test unix dev variant

The ports

all ports:

  • use common mp_hal_stdout_tx_strn_cooked instead of custom one
  • update for move of crypto-algorithms, uzlib to lib
  • rename USBD_VID/PID config macros to MICROPY_HW_USB_VID/PID

bare-arm port: no changes specific to this component/port

cc3200 port: no changes specific to this component/port

esp8266 port:

  • add len to NeoPixel driver to support iterating
  • Makefile: add more libm files to build
  • include hidden networks in WLAN.scan results
  • replace esp.neopixel with machine.bitstream
  • remove dead code for end_ticks in machine_bitstream

esp32 port:

  • boards/sdkconfig.base: disable MEMPROT_FEATURE to alloc from IRAM
  • add len to NeoPixel driver to support iterating
  • main: allow MICROPY_DIR to be overridden
  • esp32_rmt: fix RMT looping in newer IDF versions
  • esp32_rmt: enhance RMT with idle_level and write_pulses modes
  • add new machine.I2S class for I2S protocol support
  • machine_spi: calculate actual attained baudrate
  • machine_hw_spi: use a 2 item SPI queue for long transfers
  • machine_dac: add MICROPY_PY_MACHINE_DAC option, enable by default
  • machine_i2s: add MICROPY_PY_MACHINE_I2S option, enable by default
  • fix use of mp_int_t, size_t and uintptr_t
  • add initial support for ESP32C3 SoCs
  • boards/GENERIC_C3: add generic C3-based board
  • modmachine: release the GIL in machine.idle()
  • mphalport: always yield at least once in delay_ms
  • machine_uart: add flow kw-arg to enable hardware flow control
  • boards: add Silicognition wESP32 board configuration
  • mpconfigport.h: enable reverse and inplace special methods
  • include hidden networks in WLAN.scan results
  • makeimg.py: get bootloader and partition offset from sdkconfig
  • enable MICROPY_PY_FSTRINGS by default
  • machine_hw_spi: release GIL during transfers
  • machine_pin: make check for non-output pins respect chip variant
  • replace esp.neopixel with machine.bitstream
  • remove dead code for end_ticks in machine_bitstream
  • boards: add GENERIC_C3_USB board with USB serial/JTAG support

javascript port:

  • rework Makefile and GC so it works with latest Emscripten
  • Makefile: suppress compiler errors from array bounds
  • Makefile: change variable to EXPORTED_RUNTIME_METHODS

mimxrt port:

  • move calc_weekday helper function to timeutils
  • machine_spi: add the SPI class to the machine module
  • moduos: seed the PRNG on boot using the TRNG
  • boards: set vfs partition start to 1 MBbyte
  • main: skip running main.py if boot.py failed
  • main: extend the information returned by help()
  • mimxrt_flash: remove commented-out code
  • modmachine: add a few minor methods to the machine module
  • machine_led: use mp_raise_msg_varg helper
  • machine_i2c: add hardware-based machine.I2C to machine module
  • add support for Hyperflash chips
  • boards: add support for the MIMXRT1050_EVKB board
  • machine_pin: implement ioctl for Pin

minimal port:

  • Makefile: add support for building with user C modules

nrf port:

  • modules: replace master/slave with controller/peripheral in SPI
  • boards/common.ld: calculate unused flash region
  • modules/nrf: add new nrf module with flash block device
  • drivers: add support for using flash block device with SoftDevice
  • mpconfigport.h: expose nrf module when MICROPY_PY_NRF is set
  • README: update README.md to reflect internal file systems
  • mpconfigport.h: tune FAT FS configuration
  • Makefile: add _fs_size linker script override from make
  • modules/uos: allow a board to configure MICROPY_VFS_FAT/LFS1/LFS2
  • mpconfigport.h: enable MICROPY_PY_IO_FILEIO when an FS is enabled
  • qstrdefsport.h: add entries for in-built FS mount points
  • main: add auto mount and auto format hook for internal flash FS
  • boards: enable needed features for FAT/LFS1/LFS2
  • facilitate use of freeze manifest
  • boards: set FROZEN_MANIFEST blank when SD present on nrf51 targets
  • modules/scripts: add file system formatting script
  • Makefile: set default manifest file for all targets
  • mphalport: add dummy function for mp_hal_time_ns()
  • boards: enable MICROPY_VFS_LFS2 for all target boards
  • modules/uos: add ilistdir to uos module
  • modules/nrf: add function to enable/disable DCDC
  • enable source line on tracebacks
  • set .mpy features consistent with documentation and other ports

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

rp2 port:

  • use 0=Monday datetime convention in RTC
  • machine_rtc: in RTC.datetime, compute weekday automatically
  • CMakeLists.txt: suppress compiler errors for pico-sdk and tinyusb
  • tusb_config.h: set CFG_TUD_CDC_EP_BUFSIZE to 256
  • machine_uart: add hardware flow control support
  • machine_uart: allow overriding default machine UART pins
  • machine_i2c: allow boards to configure I2C pins using new macros
  • machine_spi: allow boards to configure SPI pins using new macros
  • machine_uart: fix poll ioctl to also check hardware FIFO
  • machine_uart: fix read when FIFO has chars but ringbuf doesn't
  • tusb_port: allow boards to configure USB VID and PID
  • boards/ADAFRUIT_FEATHER_RP2040: configure custom VID/PID
  • boards/ADAFRUIT_FEATHER_RP2040: configure I2C/SPI default pins
  • boards/SPARKFUN_PROMICRO: configure UART/I2C/SPI default pins
  • boards/SPARKFUN_THINGPLUS: configure I2C/SPI default pins
  • boards: add Adafruit ItsyBitsy RP2040
  • boards: add Adafruit QT Py RP2040
  • boards: add Pimoroni Pico LiPo 4MB
  • boards: add Pimoroni Pico LiPo 16MB
  • boards: add Pimoroni Tiny 2040
  • CMakeLists.txt: allow a board's cmake to set the manifest path
  • enable MICROPY_PY_FSTRINGS by default
  • Makefile: add "submodules" target, to match other ports
  • rp2_flash: disable IRQs while calling flash_erase/program
  • CMakeLists.txt: add option to enable double tap reset to bootrom
  • mpconfigport.h: allow boards to add root pointers

samd port:

  • add support for building with user C modules

stm32 port:

  • softtimer: add soft_timer_reinsert() helper function
  • mpbthciport: change from systick to soft-timer for BT scheduling
  • provide a custom BTstack runloop that integrates with soft timer
  • usb: make irq's default trigger enable all events
  • boardctrl: skip running main.py if boot.py had an error
  • sdio: fix undefined reference to DMA stream on H7
  • dma: add DMAMUX configuration for H7 to fix dma_nohal_init
  • main: call mp_deinit() at end of main
  • adc: allow using ADC12 and ADC3 for H7
  • adc: define the ADC instance used for internal channels
  • adc: simplify and generalise how pin_adcX table is defined
  • add new machine.I2S class for I2S protocol support
  • boards/NUCLEO_F446RE: fix I2C1 pin assignment to match datasheet
  • replace master/slave with controller/peripheral in I2C and SPI
  • systick: always POLL_HOOK when delaying for milliseconds
  • sdram: make SDRAM test cache aware, and optional failure with msg
  • boards/NUCLEO_F446RE: enable CAN bus support
  • boards: add support for SparkFun STM32 MicroMod Processor board
  • uart: fix LPUART1 baudrate set/get
  • uart: support low baudrates on LPUART1
  • boards/STM32F429DISC: set correct UART2 pins and add UART3/6
  • boards/NUCLEO_F439ZI: add board definition for NUCLEO_F439ZI
  • boards/LEGO_HUB_NO6: add board definition for LEGO_HUB_NO6
  • Makefile: update to only pull in used Bluetooth library
  • README.md: update supported MCUs, and submodule and mboot use
  • usbd_desc: rename USBD_xxx descriptor opts to MICROPY_HW_USB_xxx
  • usbd_cdc_interface: rename USBD_CDC_xx opts to MICROPY_HW_USB_xx
  • powerctrl: support changing frequency on WB MCUs
  • boards/NUCLEO_H743ZI2: add modified version of NUCLEO_H743ZI
  • mbedtls: fix compile warning about uninitialized val
  • enable MICROPY_PY_FSTRINGS by default
  • add implementation of machine.bitstream
  • Makefile: allow GIT_SUBMODULES and LIBS to be extended
  • stm32_it: support TIM17 IRQs on WB MCUs
  • disable computed goto on constrained boards
  • storage: make extended-block-device more configurable
  • boards/LEGO_HUB_NO6: change SPI flash storage to use hardware SPI
  • boards/LEGO_HUB_NO6: skip first 1MiB of SPI flash for storage
  • boards/LEGO_HUB_NO6: add make commands to backup/restore firmware

teensy port: no changes specific to this component/port

unix port:

  • modffi: add option to lock GC in callback, and cfun access
  • Makefile: add back LIB_SRC_C to list of object files
  • variants: enable help and help("modules") on standard and dev
  • Makefile: disable error compression on arm-linux-gnueabi-gcc

windows port:

  • Makefile: add .exe extension to executables name
  • appveyor: update to VS 2017 and use Python 3.8 for build/test

zephyr port:

  • machine_spi: add support for hardware SPI

v1.16

2 years ago

This release of MicroPython includes a new command-line tool called "mpremote", which is intended to be the main way to remotely control a MicroPython-based device from the command line. It features a serial terminal, filesystem access, support to mount a local directory on the remote device, and a macro language to define custom commands. This tool can be installed from PyPI via "pip3 install mpremote", and it works on Linux, Windows and Mac. As part of this, improvements were made to pyboard.py including opening serial ports in exclusive mode to more easily manage multiple devices.

In the Python core, OSError exceptions now support the ".errno" attribute, and an option was added to compile MicroPython without error messages to further reduce code size where needed. The REPL was improved so that it does not tab-complete private methods (those starting with underscore, if no underscore has been typed yet), and it also now tab completes built-in module names after "import" is typed.

There has been a minor breaking change to a relative import exception: what was previously a ValueError was changed to ImportError, following the same change in CPython. See commit 53519e322a5a0bb395676cdaa132f5e82de22909.

In the extmod components, uctypes has a fix for the size and offset calculation for ARRAY of FLOAT32, uhashlib now raises an exception if a hash is reused after digest is called, and urandom supports passing 0 to getrandbits (following the CPython change). In uasyncio, the readinto method is added to the Stream class, and two race conditions were fixed: one with start_server and wait_closed, and the other with cancelling a task waiting on finished task; see de2e081260395f47d21bf39a97f3461df3d8b94f and 514bf1a1911ac9173a00820b7e09dfb387e6b941 respectively.

The esp32 port now supports specifying FROZEN_MANIFEST with new CMake build system, has NeoPixel support on GPIO32 and GPIO33, network.LAN support in IDF v4.1 and above, and a new "reconnects" option in the WLAN STA interface to configure how many (if any) reconnection attempts are made if the WiFi goes down.

Many features have been added to the mimxrt port, including: VFS filesystem support with internal flash storage, Pin, Pin.irq and ADC support, UART, SoftI2C and SoftSPI bus support, Timer and RTC classes, and floating point numbers.

The rp2 port now has the machine.RTC class to configure the RTC, as well as new board definition files for SparkFun's Thing Plus RP2040 and Pro Micro boards.

The stm32 port now supports static soft timers with a C-based callback, and mboot has been made more configurable, in particular the LEDs and reset mode selection can now be fully customised by a board. Two new boards have been added: VCC_GND_F407VE and VCC_GND_F407ZG. A bug fix was made to the SDIO driver to make sure DMA doesn't turn off mid-transfer; this affected WLAN operation when certain SPI buses were being used. See commit a96afae90f6e5d693173382561d06e583b0b5fa5 for details. Pin configuration of UART has been modified so pull-up is now configured only on RX and CTS, not TX and RTS; see 748339b28126e69fd2dc2778b2a182901d0a4693. The USB_VCP class has a new irq method to set a callback on USB data RX events. The Ethernet driver now supports low-power mode, and has a fix so the link status is reported correctly.

On the zephyr port, scheduled callbacks are now run at idle REPL and during sleeps, and there is an initial ubluetooth module which supports BLE scanning and advertising. Configuration is provided for the nucleo_wb55rg board.

What follows is a detailed list of changes, generated from the git commit history, and organised into sections.

Thanks to everyone who contributed to this release!

Main components

all:

  • rename mp_keyboard_interrupt to mp_sched_keyboard_interrupt
  • replace busses with buses

py core:

  • objexcept: support errno attribute on OSError exceptions
  • add option to compile without any error messages at all
  • dynruntime.h: add mp_obj_get_array() function
  • profile: use mp_handle_pending() to raise pending exception
  • scheduler: add mp_sched_exception() to schedule a pending exception
  • scheduler: add optional port hook for when something is scheduled
  • runtime: remove commented-out code from mp_deinit()
  • scheduler: add missing MICROPY_WRAP_MP_SCHED_EXCEPTION usage
  • repl: filter private methods from tab completion
  • repl: enter four spaces when there are no matches
  • repl: refactor autocomplete to reduce nesting
  • repl: refactor autocomplete, extracting reusable parts
  • repl: autocomplete builtin modules
  • gc: make gc_lock_depth have a count per thread
  • mkenv.mk: don't emit info about BUILD_VERBOSE if it's set
  • objarray: prohibit comparison of mismatching types
  • objarray: implement more/less comparisons for array
  • objarray: use mp_obj_memoryview_init helper in mp_obj_new_memoryview
  • objarray: fix constructing a memoryview from a memoryview
  • nlraarch64: add underscore prefix to function symbols for Darwin ABI
  • nlrx64: correct the detection of Darwin ABI
  • asmx64: support use of top 8 regs in src_r64 argument
  • emitnative: fix x86-64 emitter to generate correct 8/16-bit stores
  • mkrules.cmake: add MPY_LIB_DIR and BOARD_DIR to makemanifest call
  • asmarm: use builtin func to flush I- and D-cache on ARM 7 archs
  • compile: raise an error on async with/for outside an async function
  • gc: access the list of root pointers in an asan-compatible way
  • repl: don't read past the end of import_str
  • builtinimport: change relative import's ValueError to ImportError
  • emitglue: always flush caches when assigning native ARM code
  • stackctrl: prevent unused-var warning when stack checking disabled
  • gc: only use no_sanitize_address attribute for GCC 4.8 and above

extmod:

  • uasyncio: use .errno instead of .args[0] for OSError exceptions
  • remove old comments used for auto-doc generation
  • moductypes: remove double blank lines and debugging printf's
  • moductypes: replace numbers with macro constants
  • moductypes: fix size and offset calculation for ARRAY of FLOAT32
  • moduhashlib: put hash obj in final state after digest is called
  • modurandom: add error message when getrandbits has bad value
  • modurandom: support an argument of bits=0 to getrandbits
  • uasyncio: fix start_server and wait_closed race condition
  • uasyncio: add readinto() method to Stream class
  • uasyncio: fix race with cancelled task waiting on finished task
  • nimble: remove TODO comment about notify_custom freeing om

lib:

  • utils: remove unused PYEXEC_SWITCH_MODE from pyexec.h
  • utils: add ARM semihosting utility functions
  • lwip: switch to use GitHub mirror repo
  • mbedtls: switch to currently latest commit of LTS branch v2.16

drivers:

  • sdcard: add sleep_ms(1) delay in SDCard.readinto sync loop
  • cyw43/cyw43_ctrl: use new sdio enable API functions
  • cyw43/cywbt: add compile option for RF switch
  • cyw43/cywbt: remove hard-coded UART6 alternate function setting
  • display/ssd1306.py: add rotate method
  • display/ssd1306.py: add support for 72x40 displays

mpy-cross: no changes specific to this component/port

Support components

docs:

  • library/machine: specify initial machine.PWM class
  • library/machine: add machine.bootloader docs
  • esp8266: add note about simultaneous use of STA_IF and AP_IF
  • esp8266: add instructions on entering programming mode manually
  • esp8266: clarify limitations of SSL in esp8266 and fix typos
  • fix some spelling mistakes
  • pyboard: fix typo in pyb.Switch tutorial
  • esp32: add UART to quickref
  • esp32: add WDT to quickref
  • esp32: add SDCard to quickref
  • esp8266: add WDT to quickref
  • library: add initial API reference for rp2 module and its classes
  • library/rp2.rst: fix typo overriden->overridden
  • esp32: add APA106 to quickref
  • esp32: mention Signal in GPIO section of quickref
  • esp8266: mention Signal in GPIO section of quickref
  • esp8266: add SSD1306 to quickref and tutorial
  • library: clarify what type of algorithm is implemented in heapq
  • library: add a blank line to fix formatting for ussl docs
  • library/pyb.Pin.rst: update the arguments for Pin.init()
  • rp2: add skeleton docs for the rp2 port
  • library/machine.RTC.rst: document datetime method and fix ex code
  • esp32: document WLAN "reconnects" config option

examples: no changes specific to this component/port

tests:

  • use .errno instead of .args[0] for OSError exceptions
  • run-multitests.py: provide some convenient serial device shorcuts
  • multi_bluetooth: add performance test for gatt char writes
  • thread: make stress_create.py test run on esp32
  • thread: make stress_aes.py test run on bare-metal ports
  • thread: make exc1,exit1,exit2,stacksize1,start1 tests run on rp2
  • run-perfbench.py: fix native feature check
  • run-multitests.py: flush stdout for each line of trace output
  • run-tests.py: parallelize running tests by default
  • cpydiff: add test and workaround for function.module attr
  • make float and framebuf tests skip or run on big-endian archs
  • extmod/btree_gc.py: close the database to avoid a memory leak
  • basics: split out literal tests that raise SyntaxWarning on CPy
  • run-multitests.py: allow to work without sys.stdout on target
  • multi_bluetooth/ble_gap_advertise.py: allow to work without set
  • unix: add ffi test for integer types
  • cpydiff: add test for array constructor with overflowing value
  • float: make bytes/bytearray construct tests work with obj repr C

tools:

  • metrics.py: add rp2 port to table of ports that can be built
  • upip.py: use .errno instead of .args[0] for OSError exceptions
  • pyboard.py: support opening serial port in exclusive mode
  • gen-cpydiff.py: fix formatting of doc strings for new Black
  • makemanifest.py: show directory name if there is a FreezeError
  • mpy_ld.py: support R_X86_64_GOTPCREL reloc for x86-64 arch
  • pydfu.py: remove default VID/PID values
  • ci.sh: update zephyr docker image to v0.17.3
  • ci.sh: use FROZEN_MANIFEST in an esp32 build to test feature
  • mpy-tool.py: support relocating ARMv6 arch
  • tinytest-codegen.py: add command-line option to exclude tests
  • ci.sh: build Cortex-A9 sabrelite board as part of qemu-arm CI
  • pyboard.py: track raw REPL state via in_raw_repl variable
  • pyboard.py: add "soft_reset" option to Pyboard.enter_raw_repl()
  • mpremote: add new CLI utility to interact with remote device
  • ci.sh: build mpy-cross as part of ci_mimxrt_build
  • mpremote: use available ports instead of auto-connect list
  • mpremote: use signal to capture and handle ctrl-C on Windows

CI:

  • workflows: add CI workflow for mimxrt port
  • workflows: add workflow to build and run unix port on MIPS
  • workflows: add workflow to build and run unix port on ARM

The ports

bare-arm port:

  • switch to use MICROPY_ERROR_REPORTING_NONE to reduce size

cc3200 port: no changes specific to this component/port

esp8266 port:

  • modnetwork: use mp_handle_pending() to raise pending exception
  • boards/GENERIC_512K: add custom manifest without FS modules
  • update manifest to point to new dirs in micropython-lib
  • boards/GENERIC_512K: add custom minimal _boot.py

esp32 port:

  • CMakeLists.txt: require CMake version 3.12
  • restore FROZEN_MANIFEST support with new CMake build system
  • esp32_rmt: clear config struct before filling it out
  • mpthreadport: don't explicitly free thread struct in TCB cleanup
  • mpthreadport: use binary semaphore instead of mutex
  • extend support for S2 series, and S3 where applicable
  • boards: rename TINYPICO board to UM_TINYPICO
  • boards: add UM_FEATHERS2 and UM_TINYS2 board definitions
  • boards/UM_TINYPICO: fix include of sdkconfig fragment
  • machine_i2c: allow boards to configure I2C pins using new macros
  • boards: set default I2C and SPI pins on UM_xxx boards
  • boards: fix spelling mistakes in comments for UM_xxx boards
  • update manifest to point to new dirs in micropython-lib
  • boards: add M5STACK_ATOM board definition
  • espneopixel: add support for GPIO32 and GPIO33
  • Makefile: fix wrong target for partition-table.bin
  • makeimg.py: load sizes from partition table and verify data fits
  • partitions-2MiB.csv: update table so firmware fits
  • README: describe how to select compatible version of existing IDF
  • network_lan: add Ethernet support for IDF v4.1 and above
  • modnetwork: add "reconnects" option to WLAN STA interface
  • machine_hw_spi: allow None for unused pins in initializer
  • machine_sdcard: use deinit_p to deinit SD bus in SPI mode

javascript port: no changes specific to this component/port

mimxrt port:

  • improve ticks and sleep functions using GPT
  • implement machine.Pin class
  • enable built-in help
  • extend the Pin module for SoftI2C, SoftSPI support
  • add custom help text and enable help("modules")
  • enable frozen modules
  • add flash storage support with VFS and littlefs filesystem
  • boards/TEENSY40: re-create the flash FS after deploy
  • add the Timer class to the machine module
  • remove __WFE() from MICROPY_EVENT_POLL_HOOK
  • machine_timer: reuse any existing timer objects
  • machine_timer: leave the Timer clock source at IPG clock
  • machine_rtc: add the RTC class to the machine module
  • add floating point support
  • enable many Python and some extmod features
  • machine_adc: add the ADC class to the machine module
  • boards: add board configuration files for Teensy 4.1
  • machine_rtc: change RTC.datetime() tuple to match other ports
  • machine_rtc: maintain microsecond offset
  • machine_uart: add the UART class to the machine module
  • machine_pin: implement pin.irq() functionality
  • modutime: extend the time module

minimal port: no changes specific to this component/port

nrf port:

  • boards/microbit: use mp_sched_exception() where appropriate
  • add machine.memXX, and allow boards to customise some features
  • boards: add support for evk_nina_b3 board
  • add more math sources to Makefile, and enable log2 implementation

pic16bit port:

  • Makefile: make the XC compiler version user-configurable

powerpc port: no changes specific to this component/port

qemu-arm port:

  • add support for Cortex-A9 via sabrelite board

rp2 port:

  • boards: add board definition for SparkFun Thing Plus RP2040
  • boards: add board definition for SparkFun Pro Micro board
  • tusb_port: add the device unique-id to the USB id
  • move manifest.py to boards directory
  • mpthreadport: add mp_thread_deinit to reset core1 on soft reset
  • CMakeLists.txt: include tinyusb_common in PICO_SDK_COMPONENTS
  • machine_rtc: add initial support for RTC
  • machine_rtc: check return value from rtc_set_datetime

samd port: no changes specific to this component/port

stm32 port:

  • boards/pllvalues.py: support wider range of PLL values for F413
  • machine_timer: improve usability of Timer constructor and init
  • mboot: allow unpacking dfu without secret key
  • correct typos in project README files
  • uart: fix H7 UART clock source configuration
  • softtimer: add support for having a C-based callback
  • softtimer: support static soft timer instances
  • boardctrl: add constants for reset mode values
  • boardctrl: show first reset-mode state on LEDs when selecting
  • mboot: allow a board to add source files to the build
  • adc: allow mboot to use basic ADC functions
  • mboot: fix mp_hal_delay_us() and add mp_hal_ticks_ms()
  • mboot: allow a board to customise the linker scripts
  • mboot: allow mboot to be placed at any location in flash
  • sdcard: allow configuring the SDMMC periph used for SD/MMC card
  • uart: enable HW flow control for UART 1/5/7/8
  • sdio: add functions to re/enable SDIO/SDIOIT
  • boards/PYBD_SF2: enable RF switch compile option
  • sdio: allow configuring the SDMMC periph used for SDIO
  • boards: change default LSI_VALUE to 32000 for F4 MCUs
  • powerctrl: add MICROPY_HW_ENTER_BOOTLOADER_VIA_RESET option
  • boardctrl: adjust logic for running boot.py, main.py
  • mboot: add MBOOT_LEAVE_BOOTLOADER_VIA_RESET option
  • mboot: make LEDs and reset-mode selection more configurable
  • boards: add VCC_GND_F407VE board
  • boards: add VCC_GND_F407ZG board
  • sdio: fix case of SDIO DMA turning off mid transfer
  • uart: configure pull-up only on RX and CTS, not TX and RTS
  • mboot: leave bootloader from thread mode, not from IRQ
  • boards/NUCLEO_L432KC: fix FS size and enable LFS1 filesystem
  • boards/PYBD_SF2: disable GCC 11 warnings for array bounds
  • usb: add USB_VCP.irq method, to set a callback on USB data RX
  • boards: enable MICROPY_HW_SPIFLASH_ENABLE_CACHE on VCC_GND boards
  • sdram: prevent array-bounds warnings with GCC 11
  • eth: add low-power mode configuration option
  • eth: fix eth_link_status function to use correct BSR bit

teensy port:

  • provide own implementation of gc_collect, to not use stm32
  • correct typos in project README files

unix port:

  • modffi: use a union for passing/returning FFI values
  • main: increase stack limit on ARM architectures
  • modffi: fix conversion between Python integers and ffi types
  • fix build on arm64-darwin due to integer cast

windows port:

  • mpconfigport.h: enable features also present in unix port

zephyr port:

  • run scheduled callbacks at REPL and during mp_hal_delay_ms
  • modmachine: add machine.idle()
  • boards: add config for nucleo_wb55rg board
  • update disk access configuration for Zephyr v2.6.0
  • disable CONFIG_NET_SOCKETS_POSIX_NAMES
  • update to Zephyr v2.6.0
  • add initial ubluetooth module integration
  • boards: enable ubluetooth on nucleo_wb55rg board

v1.15

3 years ago

This release of MicroPython adds general support in the core for using CMake as a build system. The rp2 port is consolidated to use the new CMake files, and the esp32 and zephyr ports have switched to build as pure CMake projects. These three ports have SDKs which are built around CMake and this change should make them easier to maintain and use.

As part of this work, CMake based ports now have support for user C modules. Authors of user C modules should now provide both .mk and .cmake configuration files (following the documentation and examples).

A bug was fixed in the multiple precision integer library, an arithmetic overflow in the long division routine. Prior to this fix certain integer divisions would take excessive time and produce incorrect results. See commit 0a59938574502b19b3d685133084399c090d3c11 for details. There was also a fix for regular expressions, to check and report byte overflow errors when compiling expressions. See commit 172fb5230a3943eeb6fbbb4de1dc56b16e2a7637.

In the uasyncio library, a new MicroPython extension has been added, ThreadSafeFlag, which can be set from outside the asyncio event loop, such as other threads, IRQs or scheduler context. It allows preemptive code like IRQs to signal asyncio tasks, which are by nature cooperative (non-preemptive). asyncio.current_task() has also been added, with the same semantics as CPython.

As mentioned above, the esp32 port has switched to a full CMake-based project, and traditional make capability has been removed (although a simple helper Makefile remains to keep top-level build/deploy commands consistent with other ports). Because of the move to CMake, network.LAN support has been removed, to be added back in the future (use a prior release if LAN is needed). Basic support for Non-Volatile-Storage is added to the esp32 module. And there is also preliminary support for ESP32S2 SoCs and USB, with a GENERIC_S2 board defined.

On the mimxrt and samd ports, USB CDC TX handling has been fixed so that it now works reliably.

The rp2 port has had many more core Python features enabled, along with the enabling of ubinascii.crc32(), the uos.VfsFat and machine.Signal classes, and the uerrno module. uos.urandom() has been added and machine.freq() can now change the CPU clock frequency. The machine.UART class now has support for timeout/timeout_char, inverted TX/RX lines, and buffered TX/RX with configurable sized buffers. For PIO, StateMachine has added restart(), rx_fifo() and tx_fifo() helper functions, and support for FIFO joining. There is now support for user C modules (via CMake) and for building different board configurations (the default remains the PICO board). USB reliability has been improved.

For the stm32 port, there is now more configuration options for boards, such as USBD VID/PID and fine-grained selection of modules. The UART class now supports LPUART on L0, L4, H7 and WB MCUs. WB MCUs have a fix for a race condition accessing the BLE ACL free buffer list, and a workaround for a low-level BLE bug.

The zephyr port has been updated to use zephyr v2.5.0, and now builds MicroPython as a CMake target.

What follows is a detailed list of changes, generated from the git commit history, and organised into sections.

Main components

all:

  • rename BYTES_PER_WORD to MP_BYTES_PER_OBJ_WORD
  • add .git-blame-ignore-revs for fixing up git blame output

py core:

  • gc: don't include mpconfig.h and misc.h in gc.h
  • remove BITS_PER_WORD definition
  • rename BITS_PER_BYTE to MP_BITS_PER_BYTE
  • rename WORD_MSBIT_HIGH to MP_OBJ_WORD_MSBIT_HIGH
  • gc: change include of stdint.h to stddef.h
  • mpz: fix overflow of borrow in mpn_div
  • add core cmake rule files
  • expand lists in core cmake custom commands
  • mkrules.cmake: rename QSTR_DEFS variables to QSTRDEFS
  • mkrules.cmake: add MICROPY_QSTRDEFS_PORT to qstr build process
  • nlr: implement NLR for AArch64
  • nlrx64: fix typo in comment
  • vm: for tracing use mp_printf, and print state when thread enabled
  • rename remaining object types to be of the form mp_type_xxx
  • py.cmake: move qstr helper code to micropy_gather_target_properties
  • py.cmake: introduce MICROPY_INC_CORE as a list with core includes
  • profile: resolve name collision with STATIC unset
  • runtime: make sys.modules preallocate to a configurable size

extmod:

  • vfs_posix_file: allow closing an already closed file
  • btstack: add HCI trace debugging option in btstack_hci_uart
  • btstack: add stub functions for passkey, l2cap bindings
  • btstack: enable SYNC_EVENTS, PAIRING_BONDING by default
  • uasyncio: add asyncio.current_task()
  • add core cmake rule files
  • nimble: ensure handle is set on read error
  • moduselect: fix unsigned/signed comparison for timeout!=-1
  • uasyncio: add ThreadSafeFlag
  • nimble/hal/hal_uart: fix HCI_TRACE format specifiers
  • modbluetooth: allow NimBLE to use Zephyr static address
  • modussl: fix ussl read/recv/send/write errors when non-blocking
  • btstack: use MICROPY_HW_BLE_UART_BAUDRATE for first UART init
  • modbluetooth: separate enabling of "client" from "central"
  • extmod.cmake: add modonewire.c to MICROPY_SOURCE_EXTMOD list
  • modbluetooth: free temp arrays in gatts register services
  • re1.5: check and report byte overflow errors in _compilecode
  • extmod.cmake: add support to build btree module with CMake

lib:

  • tinyusb: update to version 0.8.0
  • mbedtls: switch to currently latest commit of LTS branch v2.16
  • utils/gchelper_generic: implement AArch64 support
  • pico-sdk: update to latest version 1.1.0

drivers: no changes specific to this component/port

mpy-cross: no changes specific to this component/port

Support components

docs:

  • library/uasyncio.rst: add docs for ThreadSafeFlag
  • develop/cmodules.rst: document C-modules and micropython.cmake
  • develop: improve user C modules to properly describe how to build

examples:

  • usercmodule: add micropython.cmake to the C and CPP examples
  • usercmodules: simplify user C module enabling
  • embedding: fix example so it compiles again

tests:

  • extmod/vfs_posix.py: add more tests for VfsPosix class
  • extmod: add test for ThreadSafeFlag
  • multi_bluetooth: add basic performance tests
  • rename run-tests to run-tests.py for consistency
  • run-tests.py: reformat with Black
  • multi_bluetooth: skip tests when BLE features are unsupported
  • extmod/vfs_fat_fileio2.py: close test file at end of test
  • run-tests.py: provide more info if script run via pyboard crashes
  • feature_check: check for lack of pass result rather than failure
  • net_inet: add 'Strict-Transport-Security' to exp file

tools:

  • add filesystem action examples to pyboard.py help
  • ci.sh: change esp32 CI to work with idf.py and IDF v4.0.2
  • makemanifest.py: allow passing option args to include()
  • ci.sh: update zephyr docker image to v0.11.13
  • verifygitlog.py: show required format regexp in error message
  • pydfu.py: support DFU files with elements of zero size
  • ci.sh: add CI for CMake USER_C_MODULE support
  • ci.sh: build user C modules for esp32
  • metrics.py: fix esp32 output filename due to move to CMake
  • ci.sh: build esp32 using IDF v4.0.2 and v4.3

The ports

all ports:

  • remove def of MP_PLAT_PRINT_STRN if it's the same as the default
  • update to build with new tinyusb

bare-arm port:

  • clean up the code, make it run on an F405, and add a README

cc3200 port: no changes specific to this component/port

esp8266 port:

  • modules: fix fs_corrupted() to use start_sec not START_SEC

esp32 port:

  • add support to build using IDF with cmake
  • esp32_rmt: don't do unnecessary check for unsigned less than zero
  • add explicit initialisers to silence compiler warnings
  • remove traditional "make" capability
  • boards: remove old IDF v3 sdkconfig values
  • boards: enable BLE on all boards
  • README: update based on new IDF v4 cmake build process
  • add support to build with ESP-IDF v4.1.1
  • add support to build with ESP-IDF v4.2
  • remove obsolete IDF v3 code wrapped in MICROPY_ESP_IDF_4
  • modsocket: remove unix socket error code translation
  • set MICROPY_USE_INTERNAL_ERRNO=0 to use toolchain's errno.h
  • boards: enable size optimisation for builds
  • add support to build with ESP-IDF v4.3 pre-release
  • add basic support for Non-Volatile-Storage in esp32 module
  • make machine.soft_reset() work in main.py and reset_cause()
  • define MICROPY_QSTRDEFS_PORT to include special qstrs
  • Makefile: specify port and baud on erase_flash command
  • machine_hw_spi: use default pins when making SPI if none given
  • restore USER_C_MODULE support with new CMake build system
  • fix multiple definition errors with mp_hal_stdout_tx functions
  • enable btree module
  • modsocket: correctly handle poll/read of unconnected TCP socket
  • add initial support for ESP32S2 SoCs
  • add support for USB with CDC ACM
  • boards: add GENERIC_S2 board definition
  • machine_pin: use rtc_gpio_deinit instead of gpio_reset_pin

javascript port: no changes specific to this component/port

mimxrt port:

  • fix USB CDC handling so it works reliably
  • boards: add MIMXRT1050_EVK board, based on MIMXRT1060_EVK
  • enable CPYTHON_COMPAT, PY_ASYNC_AWAIT, PY_ATTRTUPLE options

minimal port: no changes specific to this component/port

nrf port:

  • drivers/usb: add USBD_IRQHandler which calls tud_int_handler

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

rp2 port:

  • machine_adc: only initialise the ADC periph if not already enabled
  • micropy_rules.cmake: fix makemoduledefs vpath to work with abs path
  • use local tinyusb instead of the one in pico-sdk
  • enable MICROPY_PY_UBINASCII_CRC32 to get ubinascii.crc32()
  • enable VfsFat class for FAT filesystem support
  • machine_uart: add timeout/timeout_char to read and write
  • machine_uart: add support for inverted TX and RX lines
  • rp2_pio: allow more than 8 consecutive pins for PIO out/set/sideset
  • rp2_pio: fix sm.get(buf) to not wait after getting last item
  • modmachine: allow changing CPU clock frequency
  • modmachine: re-init UART for REPL on frequency change
  • rp2_flash: prevent MICROPY_HW_FLASH_STORAGE_BASE being set negative
  • enable uerrno module
  • enabled more core Python features
  • modmachine: enable machine.Signal class
  • use core-provided cmake fragments instead of custom ones
  • mpthreadport.h: cast core_state to _mp_state_thread_t
  • add support for USER_C_MODULES to CMake build system
  • don't advertise remote wakeup for USB serial
  • CMakeLists.txt: enable USB enumeration fix
  • import uarray instead of array in rp2 module
  • rp2_pio: validate state machine frequency in constructor
  • moduos: implement uos.urandom()
  • rp2_pio: add StateMachine restart,rx_fifo,tx_fifo helper functions
  • machine_uart: add buffered transfer of data with rxbuf/txbuf kwargs
  • add support for building different board configurations
  • rp2_pio: add fifo_join support for PIO

samd port:

  • mphalport: fix USB CDC tx handling to work reliably

stm32 port:

  • uart: add uart_set_baudrate function
  • mpbthciport: only init the uart once, then use uart_set_baudrate
  • mboot: add unpack-dfu command to mboot_pack_dfu.py tool
  • usb: allow a board to configure USBD_VID and all PIDs
  • make pyb, uos, utime, machine and onewire modules configurable
  • boards: disable onewire module on boards with small flash
  • mpbthciport: fix initial baudrate to use provided value
  • mpbthciport: use mp_printf instead of printf for error message
  • mpbtstackport: allow chipset and secondary baudrate to be set
  • mboot: after sig verify, only write firmware-head if latter valid
  • uart: add support for LPUART1 on L0, L4, H7 and WB MCUs
  • boards/NUCLEO_WB55: enable LPUART1 on PA2/PA3
  • enable MICROPY_PY_UBINASCII_CRC32 to get ubinascii.crc32()
  • rfcore: allow BLE settings to be changed by a board
  • storage: prevent attempts to read/write invalid block addresses
  • make-stmconst.py: allow "[]" chars when parsing source comments
  • main: fix passing state.reset_mode to init_flash_fs
  • powerctrl: save and restore EWUP state when configuring standby
  • spi: fix baudrate calculation for H7 series
  • boardctrl: add MICROPY_BOARD_STARTUP hook
  • Makefile: fix C++ linker flags when toolchain has spaces in path
  • Makefile: allow QSTR_DEFS,QSTR_GLOBAL_DEPENDENCIES to be extended
  • include .ARM section in firmware for C++ exception handling
  • powerctrl: allow a board to configure AHB and APB clock dividers
  • powerctrl: support using PLLI2C on STM32F413 as USB clock source
  • boards/pllvalues.py: relax PLLQ constraints on STM32F413 MCUs
  • mpconfigport.h: add support for a board to specify root pointers
  • boardctrl: give boards control over execution of boot.py,main.py
  • boards/NUCLEO_L476RG: add 5 remaining UARTs
  • rfcore: fix race condition with C2 accessing free buffer list
  • rfcore: intercept addr-resolution HCI cmd to work around BLE bug
  • boards: split UARTx_RTS_DE into UARTx_RTS/UARTx_DE in pin defs
  • uart: use LL_USART_GetBaudRate to compute baudrate
  • sdram: make MICROPY_HW_FMC_BA1,MICROPY_HW_FMC_A11 optional pins

teensy port: no changes specific to this component/port

unix port:

  • mpbtstackport_common: implement mp_bluetooth_hci_active
  • moduselect: don't allow both posix and non-posix configurations
  • improve command line argument processing
  • main: make static variable that's potentially clobbered by longjmp

windows port: no changes specific to this component/port

zephyr port:

  • update to zephyr v2.5.0
  • disable frozen source modules
  • remove unused build files
  • build MicroPython as a cmake target
  • boards: add support for the nucleo_h743zi board
  • modusocket: fix parameter in calls to net_context_get_XXX()