Zerynth Virtual Machine

Einleitung

Bei einer unserer Forschungsreisen in Richtung MicroPython kam uns kürzlich Zerynth unter. Es steht in der List of ARM Cortex-M development tools - Wikipedia neben MicroPython, bei List of Mikrocontroller Plattforms | Andreas' Blog wird es unter “Commercial Open Sourced” aufgeführt.

Es unterstützt eine Vielzahl an Hardware in Form von BSPs und Peripherietreibern und wurde scheinbar - genau wie Arduino als Marke auch [1] - mindestens teilweise in Italien auf die Welt gebracht.

Historie

Die ursprünglichen Autoren sind Daniele Mazzei, Gabriele Montelisciani, Gualtiero Fantoni und Giacomo Baldi aus dem Umfeld des FabLabPisa und der Universität Pisa, an der schon Galileo Galilei studierte und lehrte.

Zerynth wurde zur Gründungszeit um 2015/2016 herum scheinbar noch “Viper” genannt.

Abstract

The Zerynth Virtual Machine (VM) is the core of Zerynth and is a multithreaded real-time OS that provides real hardware independence, allowing code reuse on a wide range of 32-bit microcontrollers. Zerynth VM brings Python to the embedded world with support for multi-thread and cross board compatibility. Zerynth VM supports Python high-level features like modules, classes, multithreading, callback, timers and exceptions. Use custom hardware-related features like interrupts, PWM and digital I/O.

FreeRTOS Middleware for IoT & Industry 4.0 - Zerynth | Mouser Deutschland

About

Zerynth Virtual Machine (VM) is a multithreaded Real-Time OS that provides real hardware independence, allowing code reuse on a wide range of 32-bit microcontrollers, in just 60-80kB of Flash and 3-5kB of RAM.

Main features:

  • The first virtual machine tailored for embedded and IoT that supports hybrid C/Python coding
  • A tiny footprint: 60k-80kB of Flash, 3-5kB of RAM
  • Multithreaded Real-Time OS: Each Python thread is an RTOS thread managed by a priority aware real-time scheduler
  • Real hardware independence allowing code reuse on a wide range of 32-bit Microcontrollers
  • Python high-level features like modules, classes, multithreading, callbacks, timers, and exceptions, plus some all the embedded-related features like interrupts, PWM, digital I/O, ICU
  • Customizable for specific hardware solutions based on already supported microcontrollers

Description

The Zerynth Virtual Machine can run Python scripts that are board independent allowing a high reusability of code. Zerynth supports all the most used high-level features of Python like modules, classes, multithreading, callbacks, timers and exceptions, plus some hardware-related features like interrupts, PWM, digital I/O, etc.

The Zerynth VM is natively multithreaded and realtime. Indeed it is built on top of a RTOS (CHIBIOS or FreeRTOS), by wrapping its functionalities in a operative system abstraction layer (VOSAL). This means that the VM is agnostic of the underlying RTOS: porting activities are ongoing to have many VMs based on different RTOS.

The Zerynth Virtual Machine — Zerynth Docs documentation

image

Resources





  1. https://arduinohistory.github.io/ ↩︎

Weitere Details

Wenn man die Entwicklungshistorie detaillierter verfolgen will, wird man bei Release Notes — Zephyr Project Documentation fündig.

Tutorials

Ein überschaubar-kompaktes “Getting started” Tutorial findet sich bei 2018-02-21 Getting started with Python on Embedded - and Zerynth | ThingForward.

Elsewhere

Softwarelizenzen

Open Source Lizenz

Auch wenn sich im Quelltext und in den Repositories kaum Spuren dazu finden, stehen die meisten Dinge im Zerynth-Ökosystem nach kurzen Nachforschungen unter einer Apache2-Lizenz.

Daniele Mazzei berichtet allerdings bereits 2016 im Teensy Forum:

Giacomo Baldi berichtet im Zerynth Forum das gleiche.

Kommerzielle Lizenz

https://www.zerynth.com/get-started/#licensing
https://store.zerynth.com/

Differences between Zerynth and MicroPython

Luigi Cerfeda gives a summary:

Giacomo gives more details:

2 posts were split to a new topic: Viper MicroPython native code emitter

Viper/Zerynth review

By Allankliu from the Electronic Engineering World Forum.

Hardcopy attached.


Electronic Engineering World - Forum

Title: Selection outside of micropython: viper/zerynth python VM [Print this page]
Author: allankliu Time: 2016-9-13 09:05
Title: Selection outside of micropython: viper/zerynth python VM
This post was last edited by allankliu at 2016-9-13 09:05

Although this column is a micropython column, there are some things related to Embedded Python that are also prepared for inclusion in this column.

About VIPER/Zerynth

This article introduces Viper/Zerynth from Italy and the United States. The project was originally named VIPER: Viper Is Python Embedded in Realtime. Later, because the same product name was registered by another company, it was renamed to Zerynth. Personally feel that it is not as loud as it turned out. Originally an Italian company, Zerynth is based in Pisa and has a branch office in New York.

Zerynth is an easy-to-use, professional development kit designed for high-level design and cross-platform design of interactive products, art products, and Internet/networked devices. Zerynth is a development tool for interactive devices and applications based on ARM Cortex 32-bit microcontrollers, new sensors, actuators and expansion boards. Developers can take advantage of these development board hardware platforms for prototyping, productization with their scale effects and proven production lines, and rapid roll-to-market. At the same time, Zerynth helps designers to prototype prototyping software for rapid software through various programming examples and reference designs.

Zerynth uses open source design, and I have doubts about this. Later, I found that the Python code under the Zerynth Studio is kept, so it is really open source. In fact, after Zerynth was installed, there were more Python 3.4 and extension libraries in the PC, as well as the Zerynth IDE and background tools. These can all be found in the installation path, but developers need to carefully read the source code to understand the mystery.


https://docs.zerynth.com/

Target population and technical support

Zerynth’s development goals are different from micropython. The former is aimed at makers, artists, and system designers, so it provides a relatively complete tool chain. Micropython is mainly for hardware Hacker and engineers. There are overlaps, but there are differences. Zerynth claims to let developers focus on the application itself without having to entangle the underlying development with no added value, such as I/O customization, device drivers, memory management and other details for the development board. Zerynth’s built-in RTOS (FreeRTOS/ChibiOS) support, if necessary, can make full use of the underlying resources.

Micropython’s technical support is mainly based on the community, such as @dcexpert, which is used first. Zerynth relies mainly on forums and its own technical team. Probably because of knowing why I wrote books, Zerynth’s technical support has been very consistent.

  • Zerynth’s original environment was not available in the country, and after some optimizations, the forum can now be used without having to overturn the wall.
  • Zerynth’s hardware can be initialized, but user code cannot be uploaded, so Zerynth provides Ubuntu virtual machines for testing.
  • With Zerynth’s remote support, the final problem is located in the ST-Link firmware needs to be updated. And finally completed the assessment.

System composition

  • The Zerynth VM virtual machine is the core part of Zeynth, supports Python 3 scripting, and can write high-level application code that is reusable without relying on specific hardware.
  • Zerynth Studio is a dedicated development environment that develops code in the IDE that allows users to synchronize code between the local and the cloud. At the same time, the IDE can manage different hardware platforms and download different virtual machines for different hardware. However, domestic users may experience networking problems when updating the IDE.
  • The Zerynth APP is a simple app that allows users to control devices without having to write any code.
  • The Zerynth Shield is a multi-sensor expansion board that can be used on Arduino (Atmel Cortex) and Particle (STM32F103) platforms.
  • Zerynth Cloud is an implicit service that uses git to work with Studio for source management.

Zerynth Studio

Zerynth Studio is an IDE based on Python and node.js. It’s not entirely developed by Python QT/Tinker, it’s a WebKit wrapper. It covers all aspects of development, including source management (Git integration), serial terminals, compiled links, and many more. From a certain point of view, it is similar to the Arduino Processing IDE.


https://www.zerynth.com/zerynth-studio/

Target hardware

The hardware supported by Zerynth is mainly from STM/Atmel series, including STM32F401RE/STM32F103CB/SAM3X8E. Since Zerynth also has its own Cloud, APP. So the UDOO platform can support both Zerynth Python and the Zerynth Android APP.

Difference from standard Python

The Zerynth VM is a Python implementation designed for embedded devices with valuable storage and computing resources. Zerynth is a subset of Python because some features are too wasteful for embedded programming.

Python 3.4 features not supported by Zerynth:

  • There are no getattr and setattr with character arguments;
  • No more than 65,535 names (object names);
  • The function must not exceed 256 parameters, no **kwargs support;
  • Sequence/map is limited to 65535 elements;
  • Use built-in and other modules instead of standard Python libraries;
  • No closures, generators, decorators;
  • There is no eval() and compile().

Zerynth additional features:

  • Built-in real-time thread;
  • Built-in native C function call;
  • An exception is not a class, but a name with an optional error code;
  • Support for hardware-related built-in classes such as GPIO, ADC, PWM, etc.

For developers, it is valuable to be able to support the STM32F103 entry-level MCU and to share the STM32F401 development board with Micropython.
Author: dcexpert Time: 2016-9-13 09:42
This post was last edited by dcexpert at 2016-9-13 09:45

It looks very good and gives us another option, especially for MCUs like the STM32F103, which are much larger than the STM32F4. Thanks anlankliu. Author: nmg Time: 2016-9-13 09:45
Allankliu moderator appeared Author: strong161 Time: 2016-9-13 10:37
Would you like to play it! Author: Maier wind over time: 2016-9-13 11:28
Microphthon is still fainting, and it’s a big one, it’s even more dizzy. I’m still entangled in the underlying development, and I’m not working on this kind of upper-layer application development. Author: dcexpert Time: 2016-9-13 21:27
I tried it today and it didn’t work. Without the Nucleo-F401 board, you can download the virtualization firmware instead of F411, but the script can’t be downloaded. Can you give me a tutorial? Are you writing Zerynth’s book? Author: allankliu Time: 2016-9-14 07:24

Dcexpert Posted on 2016-9-13 21:27
I tried it today and it didn’t work. Without the Nucleo-F401 board, you can download the virtualization firmware instead of F411, but the script can’t be downloaded…

I have not tried the board of F411. The problem with the board of F401 is that you need to upgrade ST-LINK first, please STSW-LINK007, upgrade ST-LINK firmware. I and Zerynth’s technical support took a long time to discover the problem. Uplink does not work with ST-LINK firmware. Author: allankliu Time: 2016-9-14 08:01

Dcexpert Posted on 2016-9-13 21:27
I tried it today and it didn’t work. Without the Nucleo-F401 board, you can download the virtualization firmware instead of F411, but the script can’t be downloaded…

The F411 is not listed on the PCBA list that Zerynth officially supports, but you may try it out with 411/Qualiboard. What it supports is:

ESP8266/NodeMCU;
NUCLEO F401;
Arudino DUE, SAM3X;
Flip_Click from mikroE, based upon SAM3X;
Quali board,based upon STM32F427;
Spark/Paticle, STM32F103CB and STM32F205RG.

I will take some time to add some Zerynth tutorials every day. Zerynth’s developers are very professional and adapt quickly. But I also need to understand their business model in depth.

The Python manuscript has been delivered to the Electronics Industry Press. It took 11 months to complete, and the editor said that he still had to wait three months for the final publication. Among them, the embedded Linux virtual machine includes micropython, zerynth, and pymite over mbed as the key introduction. In addition to the MCU-level Python virtual machine, this chapter summarizes the available Python virtual machines for running environments on various types of embedded Linux. mainly includes:

  1. LFS/CLFS (Cross Linux from Scratch), cross-compilation standard CPython (most troublesome);
  2. LFS/CLFS, cross-compile pymite desktop and micropython UNIX version (very simple, but requires OS/C API adaptation)
  3. Embedded Linux, such as OpenMoko/OpenWRT, install pre-cross-compilation using a software manager (a bunch of routers are available);
  4. Embedded Linux, such as Raspberry Pi and NanoPi, install CPython using apt/yum;
  5. Embedded Linux+Java, using Jython to run Python scripts and Java programs (tested TigerJython from Switzerland on the Raspberry Pi);
  6. The full version of Linux/OS, using native GCC, often has its own CPython version and Pypy accelerated version.

Another application of Python focuses on server-side and data analysis. Because GIL and CPython are not running fast, I have evaluated pypy to run 8 times faster than CPython. Next, evaluate the use of the libuv asynchronous library in Python. It is said that the optimized speed and Golang are on an order of magnitude.

There are many topics to discuss.