Open Gerriko opened 3 years ago
I just noticed that there is some overlap with the issues raised here and some of the solutions given will help some of my issues (re. issue about use of delay): https://github.com/arduino/ArduinoCore-mbed/issues/217
I am reading the Pico documentation again and I see that there are two other methods that can also be used to launch core1.
I wondered if any these two methods have been tested with ArduinoCore-mbed and wondered whether any of these two methods may be better suited with mbed.
void multicore_launch_core1_with_stack (void(*entry)(void), uint32_t *stack_bottom, size_t stack_size_bytes)
void multicore_launch_core1_raw (void(*entry)(void), uint32_t *sp, uint32_t vector_table)
I'm also working with multicore, and I'd just like to add a couple of observations.
delay
(since it calls rtos::ThisThread::sleep_for
).Basically, anything running on core1 (at the time of writing) needs to be pure pico-sdk code.
@magnusnordlander i dont quite get what you mean by "pure pico-sdk". Regarding the RTOS issue do you mean core1 stops running after a short period?
[Caveat: I haven't looked in to this for a few months. Things might have changed, but I'm guessing this is all still true]
@MNS26 There are basically three SDKs you can use when developing for the RP2040. There's the pico-sdk, written in C and supplied by the Raspberry Pi foundation; there's Mbed OS, which internally uses pico-sdk, but which provides a nicer, C++ development environment with an RTOS; and there's the Arduino core, which internally uses Mbed OS, which provide that Arduino ease of use we all know and love.
Mbed OS is not designed for multi-core and is not multi-core aware at all. The RTOS isn't initialized on core 1, and there's no easy way of running two instances of the RTOS (one on each core). Running anything based on the RTOS on core 1 will cause it to freeze. Furthermore, you can't enter into Mbed OS critical sections simultaneously on Core 0 and Core 1, doing so will cause a crash.
A lot of Mbed OS uses either the RTOS or critical sections. As such, it's practically impossible to use any of it on Core 1. Since Arduino Core is built upon Mbed OS, that's also out. Thus you are left with using the pico-sdk.
I'm using a Raspberry Pi Pico board with the ArduinoCore-mbed 2.1.0.
I'm experimenting with the multicore library, which is part of the pico-SDK and I am using a mix of Arduino commands and mbedOS commands.
Observation 1: CORE1 does not like the standard
delay()
or thesleep_ms()
function within a while loop.For example this does not work:
But if I use millis() as a timer function within Core1 it does work:
So this code works for me:
Observation 2: multicore does not like the mbedOS EventQueue function.
First I tried using EventQueue in CORE0, and I found that only one core works and this depends on the order you place things. For example, with this code only Core 1 works:
but if I change the order around so that
multicore_launch_core1(core1_entry);
is called afterqueue.dispatch()
then only core0 works. As in:But if I try and use the EventQueue method in Core 1 it causes a hardware crash. I added a Serial1.begin() in my Core0 setup() and it spits out this info