73 lines
2.2 KiB
Makefile
73 lines
2.2 KiB
Makefile
set export := true
|
|
|
|
default: deps check
|
|
|
|
# Check and install dependencies via rustup
|
|
deps:
|
|
@just _setup-rustup
|
|
@just _setup-rust-toolchain
|
|
@just _setup-targets
|
|
@just _setup-cargo-binutils
|
|
@just _check-python
|
|
|
|
_setup-rustup:
|
|
@if ! command -v rustup >/dev/null 2>&1; then \
|
|
echo "Installing rustup..."; \
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y; \
|
|
echo "Please run: source ~/.cargo/env"; \
|
|
echo "Then run 'just deps' again"; \
|
|
exit 1; \
|
|
fi
|
|
|
|
_setup-rust-toolchain:
|
|
@if ! rustc -vV >/dev/null 2>&1; then \
|
|
echo "Installing stable Rust toolchain..."; \
|
|
rustup default stable; \
|
|
fi
|
|
|
|
_setup-targets:
|
|
@if ! rustup target list --installed | grep -q "thumbv6m-none-eabi"; then \
|
|
echo "Installing thumbv6m-none-eabi target..."; \
|
|
rustup target add thumbv6m-none-eabi; \
|
|
fi
|
|
@if ! rustup component list --installed | grep -q "llvm-tools"; then \
|
|
echo "Installing llvm-tools component..."; \
|
|
rustup component add llvm-tools; \
|
|
fi
|
|
|
|
_setup-cargo-binutils:
|
|
@if ! cargo objcopy --version >/dev/null 2>&1; then \
|
|
echo "Installing cargo-binutils..."; \
|
|
cargo install cargo-binutils; \
|
|
fi
|
|
|
|
_check-python:
|
|
@command -v python3 >/dev/null 2>&1 || (echo "Missing: python3 - please install via nix" && exit 1)
|
|
|
|
check: deps
|
|
cd rp2040 && cargo check --target thumbv6m-none-eabi
|
|
|
|
test:
|
|
cd rp2040 && cargo test --lib --target x86_64-unknown-linux-gnu --features std
|
|
|
|
build-uf2:
|
|
cd rp2040 && cargo build --release --target thumbv6m-none-eabi
|
|
cd rp2040 && cargo objcopy --release --target thumbv6m-none-eabi -- -O binary target/thumbv6m-none-eabi/release/cmdr-joystick.bin
|
|
cd rp2040 && python3 uf2conv.py target/thumbv6m-none-eabi/release/cmdr-joystick.bin --base 0x10000000 --family 0xe48bff56 --convert --output target/firmware.uf2
|
|
|
|
clean:
|
|
cargo clean --manifest-path rp2040/Cargo.toml
|
|
|
|
flash mount="" timeout="10":
|
|
@just build-uf2
|
|
MOUNT="{{mount}}" python3 tools/copy_uf2.py --source rp2040/target/firmware.uf2 --timeout {{timeout}}
|
|
|
|
flash-ssh target mount="/Volumes/RPI-RP2" key="" port="22":
|
|
@just build-uf2
|
|
target="{{target}}"
|
|
mount="{{mount}}"
|
|
key_arg=""
|
|
if [ -n "{{key}}" ]; then key_arg="-i {{key}}"; fi
|
|
ssh $key_arg -p {{port}} "$target" "mkdir -p \"$mount\""
|
|
scp $key_arg -P {{port}} rp2040/target/firmware.uf2 "$target:$mount/"
|