https://github.com/manafishrov/mcu-firmware
The firmware running on the Microcontroller Unit (MCU) for communication between the electronic speed controllers (ESCs) and the main firmware.
https://github.com/manafishrov/mcu-firmware
c clang dshot pico-sdk pwm
Last synced: 13 days ago
JSON representation
The firmware running on the Microcontroller Unit (MCU) for communication between the electronic speed controllers (ESCs) and the main firmware.
- Host: GitHub
- URL: https://github.com/manafishrov/mcu-firmware
- Owner: manafishrov
- License: agpl-3.0
- Created: 2025-11-23T19:11:39.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2026-05-09T08:25:04.000Z (about 1 month ago)
- Last Synced: 2026-05-09T10:32:02.963Z (about 1 month ago)
- Topics: c, clang, dshot, pico-sdk, pwm
- Language: C
- Homepage:
- Size: 214 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Microcontroller Firmware
Firmware for the Raspberry Pi Pico and Pico 2 used in the Manafish ROV to
control thrusters. It supports two runtime-selectable control protocols:
- DShot (digital ESC control)
- PWM (analog ESC control)
All development dependencies are included in the firmware environment on the
Manafish Pi, so you can develop directly on the device.
## Prerequisites
- Raspberry Pi Pico SDK (automatically fetched by CMake)
- clang-format and clang-tidy
- picotool for flashing
- arm-none-eabi-gcc toolchain
- CMake and Make
- picocom for debugging
If you have **[Nix](https://nixos.org/)** and **[direnv](https://direnv.net/)** installed:
1. Enter the directory: `cd mcu-firmware`
2. Run `direnv allow`
This will automatically download and configure the Pico SDK, ARM toolchain,
Clang tools, and CMake.
## Building and Flashing
The project uses CMake to configure the build. The Pico SDK is downloaded
automatically on first build.
### Commands
Run `make help` to list all available targets.
Key targets include:
- `make build-pico` – Build unified thruster firmware for Pico
- `make build-pico2` – Build unified thruster firmware for Pico 2
- `make flash-pico` – Build and flash unified firmware for Pico
- `make flash-pico2` – Build and flash unified firmware for Pico 2
- `make clean` – Remove build directories
- `make format` – Format source code
- `make format-check` – Verify formatting (useful for CI)
- `make lint` – Lint and auto-fix C code
- `make lint-check` – Check C code lint
### Build Output
Compiled `.uf2` files appear in:
- `build/pico/firmware.uf2` / `build/pico2/firmware.uf2`
### Flashing
Use `make flash-pico` or `make flash-pico2` for the unified firmware.
Flashing works regardless of whether the Pico is in BOOTSEL mode—the device
reboots automatically as needed.
## Debugging
The firmware outputs debug messages via USB CDC. Use a serial monitor
like `picocom` to debug:
1. Find the Pico's serial port:
```sh
ls /dev/ttyACM* # Linux
ls /dev/tty.usbmodem* # Darwin
```
2. Connect to the device:
```sh
# Linux
picocom -b 115200 /dev/ttyACM0
# Darwin
picocom -b 115200 /dev/tty.usbmodem*
```
3. Exit with **Ctrl+A**, then **K** and confirm.
## Development Hooks
Install the Git hook once per clone:
```sh
pre-commit install
```
The pre-commit hook runs clang-format on committed C/C++ files before each
commit. To run the same checks across the repository manually:
```sh
pre-commit run --all-files
```
To update hook versions later:
```sh
pre-commit autoupdate
```
## License
This project is licensed under the GNU Affero General Public License
v3.0 or later - see the [LICENSE](LICENSE) file for details.