Einleitung
Da es mittlerweile verschiedene MicroPython Derivate gibt, wollen wir hier einen näheren Blick darauf werfen, was mit der Pycom Firmware mitgeliefert wird bzw. auf welchem Softwarestand das Pycom Ökosystem ist – sowohl hinsichtlich MicroPython als auch hinsichtlich des Espressif ESP-IDF SDKs bzw. dessen Fork GitHub - pycom/pycom-esp-idf: A fork of the Espressif IDF.
Gerade die Änderungen im Vergleich zu den Ursprungskomponenten interessieren uns, um uns einen besseren Überblick zu verschaffen, wie die Dinge zusammenhängen.
MicroPython
Die erste Ausgabe der REPL-Shell zeigt folgendes.
Pycom MicroPython 1.20.0.rc11 [v1.9.4-0a38f88] on 2019-05-14; FiPy with ESP32
Auf den Pycom Geräten hat man also ein MicroPython v1.9.4-0a38f88 zur Verfügung.
Demgegenüber wurde am 29. Mai 2019 das Vanilla MicroPython v1.11 veröffentlicht, siehe MicroPython v1.11 release notes.
ESP-IDF
Weil die Frage aufkam, wie die Schwerkraftverhältnisse im Pycom Universum sind – hier ein paar isolierte commits, die das ESP-IDF entsprechend für den Einsatz auf Pycom Geräten anpassen.
2018
2019
Diese Änderungen gehen gegen das ESP-IDF v3.2.
Interrupt handling capabilities
Introduction
Pycom’s MicroPython port introduces a significant improvement to the interrupt handling mechanism.
In Pycom’s ESP32 MicroPython port there are no restrictions on what can be done within an interrupt handler. For example, other ports do not allow allocating memory inside the handler or the use of sockets.
Description
These limitations have been relaxed by handling the interrupt events differently. When an interrupt happens, a message is posted into a queue, notifying a separate thread that the appropriate callback handler should be called. Such handler would receive an argument. By default it is the object associated with the event.
The user can do whatever is required inside of the callback, such as creating new variables, or even sending network packets. Bear in mind that interrupts are processed sequentially and thus it is ideal to keep the handlers as short as possible in order to attend all of them in the minimum time.
Currently, there are 2 classes that support interrupts; the Alarm
and Pin
classes. Both classes provide the .callback()
method that enables the interrupt and registers the given handler. For more details about interrupt usage along with examples, please visit their respective sections.
Currently, the interrupt system can queue up to 16 interrupts.
https://docs.pycom.io/firmwareapi/notes/
Review
It looks like the designers at Pycom have studied their textbooks well and took the chance to implement the concept of Tasklets and Bottom-Half Processing on top of the ESP-IDF.
The implementation in components/driver/dma.c most probably brings in this extension to the vanilla Espressif SDK, see also https://github.com/pycom/pycom-esp-idf/commit/127a49975bd11413a6be94813b394a8232b2265c.
We can’t tell whether there’s an overhead when not requiring to perform a longish task at all and if there’s a downside to this approach when it comes to eventual timing issues .