Make sure you have Rust installed:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
You might want UPX installed to compress the binary depending on your target. Your distribution's repos should provide it, e.g. sudo apt install upx
.
I've optimized for size a best as I can. Remaining wishes are: gnutls
or mbedtls
support through FFI instead of shipping rustls
. This would save space in the binary.
Currently GitHub actions are building binaries targeting three devices/use cases:
- Alpine Linux containers running
musl-x86_64
ormusl-arm64
(with native TLS, system logging, and postgres) - Beaglebone Blacks running an Ubuntu distribution for the
gnueabihf-armv7
platform (with Rust TLS, debug logging to stdout, and postgres)
These builds should not require Rust to be installed, and should only require a valid config at /etc/meshtastic_telem.toml
with an accessible Postgres database running.
cargo build --features debug
cargo build --features release --release
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUSTFLAGS="-Zlocation-detail=none -Zfmt-debug=none" cross +nightly build --features rustls,postgres,syslog --no-default-features --release --target aarch64-unknown-linux-gnu -Zbuild-std-features=optimize_for_size,panic_immediate_abort
CARGO_TARGET_x86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-Zlocation-detail=none -Zfmt-debug=none" cross +nightly build --features alpine --no-default-features --release --target x86_64-unknown-linux-musl -Zbuild-std-features=optimize_for_size,panic_immediate_abort
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-Zlocation-detail=none -Zfmt-debug=none" cross +nightly build --features alpine --no-default-features --release --target aarch64-unknown-linux-musl -Zbuild-std-features=optimize_for_size,panic_immediate_abort
You must have cross installed with all its dependencies. Unless you are building natively on MIPS
.
CARGO_TARGET_MIPS_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-Zlocation-detail=none -Zfmt-debug=none" cross +nightly build --features rustls,postgres,syslog --no-default-features --release --target mips-unknown-linux-musl -Zbuild-std-features=optimize_for_size,panic_immediate_abort
# Then compress the executable further with upx
upx --brute target/mips-unknown-linux-musl/release/meshtastic-telemetry-daemon-rs
Sometimes, running a cross compile after a normal compile will fail spitting out some errors about GLIBC
versions. This is most likely due to build caching of some sort (I am not entirely sure). If you just run cargo clean
and then re-run the cross compilation command above it should work.
This is not recommended due to MIPS
devices typically having little free disk space and the debug binary being large.
To run the debug version (native TLS, postgres, and logging to stdout):
cargo run
This will use the example_config.toml
file provided in the root of this repository.
Then specify the serial device connected via USB when prompted.
If you want to see Meshtastic packets as json
output add --features print-packets
to the above command.
Run the release version with:
cargo run --features alpine --no-default-features --release
But this is also not recommended due to logs going straight to journalctl
or wherever your system logs things by default.
To view documentation on this, run the following after you install Rust and clone this repo:
cargo doc --features alpine --release --no-deps --document-private-items --open
Your browser should then open to this repo's documentation as generated from the Rust docstrings.