- Install rustup, instructions can be found here
- Run
rustup target add aarch64-unknown-linux-gnuto enable cross-compilation - Install just by running
cargo install just - Update the
pi_hostvariable in the justfile with the local address of the pi
- Install Rasberry Pi OS x64 Lite
- During install, create a user called
sunk, or change the defined name in the justfile - Run
sudo raspi-config - Enable SSH, SPI, and I2C under
3 Interface Options - You can chagne any other settings to your preferences, with particular attention to
Localization Options
Thanks to the justfile this is rather trivial
You have the following options for easily building and syncing with the pi:
- Run
just buildto build. - Run
just syncto build and sync to the pi. - Run
just deploy-binaryto build and deploy the binary to pi. (THIS ONLY COPIES THE BINARY AND DOES NOT PERFORM A SYNC) - Run
just runto build, deploy, and run the binary on the pi. (THIS ONLY COPIES THE BINARY AND DOES NOT PERFORM A SYNC) - Run
just run-cargoto build, sync, andcargo runon the pi. - Run
just test-cargoto build, sync andcargo teston the pi.
You can pass any arguments after the commands that would be valid for the corresponding cargo command.
build, deploy-binary, and run will take in the arguments to cargo build, as that is run as part of their process
This is because run and deploy-binary build the executable on the host machine, and than copy it over for faster build times.
run-cargo and test-cargo take in the arguments to cargo run or cargo test respectively.
- Build-time variables (like
RUSTFLAGS) affect compilation and must be set when cargo compiles the code - Runtime variables (like
RUST_LOG) affect the running program and are set when executing the binary
Since the binary is built on the host machine, build-time variables must be set locally before calling just. Run-time variables can be passed to run after:
# Syntax: BUILD_ENVs just build/deploy-binary [cargo-args]
RUSTFLAGS="--cfg tokio_unstable" just build -r --features tokio-console
RUSTFLAGS="--cfg tokio_unstable" just deploy-binary -r --features tokio-console
# Syntax: BUILD_ENVs just run "RUNTIME_ENVs" [cargo-args]
RUSTFLAGS="--cfg tokio_unstable" just run "RUST_LOG=trace" -r --features tokio-consoleThese commands compile on the Pi, so both build-time and runtime variables need to be passed through SSH:
# Syntax: just run-cargo/test-cargo "BUILD_ENVs" "RUNTIME_ENVs" [cargo-args]
just run-cargo 'RUSTFLAGS="--cfg tokio_unstable"' "RUST_LOG=trace" -r --features tokio-console
just test-cargo 'RUSTFLAGS="--cfg tokio_unstable"' "RUST_LOG=trace" -r --features tokio-consoleNote: You may need single quotes around build-time variables to preserve the inner double quotes.
Logging:
More complete information on the RUST_LOG env syntax can be found here,
but the most useful option will likely be the logging level, which can be adjusted, in descending order of verbosity with with RUST_LOG=trace/debug/info/warn/error
# With pre-compiled binary
just run "RUST_LOG=debug" -r
# With cargo run
just run-cargo "" "RUST_LOG=debug" -rTokio Console (requires unstable flag + feature):
Detailed information can be found here
Generally:
- SSH into the rp5
- Install with
cargo install --locked tokio-console(this will take a while) - On the dev machine run one of the below commands to start with console output
- run
tokio-consolein the ssh instance
# With pre-compiled binary
RUSTFLAGS="--cfg tokio_unstable" just run "RUST_LOG=trace" -r --features tokio-console
# With cargo run
just run-cargo 'RUSTFLAGS="--cfg tokio_unstable"' "RUST_LOG=trace" -r --features tokio-consoleMultiple environment variables:
# Runtime only
just run "RUST_LOG=debug RUST_BACKTRACE=1" -r
# Build-time and runtime
just run-cargo 'RUSTFLAGS="--cfg tokio_unstable"' "RUST_LOG=trace RUST_BACKTRACE=full" --features tokio-consoleNo environment variables needed:
# Use empty strings for env parameters
just run-cargo "" "" -r
# Or omit them entirely
just run-cargo -r