dpgeorge released this
Dec 20, 2019
· 5 commits to master since this release
This release sees a reduction in overall bytecode size due to compression of the bytecode prelude, saving 7 bytes of bytecode per function for roughly 80% of functions. The bytecode opcode values are also redefined to group them based on their argument size and format. Support is also added for the matrix multiplication operator "@" (PEP 465).
The .mpy file format moved to version 5 to support the new bytecode encoding, and added support for relocation of native machine code, along with separate rodata and BSS sections. This allows a MicroPython system to import dynamic native modules, .mpy files that are generated from C code. Examples of this feature are provided in "examples/natmod/" and documentation in "docs/develop/natmod.rst".
Some code-size saving optimisations were implemented leading to a reduction in size of minimal firmware: bare-arm reduced by 584 bytes, minimal x86 by 5476 bytes (partly due to changed compiler optimisation flags) and minimal ARM Thumb 2 by 1440 bytes (all measured with gcc 9.2.0).
A new mechanism to freeze scripts into firmware is provided - a frozen manifest - whereby scripts to freeze are listed in a Python file (eg manifest.py). All ports are updated to use this new feature.
When weak module links are enabled (via MICROPY_MODULE_WEAK_LINKS) an import will now automatically search for the built-in u-variant of a module if the non-u-variant fails (eg searches for "ufoo" if "foo" fails), so ports no longer provide an explicit list of these. The unix and windows ports now enable this feature.
A performance benchmarking test suite is added which can be used to compare changes in absolute performance when optimising features, as well as compare across different ports. See "tests/run-perfbench.py".
Bluetooth (BLE only) support is added via the "ubluetooth" module and provides the ability to implement the four BLE roles. The BLE stack is used is Mynewt Nimble and it currently runs on PYBD boards, STM32WB55 MCUs and ESP32 boards.
Support for littlefs filesystems is added through the MicroPython VFS interface, and it works on the unix, stm32, esp8266 and esp32 ports.
A new "machine.ADC.read_u16()" method is defined and implemented on stm32, esp8266, esp32 and nrf ports, providing a consistent way to read an ADC that returns a value in the range 0-65535. This new method should be preferred to the existing "ADC.read()" method.
The stm32 port sees support for the new PYBD range of pyboards which include a fully integrated CYW43xx WiFi/BT chip. USB is enhanced to support VCP+MSC+HID mode and up to 3x simultaneous VCP interfaces. Support is also added for STM32WBxx MCUs including BLE. There is a new machine.ADC class which is compatible with other ports, along with a new machine.Timer class that implements a software timer with millisecond resolution and number of active timers only limited by RAM. Support for littlefs is available by default via uos.VfsLfs2. Documentation for using littlefs is found in "docs/reference/filesystem.rst".
The esp8266 port has switched to use per-board configurations and builds, as well as the new frozen manifest feature. It also has optional littlefs support (requires a separate build).
The esp32 port has the following new features: native code generation, machine.SDCard, hardware I2C, mDNS queries and responder, esp32.Partition, esp32.RMT, BLE (requires IDF v4), and built-in support for VfsLfs2. It has switched to use per-board configurations and builds, and frozen manifests. The default SSL output buffer is resized from 16kiB down to 4kiB to save RAM.
There are new, minimal ports to Microchip SAMDxx microcontrollers, and the bare metal PowerPC architecture.
A code-of-conduct based on the PSF's code is added in CODEOFCONDUCT.md.
The following new Git submodules are added: mbedtls, asf4, tinyusb, mynewt-nimble. And a new third-party library: littlefs.
A detailed list of changes follows.
dpgeorge released this
May 29, 2019
· 10 commits to master since this release
In this release the mpy file format has been moved to version 4 and has some significant improvements: mpy file size is reduced on average by about 35%, loading time of mpy files is reduced by about 40%, and they now have support to save native, viper and inline assembler code (or machine code generated from any other source). Size reduction of mpy files was achieved by adding a qstr window to reuse past qstrs when encoding them, by packing qstrs directly in the bytecode, and by defining a static qstr set.
Some VM opcodes were also changed to fix a bug when doing a break/continue out of a finally block, and to make some simplifications. In particular POP_BLOCK and POP_EXCEPT opcodes were replaced with POP_EXCEPT_JUMP.
Most uppercase macros have been converted to lowercase to make a more consistent C API, including all MP_OBJ_IS_xxx and MP_xxx_SLOT_IS_FILLED macros.
The default PYTHON makefile variable is now changed from "python" to "python3", but Python 2 is still supported via "make PYTHON=python2".
The mpy-cross compiler supports the new mpy version 4 and has new command line options: "-march=" to select the native emitter, and "--version" to print the MicroPython version and the mpy version. Also mpy-tool.py has support for freezing native code.
A module system for external, user C modules has been implemented and documentation for this is available in the new "docs/develop" section.
All bare-metal ports have the following improvements: machine.sleep() is now machine.lightsleep(), and both lightsleep() and deepsleep() now take an optional argument which is the maximum time to sleep in milliseconds. These ports also now allow freezing of boot.py and main.py using the usual methods. And a new I2C method i2c.writevto(addr, vect) is added which can be used to write a tuple/list of buffers all at once to an I2C device.
The stm32 port now has a fully integrated Ethernet MAC driver (see the network.LAN class) using lwIP for the TCP/IP stack, and sockets were made significantly more robust. Support for F413 MCUs was added. There are also some minor user-facing changes to this port:
For the esp32 port, the build process has been updated to align better with the ESP IDF and now uses sdkconfig to configure features. Dual core mode is now enabled by default, SPIRAM is in memory-mapped mode so all of it can be used for the MicroPython heap, there is support to change the CPU frequency, and the WDT now panics and resets the device if it times out.
dpgeorge released this
Jan 25, 2019
In this release there are a wide range of improvements and additions to both the core and the ports. In the core the main improvement was to the native emitter to have much more comprehensive support for general Python features, such as generators and complex exception handling, and the generated machine code is smaller and retains its efficiency. Elsewhere, fuzzy testing was used to find and eliminate some corner-case bugs, user classes were optimised when they don't use special accessors, underscores in numeric literals are now supported (PEP515), and the uio.IOBase class was added to allow user defined streams.
For the extended modules there is now a VfsPosix filesystem component, a new ucryptolib module with AES support, addition of ure.sub() and of uhashlib.md5, and the lwIP socket implementation now has working TCP listen/accept backlog.
Compared to the last release the minimal baseline core code size is reduced by about 2.2%, down by roughly 1500 bytes for bare-arm port and 3500 bytes for minimal x86 port. Most other ports have increased in size due to the addition of new features (eg ucryptolib, ure.sub).
The stm32 port sees the introduction of a new bootloader -- mboot -- which supports DFU upload via USB FS, USB HS, as well as a custom I2C protocol, and also support to program external SPI flash. There is significant refactoring of the USB device driver, improved VCP throughput, and support for 2x VCP interfaces on the one USB device. lwIP has been integrated, and support added for SDRAM. Cortex-M0 CPUs are now supported along with STM32F0 MCUs.
For the esp8266 port the heap is increased by 2kbytes, the radio is automatically put to sleep if no WLAN interfaces are active, and the UART can now be disconnected from the REPL and its RX buffer length configured. Upon soft-reset sockets are now cleaned up.
The esp32 port has added support for external SPI RAM, PPPoS functionality, improved performance and stability when using threads, and other general bug fixes.
There is a new nrf port for Nordic MCUs, currently supporting nRF51x and nRF52x chips.
The docs have now been unified so there is just one set of documentation covering all ports. And initial documentation for the esp32 port is added.
There are two changes at the Python API level that are not backwards with previous versions:
dpgeorge released this
May 11, 2018
· 8 commits to master since this release
This release brings some significant size reductions to the parser, as well as removal of unused code and additional tests to improve coverage of the core. A new optional, internal Python stack is introduced for scoped allocation and can be used instead of alloca to provide more efficient and flexible temporary memory; see MICROPY_ENABLE_PYSTACK. There have been many improvements and internal code refactors of the stm32 port, and the port to the Espressif ESP32 SoC has been merged from its development repository.
Compared to the last release the change in code size is (in bytes, using gcc 7.3):
bare-arm: -1832 minimal x86: -2608 unix x64: -5129 unix nanbox: +1024 stm32: +2120 cc3200: -928 esp8266: +336
The decrease is mainly due to the reduced size of the parser, where the table of rule pointers was compressed to a table of offsets. The increase in the stm32 and esp8266 ports is due to additional features, such as more colour formats in the framebuf module and the addition of ujson.dump().
Code coverage (measured by gcov) has improved since the last version (v1.9.3 on the left, v1.9.4 on the right):
py: 15202/15447 = 98.4% -> 15391/15513 = 99.2% extmod: 2227/ 2363 = 94.2% -> 2291/ 2430 = 94.3%
Changes and additions seen by the Python user include: improvement of dir() and tab-completion to list all available attributes of an object; addition of efficient ucollections.deque type with fixed size; better handling and polling support of sockets that get into an error state; implementation of key and cert keyword arguments in ussl.wrap_socket (for axtls); uos.ilistdir now return 4-tuples with the file size in the fourth position.
Changes at the C level include: removal of "make_qstr_if_not_already" argument from mp_obj_new_str; rename of mp_exc_recursion_depth to mp_raise_recursion_depth; removal of mp_const_MemoryError_obj; switching of stream close operation from method to ioctl; refactoring of how native emitter code is compiled with a file per architecture.
The stm32 port has seen a lot of improvements and additions, as well as some significant internal refactoring to better support configuring custom boards. STM32F7 support is improved, USB HS is supported for F723 and F733, the CAN class has improvements to handle bus errors, ctrl-C can now interrupt running code when the REPL is over UART, and the ADC class added the read_timed_multi static method. Board configuration has seen some internal changes, in particular with setting LD_FILES, TEXT0_ADDR, and TEXT1_ADDR in mpconfigboard.mk (previously LD_FILE, FLASH_ADDR, TEXT_ADDR). The pin_X and pyb_pin_X identifiers have been changed to be pointers to objects rather than objects, and main is renamed to stm32_main.
A detailed list of changes follows. py core: