Moving all read only data/code into the .irom0.text section
Posted: Mon Jun 24, 2019 4:14 pm
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:
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:
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.
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.