Skip to content

Commit 3878c54

Browse files
committed
Fixed .env not getting loaded in build.rs, added dev.toml
1 parent 4012965 commit 3878c54

File tree

8 files changed

+28
-10
lines changed

8 files changed

+28
-10
lines changed

firmware/.env.template

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@ DEFMT_LOG="info"
1212

1313
# Provide this if you have a particular board you want to use. Note that relative paths
1414
# are resolved from the same folder as `build.rs`.
15-
BOARD="boards/ferrous_slime.toml"
16-
15+
BOARD="boards/dev.toml"

firmware/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
*.bin
44
*.uf2
55
\.env
6+
/boards/dev.toml # convenient for testing out settings locally

firmware/.vscode/launch.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
"type": "probe-rs-debug",
1010
"request": "launch",
1111
"flashingConfig": {
12-
"flashingEnabled": true,
12+
"flashingEnabled": false,
1313
"resetAfterFlashing": true,
1414
"haltAfterReset": true,
1515
},
16+
"connectUnderReset": true,
1617
"runtimeExecutable": "/home/ryan/.cargo/bin/probe-rs-debugger",
17-
"consoleLogLevel": "Debug",
18+
// "consoleLogLevel": "Trace",
1819
"name": "probe_rs Executable Test",
1920
"chip": "esp32c3", //!MODIFY
2021
"wireProtocol": "Jtag",

firmware/Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

firmware/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ fugit = "0.3"
207207
firmware_protocol = { path = "../networking/firmware_protocol", features = [
208208
"nalgebra031",
209209
] }
210-
load-dotenv = "0.1"
211210
paste = "1.0"
211+
load-dotenv = "0.1"
212212

213213
[build-dependencies]
214214
feature_utils = "0.0.0"
@@ -217,7 +217,7 @@ serde = { version = "1", features = ["derive"] }
217217
toml = "0.5"
218218
eyre = "0.6"
219219
color-eyre = "0.6"
220-
220+
dotenvy = "0.15"
221221

222222
[patch.crates-io]
223223
# Enable non-default I2C addresses and InitError

firmware/boards/dev.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[pins]
2+
scl = "2"
3+
sda = "4"
4+
int0 = "6"
5+
int1 = "7"
6+
tx = "8"
7+
rx = "9"

firmware/build.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ macro_rules! memory_x {
3333
}
3434

3535
fn main() -> Result<()> {
36+
let _ = dotenvy::dotenv();
3637
#[cfg(all(feature = "mcu-nrf52832", feature = "log-usb-serial"))]
3738
compile_error!("the nrf52832 doesn't support USB!");
3839

@@ -146,7 +147,8 @@ struct Pins {
146147
impl BoardConfig {
147148
/// Loads a board config from a file
148149
fn from_file(p: &Path) -> Result<Self> {
149-
let s = std::fs::read_to_string(p).wrap_err("Failed to read board toml")?;
150+
let s = std::fs::read_to_string(p.clone())
151+
.wrap_err(format!("Failed to read board toml: {}", p.display()))?;
150152
toml::from_str(&s).wrap_err("Failed to deserialize board toml")
151153
}
152154
/// Gets the path to the board config, or errors if we can't pick one.

firmware/src/peripherals/esp32c3.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,12 @@ pub fn get_peripherals() -> Peripherals<I2cConcrete<'static>, DelayConcrete> {
6363
}
6464

6565
let io = esp32c3_hal::IO::new(p.GPIO, p.IO_MUX);
66-
// let hz =
66+
let sda = map_pin!(io, env!("PIN_SDA"));
67+
let scl = map_pin!(io, env!("PIN_SCL"));
6768
let i2c = esp32c3_hal::i2c::I2C::new(
6869
p.I2C0,
69-
map_pin!(io, env!("PIN_SDA")),
70-
map_pin!(io, env!("PIN_SCL")),
70+
sda,
71+
scl,
7172
400u32.kHz(),
7273
&mut system.peripheral_clock_control,
7374
&clocks,

0 commit comments

Comments
 (0)