Page 1 of 1

`.text' will not fit in region `iram1_0_seg'

Posted: Sat Dec 03, 2016 3:25 am
by Stational
Hello,

if i try to build my project with the esp-open-sdk i get this error:

xtensa-lx106-elf-gcc -Teagle.app.v6.ld segmentled.o -nostdlib -Wl,--start-group -lmain -lnet80211 -lwpa -llwip -lpp -lphy -lc -Wl,--end-group -lgcc -o segmentled
/home/test/Desktop/opt/esp-open-sdk/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.5/../../../../xtensa-lx106-elf/bin/ld: segmentled section `.text' will not fit in region `iram1_0_seg'
/home/test/Desktop/opt/esp-open-sdk/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.5/../../../../xtensa-lx106-elf/bin/ld: region `iram1_0_seg' overflowed by 1000 bytes
collect2: error: ld returned 1 exit status
<builtin>: recipe for target 'segmentled' failed
make: *** [segmentled] Error 1


My code isn't very long (~250 lines). Why does this happen and how can i fix it?

Re: `.text' will not fit in region `iram1_0_seg'

Posted: Sun Dec 04, 2016 8:35 pm
by pratik
Have you modified your LD files?
Also, note that mbedTLS based builds must use the LD file provided by Espressif (otherwise you have to relocate code to iCache in your LD file).
Also, please specify the SDK version and your environment setup details so that it is easier to track the issue down.

Re: `.text' will not fit in region `iram1_0_seg'

Posted: Fri Dec 09, 2016 5:17 am
by Stational
Hi and thanks for your reply,

could you tell me where i find the LD-files and how i should modify them? SDK is 2.0.0_16_08_10, i use the esp-open-sdk on debian 8.6 64-bit.
I moved the libgcc.a file from:
esp-open-sdk/ESP8266_NONOS/lib/
to
esp-open-sdk/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.5
This helped a bit. I am working on a bigger project right now (~200 lines of code) and i am alredy running against the bound again! I don't understand why this happens, i thought the ESP-12F has 4MB of flash (which is a lot, i think...).

Best regards

Max

Re: `.text' will not fit in region `iram1_0_seg'

Posted: Sun Dec 11, 2016 12:15 pm
by pratik
Please use ICACHE_FLASH_ATTR in all your functions. That is what will place them in flash.
Your functions are getting placed in the iRAM... it is RAM and is in a few KBs only!

Re: `.text' will not fit in region `iram1_0_seg'

Posted: Sat Dec 17, 2016 5:13 am
by Stational
That didn't help, i added:

LOCAL void ICACHE_FLASH_ATTR


in front of all my functions but the message is still the same:

xtensa-lx106-elf-gcc -I. -mlongcalls -c -o sensor.o sensor.c
xtensa-lx106-elf-gcc -Teagle.app.v6.ld sensor.o -nostdlib -Wl,--start-group -lmain -lnet80211 -lwpa -llwip -lpp -lphy -lc -Wl,--end-group -lgcc -o sensor
/home/test/Desktop/opt/esp-open-sdk/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.5/../../../../xtensa-lx106-elf/bin/ld: sensor section `.text' will not fit in region `iram1_0_seg'
/home/test/Desktop/opt/esp-open-sdk/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.5/../../../../xtensa-lx106-elf/bin/ld: region `iram1_0_seg' overflowed by 344 bytes
collect2: error: ld returned 1 exit status
<builtin>: recipe for target 'sensor' failed
make: *** [sensor] Error 1


Could you explain how i fix this problem and how it is caused, please?

Re: `.text' will not fit in region `iram1_0_seg'

Posted: Sun Dec 18, 2016 5:23 am
by Stational
-DICACHE_FLASH
after
CFLAGS = -I.
in the Makefile did it for me.

Re: `.text' will not fit in region `iram1_0_seg'

Posted: Wed Mar 22, 2017 7:12 pm
by rajkumar patel
pratik wrote:Please use ICACHE_FLASH_ATTR in all your functions. That is what will place them in flash.
Your functions are getting placed in the iRAM... it is RAM and is in a few KBs only!


Thanks a lot Pratik, your suggestion worked out!