Immortals robot firmware for the Robocup Soccer Small-Size League, split across three targets:
- cm4 — C++ program running on the Compute Module 4
- cm4-gui — Dear ImGui GUI application running on the CM4's DSI display
- rp2040 — firmware running on the on-board RP2040 microcontroller
sudo apt install cmake git libzmq3-dev libprotobuf-dev protobuf-compilerA C library for accessing GPIO on the Raspberry Pi.
sudo apt install python3-setuptools
git clone https://github.com/joan2937/pigpio
cd pigpio
make
sudo make installsudo apt install libsdl2-dev libgles2-mesa-devsudo apt install python3 build-essential gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib openocdClone the Pico SDK and point PICO_SDK_PATH to it:
git clone https://github.com/raspberrypi/pico-sdk /path/to/pico-sdk
echo 'export PICO_SDK_PATH=/path/to/pico-sdk' >> ~/.bashrc
source ~/.bashrcAdd the following:
# Power button
dtoverlay=gpio-shutdown,gpio_pin=3
dtoverlay=gpio-poweroff,gpiopin=4,active_low=1
# DSI display
dtoverlay=vc4-kms-dsi-7inch
To allow the CM4 to receive logs from the RP2040 over UART, the serial port hardware must be enabled and the login shell over serial must be disabled. Run sudo raspi-config and navigate to Interface Options > Serial Port:
- Would you like a login shell to be accessible over the serial? → No
- Would you like the serial port hardware to be enabled? → Yes
Run sudo raspi-config and navigate to Advanced Options > WLAN Power Save:
- Would you like to enable WLAN power saving? -> No
cd cm4 # or rp2040, or cm4-gui
cmake --preset debug # or release
cmake --build --preset debugBuild output is placed in out/.
Build first, then run the deploy script from your dev machine:
bash scripts/deploy.sh <robot-host>This copies the binaries to the robot and installs/restarts firmware-cm4 and cm4-gui as systemd services. Both services start at boot automatically.
To install locally on the robot itself:
sudo bash scripts/install.shFlashing is done via SWD using OpenOCD. This also resets the chip immediately after flashing:
openocd -f interface/raspberrypi-swd.cfg -f target/rp2040.cfg \
-c 'program out/firmware-rp2040.elf verify reset exit'For code completion and diagnostics, install clangd:
sudo apt install clangdThen configure each CMake project you want to work on by running the appropriate preset from the Building section. This generates the compile_commands.json file that clangd uses to understand the project.
If using Zed, the following tasks are available via the command palette (task: spawn):
| Task | Description |
|---|---|
cm4: configure debug / cm4: configure release |
Configure cm4 build |
cm4: build |
Build cm4 |
cm4: build and run |
Build cm4 and run it |
cm4-gui: configure debug / cm4-gui: configure release |
Configure cm4-gui build |
cm4-gui: build |
Build cm4-gui |
cm4-gui: build and run |
Build and launch the GUI app |
rp2040: configure debug / rp2040: configure release |
Configure rp2040 build |
rp2040: build |
Build rp2040 |
rp2040: build and flash |
Build and flash via SWD, then reset |
rp2040: Reset |
Reset the chip via SWD |
deploy: install local |
Install and restart services on this machine |