diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-12-06 23:39:34 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-12-06 23:39:34 +0000 |
| commit | c1b47599357fbc0c616afe56c5b77539149f6887 (patch) | |
| tree | 3d43450b7ba67112dad3968fa836f09d4d75026a | |
| parent | 7058f29cf049d2ba14c0f8d99ad964dc1ded918c (diff) | |
| parent | dde6607aec758df431eafb5844a78888bc7231e7 (diff) | |
Merge #519
519: stm32: Add timer test, add g0, g4 tests. r=Dirbaio a=Dirbaio
Co-authored-by: Dario Nieuwenhuis <[email protected]>
| -rwxr-xr-x | ci.sh | 22 | ||||
| -rw-r--r-- | tests/stm32/.cargo/config.toml | 3 | ||||
| -rw-r--r-- | tests/stm32/Cargo.toml | 9 | ||||
| -rw-r--r-- | tests/stm32/src/bin/gpio.rs | 7 | ||||
| -rw-r--r-- | tests/stm32/src/bin/timer.rs | 27 |
5 files changed, 56 insertions, 12 deletions
| @@ -6,14 +6,14 @@ export CARGO_TARGET_DIR=$PWD/target_ci | |||
| 6 | export RUSTFLAGS=-Dwarnings | 6 | export RUSTFLAGS=-Dwarnings |
| 7 | export DEFMT_LOG=trace | 7 | export DEFMT_LOG=trace |
| 8 | 8 | ||
| 9 | #find . -name '*.rs' -not -path '*target*' -not -path '*stm32-metapac-gen/out/*' | xargs rustfmt --check --skip-children --unstable-features --edition 2018 | 9 | find . -name '*.rs' -not -path '*target*' -not -path '*stm32-metapac-gen/out/*' | xargs rustfmt --check --skip-children --unstable-features --edition 2018 |
| 10 | 10 | ||
| 11 | # Generate stm32-metapac | 11 | # Generate stm32-metapac |
| 12 | # for some reason Cargo stomps the cache if we don't specify --target. | 12 | # for some reason Cargo stomps the cache if we don't specify --target. |
| 13 | # This happens with vanilla Cargo, not just cargo-batch. Bug? | 13 | # This happens with vanilla Cargo, not just cargo-batch. Bug? |
| 14 | #(cd stm32-metapac-gen; cargo run --release --target x86_64-unknown-linux-gnu) | 14 | (cd stm32-metapac-gen; cargo run --release --target x86_64-unknown-linux-gnu) |
| 15 | #rm -rf stm32-metapac | 15 | rm -rf stm32-metapac |
| 16 | #mv stm32-metapac-gen/out stm32-metapac | 16 | mv stm32-metapac-gen/out stm32-metapac |
| 17 | 17 | ||
| 18 | cargo batch \ | 18 | cargo batch \ |
| 19 | --- build --release --manifest-path embassy/Cargo.toml --target thumbv7em-none-eabi \ | 19 | --- build --release --manifest-path embassy/Cargo.toml --target thumbv7em-none-eabi \ |
| @@ -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 | ||
| 63 | function run_elf { | 65 | function 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') |
| 84 | fi | 87 | fi |
| 85 | 88 | ||
| 86 | 89 | for board in $(ls out/tests); do | |
| 87 | run_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 | ||
| 94 | 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"] | |||
| 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` |
| 7 | runner = "probe-run --chip STM32F429ZITx" | 7 | #runner = "teleprobe run --chip STM32G071RBTx --elf" |
| 8 | runner = "./teleprobe.sh nucleo-stm32f429zi" | ||
| 8 | 9 | ||
| 9 | rustflags = [ | 10 | rustflags = [ |
| 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" | |||
| 5 | version = "0.1.0" | 5 | version = "0.1.0" |
| 6 | resolver = "2" | 6 | resolver = "2" |
| 7 | 7 | ||
| 8 | [features] | ||
| 9 | stm32f429zi = ["embassy-stm32/stm32f429zi"] | ||
| 10 | stm32g071rb = ["embassy-stm32/stm32g071rb"] | ||
| 11 | stm32g491re = ["embassy-stm32/stm32g491re"] | ||
| 12 | |||
| 8 | [dependencies] | 13 | [dependencies] |
| 9 | embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] } | 14 | embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] } |
| 10 | embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] } | 15 | embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] } |
| 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-tim2"] } | 16 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "unstable-pac", "memory-x", "time-driver-tim2"] } |
| 12 | 17 | ||
| 13 | defmt = "0.3.0" | 18 | defmt = "0.3.0" |
| 14 | defmt-rtt = "0.3.0" | 19 | defmt-rtt = "0.3.0" |
| @@ -19,10 +24,8 @@ embedded-hal = "0.2.6" | |||
| 19 | panic-probe = { version = "0.3.0", features = ["print-defmt"] } | 24 | panic-probe = { version = "0.3.0", features = ["print-defmt"] } |
| 20 | 25 | ||
| 21 | [profile.dev] | 26 | [profile.dev] |
| 22 | codegen-units = 1 | ||
| 23 | debug = 2 | 27 | debug = 2 |
| 24 | debug-assertions = true | 28 | debug-assertions = true |
| 25 | incremental = false | ||
| 26 | opt-level = 's' | 29 | opt-level = 's' |
| 27 | overflow-checks = true | 30 | overflow-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::*; | |||
| 15 | async fn main(_spawner: Spawner, p: Peripherals) { | 15 | async 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"] | ||
| 6 | mod example_common; | ||
| 7 | use defmt::assert; | ||
| 8 | use embassy::executor::Spawner; | ||
| 9 | use embassy::time::{Duration, Instant, Timer}; | ||
| 10 | use embassy_stm32::Peripherals; | ||
| 11 | use example_common::*; | ||
| 12 | |||
| 13 | #[embassy::main] | ||
| 14 | async 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 | } | ||
