Setup and build
maritime is a Zephyr application in a T2 workspace.
The repository is the west manifest, and west checks Zephyr out at a specified version next to it. Read the workspaces documentation for more information.
The only board currently supported is rpi_pico.
Prerequisites
Section titled “Prerequisites”The installer is written for Ubuntu on x86_64 or aarch64. Debian should also be supported, as it also uses apt, but it has not been tested. The installer does not currently support other Linux distributions, Windows, or macOS.
First-time setup
Section titled “First-time setup”In the directory that should hold the workspace (do not clone the repository, the installer does):
curl -sSL https://raw.githubusercontent.com/avbotz/maritime/refs/heads/main/install.sh | bashinstall.sh:
- Installs the build tools and other necessary utils with
apt. - Creates
maritime-workspace/, with a Python virtual environment inmaritime-workspace/.venv, and clones maritime into it. - Installs west, then runs
west init -l .andwest update, which check out Zephyr at the revisionwest.ymlpins and downloads the modules the RP2040 build uses. - Installs Zephyr’s Python packages (
west packages pip --install), and the Zephyr SDK’s Arm toolchain (west sdk install -t arm-zephyr-eabi). - Installs
dts-linter, at the version Zephyr pins, forformat.sh. - Installs a git pre-commit hook that runs
./format.sh --check.
The workspace it leaves:
maritime-workspace/├── .venv/ # Python, with west and pyserial├── .west/ # west's configuration├── zephyr/ # Zephyr, at the revision west.yml pins├── modules/ # cmsis_6, hal_rpi_pico└── maritime/ # this repositoryBuilding
Section titled “Building”In every new terminal, from maritime/:
source ./setup.sh # activates ../.venvThen:
west build -b rpi_picoThe built firmware is located in build/zephyr, specifically build/zephyr/zephyr.uf2.
Debug build
Section titled “Debug build”west build -b rpi_pico -- -DEXTRA_CONF_FILE=debug.confdebug.conf turns logging on. The logs are sent over the same USB link as the protocol, between frames. maritime.py prints them as board: ... lines, but thalassic’s sub_low does not expect them, so don’t run a debug build with thalassic (Logging). Build from scratch (west build -p -b rpi_pico) when switching between a debug build and a normal one.
Flashing
Section titled “Flashing”The RP2040 is flashed from its UF2 bootloader, in its boot ROM, where it shows up as a USB drive named RPI-RP2. To put the board in this mode:
- With maritime running, run
./maritime.py bootloader. This command reboots the board into the bootloader. - Or, unplug the board, then hold its BOOTSEL button while plugging it back in, then release the BOOTSEL button.
Then:
west flash -r uf2which copies build/zephyr/zephyr.uf2 to the drive. The board reboots into the new firmware once the copy finishes and starts killed. The kill switch must be cycled before the thrusters can be used (Kill switch).
Without a desktop to mount the drive (on the Jetson for example), ./mount_pico.sh mounts it at /mnt/rpi_pico, after which west flash -r uf2 can find it and use it as normal.
Formatting
Section titled “Formatting”./format.sh # format C and devicetree, and report checkpatch issues./format.sh --check # change nothing and fail if anything needs fixingformat.sh formats C with clang-format (.clang-format, Zephyr’s style) and devicetree with dts-linter, then checks the C with Zephyr’s checkpatch.pl (settings in .checkpatch.conf). Checkpatch’s issues, such as // comments, have to be fixed by hand.
The pre-commit hook runs ./format.sh --check. Pre-commit hooks are used to ensure compliance with the project’s coding standards. In this case, they are used for compliance with formatting rules. Running git commit --no-verify will skip the pre-commit hook. For a clone made before the installer added the hook:
npm --prefix ../zephyr/scripts/ci ciprintf '#!/bin/sh\nexec ./format.sh --check\n' > .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit.github/workflows/ci.yml runs on every pull request and every push to main:
| Job | Does |
|---|---|
format |
runs ./format.sh --check and ensures compliance with formatting rules |
build |
runs west build -b rpi_pico and uploads generated zephyr.uf2 |