You can chat about native SDK questions and issues here.

User avatar
By emi11
#65516 I am using the latest RTOS SDK release from Github ie SDK version:1.5.0-dev(488a5a6).
While writing applications I was faced regulary with the linker error message section `.text' will not fit in region `iram1_0_seg'. Of course one can add the attribute "ICACHE_FLASH_ATTR" to allmost all user function (except interrupt handler etc). One finds many questions and proposals what to do. However I did not find an explanation with all the fact but puzzles of single items on many web pages.
Here my summary of investigations:
I run xtensa-lx106-elf-objcopy --only-section .text on my elf object to get the size of the .text section. I was really suprised that I got a size of 32200 bytes. To analyse which function are loaded into the .text section I added the option -Wl,-Map -Wl,map.txt to the linker command. A file map.txt is generated which can be read by a normal text editor.
As iram1_0_seg starts at 0x40100000 one needs to search for this address. Here one finds the start addresses and sizes of all the functions allocated in the .text / iram1_0_seg (and of course also in the other sections). I found out that eg libpp.a allocates a significant amount of memory in the .text section.
I did a copy of libpp.a and run
xtensa-lx106-elf-objcopy --rename-section .text=.irom0.text --rename-section .literal=.irom0.literal libpp.a
which marks all functions in the libpp.a archieve to be allocated in the .irom section ie flash memory.
This is equivalent to the ICACHE_FLASH_ATTR macro in the user code.
I linked the code again - and - the result was a significant reduction of the .text size.
I did the same with libgcc.a and also liblwip.a. Now the .text section of the same user code is reduced to 13145 bytes ie less than 50%.
Of course running code in flash memory is slower as running in RAM., eg RTOS runs in the .text section which makes absolutely sense.
However does anybody know if there are obvious reasons why these libraries (and others) are allocated in the .text section instead in Flash memory by default in the RTOS release of Espressif??