REPL

F1 smart module pre-installed MicroPython as operating system (OS), which equips with REPL. REPL stands for Read-Eval-Print Loop which is an Interactive Interpreter Mode that allows you to input code, execute it, and immediately see the results.

Using the CtrlR Plugin, open and connect a device or use serial terminal (PuTTY, screen, picocom, etc). Upon connecting, there should be a blank screen with a flashing cursor. Press Enter and a MicroPython prompt should appear, i.e. >>>. Let’s make sure it is working with the obligatory test:

print("Hello F1!")
Hello F1!

In the example above, the >>> characters should not be typed. They are there to indicate that the text should be placed after the prompt. Once the text has been entered print("Hello F1!") and pressed Enter, the output should appear on screen, identical to the example above.

     
Basic Python commands can be tested out in a similar fashion.

If this is not working, try either a hard reset or a soft reset; see below.

Resetting the Device

If something goes wrong, the device can be reset with two methods: hard reset and soft reboot

Hard reset

By pressing the RESET button on F1 starter kit (or applying a high signal to F1 module reset signal), a reset signal is triggered to the RESET pin of F1 module. F1 module will reset itself.

Please notice that any serial/COM port connection will reset and may need to manually reconnect if auto-connect option is not enabled in CtrlR plug-in.

After reset, normal Micropython boot message will appear in the terminal of CtrlR plug-in or other serial terminals that have been connected as shown below:

Soft reboot

By pressing CTRL-D at the MicroPython prompt, which will perform a soft reset. A soft reboot message will appear in the terminal of CtrlR plug-in or other serial terminals that have been connected as shown below:

REPL control commands

In MicroPython, there are several control commands that can be used for the REPL mode as shown below.

Control commands:

CTRL-A        — on a blank line, enter raw REPL mode

CTRL-B        — on a blank line, enter normal REPL mode

CTRL-C        — interrupt a running program

CTRL-D        — on a blank line, do a soft reset of the board

CTRL-E        — on a blank line, enter paste mode

CTRL-F        — do hard reset in safeboot mode

Boot modes

There are two boot modes in MicroPython: normal boot mode and safe boot mode

Normal boot mode

Micropython searches and run boot.py during startup, and then runs main.py after boot.py if those files exist in the file system under “/” directory.

If those files are absent in the file system, Micropython will skip and continue on booting.

 

Safe boot mode

In safe boot mode, Micropython will intentionally bypass searching and running boot.py and main.py. This is a measure to boot up Micropython in case of lock-up in running boot.py or main.py.