joostn wrote:jcmvbkbc wrote:This script produces ELF as expected, but still doesn't work when I flash it. Maybe I'm doing something wrong as well...
I found a way to get all code in Flash by default! Modify the linker script as follows:Code: Select all.text : ALIGN(4)
{
...
/* *(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*) */
*(.literal .text .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
...
} >iram1_0_seg :iram1_0_phdr
.irom0.text : ALIGN(4)
{
_irom0_text_start = ABSOLUTE(.);
*(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text)
*(.literal.* .text.*)
_irom0_text_end = ABSOLUTE(.);
} >irom0_0_seg :irom0_0_phdr
So I've moved the .text.* and .literal.* to the irom0 section. I've added '-ffunction-sections -fdata-sections' to the gcc compiler flags, which causes my own code to go into .text.* instead of .text. The startup code is in .text so it will end up in the right section.
Thank you for that great tip! I was searching for solutions for days now and it is finally working. I believe there is slight effect on the performance because my debug prints (which were all nice and aligned before) are all kinda messed up.
One question - ICACHE_FLASH_ATTR and ICACHE_RODATA_ATTR does not have sense now as all goes to the irom0_0_seg section automatically. But what if I want to move something back, as example ISR (UART) functions? Will macro like this help? :
#define ICACHE_IRAM_ATTR __attribute__((section(".text")))
Just tested - it is working as expected But, is it the right section or should I use any other or even define my own?
__attribute__((section(".iram1.text")))
This would force it into ram regardless of where .text goes.
And yes all interrupt code must go into ram entirely:
http://bbs.espressif.com/viewtopic.php?f=7&t=150