In this Section
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.
<aside> 📢 If you're just looking how to update the bootloader or firmware, see Updating PyCubed
</aside>
What are some reasons to compile CircuitPython (CP) when it's already done for you (above)?
Adafruit has put together an excellent guide on how to build CP from source:
⭐ https://learn.adafruit.com/building-circuitpython
Once you're ready, you'll use the following commands to build the PyCubed firmware:
cd ports/atmel-samd
make BOARD=pycubed
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.
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:
mpconfigboard.h
Low-level micropython definitions for the SAMD microcontroller and off-chip flash info
Specifies which CircuitPython features we want to enable/disable
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.
pins.c
Defines the Python names used to access microcontroller pins