Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 7672

MicroPython • Re: Running SDK-C Code on Core in MicroPython

$
0
0
Issue confirmed - as best I can tell

That turned out to be more of a faff than I was expecting. I created a simplified version of what I had been using which has a 'read a counter' method, and a 'launch code on core 1 to increment that counter' method. Compiled, loaded, but that wouldn't appear as a built-in module. No idea why not.

I moved the method calls into the '_rp2' module (modrp2.c) which does import. That worked fine for reading the counter which is initialised to -1 in the C file, then it hung when I attempted to launch on core 1.

I removed my own module, added the code to the '_rp2' module and tried that. Same result, hangs on '.launch' -

Code:

MicroPython v1.29.0-preview.115.g9f396bba8d.dirty on 2026-05-03; Raspberry Pi Pico 2 W with RP2350Type "help()" for more information.>>> import _rp2>>> _rp2.counter()-1>>> _rp2.launch()
That required a power-cycle reset to recover from that.

That it won't "import core1" may suggest there is something wrong in my 'modcore1.c' though it looks to me just like 'modrp2.c'.

That '.counter' works in '_rp2' but not '.launch' suggests to me that should have worked and the issue is with the launching rather than what I have.

No idea what the problem is but it seems there is one. This is the relevant code. I can't see anything wrong with it. I even tried removing the 'sleep_ms', tried launching '&core1_code', forced the lsb of address, made 'core1_code' just a do nothing loop, not touching 'counter' not calling 'sleep_ms', tried adding 'multicore_reset_core1' first, but nope, still hangs -

Code:

static int32_t counter = -1;static void core1_code(void) {    counter = 0;    while (true) {        sleep_ms(1);        counter++;    }}static mp_obj_t core1_launch(void) {    multicore_launch_core1(core1_code);    return mp_const_none;}MP_DEFINE_CONST_FUN_OBJ_0(core1_launch_obj,                          core1_launch);
Also hangs on an RP2040 non-wireless Pico.

My Pico SDK code from 2023, presumably using SDK 1.5.1, which just calls multicore_launch_core1(core1_code)' still works fine on the RP2040 with SDK 2.2.0 so I suspect it is a MicroPython issue.

I think it's going to need someone with a Debug Probe but it might be figured out by looking at the SDK source.

Statistics: Posted by hippy — Sun May 03, 2026 8:35 pm



Viewing all articles
Browse latest Browse all 7672

Latest Images

Trending Articles



Latest Images