New psoc-edge port, CAN on alif and mimxrt, mem_backup, manifest c_module #19648
Replies: 3 comments 2 replies
|
Will the esp32 machine.CAN module comes out in next v1.30 release? |
|
Disallowing "UTF8" in |
|
Any chance of collapsing the 2 regions and rendering |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Overview
This release of MicroPython adds a new "psoc-edge" port for Infineon PSOC Edge microcontrollers. This is a bare-metal port using CMSIS 6 and a set of low-level HAL submodules from Infineon's Modus Toolbox. It uses the standard ARM toolchains and builds with make. It currently supports a UART REPL, a filesystem (using QSPI flash), machine Pin, UART and RTC classes, including IRQs for Pin and UART. There is currently one supported board, the KIT_PSE84_AI.
The previous v1.28.0 release introduced a new
machine.CANAPI with an implementation for the stm32 port. This release implements that API on both the alif and mimxrt ports. Much effort went into making sure these three ports have the same consistent behaviour when using CAN, so that reliable applications can be built upon that API.Also in this release is a new
machine.mem_backup()interface which gives consistent access to backup memory on the alif, esp32, mimxrt, nrf, rp2, samd and stm32 ports. Calling this function returns a writablememoryviewthat survives (in most cases) a hard reset. The available regions can be discovered viamachine.mem_backup(-1). See the documentation for more details and examples: https://docs.micropython.org/en/latest/library/machine.html .Configuring a custom build with user C modules is now a lot simpler thanks to the addition of the
c_module()function to the manifest API. This function lets a manifest file declare which user C modules should be included in the build. They are declared alongside the declaration of frozen modules, making it much easier to configure firmware with extensions. For example, amanifest.pyfile containing:will freeze in the networking bundle from micropython-lib, freeze in custom Python code, and include the micropython-ulab C library in the build. This
c_module()feature is intended to replace the existingUSER_C_MODULESoption (although it currently works together with that option).Unicode support is improved in this release:
bytes.decode()and three-argumentstr()now support "strict", "ignore" and "replace" for the errors argument;str.center()is fixed so it handles Unicode characters correctly;A USB network (Network Control Model, NCM) driver implementation has been added, providing Ethernet-over-USB backed by the lwIP stack, available to Python through the new
network.USBD_NCMclass. With this enabled, the host computer sees the MicroPython device as a USB Ethernet adapter, and the host is assigned an IP address via DHCP (served by the MicroPython device). Python code on the device can then use all the usual networking facilities to communicate with the host. It's disabled by default, and needsMICROPY_PY_NETWORK_USBD_NCMenabled in a custom build.The parser now recognises const assignments with type hints, for example
_X: int = const(123). There is now support forbytes.find(int)as well asint.to_bytes()with argumentsigned=True. The RISC-V inline assembler adds support for Zcmp opcodes and has improved register allocation. The LoongArch64 architecture is now supported and that is tested as part of CI.Native .mpy modules built via
mpy_ld.pynow automatically includememset,memmoveandmemcpyin the linking stage so these no longer need to be manually provided. Native modules can also now be built with Clang.The mbedTLS component is updated to v3.6.6, and support is added for TLS-PSK (pre-shared key) in the
SSLContextclass. Parsing of PEM certificates is also enabled for all ports using mbedTLS. LittleFS is updated to v2.11.3, TinyUSB to 0.21.0, and CMSIS v6.3.0 is now used in the mimxrt, nrf, psoc-edge, samd and stm32 ports.Mpremote adds an alias for codeberg repositories, and fixes Unicode errors on Windows as well as some other minor bugs. It also implements incremental preparation for ROMFS deployment, allowing large partition sizes without a timeout.
The alif port implements
machine.CAN,machine.WDTand the timeout argument tomachine.lightsleep(). It also implements the five states ofmachine.reset_cause().The esp32 port updates the IDF to v5.5.2 and adds support for ESP32-H2 chips along with two new board definitions. ESP-NOW is updated to v2.0, a new
machine.wake_pins()function is added, mDNS is enabled on the Ethernet interface, the LDO is configurable from the SDCard constructor, and virtual timers are now supported viamachine.Timer(-1). A new CSI (Channel State Information) API is exposed via new methods on theWLANobject, allowing access to per-packet physical layer channel data. See documentation and some examples at: https://docs.micropython.org/en/latest/library/network.WLAN.html .The mimxrt port implements
machine.CANand configures it for all boards that break out a CAN peripheral. It improves event handling andtime.sleep(0), fixes flash erase operations on Hyperflash boards, and fixes SDCard caching issues.The nrf port updates the nrfx library to v3.14.0 (up from v2.0.0), modernises
Pin.irq, adds the I2C timeout argument, and changessys.platformto "nrf" for all boards for consistency.The rp2 port updates pico-sdk to 2.3.0, refactors the linker scripts, adds support for DMA pacing timers via the
rp2.DMATimerclass, enablesnetwork.PPPon all boards that have networking enabled, and fixes watchdog interactions withmachine.lightsleep().The samd port adds
adc.read_timed()anddac.write_timed()methods, and fixes handling of some UART IRQ events.The stm32 port adds
pulse_width_us()andpulse_width_ns()methods to theTimerChannelclass, adds themachine.SDCardclass (alias of the existingpyb.SDCard), and implements the WWDG watchdog peripheral (in addition to IWDG) with up to four watchdogs on STM32H7. There is now support for FDCAN on the STM32N6, along with significant improvements tonetwork.LANactivation, link detection and hot-plug support. There is also a fix for SDCard caching issues.The unix port adds the
sendall()method to the socket class, and has better support for FreeBSD.The zephyr port updates Zephyr to v4.4.0, adds support for user C modules, and the I2C driver is reworked to make continuous transactions (rather than a separate write followed by a read).
Thirteen new boards are added in this release:
Breaking changes
MicroPython now validates the encoding argument to
str.encode()andbytes.decode()(along with the corresponding constructors), and only "utf-8", "utf8" and "ascii" are accepted. In particular, "latin-1" is not supported, and neither are uppercase variants like "UTF8". The previous behaviour for an unsupported encoding was to silently pass through the data using "utf8" encoding, but MicroPython will now raise aLookupErrorexception. Affected code should be changed to use a supported encoding.The MICROPY_FORCE_32BIT flag has been removed from the unix port. Instead, 32-bit x86 is now treated as a cross-compilation target. See the unix port README for more details.
For the esp32 and stm32 ports the
machine.SDCard.readblocks()and.writeblocks()methods now return 0 for success and a negative integer for failure. They previously returned a bool with True for success, so the logic is essentially reversed and affected code should be updated.For the nrf port all boards have been consolidated to use "nrf" for their
sys.platformvalue. Some boards previously used custom names here, such as "nrf51-DK" and "nrf52", but they are all just "nrf" now. All code usingsys.platformon nrf boards needs to be updated.The powerpc port was removed and its functionality merged into the qemu port.
For the stm32 port, on boards with Cortex-M33/M55 MCUs, peripheral register naming in the
stmmodule has been changed such that the constants no longer end in _S or _NS. For example, previously bothstm.RTC_Sandstm.RTC_NSwere provided but they are now removed and replaced by the singlestm.RTC. The value of the constant (e.g.stm.RTC) is chosen as the _S or _NS peripheral address depending on whether the firmware is built in secure or non-secure mode, respectively.Also on the stm32 port, the PRNG implementation of
rng_get()has been removed, and this function renamed tomp_hal_get_hw_random_u32()to make it clearer what it does.Firmware size
The change in code size since the previous release for select builds of various ports is (absolute and percentage change in the text section):
These size changes provide a good summary of the changes and additions in
the firmware itself. Some of the things responsible for these changes are:
int.to_bytes(signed=True);bytes.find(int);bytes.decode()"ignore" and "replace", and validation of encoding mode;machine.mem_backup()to most ports;machine.CANsupport on alif and mimxrt ports;requestsmodule now supporting HTTP/1.1 on network boards;asyncioon the nrf port;adc.read_timed()anddac.write_timed()on the samd port;pulse_width_us()andpulse_width_ns()on the stm32 port.Acknowledgements
Thanks to everyone who contributed to this release: Alessandro Gatti, Amirreza Hamzavi, Andrew Leech, Andrii Anoshyn, Angus Gratton, Anson Mansfield, Antonio Galea, Calin Faja, Carl Pottle, Charalampos Stratakis, Chris Mason, Cristian Dinca, Damien George, Dan Halbert, Daniël van de Giessen, David (Pololu), Denis Dowling, Dryw Wade, Duncan Lowther, EngineerWill, Fin Maaß, Finn Glas, Francesco Pace, Frédéric Pierson, Harris, Howard Lovatt, Hugo Frisk, iabdalkader, Ihor Nehrutsa, Jacob Peck, jaenrig-ifx, Jeff Epler, Jeongseop Lim, jetpax, Jim Lipsey, Jim Mussared, Joel Stanley, Jon Nordby, Jos Verlinde, Josip Šimun Kuči, Julia Vassiliki, Keenan Johnson, Kwabena W. Agyeman, Luca Burelli, MarcelloTheArcane, massimosala, Matt Trentini, Meir Armon, Mikhail Zakharov, Mo Nazemi, Mrpli, Ned Konz, Nicko van Someren, npt-1707, o-murphy, Owen, Pavel Revak, Phil Howard, phuzzyday, Pierre Gaufillet, radiofan, Rafal, Rafal Wadowski, Rick Sorensen, rmouro_QCOM, robert-hh, Roman Zeyde, Sandor Attila Gerendi, Tomasz Cwik, Vdragon, vlad.maglasu, Weixie Cui, William Vinnicombe, Yanfeng Liu, Yuuki NAGAO.
And thanks to additional contributors to micropython-lib: Daniel Houck, Greg Darke, Hagb Green, John Moser, kolten, Mark A. Ziesemer, Max Holliday, Michael Bentley, Mike Cifelli, Mr Keuz, Naidile, Pablo Ventura, PermissionDenied7335, puuu, scivision, Stefan, tharuka-pavith, trevor.
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, +0330, +0530, +0700, +0800, +0900, +0930, +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 New psoc-edge port, CAN on alif and mimxrt, mem_backup, manifest c_module.
All reactions