How to link write_voloatile core library function to ram

⚓ Rust    📅 2026-04-05    👤 surdeus    👁️ 6      

surdeus

In low level boot loader development, its normal to keep functions at load address from FLASH memory & with vMA at RAM & write init functions that would copy the functions into RAM and execute.

In one such function (one example here) below, though the function is linked to RAM & loaded at run time from flash, the embeddes sytems crashes. While debugging find that write_volatile internal calls (into core library) are mapped to flash sections.

Is there a way to map all the internal calls (into core library too) to .ramfunc ? t trying to explore any rust specific flags that can do this. I can't map the entire core library into RAM section.

The other option for me is to re-write this function without using any core library functions.

#[link_section = ".ramfunc"]
    #[inline(never)]
    pub fn en_flash_controller (&self)
    {
        unsafe {
            //en flash controller
            let qspi0_fctrol  = (self.base as *mut u32).byte_add(REG_FCTRL);
            write_volatile(qspi0_fctrol, 1);
        }
    }

2 posts - 2 participants

Read full topic

🏷️ Rust_feed