PWM on alif and stm32, new machine.CAN API, t-strings and weakref module #19045
dpgeorge
announced in
Announcements and news
Replies: 2 comments
-
|
I'm always surprised by the loooong list of changes, showing how much work you did. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This release of MicroPython sees
machine.PWMsupport finally added to the stm32 port, as well as the alif port. This rounds out PWM support to all Tier 1 and Tier 2 microcontroller-based ports, making it easy to create and control PWM outputs in a consistent way.A new
machine.CANclass that has been in development for a couple of years has now been finalised in this release, with added documentation, a common set of bindings, comprehensive tests, and an implementation for the stm32 port. This is a big step forward for a consistent way to use CAN across all of the ports, and implementations for other ports will follow soon.This release also sees the addition of template strings as per PEP 750 https://peps.python.org/pep-0750/. Template strings (or t-strings) are similar to f-strings, allowing expressions within the string literal. But unlike f-strings, t-strings do not concatenate the pieces of the literal, rather they remain as separate components within a
Templateobject. MicroPython's t-strings match CPython almost exactly, except for a few minor differences (the a/ascii conversion specifier and space after a conversion specifier are not supported). Template strings are enabled at the "full feature" level, which includes the alif, mimxrt, samd (SAMD51 only) and webassembly (pyscript variant) ports.The t-string parsing code is an extension of the existing f-string parser, and in order to support nested t-string, f-strings now also support nested f-strings: f-strings within expressions within f-string literals.
Another Python feature added in this release is the
weakrefmodule withweakref.refandweakref.finalizeclasses. These classes allow registering a callback to be called when an object is reclaimed by the garbage collector. The semantics of this follow very closely the weakref semantics in CPython (except for the fact that MicroPython does not use reference counting). Due to the memory and garbage collector overhead, this module is currently only enabled on the webassembly pyscript variant, although it can be manually enabled on any port if needed.An outline of MicroPython's design values has been added to the main README. This aims to put into words some of the more intangible aspects of the project, in the hope that it will help strengthen and maintain those values moving forward. All MicroPython users and developers are encouraged to read these values, which can be found at https://github.com/micropython/micropython/blob/master/README.md#micropython-design-values
In the native emitter component, the RISC-V 32-bit emitter has a new architecture flag "zcmp" which can be enabled for RV32 targets that support compressed instructions. When this flag is enabled, Zcmp opcodes are used for function prologues and epilogues. There have also been some optimisations to generated native code, as well as added support for inline Xtensa assembler on windowed cores (like the esp32). Furthermore, it's now possible to configure MicroPython (at build time) to be able to load native code from .mpy files without having the native emitter enabled.
As usual, work has continued on the test suite, making it more robust to target failures, better able to skip tests that can't run on a target, and run consistently across a broader range of targets. All these things help maintain the high quality of the MicroPython code base.
ROM filesystem support and the VfsRom class have been enabled on a few more ports, namely: mimxrt, nrf, renesas-ra and samd (both SAMD21 and SAMD51).
The alif port sees the
alif_ensemble-cmsis-dfplibrary updated to v1.3.4, support to put external flash to sleep, and improved support for deepsleep power saving modes, with wake-up from deepsleep via a falling GPIO or RTC alarm (the latter is available by the standardtimeout_msargument tomachine.deepsleep()). As mentioned above, this port now has PWM support via the standardmachine.PWMinterface, and provides thefreq(),duty_u16()andduty_ns()methods as well as theinvertkeyword argument in the PWM constructor. There are 11 independent timers with 22 PWM outputs.The esp32 port adds a new LDO driver, and enables Zcmp opcodes, both for ESP32-P4 SoCs.
os.dupterm()reading has been improved (it's no longer necessary to callos.dupterm_notify()) and various bugs have been fixed. Support for ESP-IDF from v5.3 and up to v5.5.1 has been consolidated, and support for IDF below v5.3 has now been dropped.The mimxrt port now implements the standard
machine.Counterandmachine.Encoderclasses, and adds a few new features such as: min/max counter values, index, reset and match pins, support for cycle counting and support for IRQ callbacks. The general documentation and mimxrt quick reference has been updated to describe these additions. This port has also updated thenxp_driverSDK to MCUX_2.16.100, added PSRAM support, added support for DP83867 PHY Ethernet, and increased the resolution of the RTC from 1 second to 1/32768 seconds.The rp2 port has updated
pico-sdkto its 2.2.0 release, and as part of this switched all RNG sources from ROSC to the newpico_randcomponent. This port has also enabled Zcmp opcodes for RP2350 in RV32 mode.As mentioned above, the stm32 port now has the standard
machine.PWMclass available, which works across all 14 MCU families supported by this port. Thefreq(),duty_u16()andduty_ns()methods are available, as well as output inversion. A heuristic is used to statically assign a TIM and channel to each pin that can support PWM, and the heuristic is chosen to maximise the number of independent PWM outputs. The newmachine.CANimplementation is available on MCUs with either a bxCAN or FD-CAN peripheral, although flexible data-rates are not yet supported.New boards added in this release are:
The change in code size since the previous release for select builds of various ports is (absolute and percentage change in the text section):
The leading causes of these changes in code size are:
machine.PWMandmachine.CANclassesmachine.Counterandmachine.EncoderclassesThanks to everyone who contributed to this release: Alessandro Gatti, Algy Tynan, Alon Bar-Lev, Andrew Leech, Angus Gratton, Anson Mansfield, Antonio Galea, Artem Makarov, Chris Webb, Damien George, Daniël van de Giessen, Didier C, Dryw Wade, Elvis Pfutzenreuter, EngWill, FH, Fin Maaß, iabdalkader, Jack Whitham, Jacob Williams, Jeff Epler, jetpax, Jos Verlinde, Koudai Aono, Kwabena W. Agyeman, Matt Trentini, Matthias Urlichs, mdaeron, Michel Le Bihan, Ned Konz, Oliver Joos, Paul Grayson, Peter Harper, Phil Howard, robert-hh, stijn, sync-on-luma, Thomas Kiss, Thomas Propst, Yuuki NAGAO.
MicroPython is a global Open Source project, and contributions were made from the following timezones: -0800, -0700, -0600, -0500, -0400, -0300, +0000, +0100, +0200, +0300, +0800, +0900, +1000, +1100.
The work done in this release was funded in part through GitHub Sponsors, and in part by George Robotics, Espressif, Arduino, OpenMV, and Planet Innovation.
This discussion was created from the release PWM on alif and stm32, new machine.CAN API, t-strings and weakref module.
Beta Was this translation helpful? Give feedback.
All reactions