Skip to content

Commit 07be4ef

Browse files
fix: improve template usability and reproducibility
- Fix rust-analyzer "can't find crate for test" by adding check.allTargets: false - Add rust-toolchain.toml to pin toolchain version, target, and components - Add cargo-binutils and llvm-tools to Dockerfile for binary inspection/disassembly - Add defmt-test for on-target embedded testing with example test Agent-Logs-Url: https://github.com/Baker-link-Lab/bakerlink_tutorial_template/sessions/f183cbad-512b-43ab-a93c-048310787e22 Co-authored-by: Baker-Tanaka <42606588+Baker-Tanaka@users.noreply.github.com>
1 parent 71e3b1a commit 07be4ef

5 files changed

Lines changed: 34 additions & 0 deletions

File tree

.docker/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ FROM rust:1.86.0-bullseye
33
RUN rustup target install thumbv6m-none-eabi
44
RUN cargo install flip-link --version 0.1.10
55
RUN rustup component add rustfmt
6+
RUN rustup component add llvm-tools
7+
RUN cargo install cargo-binutils

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"rust-analyzer.cargo.target": "thumbv6m-none-eabi",
3+
"rust-analyzer.check.allTargets": false,
34
"editor.formatOnSave": true
45
}

Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ rp2040-hal = { version = "0.10", features = ["rt", "critical-section-impl"] }
1616
rp2040-boot2 = "0.3"
1717
critical-section = "1.0.0"
1818

19+
[dev-dependencies]
20+
defmt-test = "0.3"
21+
22+
[[test]]
23+
name = "example_test"
24+
harness = false
25+
1926
# cargo build/run
2027
[profile.dev]
2128
codegen-units = 1

rust-toolchain.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[toolchain]
2+
channel = "1.86.0"
3+
targets = ["thumbv6m-none-eabi"]
4+
components = ["rustfmt", "llvm-tools"]

tests/example_test.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#![no_std]
2+
#![no_main]
3+
4+
use defmt_rtt as _;
5+
use panic_probe as _;
6+
use rp2040_hal as _;
7+
8+
#[link_section = ".boot2"]
9+
#[used]
10+
pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_GENERIC_03H;
11+
12+
#[defmt_test::tests]
13+
mod tests {
14+
use defmt::assert;
15+
16+
#[test]
17+
fn it_works() {
18+
assert!(true);
19+
}
20+
}

0 commit comments

Comments
 (0)