aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2021-12-07 00:28:32 +0100
committerDario Nieuwenhuis <[email protected]>2021-12-07 00:29:41 +0100
commitdde6607aec758df431eafb5844a78888bc7231e7 (patch)
tree3d43450b7ba67112dad3968fa836f09d4d75026a
parent693690cb5abf5855d190e58142e2b5f7dd63f2bb (diff)
Add timer test, add g0, g4 tests.
-rwxr-xr-xci.sh14
-rw-r--r--tests/stm32/.cargo/config.toml3
-rw-r--r--tests/stm32/Cargo.toml9
-rw-r--r--tests/stm32/src/bin/gpio.rs7
-rw-r--r--tests/stm32/src/bin/timer.rs27
5 files changed, 52 insertions, 8 deletions
diff --git a/ci.sh b/ci.sh
index e6a882da3..046038ffa 100755
--- a/ci.sh
+++ b/ci.sh
@@ -57,7 +57,9 @@ cargo batch \
57 --- build --release --manifest-path examples/stm32wb55/Cargo.toml --target thumbv7em-none-eabihf --out-dir out/examples/stm32wb55 \ 57 --- build --release --manifest-path examples/stm32wb55/Cargo.toml --target thumbv7em-none-eabihf --out-dir out/examples/stm32wb55 \
58 --- build --release --manifest-path examples/stm32wl55/Cargo.toml --target thumbv7em-none-eabihf --out-dir out/examples/stm32wl55 \ 58 --- build --release --manifest-path examples/stm32wl55/Cargo.toml --target thumbv7em-none-eabihf --out-dir out/examples/stm32wl55 \
59 --- build --release --manifest-path examples/wasm/Cargo.toml --target wasm32-unknown-unknown --out-dir out/examples/wasm \ 59 --- build --release --manifest-path examples/wasm/Cargo.toml --target wasm32-unknown-unknown --out-dir out/examples/wasm \
60 --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --out-dir out/tests/stm32f4 \ 60 --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi --out-dir out/tests/nucleo-stm32f429zi \
61 --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g491re --out-dir out/tests/nucleo-stm32g491re \
62 --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32g071rb --out-dir out/tests/nucleo-stm32g071rb \
61 63
62 64
63function run_elf { 65function run_elf {
@@ -70,6 +72,7 @@ function run_elf {
70 -H "Authorization: Bearer $TELEPROBE_TOKEN" \ 72 -H "Authorization: Bearer $TELEPROBE_TOKEN" \
71 https://teleprobe.embassy.dev/targets/$1/run --data-binary @$2 73 https://teleprobe.embassy.dev/targets/$1/run --data-binary @$2
72 ) 74 )
75 echo
73 echo HTTP Status code: $STATUSCODE 76 echo HTTP Status code: $STATUSCODE
74 test "$STATUSCODE" -eq 200 77 test "$STATUSCODE" -eq 200
75} 78}
@@ -83,6 +86,9 @@ if [[ -z "${TELEPROBE_TOKEN-}" ]]; then
83 export TELEPROBE_TOKEN=$(curl -sS -H "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL" | jq -r '.value') 86 export TELEPROBE_TOKEN=$(curl -sS -H "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL" | jq -r '.value')
84fi 87fi
85 88
86 89for board in $(ls out/tests); do
87run_elf nucleo-stm32f429zi out/tests/stm32f4/gpio 90 echo Running tests fo board: $board
88 91 for elf in $(ls out/tests/$board); do
92 run_elf $board out/tests/$board/$elf
93 done
94done
diff --git a/tests/stm32/.cargo/config.toml b/tests/stm32/.cargo/config.toml
index 40a13ddd3..586a63875 100644
--- a/tests/stm32/.cargo/config.toml
+++ b/tests/stm32/.cargo/config.toml
@@ -4,7 +4,8 @@ build-std-features = ["panic_immediate_abort"]
4 4
5[target.'cfg(all(target_arch = "arm", target_os = "none"))'] 5[target.'cfg(all(target_arch = "arm", target_os = "none"))']
6# replace STM32F429ZITx with your chip as listed in `probe-run --list-chips` 6# replace STM32F429ZITx with your chip as listed in `probe-run --list-chips`
7runner = "probe-run --chip STM32F429ZITx" 7#runner = "teleprobe run --chip STM32G071RBTx --elf"
8runner = "./teleprobe.sh nucleo-stm32f429zi"
8 9
9rustflags = [ 10rustflags = [
10 # Code-size optimizations. 11 # Code-size optimizations.
diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml
index f64043a86..e092caf8b 100644
--- a/tests/stm32/Cargo.toml
+++ b/tests/stm32/Cargo.toml
@@ -5,10 +5,15 @@ name = "embassy-stm32-tests"
5version = "0.1.0" 5version = "0.1.0"
6resolver = "2" 6resolver = "2"
7 7
8[features]
9stm32f429zi = ["embassy-stm32/stm32f429zi"]
10stm32g071rb = ["embassy-stm32/stm32g071rb"]
11stm32g491re = ["embassy-stm32/stm32g491re"]
12
8[dependencies] 13[dependencies]
9embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] } 14embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] }
10embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] } 15embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] }
11embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-tim2"] } 16embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "unstable-pac", "memory-x", "time-driver-tim2"] }
12 17
13defmt = "0.3.0" 18defmt = "0.3.0"
14defmt-rtt = "0.3.0" 19defmt-rtt = "0.3.0"
@@ -19,10 +24,8 @@ embedded-hal = "0.2.6"
19panic-probe = { version = "0.3.0", features = ["print-defmt"] } 24panic-probe = { version = "0.3.0", features = ["print-defmt"] }
20 25
21[profile.dev] 26[profile.dev]
22codegen-units = 1
23debug = 2 27debug = 2
24debug-assertions = true 28debug-assertions = true
25incremental = false
26opt-level = 's' 29opt-level = 's'
27overflow-checks = true 30overflow-checks = true
28 31
diff --git a/tests/stm32/src/bin/gpio.rs b/tests/stm32/src/bin/gpio.rs
index 7f7fccbfd..7a9d38f2d 100644
--- a/tests/stm32/src/bin/gpio.rs
+++ b/tests/stm32/src/bin/gpio.rs
@@ -15,6 +15,13 @@ use example_common::*;
15async fn main(_spawner: Spawner, p: Peripherals) { 15async fn main(_spawner: Spawner, p: Peripherals) {
16 info!("Hello World!"); 16 info!("Hello World!");
17 17
18 // Arduino pins D0 and D1
19 // They're connected together with a 1K resistor.
20 #[cfg(feature = "stm32g491re")]
21 let (mut a, mut b) = (p.PC4, p.PC5);
22 #[cfg(feature = "stm32g071rb")]
23 let (mut a, mut b) = (p.PC4, p.PC5);
24 #[cfg(feature = "stm32f429zi")]
18 let (mut a, mut b) = (p.PG14, p.PG9); 25 let (mut a, mut b) = (p.PG14, p.PG9);
19 26
20 // Test initial output 27 // Test initial output
diff --git a/tests/stm32/src/bin/timer.rs b/tests/stm32/src/bin/timer.rs
new file mode 100644
index 000000000..de19a22e3
--- /dev/null
+++ b/tests/stm32/src/bin/timer.rs
@@ -0,0 +1,27 @@
1#![no_std]
2#![no_main]
3#![feature(type_alias_impl_trait)]
4
5#[path = "../example_common.rs"]
6mod example_common;
7use defmt::assert;
8use embassy::executor::Spawner;
9use embassy::time::{Duration, Instant, Timer};
10use embassy_stm32::Peripherals;
11use example_common::*;
12
13#[embassy::main]
14async fn main(_spawner: Spawner, _p: Peripherals) {
15 info!("Hello World!");
16
17 let start = Instant::now();
18 Timer::after(Duration::from_millis(100)).await;
19 let end = Instant::now();
20 let ms = (end - start).as_millis();
21 info!("slept for {} ms", ms);
22 assert!(ms >= 99);
23 assert!(ms < 110);
24
25 info!("Test OK");
26 cortex_m::asm::bkpt();
27}