# Flash memory overflow message on pico lipo 16MB

**URL:** <https://forums.pimoroni.com/t/flash-memory-overflow-message-on-pico-lipo-16mb/22570>\
**Category:** Support\
**Created:** [July 23, 2023, 3:22pm UTC](https://forums.pimoroni.com/t/flash-memory-overflow-message-on-pico-lipo-16mb/22570 "2023-07-23T15:22:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Krytes42](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/krytes42/32/9964_2.png) [@Krytes42](https://forums.pimoroni.com/u/Krytes42)\
**Post date:** [July 23, 2023, 3:22pm UTC](https://forums.pimoroni.com/t/flash-memory-overflow-message-on-pico-lipo-16mb/22570/1 "2023-07-23T15:22:39Z")

</div>

Hello,  
I’m trying to turn a 16 MB pico lipo into a Chinese-English dictionary. My code works fine when there are only 1,000 entries in the dictionary, but when there are 10,000 entries, I get the following error when running make:

> [97%] Building C object CMakeFiles/epd.dir/home/astra/pico/pico-sdk/lib/tinyusb/src/class/video/video\_device.c.obj  
> [97%] Building C object CMakeFiles/epd.dir/home/astra/pico/pico-sdk/lib/tinyusb/src/portable/raspberrypi/pio\_usb/dcd\_pio\_usb.c.obj  
> [97%] Building C object CMakeFiles/epd.dir/home/astra/pico/pico-sdk/lib/tinyusb/src/tusb.c.obj  
> [98%] Building C object CMakeFiles/epd.dir/home/astra/pico/pico-sdk/lib/tinyusb/src/common/tusb\_fifo.c.obj  
> [98%] Building C object CMakeFiles/epd.dir/home/astra/pico/pico-sdk/src/rp2\_common/pico\_fix/rp2040\_usb\_device\_enumeration/rp2040\_usb\_device\_enumeration.c.obj  
> [98%] Building C object CMakeFiles/epd.dir/home/astra/pico/pico-sdk/src/rp2\_common/hardware\_spi/spi.c.obj  
> [100%] Linking CXX executable epd.elf  
> /usr/lib/gcc/arm-none-eabi/10.3.1/…/…/…/arm-none-eabi/bin/ld: epd.elf section `.rodata' will not fit in region `FLASH’  
> /usr/lib/gcc/arm-none-eabi/10.3.1/…/…/…/arm-none-eabi/bin/ld: region `FLASH’ overflowed by 638420 bytes  
> collect2: error: ld returned 1 exit status  
> make[2]: \*\*\* [CMakeFiles/epd.dir/build.make:1212: epd.elf] Error 1  
> make[1]: \*\*\* [CMakeFiles/Makefile2:1604: CMakeFiles/epd.dir/all] Error 2  
> make: \*\*\* [Makefile:91: all] Error 2

Currently, the file containing font data for the Chinese characters is about 4.6 MB, and the file containing dictionary entries is about 800 kB, so it should be well within the space requirements.

I’m running cmake with the -D PICO\_BOARD=“pimoroni\_picolipo\_16mb” option. Here’s what cmake spits out:

> mycomputer@LAPTOP-61HUGN86:~/pyCode/dictForPico/build$ cmake -D PICO\_BOARD=“pimoroni\_picolipo\_16mb” …  
> Using PICO\_SDK\_PATH from environment (‘/home/mycomputer/pico/pico-sdk’)  
> PICO\_SDK\_PATH is /home/mycomputer/pico/pico-sdk  
> Defaulting PICO\_PLATFORM to rp2040 since not specified.  
> Defaulting PICO platform compiler to pico\_arm\_gcc since not specified.  
> – Defaulting build type to ‘Release’ since not specified.  
> PICO compiler is pico\_arm\_gcc  
> – The CXX compiler identification is GNU 10.3.1  
> – The C compiler identification is GNU 10.3.1  
> – The ASM compiler identification is GNU  
> – Found assembler: /usr/bin/arm-none-eabi-gcc  
> – Detecting CXX compiler ABI info  
> – Detecting CXX compiler ABI info - done  
> – Check for working CXX compiler: /usr/bin/arm-none-eabi-g++ - skipped  
> – Detecting CXX compile features  
> – Detecting CXX compile features - done  
> – Detecting C compiler ABI info  
> – Detecting C compiler ABI info - done  
> – Check for working C compiler: /usr/bin/arm-none-eabi-gcc - skipped  
> – Detecting C compile features  
> – Detecting C compile features - done  
> Build type is Release  
> PICO target board is pimoroni\_picolipo\_16mb.  
> Using board configuration from /home/mycomputer/pico/pico-sdk/src/boards/include/boards/pimoroni\_picolipo\_16mb.h  
> – Found Python3: /usr/bin/python3.10 (found version “3.10.6”) found components: Interpreter  
> TinyUSB available at /home/mycomputer/pico/pico-sdk/lib/tinyusb/src/portable/raspberrypi/rp2040; enabling build support for USB.  
> BTstack available at /home/mycomputer/pico/pico-sdk/lib/btstack  
> cyw43-driver available at /home/mycomputer/pico/pico-sdk/lib/cyw43-driver  
> Pico W Bluetooth build support available.  
> lwIP available at /home/mycomputer/pico/pico-sdk/lib/lwip  
> mbedtls available at /home/mycomputer/pico/pico-sdk/lib/mbedtls  
> – Configuring done  
> – Generating done  
> – Build files have been written to: /home/mycomputer/pyCode/dictForPico/build

I know that pico-sdk/src/boards/include/boards/pimoroni\_picolipo\_16mb.h has

> #ifndef PICO\_FLASH\_SIZE\_BYTES  
> #define PICO\_FLASH\_SIZE\_BYTES (16 \* 1024 \* 1024)  
> #endif

I changed the PICO\_FLASH\_SIZE\_BYTES to be 166 MB instead of 16 just to see what would happen, and there was no effect - I still got the message that region `FLASH’ overflowed by 638420 bytes. How can I get my code to recognize that my pico actually does have 16MB of flash?

---

<div class="post-metadata">

**Author:** ![Krytes42](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/krytes42/32/9964_2.png) [@Krytes42](https://forums.pimoroni.com/u/Krytes42)\
**Post date:** [July 24, 2023, 7:54am UTC](https://forums.pimoroni.com/t/flash-memory-overflow-message-on-pico-lipo-16mb/22570/2 "2023-07-24T07:54:18Z")

</div>

Answer [here](https://forums.raspberrypi.com/viewtopic.php?t=311632) - the 2MB limit needs to be changed in _…/pico-sdk/src/rp2\_common/pico\_standard\_link/memmap\_default.ld_.  
Now my code compiles, but it still won’t run if the dictionary is too large. Is there anything else that I’m missing?

---

<div class="post-metadata">

**Author:** ![bablokb](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@bablokb](https://forums.pimoroni.com/u/bablokb)\
**Post date:** [July 24, 2023, 4:17pm UTC](https://forums.pimoroni.com/t/flash-memory-overflow-message-on-pico-lipo-16mb/22570/3 "2023-07-24T16:17:29Z")

</div>

Flash is one thing, RAM the other. The latter is much smaller (264kB). So if you load a large dictionary, this will probably be too much.

---

<div class="post-metadata">

**Author:** ![Krytes42](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/krytes42/32/9964_2.png) [@Krytes42](https://forums.pimoroni.com/u/Krytes42)\
**Post date:** [July 24, 2023, 8:15pm UTC](https://forums.pimoroni.com/t/flash-memory-overflow-message-on-pico-lipo-16mb/22570/4 "2023-07-24T20:15:11Z")

</div>

The linker seems to indicate that it was using flash. How can I control how much gets loaded into RAM at a time? The dictionary is currently stored in three C++ vectors of (C++) strings:

> vector chineseEntries = {  
> “一”,  
> “一丁不识”,  
> “一丁点”,  
> “一下”,  
> “一下子”,  
> “一不小心”  
> }

If I later access, say, chineseEntries[3], does it try to load the entire vector into RAM at once?

---

<div class="post-metadata">

**Author:** ![bablokb](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@bablokb](https://forums.pimoroni.com/u/bablokb)\
**Post date:** [July 25, 2023, 10:35am UTC](https://forums.pimoroni.com/t/flash-memory-overflow-message-on-pico-lipo-16mb/22570/5 "2023-07-25T10:35:43Z")

</div>

The linker will put your vector (as part of your code) into flash. And the RP2040 can execute code directly from flash. But the vector content isn’t code, it is not executed.

Two options I can think of: partition your vector, but I’m not sure this would really work (no idea how to remove loaded code again). Or use a file-system on part of the flash and load the data from there. I haven’t done that with C++, but it must be possible since MicroPython/CircuitPython do that (and the python-interpreter is nothing but C-code).
