On an RP2040 there are two 4k memory blocks that are unique to each core that can be assigned to each core for stack respectively. How do you do this in Rust? The following code works but you have no control over the memory location.
use rp2040_hal::{pac, gpio::Pins, sio::Sio, multicore::{Multicore, Stack}};
static mut CORE1_STACK: Stack<4096> = Stack::new();
fn core1_task() -> ! {
loop {}
}
fn main() -> ! {
let mut pac = pac::Peripherals::take().unwrap();
let mut sio = Sio::new(pac.SIO);
// Other init code above this line
let mut mc = Multicore::new(&mut pac.PSM, &mut pac.PPB, &mut sio.fifo);
let cores = mc.cores();
let core1 = &mut cores[1];
let _test = core1.spawn(unsafe { &mut CORE1_STACK.mem }, core1_task);
// The rest of your application below this line
}
With a memory model like:
MEMORY {
BOOT2 : ORIGIN = 0x10000000, LENGTH = 0x100
FLASH : ORIGIN = 0x10000100, LENGTH = 2048K - 0x100
RAM : ORIGIN = 0x20000000, LENGTH = 231K
RAM1 : ORIGIN = 0x20039c00, LENGTH = 25K
STK : ORIGIN = 0x20040000, LENGTH = 4K
STK1 : ORIGIN = 0x20041000, LENGTH = 4K
}
I want to assign STK1 to Core1.