This guide gets CircuitPython running on your custom SAMD51J20A board using PICkit5.
- CircuitPython firmware for SAMD51 (pre-built)
- PICkit5 programmer
- Microchip Studio
- USB connection to your board (for REPL access)
- Visit https://circuitpython.org/downloads
- Search for SAMD51 board that matches your hardware
- I used this one: https://circuitpython.org/board/sparkfun_samd51_micromod/
- Download the
.binor.uf2file - Save it to: c:\Projects_2025\BlackWing\Blinky\firmware.uf2
- Convert .uf2 to .bin
- Use Python script called uf2_to_bin.py
- Run it to create firmware.bin: PS Prompt> python uf2_to_bin.py
- Convert .bin to .hex
- PS Prompt> wsl arm-none-eabi-objcopy -I binary -O ihex firmware.bin firmware.hex
Output: firmware.hex
- Open Microchip Studio
- File → Open → Select
firmware.hex - Tools → Device Programming
- Tool: PICkit 5
- Device: ATSAMD51J20A
⚠️ CRITICAL: Set these parameters:- SWD Speed: 0.100 MHz
- Program Speed: LOW
- Click Program
- Wait for "Programming complete"
- blink.hex - Bare-metal C LED blink (development reference)
- firmware.hex - CircuitPython interpreter (production firmware)
- Use this for board bring-up and CubeSat mission logic
- Program via PICkit5 with 0.100 MHz SWD speed
To switch between them, just reprogram with different .hex file via Microchip Studio.
| No COM port enumeration | Custom board missing USB hardware | Verify USB D+/D- connected to SAMD51 PA24/PA25. Check schematic. | | USB not working | Wrong CircuitPython build for your board | CircuitPython needs custom board definition with USB pins configured | | Got firmware.hex from generic SAMD51 | Generic build doesn't know your custom USB pins | Need to compile CircuitPython with your board definition | Once programmed:
-
Connect your board via USB to your PC
-
Open a serial terminal:
- Option A (VS Code): Install "Serial Monitor" extension
- Option B (PuTTY): Download from https://www.putty.org/
- Option C (Thonny): Download from https://thonny.org/
-
Select COM port (check Device Manager)
-
Set baud rate: 115200
-
You should see:
Adafruit CircuitPython X.X.X on SAMD51 >>>
Type in the REPL:
>>> print("Hello BlackWing!")
Hello BlackWing!
>>> import board
>>> print(dir(board))Create code.py on your board:
# code.py - LED Blink in CircuitPython
import board
import digitalio
import time
led = digitalio.DigitalInOut(board.PA22)
led.direction = digitalio.Direction.OUTPUT
while True:
led.value = True
time.sleep(0.5)
led.value = False
time.sleep(0.5)Option A: Thonny IDE (easiest)
- Download Thonny: https://thonny.org/
- File → Open → Select
code.py - Run → Save to device
Option B: mpremote (command-line)
pip install mpremote
mpremote cp code.py :Option C: Manual drag-drop
- Connect board via USB
- If board shows as USB drive, drag
code.pyonto it - Board auto-runs code.py on boot
Create board.py in CircuitPython root:
# board.py - Custom pin definitions
import board as board_module
# Map your custom pins
LED = board_module.PA22
SENSOR_SDA = board_module.PA17
SENSOR_SCL = board_module.PA16Use in your code:
import board
led = digitalio.DigitalInOut(board.LED)PA0, PA1, PA2, PA3, PA4, PA5, PA6, PA7
PA8, PA9, PA10, PA11, PA12, PA13, PA14, PA15
PA16, PA17, PA18, PA19, PA20, PA21, PA22, PA23
PA24, PA25, PA26, PA27, PA28, PA29, PA30, PA31| Issue | Cause | Solution |
|---|---|---|
| No REPL prompt | Wrong COM port | Check Device Manager for correct port |
| "Device not found" when programming | SWD speed too fast | Set to 0.100 MHz in Microchip Studio |
| Code doesn't run | File not named code.py |
Rename to code.py |
| Import errors (no board module) | Wrong CircuitPython build | Download SAMD51-specific version |
| LED doesn't toggle | Wrong pin number | Verify PA22 or your custom pin |
- Explore CircuitPython libraries: https://circuitpython.org/libraries
- Add sensors (I2C, SPI, analog)
- Integrate with PyCubed framework
- Build your CubeSat mission logic
- CircuitPython Docs: https://docs.circuitpython.org/
- SAMD51 Datasheet: https://ww1.microchip.com/downloads/en/DeviceDoc/60001507F.pdf
- Thonny IDE: https://thonny.org/
- mpremote: https://github.com/micropython/micropython/tree/master/tools/mpremote