2

The RP2040 on my board (Seeeduino XIAO) comes with 2MB of flash ram.

How can I store an array that is too large to fit into RAM in flash, using C and the pico sdk?

As the array exceeds a certain size, the linker throws errors like this one:

[  0%] Linking CXX executable test.elf
/usr/lib/gcc/arm-none-eabi/10.3.1/../../../arm-none-eabi/bin/ld: test.elf section `.data' will not fit in region `RAM'
/usr/lib/gcc/arm-none-eabi/10.3.1/../../../arm-none-eabi/bin/ld: region RAM overflowed
/usr/lib/gcc/arm-none-eabi/10.3.1/../../../arm-none-eabi/bin/ld: region `RAM' overflowed by 182056 bytes

With Arduino, I could just add PROGMEM like so and be done with it:

const PROGMEM uint8_t samples[] = { ... }

This does however not work with the pico sdk.

1 Answer 1

1

Following and slighly modifying the suggestions on the Raspberry Pi forum I got it to work. __in_flash() is what needs to be added:

#include <pico/platform.h>

const uint8_t __in_flash() samples [] = {

This way, I can now use an array of 442615 bytes that would not fit into the 264k internal RAM.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.