diff options
| author | Dario Nieuwenhuis <[email protected]> | 2024-10-13 20:54:22 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-10-13 20:54:22 +0000 |
| commit | 4eb820ab6c50a0bd84f22439dab305289b3ba4a1 (patch) | |
| tree | a6606949cbda1ab2112cfc3b162a636fcd2a3bce | |
| parent | 0222faa8a1f3afbc60eb455989fc581ec9adfac1 (diff) | |
| parent | a4636d819f4b98a781cc88a05c2e89397c71e1ed (diff) | |
Merge pull request #3377 from Totto8492/enable-fpu
Enable FPU for RP235X Core1
| -rw-r--r-- | embassy-rp/build.rs | 22 | ||||
| -rw-r--r-- | embassy-rp/src/multicore.rs | 7 |
2 files changed, 28 insertions, 1 deletions
diff --git a/embassy-rp/build.rs b/embassy-rp/build.rs index 3216a3826..a8d387611 100644 --- a/embassy-rp/build.rs +++ b/embassy-rp/build.rs | |||
| @@ -1,7 +1,8 @@ | |||
| 1 | use std::env; | 1 | use std::env; |
| 2 | use std::ffi::OsStr; | ||
| 2 | use std::fs::File; | 3 | use std::fs::File; |
| 3 | use std::io::Write; | 4 | use std::io::Write; |
| 4 | use std::path::PathBuf; | 5 | use std::path::{Path, PathBuf}; |
| 5 | 6 | ||
| 6 | fn main() { | 7 | fn main() { |
| 7 | if env::var("CARGO_FEATURE_RP2040").is_ok() { | 8 | if env::var("CARGO_FEATURE_RP2040").is_ok() { |
| @@ -16,4 +17,23 @@ fn main() { | |||
| 16 | println!("cargo:rerun-if-changed=build.rs"); | 17 | println!("cargo:rerun-if-changed=build.rs"); |
| 17 | println!("cargo:rerun-if-changed=link-rp.x.in"); | 18 | println!("cargo:rerun-if-changed=link-rp.x.in"); |
| 18 | } | 19 | } |
| 20 | |||
| 21 | // code below taken from https://github.com/rust-embedded/cortex-m/blob/master/cortex-m-rt/build.rs | ||
| 22 | |||
| 23 | let mut target = env::var("TARGET").unwrap(); | ||
| 24 | |||
| 25 | // When using a custom target JSON, `$TARGET` contains the path to that JSON file. By | ||
| 26 | // convention, these files are named after the actual target triple, eg. | ||
| 27 | // `thumbv7m-customos-elf.json`, so we extract the file stem here to allow custom target specs. | ||
| 28 | let path = Path::new(&target); | ||
| 29 | if path.extension() == Some(OsStr::new("json")) { | ||
| 30 | target = path | ||
| 31 | .file_stem() | ||
| 32 | .map_or(target.clone(), |stem| stem.to_str().unwrap().to_string()); | ||
| 33 | } | ||
| 34 | |||
| 35 | println!("cargo::rustc-check-cfg=cfg(has_fpu)"); | ||
| 36 | if target.ends_with("-eabihf") { | ||
| 37 | println!("cargo:rustc-cfg=has_fpu"); | ||
| 38 | } | ||
| 19 | } | 39 | } |
diff --git a/embassy-rp/src/multicore.rs b/embassy-rp/src/multicore.rs index 9f7d77bf5..81de84907 100644 --- a/embassy-rp/src/multicore.rs +++ b/embassy-rp/src/multicore.rs | |||
| @@ -169,6 +169,13 @@ where | |||
| 169 | interrupt::SIO_IRQ_FIFO.enable() | 169 | interrupt::SIO_IRQ_FIFO.enable() |
| 170 | }; | 170 | }; |
| 171 | 171 | ||
| 172 | // Enable FPU | ||
| 173 | #[cfg(all(feature = "_rp235x", has_fpu))] | ||
| 174 | unsafe { | ||
| 175 | let p = cortex_m::Peripherals::steal(); | ||
| 176 | p.SCB.cpacr.modify(|cpacr| cpacr | (3 << 20) | (3 << 22)); | ||
| 177 | } | ||
| 178 | |||
| 172 | entry() | 179 | entry() |
| 173 | } | 180 | } |
| 174 | 181 | ||
