Skip to content

Immortals-Robotics/MainBoardFirmware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

187 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Immortals Firmware

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

Prerequisites

Common

sudo apt install cmake git libzmq3-dev libprotobuf-dev protobuf-compiler

cm4

pigpio

A 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 install

cm4-gui

sudo apt install libsdl2-dev libgles2-mesa-dev

rp2040

sudo apt install python3 build-essential gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib openocd

Clone 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 ~/.bashrc

CM4 Setup

/boot/firmware/config.txt

Add 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

Serial Port

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

WLAN Power Saving

Run sudo raspi-config and navigate to Advanced Options > WLAN Power Save:

  • Would you like to enable WLAN power saving? -> No

Building

cd cm4      # or rp2040, or cm4-gui
cmake --preset debug    # or release
cmake --build --preset debug

Build output is placed in out/.

Deploying (cm4 + cm4-gui)

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.sh

Flashing (rp2040)

Flashing 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'

IDE

clangd

For code completion and diagnostics, install clangd:

sudo apt install clangd

Then 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.

Zed Tasks

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

About

Immortals robot firmware for the Robocup Soccer Small-Size League

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages