Initial commit
This commit is contained in:
85
flake.nix
Normal file
85
flake.nix
Normal file
@@ -0,0 +1,85 @@
|
||||
{
|
||||
description = "Rust on STM32 Blue Pill";
|
||||
|
||||
inputs = {
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
|
||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
flake-utils,
|
||||
nixpkgs,
|
||||
rust-overlay,
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (system: let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [(import rust-overlay)];
|
||||
};
|
||||
|
||||
chip = "STM32F103C8";
|
||||
target = "thumbv7m-none-eabi";
|
||||
|
||||
rustToolchain =
|
||||
pkgs.rust-bin.stable."1.95.0".default.override {
|
||||
extensions = [
|
||||
"clippy"
|
||||
"llvm-tools-preview"
|
||||
"rust-src"
|
||||
"rustfmt"
|
||||
];
|
||||
targets = [target];
|
||||
};
|
||||
in {
|
||||
devShells.default = pkgs.mkShell {
|
||||
packages = [
|
||||
rustToolchain
|
||||
pkgs.cargo-binutils
|
||||
pkgs.flip-link
|
||||
pkgs.llvmPackages.bintools
|
||||
pkgs.probe-rs
|
||||
];
|
||||
|
||||
RUST_SRC_PATH = "${rustToolchain}/lib/rustlib/src/rust/library";
|
||||
|
||||
shellHook = ''
|
||||
alias fmt='cargo fmt --all'
|
||||
alias check='cargo check --bin 00_check --bin 01_rust_basics --bin 02_ownership --bin 03_types --bin 07_events --bin 09_sensor_pipeline --bin 10_motor_commands --bin 11_kinematics && cargo check --target ${target} --bin 04_first_firmware --bin 05_rgb_output --bin 06_button_events --bin 08_state_machine --bin 12_embassy'
|
||||
alias verify='bash ./verify-all.sh'
|
||||
|
||||
alias run-00='cargo run --bin 00_check'
|
||||
alias run-01='cargo run --bin 01_rust_basics'
|
||||
alias run-02='cargo run --bin 02_ownership'
|
||||
alias run-03='cargo run --bin 03_types'
|
||||
alias run-04='probe-rs run --chip ${chip} target/${target}/debug/04_first_firmware'
|
||||
alias run-05='probe-rs run --chip ${chip} target/${target}/debug/05_rgb_output'
|
||||
alias run-06='probe-rs run --chip ${chip} target/${target}/debug/06_button_events'
|
||||
alias run-08='probe-rs run --chip ${chip} target/${target}/debug/08_state_machine'
|
||||
alias run-12='probe-rs run --chip ${chip} target/${target}/debug/12_embassy'
|
||||
|
||||
alias test-07='cargo test --bin 07_events'
|
||||
alias test-09='cargo test --bin 09_sensor_pipeline'
|
||||
alias test-10='cargo test --bin 10_motor_commands'
|
||||
alias test-11='cargo test --bin 11_kinematics'
|
||||
|
||||
alias build-04='cargo build --target ${target} --bin 04_first_firmware'
|
||||
alias build-05='cargo build --target ${target} --bin 05_rgb_output'
|
||||
alias build-06='cargo build --target ${target} --bin 06_button_events'
|
||||
alias build-08='cargo build --target ${target} --bin 08_state_machine'
|
||||
alias build-12='cargo build --target ${target} --bin 12_embassy'
|
||||
|
||||
alias flash-04='probe-rs download --chip ${chip} target/${target}/debug/04_first_firmware'
|
||||
alias flash-05='probe-rs download --chip ${chip} target/${target}/debug/05_rgb_output'
|
||||
alias flash-06='probe-rs download --chip ${chip} target/${target}/debug/06_button_events'
|
||||
alias flash-08='probe-rs download --chip ${chip} target/${target}/debug/08_state_machine'
|
||||
alias flash-12='probe-rs download --chip ${chip} target/${target}/debug/12_embassy'
|
||||
|
||||
echo "Rust on STM32 Blue Pill dev shell"
|
||||
echo "Target: ${target}"
|
||||
echo "Chip: ${chip}"
|
||||
'';
|
||||
};
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user