Skip to content

v0.1.0

Choose a tag to compare

@rplunger rplunger released this 03 Jun 21:04
· 2 commits to main since this release
84e9036

v0.1.0 — Initial Release

cargo device is a Cargo subcommand that unifies cross-compilation, deployment, and remote execution of Rust projects on embedded Linux devices. Define your devices once in .cargo/config.toml, then build, deploy, and run with a single command.

Commands

  • cargo device build <device> — cross-compile for the target device
  • cargo device run <device> — build, deploy via rsync, and run on the device with stdout/stderr streamed locally
  • cargo device sync <device> — rsync directories to the device without building
  • cargo device list — print a table of all configured devices

Configuration

Devices are defined in .cargo/config.toml and committed to git. Machine-specific overrides (IP address, SDK path) live in .cargo/device.local.toml, which stays gitignored.

[device.raspi]
target      = "aarch64-unknown-linux-gnu"
linker      = "aarch64-linux-gnu-gcc"
ssh_host    = "pi@192.168.1.42"   # override in device.local.toml
deploy_path = "/tmp/myapp"
sync_dirs   = ["models/", "config/"]

Build backends

Configuration Backend
sdk defined Source SDK env script (Yocto/Buildroot), then cargo build
linker defined Set CARGO_TARGET_*_LINKER, then cargo build
Neither cross build fallback (requires Docker)
desktop / no target Plain cargo build / cargo run

Workspace support

Set package (and optionally binary) on the device config to target a specific crate in a workspace. cargo device injects -p <package> automatically.

Remote binary arguments

Pass cargo flags before --, binary arguments after:

cargo device run raspi --release -- status --verbose

Other highlights

  • --verbose / -v flag for debug-level tracing (respects RUST_LOG)
  • deploy_path is created automatically on first deploy (ssh mkdir -p)
  • ~ expanded in deploy_path and ssh_key
  • Shell-escaped SSH commands — safe with spaces and special characters in paths
  • features and no_default_features fields on device config

Installation

cargo install cargo-device

Requires ssh and rsync on the host. See the README for system dependency details and configuration examples.