MicroPython version 1.18 released

Announcements and news related to MicroPython.
Damien
Site Admin
Posts: 647
Joined: Mon Dec 09, 2013 5:02 pm

MicroPython version 1.18 released

Post by Damien » Mon Jan 17, 2022 1:05 am

Dear community,

We are pleased to announce the next release of MicroPython, v1.18! There were 335 commits since the last release on 2nd September 2021, so there were about 2.5 commits per day since then.

Source code and firmware can be downloaded from https://micropython.org/download/

The full change log can be found at https://micropython.org/resources/micro ... ngeLog.txt

A summary of the changes follows.

Enjoy!

v1.18: Boosted performance, board.json metadata, more mimxrt, rp2, samd features

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

Code: Select all

       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.

varylee
Posts: 7
Joined: Tue Jan 18, 2022 11:33 am

Re: MicroPython version 1.18 released

Post by varylee » Tue Jan 18, 2022 11:38 am

I found that the new 1.18 firmware has no PWM output on ESP32 and cannot be used. English is not my first language and the content comes from machine translation.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: MicroPython version 1.18 released

Post by Roberthh » Tue Jan 18, 2022 2:11 pm

Works here:

Code: Select all

>>> from machine import PWM, Pin
>>> p=PWM(Pin(18, Pin.OUT), freq=1000, duty=512)

varylee
Posts: 7
Joined: Tue Jan 18, 2022 11:33 am

Re: MicroPython version 1.18 released

Post by varylee » Tue Jan 18, 2022 4:21 pm

I see, I did not specify Pin.OUT, thank you.

varylee
Posts: 7
Joined: Tue Jan 18, 2022 11:33 am

Re: MicroPython version 1.18 released

Post by varylee » Tue Jan 18, 2022 4:44 pm

Roberthh wrote:
Tue Jan 18, 2022 2:11 pm
Works here:

Code: Select all

>>> from machine import PWM, Pin
>>> p=PWM(Pin(18, Pin.OUT), freq=1000, duty=512)
I just made the mistake of testing your code in 1.17 firmware and it works fine. After switching to 1.18 firmware, the code runs normally, but the steering gear does not react. This was the case in the beta firmware, although it looked like all 16 pins were working, there was no OUTPUT PWM signal.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: MicroPython version 1.18 released

Post by Roberthh » Tue Jan 18, 2022 5:39 pm

Which version worked for you?

varylee
Posts: 7
Joined: Tue Jan 18, 2022 11:33 am

Re: MicroPython version 1.18 released

Post by varylee » Tue Jan 18, 2022 5:55 pm

Roberthh wrote:
Tue Jan 18, 2022 5:39 pm
Which version worked for you?
Two days ago, there was only version 1.17. When I was working on my project, I found that some of the 16 pins given in the document could not be used. I tested one by one and found that only 8 pins could be used, but I needed more pins. So I tested the beta, the beta, and the beta had 16 pins, but no PWM output. I'm glad to see version 1.18 today, but unfortunately, like the beta, there is no PWM output. The code is as you gave it, the hardware has not changed at all, 1.17 works, not 1.18. But I need more than 8 PWM outputs.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: MicroPython version 1.18 released

Post by Roberthh » Tue Jan 18, 2022 7:07 pm

The most recent daily builds do not differ much from the version v1.18. Just consider V1.18 as the daily build of January 17, 2022. Between V1.17 and v1.18 was a major change in the PWM module. I am pretty sure that is it working, However, the way it hast to used may have changed somewhat. Which ESP32 module do you use, and can you show the part of your code that activates PWM?

heromed
Posts: 1
Joined: Thu Sep 07, 2017 6:28 am
Location: Australia

Re: MicroPython version 1.18 released

Post by heromed » Tue Jan 18, 2022 11:21 pm

I just run some I/O tests on ESP32-WROOM-32 using V1.18

The test wrote/read 1000 variable-length text lines between 34 and 42 characters.

The write operation using 1.18 was 11% SLOWER than 1.17

The read operation using 1.18 was 21% SLOWER than 1.17

???

varylee
Posts: 7
Joined: Tue Jan 18, 2022 11:33 am

Re: MicroPython version 1.18 released

Post by varylee » Wed Jan 19, 2022 2:51 am

Roberthh wrote:
Tue Jan 18, 2022 7:07 pm
The most recent daily builds do not differ much from the version v1.18. Just consider V1.18 as the daily build of January 17, 2022. Between V1.17 and v1.18 was a major change in the PWM module. I am pretty sure that is it working, However, the way it hast to used may have changed somewhat. Which ESP32 module do you use, and can you show the part of your code that activates PWM?
Hardware is a common ESP32 development board, MCU is ESP-32-D0WDQ6, code exactly copy your code: from machine import PWM, Pin
P = PWM (Pin (23, Pin OUT), freq = 50, duty = 66)
My steering gear is connected to Pin23. I have tried the frequency and duty cycle of other pins, but there is no response.

Post Reply