3095 views|2 replies

1w

Posts

25

Resources
The OP
 

MicroPython 1.19 released [Copy link]

 

After a long wait, MicroPython v1.19 has been released. Here is the description of this update.

v1.19: new mpy 6 file format, improved bytecode, added Renesas-ra hardware platform

In this version of MicroPython, the .mpy file format has been significantly revised and upgraded to version 6. The new format now contains both data and bytecode that are, for the most part, organized to be static and can be run directly. To achieve this, qstr references from bytecode (and native machine code) now use a table lookup to convert local qstr numbers in the module to global qstr numbers in the runtime in which the module is executed. This means that bytecode (and most native code) do not need to be rewritten when imported. Along with this change, jump opcodes have been optimized to emit 1-byte jump offsets when possible, which is a good way to reduce bytecode size, saving RAM and reducing the size of .mpy files. The changes to the bytecode

mean that code constants (such as long strings, bytes objects, and floats) are shared and de-duplicated throughout the module, rather than having a separate constant table for each code object. The parser can also now convert constant tuples to constant objects, so the tuple does not need to be built at runtime on each use. In addition, any constant object can be used in an "X = const(obj)" statement.

With the changes to the bytecode, the size of mpy files has been reduced by about 10%, and the size of frozen .mpy code has been reduced by about 5%. Heap memory usage after import has also dropped by about 5% (if the code uses a lot of constants, more savings can be seen). Although the VM's qstr indirection performance has been slightly reduced by a few percentage points on some benchmarks, the benefits of smaller code and reduced RAM usage are considered to outweigh this. See f2040bf.

At runtime, support for multiple *args and **args in function calls has been added, following PEP 448. Builtin modules can now have (optional) mutable attributes, which is used to implement sys.ps1/sys.ps2 to allow users to customize the REPL prompt. This can be useful at times, such as configuring different REPLs for different hardware so that they can be easily distinguished. The sys module also has the MicroPython git version and build date appended to sys.version, sys.implementation._machine has been added, and sys.implementation.mpy has been renamed to sys.implementation._mpy. The sys module can now be used to fully identify the MicroPython version and the target it is running on (the platform module provides additional information when 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. Support for MICROPY_PORT_BUILTIN_MODULES has also been removed, as it is no longer used and should be replaced with MP_REGISTER_MODULE (see commit 0a92469 for an example).

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

The littlefs2 library has been updated to v2.5.0, which includes some performance improvements and minor fixes.
In the REPL, the Tab key now inserts an indent after a space, and auto-indent is automatically disabled if a space or tab follows auto-indent. This means that Python code can be pasted into the standard REPL without messing up the indentation.

mpremote has been upgraded to version 0.3.0, showing progress when copying large files and fixing recursive copying on Windows. It also adds the following commands: --help, --version, version, resume, soft-reset, umount. The

esp32 platform has a new machine.ADCBlock class and an updated ADC class. Fixes have been made to ADC2 channel mapping, low PWM frequencies, UART initialization with unspecified parameters, and RMT channels on S2/S3/C3 variants. The Pin.PULL_HOLD constant has been replaced by the "hold" keyword argument to the Pic constructor, and the pin drive capability can now be configured. I2C write-then-read transfers have been optimized and are faster. WLAN.config() now supports setting/getting txpower. Support for new development boards includes LOLIN C3 MINI ESP32-C3, LilyGO LoRa32, and UM ESP32-S3, etc.

The mimxrt hardware platform has updated nxp_driver to v2.10 and fixed USB CDC RX handling to be non-blocking. Pin driver constants have been renamed DRIVE_x to match other hardware, and a machine.I2S class has been added. New development boards include the Olimex RT1010 and MIMXRT1015_EVK. The

nrf hardware environment now includes uasyncio by default, and additional features have been enabled on the nrf52840 and nrf9160 boards to match those on the stm32, rp2, and esp32. This includes enabling the json, re, zlib, and framebuf modules.

There is a new Renesas-ra hardware platform for the Renesas RA4M1, RA4W1, RA6M1, and RA6M2 MCUs, as well as board definitions for the evaluation kits for those MCUs, and the RA4M1 Clicker. The port now supports the Pin, ADC, SoftI2C, I2C, SoftSPI, SPI, UART, Timer, and RTC classes in the machine module, as well as the VFS and internal flash file system. The

rp2 y port now has optional USB MSC support and dupterm support. The machine.UART class has added init and deinit methods, and can now use the ucryptolib module. The lwIP network stack has been integrated along with the mbedtls of 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 that uses this driver. The day of the week returned by time.localtime() has been fixed, memory corruption when creating threads on core1 has been fixed, and the UART uses a mutex when reading/writing to prevent duplicate characters in the code when using two cores. The stm32 platform 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. rfcore on the WB55 MCU has been improved to remove an extra layer of buffering and to remove restrictions on using address resolution, which means that the rfcore WS firmware needs to be updated to v1.12.0 or later; see 26b1d31. Board-level configuration of mboot has been significantly improved, allowing more control over the system clock, more hooks into the boot process, and hooks into state changes. And the CRC32 of the DFU file is verified before writing.

The pyb.CAN class has been improved to support FD frames and buses with mixed legacy/extended ID nodes, allowing extended IDs to be specified on a per-message basis. CAN.recv now also returns a value indicating whether the received message had an extended ID. And CAN.initfilterbanks has been removed in favor of a num_filter_banks keyword argument to CAN.init. These are breaking changes to the pyb.CAN class API, and code needs to be updated accordingly; see commit 5cdf964. The

unix port has had compiler information displayed in the REPL to align with how the bare-metal port works, and a "-X realtime" command-line option has been added for macOS to improve timing. Switched to using the VFS subsystem, and uses the VfsPosix class to mount the host's filesystem. The os module has been merged with all other hardware, and the minimal and standard variants gained 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 dev. And BCryptGenRandom has been used to implement os.urandom.

The zephyr platform upgrades Zephyr to v3.0.0.

The code size changes on various hardware platforms since the last release are (absolute and percentage changes 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

These numbers change because:

  • bare-arm, minimal, cc3200, samd: redesign of bytecode and mpy formats, optimization of jump opcodes to use 1-byte offsets, deduplication of constants at module level, and PEP 448 support

  • unix: switched to using VFS, and the new mpy format and related changes

  • esp8266: delete esp.info and machine.WDT.deinit

  • esp32: added machine.ADCBlock, and new mpy format changes

  • nrf: enable uasyncio, enable MICROPY_PY_IO

  • rp2: enable ucryptolib with mbedtls

Note that the size of the stm32 platform remains roughly the same. This is because it has a fair amount of frozen Python code, and the reduction in frozen code size due to the reprocessed bytecode offsets the increase in runtime/VM size due to the change. Platforms such as bare-arm, minimal, cc3200, and samd do not have any frozen code, so only see an increase in runtime/VM size. Production-level projects with a lot of frozen code have seen an overall reduction in firmware size of about 4%.

Thanks to everyone who contributed to this version : 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, Danil van de Giessen, Dave Hylands, David Lechner, Emil Kondayan, Herwin Grobben, iabdalkader, IhorNehrut sa, 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 SARIIIK, Michael Himing, Michael O'Cleirigh, Mike Teachman, 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.

Latest reply

There are a lot of contributions, this is the vitality of the community.   Details Published on 2022-6-16 18:41
 
 

7422

Posts

2

Resources
2
 

There are a lot of contributions, this is the vitality of the community.

Comments

Open Source World  Details Published on 2022-6-16 21:09
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 
 
 

1w

Posts

25

Resources
3
 
freebsder posted on 2022-6-16 18:41 There are many contributions, this is the vitality of the community.

Open Source World

 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list