From dde6607aec758df431eafb5844a78888bc7231e7 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Tue, 7 Dec 2021 00:28:32 +0100 Subject: [PATCH] Add timer test, add g0, g4 tests. --- ci.sh | 14 ++++++++++---- tests/stm32/.cargo/config.toml | 3 ++- tests/stm32/Cargo.toml | 9 ++++++--- tests/stm32/src/bin/gpio.rs | 7 +++++++ tests/stm32/src/bin/timer.rs | 27 +++++++++++++++++++++++++++ 5 files changed, 52 insertions(+), 8 deletions(-) create mode 100644 tests/stm32/src/bin/timer.rs diff --git a/ci.sh b/ci.sh index e6a882da3..046038ffa 100755 --- a/ci.sh +++ b/ci.sh @@ -57,7 +57,9 @@ cargo batch \ --- build --release --manifest-path examples/stm32wb55/Cargo.toml --target thumbv7em-none-eabihf --out-dir out/examples/stm32wb55 \ --- build --release --manifest-path examples/stm32wl55/Cargo.toml --target thumbv7em-none-eabihf --out-dir out/examples/stm32wl55 \ --- build --release --manifest-path examples/wasm/Cargo.toml --target wasm32-unknown-unknown --out-dir out/examples/wasm \ - --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --out-dir out/tests/stm32f4 \ + --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi --out-dir out/tests/nucleo-stm32f429zi \ + --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g491re --out-dir out/tests/nucleo-stm32g491re \ + --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32g071rb --out-dir out/tests/nucleo-stm32g071rb \ function run_elf { @@ -70,6 +72,7 @@ function run_elf { -H "Authorization: Bearer $TELEPROBE_TOKEN" \ https://teleprobe.embassy.dev/targets/$1/run --data-binary @$2 ) + echo echo HTTP Status code: $STATUSCODE test "$STATUSCODE" -eq 200 } @@ -83,6 +86,9 @@ if [[ -z "${TELEPROBE_TOKEN-}" ]]; then export TELEPROBE_TOKEN=$(curl -sS -H "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL" | jq -r '.value') fi - -run_elf nucleo-stm32f429zi out/tests/stm32f4/gpio - +for board in $(ls out/tests); do + echo Running tests fo board: $board + for elf in $(ls out/tests/$board); do + run_elf $board out/tests/$board/$elf + done +done 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"] [target.'cfg(all(target_arch = "arm", target_os = "none"))'] # replace STM32F429ZITx with your chip as listed in `probe-run --list-chips` -runner = "probe-run --chip STM32F429ZITx" +#runner = "teleprobe run --chip STM32G071RBTx --elf" +runner = "./teleprobe.sh nucleo-stm32f429zi" rustflags = [ # 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" version = "0.1.0" resolver = "2" +[features] +stm32f429zi = ["embassy-stm32/stm32f429zi"] +stm32g071rb = ["embassy-stm32/stm32g071rb"] +stm32g491re = ["embassy-stm32/stm32g491re"] + [dependencies] embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] } embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] } -embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-tim2"] } +embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "unstable-pac", "memory-x", "time-driver-tim2"] } defmt = "0.3.0" defmt-rtt = "0.3.0" @@ -19,10 +24,8 @@ embedded-hal = "0.2.6" panic-probe = { version = "0.3.0", features = ["print-defmt"] } [profile.dev] -codegen-units = 1 debug = 2 debug-assertions = true -incremental = false opt-level = 's' overflow-checks = true 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::*; async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); + // Arduino pins D0 and D1 + // They're connected together with a 1K resistor. + #[cfg(feature = "stm32g491re")] + let (mut a, mut b) = (p.PC4, p.PC5); + #[cfg(feature = "stm32g071rb")] + let (mut a, mut b) = (p.PC4, p.PC5); + #[cfg(feature = "stm32f429zi")] let (mut a, mut b) = (p.PG14, p.PG9); // 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 @@ +#![no_std] +#![no_main] +#![feature(type_alias_impl_trait)] + +#[path = "../example_common.rs"] +mod example_common; +use defmt::assert; +use embassy::executor::Spawner; +use embassy::time::{Duration, Instant, Timer}; +use embassy_stm32::Peripherals; +use example_common::*; + +#[embassy::main] +async fn main(_spawner: Spawner, _p: Peripherals) { + info!("Hello World!"); + + let start = Instant::now(); + Timer::after(Duration::from_millis(100)).await; + let end = Instant::now(); + let ms = (end - start).as_millis(); + info!("slept for {} ms", ms); + assert!(ms >= 99); + assert!(ms < 110); + + info!("Test OK"); + cortex_m::asm::bkpt(); +}