This commit is contained in:
Hiroaki Yutani 2025-05-07 22:59:41 +09:00
parent b1d37cbf22
commit 9d9ae7c5d5
8 changed files with 38 additions and 44 deletions

View File

@ -86,7 +86,7 @@ boot2-w25x10cl = []
## Have embassy-rp not provide the boot2 so you can use your own.
## Place your own in the ".boot2" section like:
## ```
## #[unsafe(link_section = ".boot2")]
## #[link_section = ".boot2"]
## #[used]
## static BOOT2: [u8; 256] = [0; 256]; // Provide your own with e.g. include_bytes!
## ```
@ -109,7 +109,7 @@ imagedef-nonsecure-exe = []
## ```ignore
## use embassy_rp::block::ImageDef;
##
## #[unsafe(link_section = ".start_block")]
## #[link_section = ".start_block"]
## #[used]
## static IMAGE_DEF: ImageDef = ImageDef::secure_exe(); // Update this with your own implementation.
## ```
@ -174,6 +174,3 @@ smart-leds = "0.4.0"
[dev-dependencies]
embassy-executor = { version = "0.7.0", path = "../embassy-executor", features = ["arch-std", "executor-thread"] }
static_cell = { version = "2" }
[patch.crates-io]
cortex-m-rt = { git = "https://github.com/yutannihilation/cortex-m", branch = "fix/allow-unsafe-wrap-rust2024" }

View File

@ -36,7 +36,7 @@ mod ram_helpers {
/// This function must live in ram. It uses inline asm to avoid any
/// potential calls to ABI functions that might be in flash.
#[inline(never)]
#[unsafe(link_section = ".data.ram_func")]
#[link_section = ".data.ram_func"]
#[cfg(target_arch = "arm")]
pub unsafe fn read_cs_status() -> GpioStatus {
let result: u32;

View File

@ -623,7 +623,7 @@ mod ram_helpers {
/// Length of data must be a multiple of 4096
/// addr must be aligned to 4096
#[inline(never)]
#[unsafe(link_section = ".data.ram_func")]
#[link_section = ".data.ram_func"]
#[cfg(feature = "rp2040")]
unsafe fn write_flash_inner(addr: u32, len: u32, data: Option<&[u8]>, ptrs: *const FlashFunctionPointers) {
#[cfg(target_arch = "arm")]
@ -688,7 +688,7 @@ mod ram_helpers {
/// Length of data must be a multiple of 4096
/// addr must be aligned to 4096
#[inline(never)]
#[unsafe(link_section = ".data.ram_func")]
#[link_section = ".data.ram_func"]
#[cfg(feature = "_rp235x")]
unsafe fn write_flash_inner(addr: u32, len: u32, data: Option<&[u8]>, ptrs: *const FlashFunctionPointers) {
let data = data.map(|d| d.as_ptr()).unwrap_or(core::ptr::null());
@ -807,7 +807,7 @@ mod ram_helpers {
///
/// Credit: taken from `rp2040-flash` (also licensed Apache+MIT)
#[inline(never)]
#[unsafe(link_section = ".data.ram_func")]
#[link_section = ".data.ram_func"]
#[cfg(feature = "rp2040")]
unsafe fn read_flash_inner(cmd: FlashCommand, ptrs: *const FlashFunctionPointers) {
#[cfg(target_arch = "arm")]

View File

@ -434,13 +434,13 @@ macro_rules! select_bootloader {
( $( $feature:literal => $loader:ident, )+ default => $default:ident ) => {
$(
#[cfg(feature = $feature)]
#[unsafe(link_section = ".boot2")]
#[link_section = ".boot2"]
#[used]
static BOOT2: [u8; 256] = rp2040_boot2::$loader;
)*
#[cfg(not(any( $( feature = $feature),* )))]
#[unsafe(link_section = ".boot2")]
#[link_section = ".boot2"]
#[used]
static BOOT2: [u8; 256] = rp2040_boot2::$default;
}
@ -463,13 +463,13 @@ macro_rules! select_imagedef {
( $( $feature:literal => $imagedef:ident, )+ default => $default:ident ) => {
$(
#[cfg(feature = $feature)]
#[unsafe(link_section = ".start_block")]
#[link_section = ".start_block"]
#[used]
static IMAGE_DEF: crate::block::ImageDef = crate::block::ImageDef::$imagedef();
)*
#[cfg(not(any( $( feature = $feature),* )))]
#[unsafe(link_section = ".start_block")]
#[link_section = ".start_block"]
#[used]
static IMAGE_DEF: crate::block::ImageDef = crate::block::ImageDef::$default();
}

View File

@ -90,7 +90,7 @@ impl<const SIZE: usize> Stack<SIZE> {
#[cfg(all(feature = "rt", feature = "rp2040"))]
#[interrupt]
#[unsafe(link_section = ".data.ram_func")]
#[link_section = ".data.ram_func"]
unsafe fn SIO_IRQ_PROC1() {
let sio = pac::SIO;
// Clear IRQ
@ -115,7 +115,7 @@ unsafe fn SIO_IRQ_PROC1() {
#[cfg(all(feature = "rt", feature = "_rp235x"))]
#[interrupt]
#[unsafe(link_section = ".data.ram_func")]
#[link_section = ".data.ram_func"]
unsafe fn SIO_IRQ_FIFO() {
let sio = pac::SIO;
// Clear IRQ

View File

@ -190,94 +190,94 @@ pub struct RefTable {
}
// --------------------- ref table ---------------------
#[unsafe(link_section = "TL_REF_TABLE")]
#[link_section = "TL_REF_TABLE"]
pub static mut TL_REF_TABLE: MaybeUninit<RefTable> = MaybeUninit::uninit();
#[unsafe(link_section = "MB_MEM1")]
#[link_section = "MB_MEM1"]
pub static mut TL_DEVICE_INFO_TABLE: Aligned<A4, MaybeUninit<DeviceInfoTable>> = Aligned(MaybeUninit::uninit());
#[unsafe(link_section = "MB_MEM1")]
#[link_section = "MB_MEM1"]
pub static mut TL_BLE_TABLE: Aligned<A4, MaybeUninit<BleTable>> = Aligned(MaybeUninit::uninit());
#[unsafe(link_section = "MB_MEM1")]
#[link_section = "MB_MEM1"]
pub static mut TL_THREAD_TABLE: Aligned<A4, MaybeUninit<ThreadTable>> = Aligned(MaybeUninit::uninit());
#[unsafe(link_section = "MB_MEM1")]
#[link_section = "MB_MEM1"]
pub static mut TL_LLD_TESTS_TABLE: Aligned<A4, MaybeUninit<LldTestsTable>> = Aligned(MaybeUninit::uninit());
#[unsafe(link_section = "MB_MEM1")]
#[link_section = "MB_MEM1"]
pub static mut TL_BLE_LLD_TABLE: Aligned<A4, MaybeUninit<BleLldTable>> = Aligned(MaybeUninit::uninit());
#[unsafe(link_section = "MB_MEM1")]
#[link_section = "MB_MEM1"]
pub static mut TL_SYS_TABLE: Aligned<A4, MaybeUninit<SysTable>> = Aligned(MaybeUninit::uninit());
#[unsafe(link_section = "MB_MEM1")]
#[link_section = "MB_MEM1"]
pub static mut TL_MEM_MANAGER_TABLE: Aligned<A4, MaybeUninit<MemManagerTable>> = Aligned(MaybeUninit::uninit());
#[unsafe(link_section = "MB_MEM1")]
#[link_section = "MB_MEM1"]
pub static mut TL_TRACES_TABLE: Aligned<A4, MaybeUninit<TracesTable>> = Aligned(MaybeUninit::uninit());
#[unsafe(link_section = "MB_MEM1")]
#[link_section = "MB_MEM1"]
pub static mut TL_MAC_802_15_4_TABLE: Aligned<A4, MaybeUninit<Mac802_15_4Table>> = Aligned(MaybeUninit::uninit());
#[unsafe(link_section = "MB_MEM1")]
#[link_section = "MB_MEM1"]
pub static mut TL_ZIGBEE_TABLE: Aligned<A4, MaybeUninit<ZigbeeTable>> = Aligned(MaybeUninit::uninit());
// --------------------- tables ---------------------
#[unsafe(link_section = "MB_MEM1")]
#[link_section = "MB_MEM1"]
pub static mut FREE_BUF_QUEUE: Aligned<A4, MaybeUninit<LinkedListNode>> = Aligned(MaybeUninit::uninit());
#[allow(dead_code)]
#[unsafe(link_section = "MB_MEM1")]
#[link_section = "MB_MEM1"]
pub static mut TRACES_EVT_QUEUE: Aligned<A4, MaybeUninit<LinkedListNode>> = Aligned(MaybeUninit::uninit());
#[unsafe(link_section = "MB_MEM2")]
#[link_section = "MB_MEM2"]
pub static mut CS_BUFFER: Aligned<A4, MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + TL_CS_EVT_SIZE]>> =
Aligned(MaybeUninit::uninit());
#[unsafe(link_section = "MB_MEM2")]
#[link_section = "MB_MEM2"]
pub static mut EVT_QUEUE: Aligned<A4, MaybeUninit<LinkedListNode>> = Aligned(MaybeUninit::uninit());
#[unsafe(link_section = "MB_MEM2")]
#[link_section = "MB_MEM2"]
pub static mut SYSTEM_EVT_QUEUE: Aligned<A4, MaybeUninit<LinkedListNode>> = Aligned(MaybeUninit::uninit());
// --------------------- app tables ---------------------
#[cfg(feature = "mac")]
#[unsafe(link_section = "MB_MEM2")]
#[link_section = "MB_MEM2"]
pub static mut MAC_802_15_4_CMD_BUFFER: Aligned<A4, MaybeUninit<CmdPacket>> = Aligned(MaybeUninit::uninit());
#[cfg(feature = "mac")]
#[unsafe(link_section = "MB_MEM2")]
#[link_section = "MB_MEM2"]
pub static mut MAC_802_15_4_NOTIF_RSP_EVT_BUFFER: MaybeUninit<
Aligned<A4, [u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255]>,
> = MaybeUninit::uninit();
#[unsafe(link_section = "MB_MEM2")]
#[link_section = "MB_MEM2"]
pub static mut EVT_POOL: Aligned<A4, MaybeUninit<[u8; POOL_SIZE]>> = Aligned(MaybeUninit::uninit());
#[unsafe(link_section = "MB_MEM2")]
#[link_section = "MB_MEM2"]
pub static mut SYS_CMD_BUF: Aligned<A4, MaybeUninit<CmdPacket>> = Aligned(MaybeUninit::uninit());
#[unsafe(link_section = "MB_MEM2")]
#[link_section = "MB_MEM2"]
pub static mut SYS_SPARE_EVT_BUF: Aligned<A4, MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255]>> =
Aligned(MaybeUninit::uninit());
#[cfg(feature = "mac")]
#[unsafe(link_section = "MB_MEM2")]
#[link_section = "MB_MEM2"]
pub static mut MAC_802_15_4_CNFINDNOT: Aligned<A4, MaybeUninit<[u8; C_SIZE_CMD_STRING]>> =
Aligned(MaybeUninit::uninit());
#[cfg(feature = "ble")]
#[unsafe(link_section = "MB_MEM1")]
#[link_section = "MB_MEM1"]
pub static mut BLE_CMD_BUFFER: Aligned<A4, MaybeUninit<CmdPacket>> = Aligned(MaybeUninit::uninit());
#[cfg(feature = "ble")]
#[unsafe(link_section = "MB_MEM2")]
#[link_section = "MB_MEM2"]
pub static mut BLE_SPARE_EVT_BUF: Aligned<A4, MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255]>> =
Aligned(MaybeUninit::uninit());
#[cfg(feature = "ble")]
#[unsafe(link_section = "MB_MEM2")]
#[link_section = "MB_MEM2"]
// fuck these "magic" numbers from ST ---v---v
pub static mut HCI_ACL_DATA_BUFFER: Aligned<A4, MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + 5 + 251]>> =
Aligned(MaybeUninit::uninit());

View File

@ -331,7 +331,7 @@ mod dual_core {
/// use core::mem::MaybeUninit;
/// use embassy_stm32::{init_secondary, SharedData};
///
/// #[unsafe(link_section = ".ram_d3")]
/// #[link_section = ".ram_d3"]
/// static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
///
/// init_secondary(&SHARED_DATA);

View File

@ -93,6 +93,3 @@ debug = false
debug-assertions = false
opt-level = 0
overflow-checks = false
[patch.crates-io]
cortex-m-rt = { git = "https://github.com/yutannihilation/cortex-m", branch = "fix/allow-unsafe-wrap-rust2024" }