diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2023-04-19 21:10:35 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-04-19 21:10:35 +0000 |
| commit | 26f4d7d28369e9f9329b3bf34568f213e56ad86d (patch) | |
| tree | 9ce0c8f7d4ee2d02a22b35ad78de9299006c9e16 /tests | |
| parent | 37181c79d9a0c6642d4b31bfb1d1816c9ee1b315 (diff) | |
| parent | fdd6e08ed6b5445a53c8cd0752f80f203c4860ac (diff) | |
Merge #1382
1382: rp: hook up softfloat intrinsics to bootrom r=Dirbaio a=pennae
rp-hal has done this very well already, so we'll just copy their entire impl again. only div.rs needed some massaging because our sio access works a little differently, everything else worked as is.
includes a minor bit of refactoring to make it easier to check which bits we've copied from rp2040-hal and which we haven't.
Co-authored-by: pennae <[email protected]>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/rp/.cargo/config.toml | 6 | ||||
| -rw-r--r-- | tests/rp/Cargo.toml | 2 | ||||
| -rw-r--r-- | tests/rp/src/bin/float.rs | 53 |
3 files changed, 58 insertions, 3 deletions
diff --git a/tests/rp/.cargo/config.toml b/tests/rp/.cargo/config.toml index 9611db3a0..e1744c703 100644 --- a/tests/rp/.cargo/config.toml +++ b/tests/rp/.cargo/config.toml | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | [unstable] | 1 | [unstable] |
| 2 | build-std = ["core"] | 2 | # enabling these breaks the float tests during linking, with intrinsics |
| 3 | build-std-features = ["panic_immediate_abort"] | 3 | # duplicated between embassy-rp and compilter_builtins |
| 4 | #build-std = ["core"] | ||
| 5 | #build-std-features = ["panic_immediate_abort"] | ||
| 4 | 6 | ||
| 5 | [target.'cfg(all(target_arch = "arm", target_os = "none"))'] | 7 | [target.'cfg(all(target_arch = "arm", target_os = "none"))'] |
| 6 | #runner = "teleprobe client run --target rpi-pico --elf" | 8 | #runner = "teleprobe client run --target rpi-pico --elf" |
diff --git a/tests/rp/Cargo.toml b/tests/rp/Cargo.toml index 36ff735ec..6778f53d7 100644 --- a/tests/rp/Cargo.toml +++ b/tests/rp/Cargo.toml | |||
| @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" | |||
| 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } |
| 9 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 9 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt"] } | 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt"] } |
| 11 | embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = ["nightly", "defmt", "unstable-pac", "unstable-traits", "time-driver", "critical-section-impl"] } | 11 | embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = ["nightly", "defmt", "unstable-pac", "unstable-traits", "time-driver", "critical-section-impl", "intrinsics", "rom-v2-intrinsics"] } |
| 12 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } | 12 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } |
| 13 | 13 | ||
| 14 | defmt = "0.3.0" | 14 | defmt = "0.3.0" |
diff --git a/tests/rp/src/bin/float.rs b/tests/rp/src/bin/float.rs new file mode 100644 index 000000000..6715271e6 --- /dev/null +++ b/tests/rp/src/bin/float.rs | |||
| @@ -0,0 +1,53 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | |||
| 5 | use defmt::*; | ||
| 6 | use embassy_executor::Spawner; | ||
| 7 | use embassy_rp::pac; | ||
| 8 | use embassy_time::{Duration, Timer}; | ||
| 9 | use {defmt_rtt as _, panic_probe as _}; | ||
| 10 | |||
| 11 | #[embassy_executor::main] | ||
| 12 | async fn main(_spawner: Spawner) { | ||
| 13 | embassy_rp::init(Default::default()); | ||
| 14 | info!("Hello World!"); | ||
| 15 | |||
| 16 | const PI_F: f32 = 3.1415926535f32; | ||
| 17 | const PI_D: f64 = 3.14159265358979323846f64; | ||
| 18 | |||
| 19 | unsafe { | ||
| 20 | pac::BUSCTRL | ||
| 21 | .perfsel(0) | ||
| 22 | .write(|r| r.set_perfsel(pac::busctrl::vals::Perfsel::ROM)); | ||
| 23 | } | ||
| 24 | |||
| 25 | for i in 0..=360 { | ||
| 26 | let rad_f = (i as f32) * PI_F / 180.0; | ||
| 27 | info!( | ||
| 28 | "{}° float: {=f32} / {=f32} / {=f32} / {=f32}", | ||
| 29 | i, | ||
| 30 | rad_f, | ||
| 31 | rad_f - PI_F, | ||
| 32 | rad_f + PI_F, | ||
| 33 | rad_f % PI_F | ||
| 34 | ); | ||
| 35 | let rad_d = (i as f64) * PI_D / 180.0; | ||
| 36 | info!( | ||
| 37 | "{}° double: {=f64} / {=f64} / {=f64} / {=f64}", | ||
| 38 | i, | ||
| 39 | rad_d, | ||
| 40 | rad_d - PI_D, | ||
| 41 | rad_d + PI_D, | ||
| 42 | rad_d % PI_D | ||
| 43 | ); | ||
| 44 | Timer::after(Duration::from_millis(10)).await; | ||
| 45 | } | ||
| 46 | |||
| 47 | let rom_accesses = unsafe { pac::BUSCTRL.perfctr(0).read().perfctr() }; | ||
| 48 | // every float operation used here uses at least 10 cycles | ||
| 49 | defmt::assert!(rom_accesses >= 360 * 12 * 10); | ||
| 50 | |||
| 51 | info!("Test OK"); | ||
| 52 | cortex_m::asm::bkpt(); | ||
| 53 | } | ||
