Micropython-main-boot

From pymate.io wiki
Jump to navigation Jump to search

Startup Sequence

When powered up, the PymateIO initialize the MicrPython virtual machine which executes the following steps.

Micropython-startup.png

Virtual Machine Initialization

Among the various initialization tasks, the MicroPython virtual machine will open the USB-Serial communication channel.

The USB-Serial is defined as standard input & standard output (usually named stdin & stdout).

The virtual machine starts and REPL is attached to the standard input/outpout (so the USB-Serial).

From now, any print() statement and errors will be reported to the USB-Serial.

boot.py script

Loading the boot.py is the first operation performed by the virtual machine.

The virtual machine jump to the next step if the file is not available.

The role of the boot.py script is to perform a quick hardware initialization at startup.

It is also a good place to mount additionnal file systems.

The boot.py script should be short and executes its content as fast as possible. The MicroPython virtual machine will stays locked as long as the boot.py have not terminated its processing.

Remarks:

  • Interacting with MicroPython is almost impossible during the processing of boot.py .
  • When using tools like Thonny, MPRemote, etc then boot.py execution time will be added to each connection attempt.

main.py script

The main.py script is the file containing the user program to execute at startup.

If the file is missing or script produce an error then the virtual machine jump to the next step (interactive REPL session).

REPL session

xxx