Using both cores of RP2040

That solved the problem of the initialization of the secondary stack. Now it crashes at the elaboration of Ada.Real_Time:

Starting program: /home/re/Devel/rp2040/rp2040_snippets/blink_light_tasking/bin/blink_light_tasking 

Breakpoint 1, 0x10002e40 in __gnat_last_chance_handler ()
(gdb) bt
#0  0x10002e40 in __gnat_last_chance_handler ()
#1  0x100013f8 in system.bb.board_support.time.install_alarm_handler ()
#2  0x10001c7c in system.bb.time.initialize_timers ()
#3  0x10002a6e in system.bb.threads.initialize ()
#4  0x10002828 in system.tasking.initialize ()
#5  0x10001352 in ada__real_time___elabb ()
#6  0x100001fe in adainit () at b__blink_light_tasking.adb:38
#7  0x10000284 in main () at b__blink_light_tasking.adb:60
#8  0x100032a8 in _start_rom ()

It seems to me that there is some basic problem somewhere that I don’t see
(using gnat_arm_elf 14.2.1, gprbuild 25.0.1, alr 2.1.0 on Debian Trixie)

I could solve the mentioned elaboration issues by pragma Elaborate_All (Tasks); in the main program.
It now does not return from Tasks'Elab_Body;. I suppose that is where the tasks are actually started.

Glad the secondary stack workaround worked for you.

I’m not sure why Install_Alarm_Handler is raising an exception, or why Elaborate_All fixes it. Very confusing. Do you have a traceback for when it gets stuck in Tasks’Elab_Body? Is it another exception?

I’ve got another Pico on order so I can start to investigate these issues on my end. I suspect that some things have changed since I did the original port 4 years ago which may have broken things, and they’re only being found now.

As a shot in the dark you could give the more recent gnat_arm_elf 15.1.2 a try and see if that improves the situation.

Also, the embedded-rpi-pico-smp runtime enables exception propagation which might allow the runtime to capture more information about the exception. You could enable semihosting in your debugger and see if any messages get printed there from the last chance handler (the runtime uses semihosting for Ada.Text_IO).

So I’ve received my new Pico and have tried to reproduce the problems you’ve been having, but I’ve not had any luck; I have not been able to reproduce the same problems you’ve been seeing with the tasking runtime.

I created a demo project which uses light-tasking-rpi-pico-smp runtime to blink the LED using two tasks (one on each core), and it compiles and runs successfully without any issues.

The project is on my GitHub here: GitHub - damaki/pico_smp_demo: Ada multicore demo for the Raspberry Pi Pico (RP2040)

Are you able to build and run that project?

Thank you very much for all your efforts and patience.

No, it does not work for me. I can compile and upload cleanly. I can single step through the main program in the debugger. Watching blinky.blink_control.current_status always shows a false value.

OK, that was a typo! Changing the procedure Toggle to Current_Status := not Current_Status; makes it work! :fireworks: :clap: :clap: :fireworks:

Whoops, I had that fix locally too but had forgot to commit it to GitHub. That’s fixed now :slight_smile:

Glad that it’s working for you!