Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RP2350 multicore enable FPU #899

Closed
marius-meissner opened this issue Feb 8, 2025 · 2 comments · Fixed by #900
Closed

RP2350 multicore enable FPU #899

marius-meissner opened this issue Feb 8, 2025 · 2 comments · Fixed by #900

Comments

@marius-meissner
Copy link
Contributor

marius-meissner commented Feb 8, 2025

Apparently FPU is only activated by default for the first, but not the second core.
Does it make sense to do this by default for the second core as well?

By default running any floating point operations on the second core crashes:

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 }, move || {
    loop {
        for i in 0..20 {
            timer.delay_ns((i as f64 * 20.33333) as u32)
        }

        onboard_led.set_high().unwrap();
    }
});

By enabling FPU access, the example succeeds:

let _test = core1.spawn(unsafe { &mut CORE1_STACK.mem }, move || {
    unsafe {
        // SCB CPACR Register Address (Coprocessor Access Control Register)
        let scb_cpacr = 0xE000ED88 as *mut u32;

        // Enable CP10 and CP11 (FPU access)
        core::ptr::write_volatile(scb_cpacr, core::ptr::read_volatile(scb_cpacr) | (0xF << 20));

        asm::dsb();
        asm::isb();
    }

    loop {
        for i in 0..20 {
            timer.delay_ns((i as f64 * 20.33333) as u32)
        }

        onboard_led.set_high().unwrap();
    }
});
@marius-meissner marius-meissner changed the title RP2350 multcore enable FPU RP2350 multicore enable FPU Feb 8, 2025
@jannic
Copy link
Member

jannic commented Feb 8, 2025

Thanks for letting us know. This should definitely happen by default when spawning code on the second core, the current behavior is a bug.

@thejpster
Copy link
Member

yeah I can't think why you'd ever not want the FPU enabled

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants