RAK3172 ROM overflowed

I use RAK3172 in IDE Arduino.
When I import high-size libraries, I get “ROM overflowed” error.
Have you encountered an error similar to this?
How I can solve it?
When I run even the simplest example codes, it appears to be 61% full from the ROM.
Thanks in advance for your answer.

1 Like

HI Nam,

The Flash memory of the RAK3172 is small (only 256kB) and RUI3 API is large (unfortunately).

Reducing the code size of RUI3 is on the todo list but we don’t know how small we can get it.

Hi bro Beegee,
Can we extern via pin SPI without adjust firmware?
Thank you.

Sorry, I do not understand your question at all.

What do you want to do?

Can we extend it by adding a hardware via SPI communication pins?
I mean use some IC to expand ROM

No, that is not possible. The firmware does not support such external flash.

You can start by optimizing your code, removing any unnecessary elements, and using more efficient algorithms. Consider whether all the libraries you’re including are essential, and if not, try finding alternative, more lightweight libraries that still meet your requirements. Also utilize techniques such as storing constant data in PROGMEM and using the F() macro for string literals to reduce memory usage. Regards

1 Like

They’re already seeing “ROM Overflowed” error, I think that means PROGMEM is full.

2 Likes

Good day,

The space can be increased by performing the following steps:

  1. The bootloader takes 13k, although allocated for it 24k (+4.2% to free space)
  2. Swap areas MCU_USER_DATA and MCU_FACTORY_DEFAULT, and allow to change start address of MCU_USER_DATA (and its size, not everyone needs 30k to store the user settings).

In total this can easily get +15% of free space, changing the initial parameters of the code rather slightly

P.S I think changing the implementation of the printf function could add some more space

Hi croman13n3c,

Could you elaborate on this please? Would love to hear how you went about it. :smiley:

Of course,

  1. Created custom ld file for linker with changed memory layout:
  BL     (rx)    : ORIGIN = 0x08000000, LENGTH = 24K    /* Bootloader */
  ROM    (rx)    : ORIGIN = 0x08006000, LENGTH = 220K   /* Application */
  USERCFG (rx)   : ORIGIN = 0x0803D000, LENGTH = 6K    /* User configuration */

USERCFG is additional section for store device settings (factory, reserved, user), every by minimal flash page size

  1. Changed arduino.json to provide custom linker script:
    "buildPreferences": [
        [
            "build.ldscript",
            "{build.source.path}/rak3172_custom.ld"
        ],
        [
            "upload.maximum_size",
            "249856"
        ]
    ]
  1. Changed mcu_basic.h
    with swapped and new locations
    for RUI3 NVM portions (Arduino15\packages\rak_rui\hardware\stm32\4.0.5\cores\STM32WLE\component\core\mcu\stm32wle5xx)
#define MCU_SYS_CONFIG_NVM_ADDR           0x0803F000
#define MCU_FACTORY_DEFAULT_NVM_ADDR      0x0803E800
#define MCU_USER_DATA_NVM_ADDR            0x0803D000

I think system NVM for RUI3 should be placed at the end of FW and not mixed with user settings block

  1. Maked patch for uploader_ymodem.exe with fixed FW size (not actual) in “info block”. Because RUI3 bootloader check its size and stop flashing.

But RUI3 bootloader have some limitations: its can flash extended size firmware only once - its not erase pages after 220K of whole FW.
I use JLINK for flashing, its not actual for me. Maybe, if i have free time, i make patch for bootloader or write own without these limitations.

And create “platform.local.txt” for location to patched uploader

tools.uploader_ymodem.cmd.windows="{build.path}/../uploader_ymodem.exe"

Yes, encountering a “ROM overflowed” error when using the RAK3172 module with the Arduino IDE is a common issue. The error indicates that the available program memory (ROM) on the RAK3172 is insufficient to accommodate the size of the libraries you are trying to import or the code you are trying to upload.

Some good news about the available application flash for the RAK3172.

With the new RUI3 V4.0.6 (to be released soon), we reduced the RUI3 code size and there is now ~30kByte more flash available.

1 Like

Wow, congratulation developer team.
That means reducing 65% to 15%.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.