From 13cb4314725bb60d2252575f8fd06828e8661064 Mon Sep 17 00:00:00 2001 From: Caleb Jamison Date: Mon, 12 Aug 2024 05:47:16 -0400 Subject: [PATCH] Enable rp235x doc tests, fixup feature doc The rp235x doc test requires an unfortunate workaround using a private feature, "_test", in order compile. --- .github/ci/test.sh | 3 ++- embassy-rp/Cargo.toml | 11 +++++++---- embassy-rp/src/lib.rs | 6 +++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/ci/test.sh b/.github/ci/test.sh index 771251bd1..da0021684 100755 --- a/.github/ci/test.sh +++ b/.github/ci/test.sh @@ -21,7 +21,8 @@ cargo test --manifest-path ./embassy-boot/Cargo.toml --features ed25519-salty cargo test --manifest-path ./embassy-nrf/Cargo.toml --no-default-features --features nrf52840,time-driver-rtc1,gpiote -cargo test --manifest-path ./embassy-rp/Cargo.toml --no-default-features --features time-driver,rp2040 +cargo test --manifest-path ./embassy-rp/Cargo.toml --no-default-features --features time-driver,rp2040,_test +cargo test --manifest-path ./embassy-rp/Cargo.toml --no-default-features --features time-driver,rp235xa,_test cargo test --manifest-path ./embassy-stm32/Cargo.toml --no-default-features --features stm32f429vg,exti,time-driver-any,exti cargo test --manifest-path ./embassy-stm32/Cargo.toml --no-default-features --features stm32f732ze,exti,time-driver-any,exti diff --git a/embassy-rp/Cargo.toml b/embassy-rp/Cargo.toml index 1ab6cf440..453f1aa0f 100644 --- a/embassy-rp/Cargo.toml +++ b/embassy-rp/Cargo.toml @@ -98,10 +98,13 @@ rp235xa = ["_rp235x"] ## Configure the hal for use with the rp235xB rp235xb = ["_rp235x"] -# Add a binary-info header block containing picotool-compatible metadata. -# -# Takes up a little flash space, but picotool can then report the name of your -# program and other details. +# hack around cortex-m peripherals being wrong when running tests. +_test = [] + +## Add a binary-info header block containing picotool-compatible metadata. +## +## Takes up a little flash space, but picotool can then report the name of your +## program and other details. binary-info = [ "rt" ] [dependencies] diff --git a/embassy-rp/src/lib.rs b/embassy-rp/src/lib.rs index f968572b3..1fc397107 100644 --- a/embassy-rp/src/lib.rs +++ b/embassy-rp/src/lib.rs @@ -469,7 +469,7 @@ pub fn install_core0_stack_guard() -> Result<(), ()> { unsafe { install_stack_guard(core::ptr::addr_of_mut!(_stack_end)) } } -#[cfg(feature = "rp2040")] +#[cfg(all(feature = "rp2040", not(feature = "_test")))] #[inline(always)] fn install_stack_guard(stack_bottom: *mut usize) -> Result<(), ()> { let core = unsafe { cortex_m::Peripherals::steal() }; @@ -497,7 +497,7 @@ fn install_stack_guard(stack_bottom: *mut usize) -> Result<(), ()> { Ok(()) } -#[cfg(all(feature = "_rp235x", not(test)))] +#[cfg(all(feature = "_rp235x", not(feature = "_test")))] #[inline(always)] fn install_stack_guard(stack_bottom: *mut usize) -> Result<(), ()> { let core = unsafe { cortex_m::Peripherals::steal() }; @@ -517,7 +517,7 @@ fn install_stack_guard(stack_bottom: *mut usize) -> Result<(), ()> { // This is to hack around cortex_m defaulting to ARMv7 when building tests, // so the compile fails when we try to use ARMv8 peripherals. -#[cfg(test)] +#[cfg(feature = "_test")] #[inline(always)] fn install_stack_guard(_stack_bottom: *mut usize) -> Result<(), ()> { Ok(())