MyGit

v1.19

micropython/micropython

版本发布时间: 2022-06-16 14:19:58

micropython/micropython最新发布版本:v1.23.0(2024-05-31 13:03:47)

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:

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:

py core:

extmod:

shared:

drivers:

mpy-cross:

lib:

Support components

docs:

examples:

tests:

tools:

CI:

The ports

all ports:

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

cc3200 port:

esp8266 port:

esp32 port:

javascript port:

mimxrt port:

minimal port: no changes specific to this component/port

nrf port:

pic16bit port:

powerpc port: no changes specific to this component/port

qemu-arm port:

renesas-ra port:

rp2 port:

samd port:

stm32 port:

teensy port:

unix port:

windows port:

zephyr port:

相关地址:原始地址 下载(tar) 下载(zip)

1、 micropython-1.19.tar.xz 68.92MB

2、 micropython-1.19.zip 132.96MB

查看:2022-06-16发行的版本