#avr #arduino #avrdude #serial-port

app waterman

A CLI tool to easily flash code onto AVR microcontrollers using avrdude, enhancing the development workflow for embedded Rust projects

1 unstable release

0.1.0 Oct 19, 2024

#132 in Embedded development

MIT license

520KB
12K SLoC

Bitbake 12K SLoC // 0.1% comments Rust 439 SLoC // 0.0% comments

Waterman πŸ’¦

crates.io page

The smoothest way to splash some Rust code into your AVR microcontrollers! πŸ¦€πŸ”Œ
Waterman is here to wrap around avrdude and make your Rust development for AVRs as easy as doing a cannonball into a pool on a hot day! πŸ’¦ And if you’re used to the Arduino IDE, this tool's got you covered with that same easy access to your target's serial console. It's like diving head-first into coding bliss.

Why Waterman?

Forget the command-line acrobatics. Waterman turns your cargo run into a one-stop shop: build, flash, run, repeat β€” like magic, but with less effort and more water! πŸ’§

Quick Fix for Serial Port Errors

Did Waterman give you an error about serial ports? No worries! If you see:

Error: no matching serial port found, use -P or set WATERMAN_PORT in your environment

Simply run cargo run with the environment variable set or adjust your .cargo/config.toml like so:

runner = "waterman {X} -cb {X} -P /dev/ttyUSB{X}" # Replace {X} with your actual values!

And you're good to dive back in!

Installation πŸ› οΈ

Before you dive into the deep end, make sure you’ve got the right dependencies!

Linux Pre-requisites:

  • Arch Linux: pacman -S systemd pkgconf
  • Ubuntu/Debian: apt install libudev-dev pkg-config
  • Fedora: dnf install systemd-devel pkgconf-pkg-config

Get Waterman Flowing πŸ’§

To install Waterman from crates.io, just run:

cargo install waterman

Or, if you're a fan of Nix and Flakes, just add:

inputs.waterman.url = "github:cyberkutti-iedc/avr-hal?dir=waterman";

and use:

waterman.packages."${system}".default

Integrating Waterman πŸ—οΈ

Time to set Waterman as your default "runner" for AVR projects! For example, if you’re working with an Arduino Uno, tweak your .cargo/config.toml (not Cargo.toml!) like this:

[target.'cfg(target_arch = "avr")']
runner = "waterman uno --open-console --baudrate 57600"

Now, every time you run cargo run, Waterman will handle building, flashing, and running your code with grace.

Running in Style πŸ’»πŸŽ‰

Here’s what happens when you type cargo run:

cargo run --bin uno-i2cdetect

You'll see Waterman work its magic in the terminal like a synchronized swimmer:

Compiling arduino-uno-examples...
Finished dev [optimized + debuginfo] target(s) in 1.26s
Running waterman uno -cb 57600 avr-hal/target/avr-atmega328p/debug/uno-i2cdetect.elf
Board: Arduino Uno 🌊
Programming: avr-hal/target/avr-atmega328p/debug/uno-i2cdetect.elf πŸ§‘β€πŸ’» => /dev/ttyACM0

avrdude: Device signature = 0x1e950f
avrdude: Flashing with style... πŸ’«
avrdude: Writing flash... Done in 0.27s!
avrdude: Verifying flash... Perfect match! 🧩

Programmed avr-hal/target/avr-atmega328p/debug/uno-i2cdetect.elf
Console: Now open at /dev/ttyACM0 (Baud: 57600) πŸ“ž

Running I2C detect tests...

License πŸ“œ

Waterman is soaked in dual licenses:

Pick whichever you prefer, just like picking your favorite pool floatie! 🌞


Now, go and make a splash with Waterman! πŸ’§

Dependencies

~7–16MB
~221K SLoC