Merge pull request #4170 from yutannihilation/chore/fix-unsafe-attribute-rust2024
chore: Wrap `link_section` attribute in example code with `unsafe()` for compatibility with Rust 2024 edition
This commit is contained in:
commit
64a2b9b2a3
@ -268,7 +268,7 @@ General steps:
|
||||
1. Find out which memory region BDMA has access to. You can get this information from the bus matrix and the memory mapping table in the STM32 datasheet.
|
||||
2. Add the memory region to `memory.x`, you can modify the generated one from https://github.com/embassy-rs/stm32-data-generated/tree/main/data/chips.
|
||||
3. You might need to modify `build.rs` to make cargo pick up the modified `memory.x`.
|
||||
4. In your code, access the defined memory region using `#[link_section = ".xxx"]`
|
||||
4. In your code, access the defined memory region using `#[unsafe(link_section = ".xxx")]`
|
||||
5. Copy data to that region before using BDMA.
|
||||
|
||||
See link:https://github.com/embassy-rs/embassy/blob/main/examples/stm32h7/src/bin/spi_bdma.rs[SMT32H7 SPI BDMA example] for more details.
|
||||
|
||||
@ -20,7 +20,7 @@ static APP_B: &[u8] = &[0, 1, 2, 3];
|
||||
#[cfg(not(feature = "skip-include"))]
|
||||
static APP_B: &[u8] = include_bytes!("../../b.bin");
|
||||
|
||||
#[link_section = ".shared_data"]
|
||||
#[unsafe(link_section = ".shared_data")]
|
||||
static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
|
||||
|
||||
#[embassy_executor::main]
|
||||
|
||||
@ -11,7 +11,7 @@ use embassy_stm32::SharedData;
|
||||
use embassy_time::Timer;
|
||||
use panic_reset as _;
|
||||
|
||||
#[link_section = ".shared_data"]
|
||||
#[unsafe(link_section = ".shared_data")]
|
||||
static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
|
||||
|
||||
#[embassy_executor::main]
|
||||
|
||||
@ -25,7 +25,7 @@ fn main() {
|
||||
.write_all(
|
||||
format!(
|
||||
r##"
|
||||
#[link_section = ".biv"]
|
||||
#[unsafe(link_section = ".biv")]
|
||||
#[used]
|
||||
static BOOT_IMAGE_VERSION: u32 = 0x{:02x}{:02x}{:02x}00;
|
||||
"##,
|
||||
|
||||
@ -6,15 +6,15 @@ use {defmt_rtt as _, panic_probe as _};
|
||||
// auto-generated version information from Cargo.toml
|
||||
include!(concat!(env!("OUT_DIR"), "/biv.rs"));
|
||||
|
||||
#[link_section = ".otfad"]
|
||||
#[unsafe(link_section = ".otfad")]
|
||||
#[used]
|
||||
static OTFAD: [u8; 256] = [0; 256];
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[link_section = ".fcb"]
|
||||
#[unsafe(link_section = ".fcb")]
|
||||
#[used]
|
||||
static FCB: FlexSPIFlashConfigurationBlock = FlexSPIFlashConfigurationBlock::build();
|
||||
|
||||
#[link_section = ".keystore"]
|
||||
#[unsafe(link_section = ".keystore")]
|
||||
#[used]
|
||||
static KEYSTORE: [u8; 2048] = [0; 2048];
|
||||
|
||||
@ -14,7 +14,7 @@ use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
// Program metadata for `picotool info`.
|
||||
// This isn't needed, but it's recomended to have these minimal entries.
|
||||
#[link_section = ".bi_entries"]
|
||||
#[unsafe(link_section = ".bi_entries")]
|
||||
#[used]
|
||||
pub static PICOTOOL_ENTRIES: [embassy_rp::binary_info::EntryAddr; 4] = [
|
||||
embassy_rp::binary_info::rp_program_name!(c"Blinky Example"),
|
||||
|
||||
@ -18,7 +18,7 @@ use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
// Program metadata for `picotool info`.
|
||||
// This isn't needed, but it's recommended to have these minimal entries.
|
||||
#[link_section = ".bi_entries"]
|
||||
#[unsafe(link_section = ".bi_entries")]
|
||||
#[used]
|
||||
pub static PICOTOOL_ENTRIES: [embassy_rp::binary_info::EntryAddr; 4] = [
|
||||
embassy_rp::binary_info::rp_program_name!(c"Blinky Example"),
|
||||
|
||||
@ -18,7 +18,7 @@ use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
// Program metadata for `picotool info`.
|
||||
// This isn't needed, but it's recomended to have these minimal entries.
|
||||
#[link_section = ".bi_entries"]
|
||||
#[unsafe(link_section = ".bi_entries")]
|
||||
#[used]
|
||||
pub static PICOTOOL_ENTRIES: [embassy_rp::binary_info::EntryAddr; 4] = [
|
||||
embassy_rp::binary_info::rp_program_name!(c"Blinky Example"),
|
||||
|
||||
@ -16,7 +16,7 @@ use pio::{Common, Config, FifoJoin, Instance, InterruptHandler, Pio, PioPin, Shi
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
// Program metadata for `picotool info`
|
||||
#[link_section = ".bi_entries"]
|
||||
#[unsafe(link_section = ".bi_entries")]
|
||||
#[used]
|
||||
pub static PICOTOOL_ENTRIES: [embassy_rp::binary_info::EntryAddr; 4] = [
|
||||
embassy_rp::binary_info::rp_program_name!(c"example_pio_rotary_encoder_rxf"),
|
||||
|
||||
@ -8,7 +8,7 @@ use embassy_stm32::Config;
|
||||
use embassy_time::Timer;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
#[link_section = ".ram_d3"]
|
||||
#[unsafe(link_section = ".ram_d3")]
|
||||
static mut DMA_BUF: [u16; 2] = [0; 2];
|
||||
|
||||
#[embassy_executor::main]
|
||||
|
||||
@ -16,9 +16,9 @@ const DMA_BUFFER_LENGTH: usize = HALF_DMA_BUFFER_LENGTH * 2; // 2 half-blocks
|
||||
const SAMPLE_RATE: u32 = 48000;
|
||||
|
||||
//DMA buffer must be in special region. Refer https://embassy.dev/book/#_stm32_bdma_only_working_out_of_some_ram_regions
|
||||
#[link_section = ".sram1_bss"]
|
||||
#[unsafe(link_section = ".sram1_bss")]
|
||||
static mut TX_BUFFER: GroundedArrayCell<u32, DMA_BUFFER_LENGTH> = GroundedArrayCell::uninit();
|
||||
#[link_section = ".sram1_bss"]
|
||||
#[unsafe(link_section = ".sram1_bss")]
|
||||
static mut RX_BUFFER: GroundedArrayCell<u32, DMA_BUFFER_LENGTH> = GroundedArrayCell::uninit();
|
||||
|
||||
#[embassy_executor::main]
|
||||
|
||||
@ -16,7 +16,7 @@ use static_cell::StaticCell;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
// Defined in memory.x
|
||||
#[link_section = ".ram_d3"]
|
||||
#[unsafe(link_section = ".ram_d3")]
|
||||
static mut RAM_D3: GroundedArrayCell<u8, 256> = GroundedArrayCell::uninit();
|
||||
|
||||
#[embassy_executor::task]
|
||||
|
||||
@ -24,10 +24,10 @@ const HALF_DMA_BUFFER_LENGTH: usize = BLOCK_LENGTH * CHANNEL_COUNT;
|
||||
const DMA_BUFFER_LENGTH: usize = HALF_DMA_BUFFER_LENGTH * 2; // 2 half-blocks
|
||||
|
||||
// DMA buffers must be in special regions. Refer https://embassy.dev/book/#_stm32_bdma_only_working_out_of_some_ram_regions
|
||||
#[link_section = ".sram1"]
|
||||
#[unsafe(link_section = ".sram1")]
|
||||
static mut SPDIFRX_BUFFER: GroundedArrayCell<u32, DMA_BUFFER_LENGTH> = GroundedArrayCell::uninit();
|
||||
|
||||
#[link_section = ".sram4"]
|
||||
#[unsafe(link_section = ".sram4")]
|
||||
static mut SAI_BUFFER: GroundedArrayCell<u32, DMA_BUFFER_LENGTH> = GroundedArrayCell::uninit();
|
||||
|
||||
#[embassy_executor::main]
|
||||
|
||||
@ -10,7 +10,7 @@ use embassy_stm32::SharedData;
|
||||
use embassy_time::Timer;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
#[link_section = ".ram_d3.shared_data"]
|
||||
#[unsafe(link_section = ".ram_d3.shared_data")]
|
||||
static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
|
||||
|
||||
#[embassy_executor::main]
|
||||
|
||||
@ -10,7 +10,7 @@ use embassy_stm32::SharedData;
|
||||
use embassy_time::Timer;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
#[link_section = ".ram_d3.shared_data"]
|
||||
#[unsafe(link_section = ".ram_d3.shared_data")]
|
||||
static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
|
||||
|
||||
#[embassy_executor::main]
|
||||
|
||||
@ -10,7 +10,7 @@ use embassy_stm32::SharedData;
|
||||
use embassy_time::Timer;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
#[link_section = ".shared_data"]
|
||||
#[unsafe(link_section = ".shared_data")]
|
||||
static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
|
||||
|
||||
#[embassy_executor::main]
|
||||
|
||||
@ -9,7 +9,7 @@ use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
||||
use embassy_stm32::SharedData;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
#[link_section = ".shared_data"]
|
||||
#[unsafe(link_section = ".shared_data")]
|
||||
static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
|
||||
|
||||
#[entry]
|
||||
|
||||
@ -10,7 +10,7 @@ use embassy_stm32::gpio::Pull;
|
||||
use embassy_stm32::SharedData;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
#[link_section = ".shared_data"]
|
||||
#[unsafe(link_section = ".shared_data")]
|
||||
static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
|
||||
|
||||
#[embassy_executor::main]
|
||||
|
||||
@ -9,7 +9,7 @@ use embassy_stm32::flash::Flash;
|
||||
use embassy_stm32::SharedData;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
#[link_section = ".shared_data"]
|
||||
#[unsafe(link_section = ".shared_data")]
|
||||
static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
|
||||
|
||||
#[embassy_executor::main]
|
||||
|
||||
@ -14,7 +14,7 @@ bind_interrupts!(struct Irqs{
|
||||
RNG => rng::InterruptHandler<peripherals::RNG>;
|
||||
});
|
||||
|
||||
#[link_section = ".shared_data"]
|
||||
#[unsafe(link_section = ".shared_data")]
|
||||
static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
|
||||
|
||||
#[embassy_executor::main]
|
||||
|
||||
@ -12,7 +12,7 @@ use embassy_stm32::{Config, SharedData};
|
||||
use embassy_time::Timer;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
#[link_section = ".shared_data"]
|
||||
#[unsafe(link_section = ".shared_data")]
|
||||
static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
|
||||
|
||||
#[embassy_executor::main]
|
||||
|
||||
@ -14,7 +14,7 @@ bind_interrupts!(struct Irqs{
|
||||
LPUART1 => InterruptHandler<peripherals::LPUART1>;
|
||||
});
|
||||
|
||||
#[link_section = ".shared_data"]
|
||||
#[unsafe(link_section = ".shared_data")]
|
||||
static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
|
||||
|
||||
/*
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user