Use flash memory

I am trying to allocate 2-dimensionnal array on the web IDE and it seems that I quickly reach the maximum amount of memory I am able to use. When I try to allocate memory for an 144*100 array, I already get an error…

I read that the core has 1.5mo available on flash memory, is it possible to get access to it using the web IDE?
Also, is it possible to wire the Core to an external flash memory to get a bigger amount of memory?

Thanks for your answers,

Marc

PS: this is the error I get

In file included from neopixel/neopixel.cpp:50:0:
neopixel/neopixel.h: In constructor ‘Adafruit_NeoPixel::Adafruit_NeoPixel(uint16_t, uint8_t, uint8_t)’:
neopixel/neopixel.h:99:5: warning: ‘Adafruit_NeoPixel::pixels’ will be initialized after [-Wreorder]
*pixels; // Holds LED color values (3 bytes each)
^
neopixel/neopixel.h:95:5: warning: ‘const uint8_t Adafruit_NeoPixel::type’ [-Wreorder]
type; // Pixel type flag (400 vs 800 KHz)
^
neopixel/neopixel.cpp:65:1: warning: when initialized here [-Wreorder]
Adafruit_NeoPixel::Adafruit_NeoPixel(uint16_t n, uint8_t p, uint8_t t) :
^
/usr/local/gcc-arm-embedded-gcc-arm-none-eabi-4_8-2014q2-20140609-linux-tar-bz2/bin/…/lib/gcc/arm-none-eabi/4.8.4/…/…/…/…/arm-none-eabi/bin/ld: 22f2e3ad44a5cbd095b0e85627aee35d5a09ad8a44f37a51afd3f35ba85c.elf section .bss' will not fit in regionRAM’
/usr/local/gcc-arm-embedded-gcc-arm-none-eabi-4_8-2014q2-20140609-linux-tar-bz2/bin/…/lib/gcc/arm-none-eabi/4.8.4/…/…/…/…/arm-none-eabi/bin/ld: region `RAM’ overflowed by 62924 bytes
collect2: error: ld returned 1 exit status
make[1]: *** [22f2e3ad44a5cbd095b0e85627aee35d5a09ad8a44f37a51afd3f35ba85c.elf] Error 1
make: *** [main] Error 2

It not flash you are running out of but ram.
Sounds like you want to add your array to flash without it using ram .

Look at … http://playground.arduino.cc/Main/PROGMEM

You want the photon version of it.

@peter_a, there is no PROGMEM equivalent on the STM32 platform since both flash and RAM are mapped in one address space. To store a NON-MODIFIABLE array in flash, you specify the array as const. @TheDude, the Core really only has about 6-10KB of available RAM while you need way more. Have you considered getting a Photon which has about 60-70KB of RAM available?

1 Like

Thanks for your answers!
@peekay123 Even if the RAM is small, is it possible to store my array on the flash memory instead of the RAM?

@TheDude, for an array of 144x100 x 3 bytes each = 43,200bytes. The neopixel library needs RAM to act as a display buffer. If that buffer NEVER changes then flash could work but 43KB may be too much for the Core. Storing it in external flash would require a change to the Neopixel library.

Just as a reminder - RAM = Random Access Memory, ROM = Read Only Memory

That buffer will never change. Basically, I would fill the array first with the relevant data and then, in a second part, I would access this data to control my LED strip. I would only need to flush it when I stream another “LED track”.
If I only do this operation of write and read, I don’t understand why it would require to change the neopixel library?

@TheDude, first, you can’t flash the internal flash memory from your program. You CAN flash the external flash using the flashee-prom library that is available but the Neopixel library expects the buffer in RAM so all the code accessing the buffer data would need to be changed to read the buffer from external flash.

1 Like