In this Section

↩ Return Home

↩ Return to Resources

As we learned in Software & Firmware, PyCubed runs CircuitPython, a Python3 interpreter for microcontrollers. CircuitPython is open source and actively developed: https://github.com/adafruit/circuitpython, and PyCubed is apart of the main branch of CircuitPython.

If you're just looking how to update the bootloader or firmware, see Updating PyCubed

Building CircuitPython Yourself

What are some reasons to compile CircuitPython (CP) when it's already done for you (above)?

  1. You've forked the pycubed hardware repo, added custom features, and want to change firmware pin assignments (for example).
  2. You want to implement some super cool low-level C++ function and be able to call it from Python.

How to get started

Adafruit has put together an excellent guide on how to build CP from source:

https://learn.adafruit.com/building-circuitpython

  1. Once you're ready, you'll use the following commands to build the PyCubed firmware:

    cd ports/atmel-samd
    make BOARD=pycubed
    
  2. If your build was successful, retrieve the firmware.uf2 file from /circuitpython/ports/atmel-samd/build-pycubed directory. Then put your board into bootloader mode and copy the firmware.uf2 file onto the PYCUBEDBOOT drive.

    See the PyCubed tutorial on 🛠 Flashing the Firmware for more complete instructions.

PyCubed definition files

There are simple aspects aspects about the CircuitPython build we can change when compiling our PyCubed board. The build definition files are in /circuitpython/ports/atmel-samd/boards/pycubed. There are 4 files:

  1. mpconfigboard.h

    Low-level micropython definitions for the SAMD microcontroller and off-chip flash info

  2. mpconfigboard.mk

    Specifies which CircuitPython features we want to enable/disable

  3. board.c

    Any custom C++ code that you want to run when alongside the Python VM. This is where we start the Using the External Watchdog Timer pulse activity.

  4. pins.c

    Defines the Python names used to access microcontroller pins