Skip to content

Commit 53015d6

Browse files
committed
Make flashing drogue vs main board easier
Instead of hard coding the environment variable in .cargo/config.toml, you can now specify the BOARD environment variable through a commmand line override. This was previously not possible because setting it through the command line wouldnt trigger a rerun of the build. Adjusting the build.rs file fixed this issue. I also wrote cargo aliases to simplify the flash commands, and updated the READMEs.
1 parent b0cf112 commit 53015d6

File tree

5 files changed

+40
-3
lines changed

5 files changed

+40
-3
lines changed

controlSystem/RecoveryBoard/firmware-rs/.cargo/config.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
[target.thumbv6m-none-eabi]
22
runner = 'probe-rs run --chip STM32F091RCTX'
33

4+
[alias]
5+
sender = "run -r --bin sender"
6+
parachute = "run -r --bin parachute"
7+
48
[build]
59
target = "thumbv6m-none-eabi"
610

controlSystem/RecoveryBoard/firmware-rs/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,25 @@ Programming ✔ 100% [####################] 15.00 KiB @ 20.53 KiB/s (took 1s)
4040
```
4141
4242
and the led should be blinking.
43+
44+
## Flashing
45+
46+
The commands to flash the binaries are as follows:
47+
48+
*Sender*:
49+
50+
```rust
51+
cargo sender
52+
```
53+
54+
*Drogue parachute*:
55+
56+
```rust
57+
BOARD=drogue cargo parachute
58+
```
59+
60+
*Main parachute*:
61+
62+
```rust
63+
BOARD=main cargo parachute
64+
```

controlSystem/RecoveryBoard/firmware-rs/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::env;
22

33
fn main() {
4+
println!("cargo::rerun-if-env-changed=BOARD");
45
println!("cargo:rustc-link-arg-bins=--nmagic");
56
println!("cargo:rustc-link-arg-bins=-Tlink.x");
67
println!("cargo:rustc-link-arg-bins=-Tdefmt.x");

controlSystem/RecoveryBoard/firmware-rs/src/bin/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ To flash it to an ERS board, set the BOARD environment variable to `"main"`
1818
## Parachute
1919

2020
This binary is the program for either the drogue or the main ERS parachute boards.
21-
The command to flash it is `cargo run -r --bin parachute`
22-
To flash it as the drogue board set the BOARD environment variable to `"drogue"`.
23-
To flash it as the main board set the BOARD environment variable to `"main"`.
21+
To flash it as the drogue board, run `BOARD=drogue cargo parachute`.
22+
To flash it as the main board, run `BOARD=main cargo parachute`.
2423

2524
### Interrupts
2625

@@ -143,6 +142,7 @@ It accomplishes sending this message mainly by constructing a status buffer that
143142
## Sender
144143

145144
This binary is the program for the sender board, which acts as the central controller for the ERS system. It monitors parachute board status, handles deployment commands, and communicates rocket readiness.
145+
To flash the board as the sender, run `cargo sender`
146146

147147
### Interrupts
148148

controlSystem/RecoveryBoard/firmware-rs/src/bin/parachute.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,16 @@ static MOTOR_MTX: MotorType = Mutex::new(None);
137137
async fn main(spawner: Spawner) {
138138
let p = embassy_stm32::init(Default::default());
139139

140+
#[cfg(main)]
141+
{
142+
info!("main")
143+
}
144+
145+
#[cfg(drogue)]
146+
{
147+
info!("drogue")
148+
}
149+
140150
let umb_on = Input::new(p.PA8, Pull::Up);
141151
let _can_shdn = Output::new(p.PA10, Level::Low, Speed::Medium);
142152
let _can_silent = Output::new(p.PA9, Level::Low, Speed::Medium);

0 commit comments

Comments
 (0)