Skip to content

Fix heap allocation for light_tasking_rp2040 runtime#23

Merged
damaki merged 3 commits into
mainfrom
topic/fix-rp2040-heap-alloc
Apr 8, 2026
Merged

Fix heap allocation for light_tasking_rp2040 runtime#23
damaki merged 3 commits into
mainfrom
topic/fix-rp2040-heap-alloc

Conversation

@damaki

@damaki damaki commented Apr 8, 2026

Copy link
Copy Markdown
Owner

This implements __atomic_compare_exchange_4 for the RP2040 by disabling interrupts and using one of the RP2040 spinlocks (when in a multicore configuration). This is needed by s-memory.adb to atomically update the pointer to the top of the heap.

Also added a regression test which reproduces the problem.

Fixes #22

damaki added 2 commits April 8, 2026 19:32
This is intended to detect a regression on the RP2040 where doing heap
allocation causes a linker error with the light_tasking_rp2040 runtime.
This is needed by s-memory.adb for the light_tasking_rp2040 runtime
which does an atomic update of the pointer to the top of the heap.
@damaki damaki self-assigned this Apr 8, 2026
The version provided by bb-runtimes does not implement
__atomic_compare_exchange_4, which is required by System.Memory
on light-tasking runtimes. This custom version adds that primitive.
@damaki damaki merged commit 20bd973 into main Apr 8, 2026
2 checks passed
@damaki damaki deleted the topic/fix-rp2040-heap-alloc branch April 8, 2026 21:46
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 this pull request may close these issues.

RP2040: heap allocation does not work with light_tasking_rp2040 runtime

1 participant