aboutsummaryrefslogtreecommitdiff
path: root/embassy-rp
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2025-10-06 22:55:38 +0200
committerDario Nieuwenhuis <[email protected]>2025-10-06 23:19:53 +0200
commitabc8e450f936567ad42cb34b5d2a7941b206aa5d (patch)
tree57b8ec55ad4fc9048524f2899b34198c5a8e61df /embassy-rp
parente2a2bd3c573928208a4c85e7fcd6ad630f23f47d (diff)
Edition 2024.
Diffstat (limited to 'embassy-rp')
-rw-r--r--embassy-rp/Cargo.toml6
-rw-r--r--embassy-rp/src/bootsel.rs2
-rw-r--r--embassy-rp/src/flash.rs6
-rw-r--r--embassy-rp/src/intrinsics.rs6
-rw-r--r--embassy-rp/src/lib.rs14
-rw-r--r--embassy-rp/src/multicore.rs5
-rw-r--r--embassy-rp/src/psram.rs8
7 files changed, 24 insertions, 23 deletions
diff --git a/embassy-rp/Cargo.toml b/embassy-rp/Cargo.toml
index f6b0900f2..9ad4b47a3 100644
--- a/embassy-rp/Cargo.toml
+++ b/embassy-rp/Cargo.toml
@@ -1,7 +1,7 @@
1[package] 1[package]
2name = "embassy-rp" 2name = "embassy-rp"
3version = "0.8.0" 3version = "0.8.0"
4edition = "2021" 4edition = "2024"
5license = "MIT OR Apache-2.0" 5license = "MIT OR Apache-2.0"
6description = "Embassy Hardware Abstraction Layer (HAL) for the Raspberry Pi RP2040 or RP235x microcontroller" 6description = "Embassy Hardware Abstraction Layer (HAL) for the Raspberry Pi RP2040 or RP235x microcontroller"
7keywords = ["embedded", "async", "rp235x", "rp2040", "embedded-hal"] 7keywords = ["embedded", "async", "rp235x", "rp2040", "embedded-hal"]
@@ -104,7 +104,7 @@ boot2-w25x10cl = []
104## Have embassy-rp not provide the boot2 so you can use your own. 104## Have embassy-rp not provide the boot2 so you can use your own.
105## Place your own in the ".boot2" section like: 105## Place your own in the ".boot2" section like:
106## ``` 106## ```
107## #[link_section = ".boot2"] 107## #[unsafe(link_section = ".boot2")]
108## #[used] 108## #[used]
109## static BOOT2: [u8; 256] = [0; 256]; // Provide your own with e.g. include_bytes! 109## static BOOT2: [u8; 256] = [0; 256]; // Provide your own with e.g. include_bytes!
110## ``` 110## ```
@@ -127,7 +127,7 @@ imagedef-nonsecure-exe = []
127## ```ignore 127## ```ignore
128## use embassy_rp::block::ImageDef; 128## use embassy_rp::block::ImageDef;
129## 129##
130## #[link_section = ".start_block"] 130## #[unsafe(link_section = ".start_block")]
131## #[used] 131## #[used]
132## static IMAGE_DEF: ImageDef = ImageDef::secure_exe(); // Update this with your own implementation. 132## static IMAGE_DEF: ImageDef = ImageDef::secure_exe(); // Update this with your own implementation.
133## ``` 133## ```
diff --git a/embassy-rp/src/bootsel.rs b/embassy-rp/src/bootsel.rs
index 14f9e46aa..5f0bac248 100644
--- a/embassy-rp/src/bootsel.rs
+++ b/embassy-rp/src/bootsel.rs
@@ -36,7 +36,7 @@ mod ram_helpers {
36 /// This function must live in ram. It uses inline asm to avoid any 36 /// This function must live in ram. It uses inline asm to avoid any
37 /// potential calls to ABI functions that might be in flash. 37 /// potential calls to ABI functions that might be in flash.
38 #[inline(never)] 38 #[inline(never)]
39 #[link_section = ".data.ram_func"] 39 #[unsafe(link_section = ".data.ram_func")]
40 #[cfg(target_arch = "arm")] 40 #[cfg(target_arch = "arm")]
41 pub unsafe fn read_cs_status() -> GpioStatus { 41 pub unsafe fn read_cs_status() -> GpioStatus {
42 let result: u32; 42 let result: u32;
diff --git a/embassy-rp/src/flash.rs b/embassy-rp/src/flash.rs
index 8c809090e..6b5eda0a3 100644
--- a/embassy-rp/src/flash.rs
+++ b/embassy-rp/src/flash.rs
@@ -627,7 +627,7 @@ mod ram_helpers {
627 /// Length of data must be a multiple of 4096 627 /// Length of data must be a multiple of 4096
628 /// addr must be aligned to 4096 628 /// addr must be aligned to 4096
629 #[inline(never)] 629 #[inline(never)]
630 #[link_section = ".data.ram_func"] 630 #[unsafe(link_section = ".data.ram_func")]
631 #[cfg(feature = "rp2040")] 631 #[cfg(feature = "rp2040")]
632 unsafe fn write_flash_inner(addr: u32, len: u32, data: Option<&[u8]>, ptrs: *const FlashFunctionPointers) { 632 unsafe fn write_flash_inner(addr: u32, len: u32, data: Option<&[u8]>, ptrs: *const FlashFunctionPointers) {
633 #[cfg(target_arch = "arm")] 633 #[cfg(target_arch = "arm")]
@@ -692,7 +692,7 @@ mod ram_helpers {
692 /// Length of data must be a multiple of 4096 692 /// Length of data must be a multiple of 4096
693 /// addr must be aligned to 4096 693 /// addr must be aligned to 4096
694 #[inline(never)] 694 #[inline(never)]
695 #[link_section = ".data.ram_func"] 695 #[unsafe(link_section = ".data.ram_func")]
696 #[cfg(feature = "_rp235x")] 696 #[cfg(feature = "_rp235x")]
697 unsafe fn write_flash_inner(addr: u32, len: u32, data: Option<&[u8]>, ptrs: *const FlashFunctionPointers) { 697 unsafe fn write_flash_inner(addr: u32, len: u32, data: Option<&[u8]>, ptrs: *const FlashFunctionPointers) {
698 let data = data.map(|d| d.as_ptr()).unwrap_or(core::ptr::null()); 698 let data = data.map(|d| d.as_ptr()).unwrap_or(core::ptr::null());
@@ -811,7 +811,7 @@ mod ram_helpers {
811 /// 811 ///
812 /// Credit: taken from `rp2040-flash` (also licensed Apache+MIT) 812 /// Credit: taken from `rp2040-flash` (also licensed Apache+MIT)
813 #[inline(never)] 813 #[inline(never)]
814 #[link_section = ".data.ram_func"] 814 #[unsafe(link_section = ".data.ram_func")]
815 #[cfg(feature = "rp2040")] 815 #[cfg(feature = "rp2040")]
816 unsafe fn read_flash_inner(cmd: FlashCommand, ptrs: *const FlashFunctionPointers) { 816 unsafe fn read_flash_inner(cmd: FlashCommand, ptrs: *const FlashFunctionPointers) {
817 #[cfg(target_arch = "arm")] 817 #[cfg(target_arch = "arm")]
diff --git a/embassy-rp/src/intrinsics.rs b/embassy-rp/src/intrinsics.rs
index 69d5d92de..aed8a3227 100644
--- a/embassy-rp/src/intrinsics.rs
+++ b/embassy-rp/src/intrinsics.rs
@@ -223,7 +223,7 @@ macro_rules! intrinsics {
223 223
224 #[cfg(all(target_arch = "arm", feature = "intrinsics"))] 224 #[cfg(all(target_arch = "arm", feature = "intrinsics"))]
225 mod $name { 225 mod $name {
226 #[no_mangle] 226 #[unsafe(no_mangle)]
227 $(#[$($attr)*])* 227 $(#[$($attr)*])*
228 pub extern $abi fn $name( $($argname: $ty),* ) -> $ret { 228 pub extern $abi fn $name( $($argname: $ty),* ) -> $ret {
229 super::$name($($argname),*) 229 super::$name($($argname),*)
@@ -257,7 +257,7 @@ macro_rules! intrinsics {
257 257
258 #[cfg(all(target_arch = "arm", feature = "intrinsics"))] 258 #[cfg(all(target_arch = "arm", feature = "intrinsics"))]
259 mod $name { 259 mod $name {
260 #[no_mangle] 260 #[unsafe(no_mangle)]
261 $(#[$($attr)*])* 261 $(#[$($attr)*])*
262 pub unsafe extern $abi fn $name( $($argname: $ty),* ) -> $ret { 262 pub unsafe extern $abi fn $name( $($argname: $ty),* ) -> $ret {
263 super::$name($($argname),*) 263 super::$name($($argname),*)
@@ -392,7 +392,7 @@ macro_rules! division_function {
392 ); 392 );
393 393
394 #[cfg(target_arch = "arm")] 394 #[cfg(target_arch = "arm")]
395 extern "aapcs" { 395 unsafe extern "aapcs" {
396 // Connect a local name to global symbol above through FFI. 396 // Connect a local name to global symbol above through FFI.
397 #[link_name = concat!("_erphal_", stringify!($name)) ] 397 #[link_name = concat!("_erphal_", stringify!($name)) ]
398 fn $name(n: $argty, d: $argty) -> u64; 398 fn $name(n: $argty, d: $argty) -> u64;
diff --git a/embassy-rp/src/lib.rs b/embassy-rp/src/lib.rs
index d03ba1fef..4cb1a0912 100644
--- a/embassy-rp/src/lib.rs
+++ b/embassy-rp/src/lib.rs
@@ -1,5 +1,7 @@
1#![no_std] 1#![no_std]
2#![allow(async_fn_in_trait)] 2#![allow(async_fn_in_trait)]
3#![allow(unsafe_op_in_unsafe_fn)]
4#![allow(unused_unsafe)]
3#![doc = include_str!("../README.md")] 5#![doc = include_str!("../README.md")]
4#![warn(missing_docs)] 6#![warn(missing_docs)]
5 7
@@ -190,7 +192,7 @@ macro_rules! bind_interrupts {
190 192
191 $( 193 $(
192 #[allow(non_snake_case)] 194 #[allow(non_snake_case)]
193 #[no_mangle] 195 #[unsafe(no_mangle)]
194 $(#[cfg($cond_irq)])? 196 $(#[cfg($cond_irq)])?
195 unsafe extern "C" fn $irq() { 197 unsafe extern "C" fn $irq() {
196 unsafe { 198 unsafe {
@@ -446,13 +448,13 @@ macro_rules! select_bootloader {
446 ( $( $feature:literal => $loader:ident, )+ default => $default:ident ) => { 448 ( $( $feature:literal => $loader:ident, )+ default => $default:ident ) => {
447 $( 449 $(
448 #[cfg(feature = $feature)] 450 #[cfg(feature = $feature)]
449 #[link_section = ".boot2"] 451 #[unsafe(link_section = ".boot2")]
450 #[used] 452 #[used]
451 static BOOT2: [u8; 256] = rp2040_boot2::$loader; 453 static BOOT2: [u8; 256] = rp2040_boot2::$loader;
452 )* 454 )*
453 455
454 #[cfg(not(any( $( feature = $feature),* )))] 456 #[cfg(not(any( $( feature = $feature),* )))]
455 #[link_section = ".boot2"] 457 #[unsafe(link_section = ".boot2")]
456 #[used] 458 #[used]
457 static BOOT2: [u8; 256] = rp2040_boot2::$default; 459 static BOOT2: [u8; 256] = rp2040_boot2::$default;
458 } 460 }
@@ -475,13 +477,13 @@ macro_rules! select_imagedef {
475 ( $( $feature:literal => $imagedef:ident, )+ default => $default:ident ) => { 477 ( $( $feature:literal => $imagedef:ident, )+ default => $default:ident ) => {
476 $( 478 $(
477 #[cfg(feature = $feature)] 479 #[cfg(feature = $feature)]
478 #[link_section = ".start_block"] 480 #[unsafe(link_section = ".start_block")]
479 #[used] 481 #[used]
480 static IMAGE_DEF: crate::block::ImageDef = crate::block::ImageDef::$imagedef(); 482 static IMAGE_DEF: crate::block::ImageDef = crate::block::ImageDef::$imagedef();
481 )* 483 )*
482 484
483 #[cfg(not(any( $( feature = $feature),* )))] 485 #[cfg(not(any( $( feature = $feature),* )))]
484 #[link_section = ".start_block"] 486 #[unsafe(link_section = ".start_block")]
485 #[used] 487 #[used]
486 static IMAGE_DEF: crate::block::ImageDef = crate::block::ImageDef::$default(); 488 static IMAGE_DEF: crate::block::ImageDef = crate::block::ImageDef::$default();
487 } 489 }
@@ -528,7 +530,7 @@ select_imagedef! {
528/// } 530/// }
529/// ``` 531/// ```
530pub fn install_core0_stack_guard() -> Result<(), ()> { 532pub fn install_core0_stack_guard() -> Result<(), ()> {
531 extern "C" { 533 unsafe extern "C" {
532 static mut _stack_end: usize; 534 static mut _stack_end: usize;
533 } 535 }
534 unsafe { install_stack_guard(core::ptr::addr_of_mut!(_stack_end)) } 536 unsafe { install_stack_guard(core::ptr::addr_of_mut!(_stack_end)) }
diff --git a/embassy-rp/src/multicore.rs b/embassy-rp/src/multicore.rs
index adedc98ad..c305513ca 100644
--- a/embassy-rp/src/multicore.rs
+++ b/embassy-rp/src/multicore.rs
@@ -14,6 +14,7 @@
14//! use embassy_rp::multicore::Stack; 14//! use embassy_rp::multicore::Stack;
15//! use static_cell::StaticCell; 15//! use static_cell::StaticCell;
16//! use embassy_executor::Executor; 16//! use embassy_executor::Executor;
17//! use core::ptr::addr_of_mut;
17//! 18//!
18//! static mut CORE1_STACK: Stack<4096> = Stack::new(); 19//! static mut CORE1_STACK: Stack<4096> = Stack::new();
19//! static EXECUTOR0: StaticCell<Executor> = StaticCell::new(); 20//! static EXECUTOR0: StaticCell<Executor> = StaticCell::new();
@@ -36,7 +37,7 @@
36//! fn main() -> ! { 37//! fn main() -> ! {
37//! let p = embassy_rp::init(Default::default()); 38//! let p = embassy_rp::init(Default::default());
38//! 39//!
39//! embassy_rp::multicore::spawn_core1(p.CORE1, unsafe { &mut CORE1_STACK }, move || { 40//! embassy_rp::multicore::spawn_core1(p.CORE1, unsafe { &mut *addr_of_mut!(CORE1_STACK) }, move || {
40//! let executor1 = EXECUTOR1.init(Executor::new()); 41//! let executor1 = EXECUTOR1.init(Executor::new());
41//! executor1.run(|spawner| spawner.spawn(core1_task().unwrap())); 42//! executor1.run(|spawner| spawner.spawn(core1_task().unwrap()));
42//! }); 43//! });
@@ -110,7 +111,6 @@ impl<const SIZE: usize> Stack<SIZE> {
110 111
111#[cfg(all(feature = "rt", feature = "rp2040"))] 112#[cfg(all(feature = "rt", feature = "rp2040"))]
112#[interrupt] 113#[interrupt]
113#[link_section = ".data.ram_func"]
114unsafe fn SIO_IRQ_PROC1() { 114unsafe fn SIO_IRQ_PROC1() {
115 let sio = pac::SIO; 115 let sio = pac::SIO;
116 // Clear IRQ 116 // Clear IRQ
@@ -135,7 +135,6 @@ unsafe fn SIO_IRQ_PROC1() {
135 135
136#[cfg(all(feature = "rt", feature = "_rp235x"))] 136#[cfg(all(feature = "rt", feature = "_rp235x"))]
137#[interrupt] 137#[interrupt]
138#[link_section = ".data.ram_func"]
139unsafe fn SIO_IRQ_FIFO() { 138unsafe fn SIO_IRQ_FIFO() {
140 let sio = pac::SIO; 139 let sio = pac::SIO;
141 // Clear IRQ 140 // Clear IRQ
diff --git a/embassy-rp/src/psram.rs b/embassy-rp/src/psram.rs
index ae43dd5aa..22eb1ed25 100644
--- a/embassy-rp/src/psram.rs
+++ b/embassy-rp/src/psram.rs
@@ -251,7 +251,7 @@ impl<'d> Psram<'d> {
251 } 251 }
252 252
253 /// Verify APS6404L PSRAM device matches expected configuration. 253 /// Verify APS6404L PSRAM device matches expected configuration.
254 #[link_section = ".data.ram_func"] 254 #[unsafe(link_section = ".data.ram_func")]
255 #[inline(never)] 255 #[inline(never)]
256 fn verify_aps6404l(qmi: &pac::qmi::Qmi, expected_size: usize) -> Result<(), Error> { 256 fn verify_aps6404l(qmi: &pac::qmi::Qmi, expected_size: usize) -> Result<(), Error> {
257 // APS6404L-specific constants 257 // APS6404L-specific constants
@@ -306,7 +306,7 @@ impl<'d> Psram<'d> {
306 Ok(()) 306 Ok(())
307 } 307 }
308 308
309 #[link_section = ".data.ram_func"] 309 #[unsafe(link_section = ".data.ram_func")]
310 #[inline(never)] 310 #[inline(never)]
311 unsafe fn read_aps6404l_kgd_eid(qmi: &pac::qmi::Qmi) -> (u32, u32) { 311 unsafe fn read_aps6404l_kgd_eid(qmi: &pac::qmi::Qmi) -> (u32, u32) {
312 const RESET_ENABLE_CMD: u8 = 0xf5; 312 const RESET_ENABLE_CMD: u8 = 0xf5;
@@ -435,7 +435,7 @@ impl<'d> Psram<'d> {
435 } 435 }
436 436
437 /// Initialize PSRAM with proper timing. 437 /// Initialize PSRAM with proper timing.
438 #[link_section = ".data.ram_func"] 438 #[unsafe(link_section = ".data.ram_func")]
439 #[inline(never)] 439 #[inline(never)]
440 fn init_psram(qmi: &pac::qmi::Qmi, xip_ctrl: &pac::xip_ctrl::XipCtrl, config: &Config) -> Result<(), Error> { 440 fn init_psram(qmi: &pac::qmi::Qmi, xip_ctrl: &pac::xip_ctrl::XipCtrl, config: &Config) -> Result<(), Error> {
441 // Set PSRAM timing for APS6404 441 // Set PSRAM timing for APS6404
@@ -610,7 +610,7 @@ impl<'d> Psram<'d> {
610 Ok(()) 610 Ok(())
611 } 611 }
612 612
613 #[link_section = ".data.ram_func"] 613 #[unsafe(link_section = ".data.ram_func")]
614 #[inline(never)] 614 #[inline(never)]
615 unsafe fn direct_csr_send_init_command(config: &Config, init_cmd: u8) { 615 unsafe fn direct_csr_send_init_command(config: &Config, init_cmd: u8) {
616 #[cfg(target_arch = "arm")] 616 #[cfg(target_arch = "arm")]