Advanced Users can post their questions and comments here for the not so Newbie crowd.

Moderator: eriksl

User avatar
By Artium
#82921 I am trying to port a relatively big library to ESP8266. I am working with the SDK and not the Arduino libraries.

Since I hit the ROM limitation, I decided to move as much as possible of it's code and constant data to the FLASH.

One way to do this is to add an attribute to each large constant array I found in the code:

Code: Select all__attribute__((section(".irom.text"))) __attribute__((aligned(4)))


But this was not enough, and so I decided to be a smart-ass and and blindly move everything into the irom.text section.

I did this by modifying the linker script (eagle.app.v6.common.ld), moving these lines:

Code: Select all    *(.rodata)
    *(.rodata.*)


from .rodata to .irom0.text.

After flashing the device, the boot loader started resetting wildly.

So, I tried to test this approach with a basic blink code which causes the ESP to hang right after the bootloader finishes.

Maybe someone has an idea of why it was bad to put everything into irom? Maybe if the reason is specific pieces of code that can not run from FLASH, I can exclude them, while the rest of the code will run from the FLASH.
User avatar
By eriksl
#83158 As you already found out: you can't do that. There are some restrictions, one of them being that all data needs to be word aligned and you already took care of that. Bug there is another restriction that demands all data being read and written as complete words. You can't use bytes or half words. That's the most usual and annoying restriction, and it makes it impossible to store character strings in flash (without particular measures) even though in practice that's the area where you can save most memory.