Belay also supports CircuitPython. Unlike MicroPython, CircuitPython automatically mounts the device's filesystem as a USB drive. This is usually convenient, but it makes the filesystem read-only to the python interpreter. To get around this, we need to manually add the following lines to on-device.

import storage


Afterwards, reset the device and it's prepared for Belay.


To revert this configuration, there are multiple options:

  1. Edit using Thonny, then reboot. Thonny (like Belay), operates via the REPL, so it has write-access since it's operating through circuitpython.

  2. Through circuitpython's REPL via an interactive shell, such as rshell or python -m

import os

  1. Using Belay in an interactive python prompt on host:

from belay import Device

device = Device("/dev/ttyUSB0")  # replace with appropriate port
# Then reboot.

Physical Configuration

Storage mounting can be configured based on a physical pin state. Adding the following contents to / will configure the system to:

  • Be in "normal" circuitpython mode if pin 14 is floating/high (due to configured pullup) on boot.

  • Be in Belay-compatible mode if pin 14 is connected to ground on boot. This could be done, for example, by a push-button or a toggle switch.

import board
import storage
from digitalio import DigitalInOut, Pull

op_mode = DigitalInOut(board.GP14)  # Choose whichever pin you would like

if not op_mode.value:
    # Mount system in host-readonly, circuitpython-writeable mode (Belay compatible).