This guide is written for someone new to flashing firmware onto hardware, or needs guidance getting started with Python.
Warning
This guide was not written by a member of the Winterbloom team, but was rather contributed by a third-party trying this for the first time. If in doubt, CONTRIUBTING.md should be considered authoritative.
Assumptions:
- Access to a computer such that:
- With Windows installed, and you can use WSL, OR
- With a flavour of Linux installed, or the ability to install Linux
- Access to a black magic debug probe or similar hardware
- Access to a bench PSU or similar, and an oscilloscope or tuner to perform
the calibration.
- The PSU must be capable of outputting a range of voltages between -0.5V and 6.1V accurately
- The oscilloscope must be capable of indicating the frequency of the input.
Tip
Consult the designer's tool list for the same list of tools used when developing the module. These may be excessive for the construction and calibration of a Castor and Pollux module.
You will need a copy of the Gemini firmware.
Navigate to the latest released
firmware, and
download the file with the name containing release and the suffix uf2.
Starting from a new copy of Arch Linux (CachyOS, WSL, or archlinux.org), execute the following commands to:
- Install pre-requisite packages (list may be incomplete)
- Fetch a copy of this repository
- Move your current working directory to the repository
- Move your current working directory to the firmware source root
- Prepare a python virtual environment
- Activate the python virtual environment - this functions as an isolated environment to allow you to install additional dependencies/tooling without affecting the rest of your system.
- Install additional dependencies required for setting up the build process
- Set up the build environment - this will produce a
build.ninjafile, which you will use in the next step - Build the firmware. You should see some graphs showing memory usage and text indicating the output location.
sudo pacman -S arm-none-eabi-{binutils,newlib,gcc,gdb} python3 ninja git
git clone https://github.com/wntrbloom/Castor_and_Pollux
cd Castor_and_Pollux
cd ./firmware
python3 -m venv .
source ./bin/activate
python3 -m pip install -r requirements.txt
python3 ./configure.py
ninja # You should have a C&P firmware.elf and .uf2 at this point
Connect your fimrware flashing hardware of choice to the test points on the board.
For a Black magic probe, double check the pins using the debug header guide:
- Pin 1 (vref) - 3v3 test point
- Pin 3 (gnd) - gnd test point
- Pin 4 (swdio) - swio test point
- Pin 6 (swdclk) - swck test point
- Pin 10 (reset) - rst test point
Finally, I connected Micro-USB input power to the board's USB connector.
If you have a supported probe, flashing the fimrware should be as simple as:
cd ./factory
python3 -m venv .
source ./bin/activate
python3 -m pip install -r requirements.txt
python3 ./alt_flash.py
For me, the alt_flash.py script ran into multiple problems, so I ended up
reading the script and running it "manually".
This flashes the board with a utility that allows you to copy-paste the UF2 files to a Castor and Pollux board.
In a separate directory:
git clone https://github.com/adafruit/uf2-samdx1
cd uf2-samdx1
make BOARD=winterbloom_gemini
Run arm-none-eabi-gdb (or equivaluent for your system), and execute the
following commmands. These are based on the GDB
commands and Flashing
automation guide provided
by Black Magic.
The commands will:
- Connect to your debug probe.
- Ensure that the probe monitors the voltage.
- Scans for any connected debug probe. You should see your device listed here, if not, you probably need to check your connection to the board.
- Attaches to the first (and hopefully only) listed device.
- "This command instructs GDB to allow access to memory outside of the devices known memory map." I can't remember if I ran this, or if it had any effect.
- Load the relevant executable and transfers it to the device's memory - if the
.binfile doesn't work, try the.elf. - Verifies that the files match.
- Execute the program
- Execute the program
- Stop executing and restart.
- Close GDB.
target extended-remote /dev/ttyACM0 # Or wherever your probe is mounted
monitor tpwr enable
monitor auto_scan
attach 1
set mem inaccessible-by-default off #
load ${UF2_DIR}/build/winterbloom_gemini/bootloader-winterbloom_gemini-{...}.bin
compare-sections
start
run
kill
exit
Unplug the board, and detach the black magic probe. You should automatically get a new USB device mounted, to which you can copy-paste the UF2 C&P firmware. If the device does not appear, it may be necessary to restart your system before continuing.
In the same environment as in [#flashing-manually], iterate through the scripts
in the order as listed in alt_scripts.md,
following the instructions for each calibration step.
At this point, you should have a working and calibrated Castor and Pollux unit.