Skip to content

Commit 37b13d1

Browse files
authored
Merge pull request #5 from Baker-link-Lab/copilot/update-rust-and-dependencies
Update Rust/crates to latest versions, add VS Code tasks for dev tools
2 parents 2134c36 + b4400fb commit 37b13d1

9 files changed

Lines changed: 132 additions & 22 deletions

File tree

.docker/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
FROM rust:1.86.0-bullseye
1+
FROM rust:1.94.1-bookworm
22

33
RUN rustup target install thumbv6m-none-eabi
4-
RUN cargo install flip-link --version 0.1.10
4+
RUN cargo install flip-link --version 0.1.12
55
RUN rustup component add rustfmt
66
RUN rustup component add llvm-tools
77
RUN cargo install cargo-binutils

.vscode/tasks.json

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "cargo: build",
6+
"type": "shell",
7+
"command": "cargo build",
8+
"group": {
9+
"kind": "build",
10+
"isDefault": true
11+
},
12+
"problemMatcher": ["$rustc"]
13+
},
14+
{
15+
"label": "cargo: build (release)",
16+
"type": "shell",
17+
"command": "cargo build --release",
18+
"group": "build",
19+
"problemMatcher": ["$rustc"]
20+
},
21+
{
22+
"label": "cargo: build embassy example",
23+
"type": "shell",
24+
"command": "cargo build --no-default-features --features embassy --example ${input:embassyExample}",
25+
"group": "build",
26+
"problemMatcher": ["$rustc"]
27+
},
28+
{
29+
"label": "cargo: check",
30+
"type": "shell",
31+
"command": "cargo check",
32+
"group": "build",
33+
"problemMatcher": ["$rustc"]
34+
},
35+
{
36+
"label": "cargo fmt: format code",
37+
"type": "shell",
38+
"command": "cargo fmt",
39+
"problemMatcher": []
40+
},
41+
{
42+
"label": "cargo fmt: check format",
43+
"type": "shell",
44+
"command": "cargo fmt -- --check",
45+
"problemMatcher": []
46+
},
47+
{
48+
"label": "cargo size: show binary size",
49+
"type": "shell",
50+
"command": "cargo size --release -- -A",
51+
"problemMatcher": []
52+
},
53+
{
54+
"label": "cargo objdump: disassemble",
55+
"type": "shell",
56+
"command": "cargo objdump --release -- --disassemble",
57+
"problemMatcher": []
58+
},
59+
{
60+
"label": "cargo objdump: section headers",
61+
"type": "shell",
62+
"command": "cargo objdump --release -- --section-headers",
63+
"problemMatcher": []
64+
},
65+
{
66+
"label": "cargo objdump: symbol table",
67+
"type": "shell",
68+
"command": "cargo objdump --release -- --syms",
69+
"problemMatcher": []
70+
},
71+
{
72+
"label": "cargo nm: list symbols by size",
73+
"type": "shell",
74+
"command": "cargo nm --release -- --size-sort --print-size",
75+
"problemMatcher": []
76+
},
77+
{
78+
"label": "cargo readobj: file headers",
79+
"type": "shell",
80+
"command": "cargo readobj --release -- --file-headers",
81+
"problemMatcher": []
82+
},
83+
{
84+
"label": "elf2uf2: convert to UF2",
85+
"type": "shell",
86+
"command": "elf2uf2-rs target/thumbv6m-none-eabi/release/{{project-name}} target/{{project-name}}.uf2",
87+
"dependsOn": "cargo: build (release)",
88+
"problemMatcher": []
89+
},
90+
{
91+
"label": "cargo: clean",
92+
"type": "shell",
93+
"command": "cargo clean",
94+
"problemMatcher": []
95+
}
96+
],
97+
"inputs": [
98+
{
99+
"id": "embassyExample",
100+
"description": "Embassy example name",
101+
"type": "pickString",
102+
"options": [
103+
"embassy_blinky",
104+
"embassy_button",
105+
"embassy_multitask"
106+
],
107+
"default": "embassy_blinky"
108+
}
109+
]
110+
}

Cargo.toml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ edition = "2021"
66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

88
[features]
9-
default = []
9+
default = ["hal-rt"]
10+
hal-rt = ["rp2040-hal/rt"]
1011
embassy = [
1112
"dep:embassy-executor",
1213
"dep:embassy-time",
@@ -19,12 +20,12 @@ cortex-m = "0.7"
1920
cortex-m-rt = "0.7"
2021
embedded-hal = { version = "1.0.0" }
2122
embedded_hal_0_2 = { package = "embedded-hal", version = "0.2.5", features = ["unproven"] }
22-
defmt = "0.3"
23-
defmt-rtt = "0.4"
24-
panic-probe = { version = "0.3", features = ["print-defmt"] }
25-
rp2040-hal = { version = "0.10", features = ["rt", "critical-section-impl"] }
23+
defmt = "1.0"
24+
defmt-rtt = "1.1"
25+
panic-probe = { version = "1.0", features = ["print-defmt"] }
26+
rp2040-hal = { version = "0.12", features = ["critical-section-impl"] }
2627
rp2040-boot2 = "0.3"
27-
critical-section = "1.0.0"
28+
critical-section = "1.2"
2829
fugit = "0.3"
2930

3031
# Embassy dependencies (optional, enabled via "embassy" feature)
@@ -34,7 +35,7 @@ embassy-rp = { version = "0.10", features = ["defmt", "rp2040", "time-driver", "
3435
embassy-sync = { version = "0.8", features = ["defmt"], optional = true }
3536

3637
[dev-dependencies]
37-
defmt-test = "0.3"
38+
defmt-test = "0.4"
3839

3940
[[test]]
4041
name = "example_test"

examples/adc_read.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ use hal::pac;
1717

1818
use embedded_hal::delay::DelayNs;
1919

20-
// rp2040-hal のADCは embedded-hal 0.2 の OneShot トレイトを使用
21-
use embedded_hal_0_2::adc::OneShot;
22-
2320
#[link_section = ".boot2"]
2421
#[used]
2522
pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_GENERIC_03H;
@@ -77,7 +74,12 @@ fn main() -> ! {
7774
// 整数演算で近似: temp_mC = 27000 - (voltage_uV - 706000) * 1000 / 1721
7875
let temp_voltage_uv = (temp_value as i32) * 3_300_000 / 4096;
7976
let temp_mc = 27_000 - (temp_voltage_uv - 706_000) * 1000 / 1721;
80-
info!("Temperature: {}.{} deg C (raw={})", temp_mc / 1000, (temp_mc % 1000) / 100, temp_value);
77+
info!(
78+
"Temperature: {}.{} deg C (raw={})",
79+
temp_mc / 1000,
80+
(temp_mc % 1000) / 100,
81+
temp_value
82+
);
8183

8284
timer.delay_ms(1000);
8385
}

examples/embassy_blinky.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Embassy非同期フレームワークを使ったLED点滅の基本例です。
44
// async/awaitにより、ブロッキングなしでタイマーを待機できます。
55
//
6-
// 実行方法: cargo run --example embassy_blinky --features embassy
6+
// 実行方法: cargo run --no-default-features --features embassy --example embassy_blinky
77

88
#![no_std]
99
#![no_main]

examples/embassy_button.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// - GPIO20: Red LED
1010
// - GPIO23: Button(プルアップ、押すとLOW)
1111
//
12-
// 実行方法: cargo run --example embassy_button --features embassy
12+
// 実行方法: cargo run --no-default-features --features embassy --example embassy_button
1313

1414
#![no_std]
1515
#![no_main]

examples/embassy_multitask.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// - red_led_task: GPIO20の赤LEDを2秒間隔で点滅
99
// - logger_task: 5秒ごとにステータスをログ出力
1010
//
11-
// 実行方法: cargo run --example embassy_multitask --features embassy
11+
// 実行方法: cargo run --no-default-features --features embassy --example embassy_multitask
1212

1313
#![no_std]
1414
#![no_main]

examples/multicore.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_GENERIC_03H;
2727
const XTAL_FREQ_HZ: u32 = 12_000_000u32;
2828

2929
// Core1用のスタック領域
30-
static mut CORE1_STACK: Stack<4096> = Stack::new();
30+
static CORE1_STACK: Stack<4096> = Stack::new();
3131

3232
// Core1で実行される関数
3333
fn core1_task() {
@@ -98,10 +98,7 @@ fn main() -> ! {
9898
let cores = mc.cores();
9999
let core1 = &mut cores[1];
100100
core1
101-
.spawn(
102-
unsafe { &mut *core::ptr::addr_of_mut!(CORE1_STACK.mem) },
103-
core1_task,
104-
)
101+
.spawn(CORE1_STACK.take().unwrap(), core1_task)
105102
.unwrap();
106103

107104
// Core1に開始シグナルを送信

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[toolchain]
2-
channel = "1.87.0"
2+
channel = "1.94.1"
33
targets = ["thumbv6m-none-eabi"]
44
components = ["rustfmt", "llvm-tools"]

0 commit comments

Comments
 (0)