Skip to content

section .text' will not fit in region iram1_0_seg' #2908

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
olileger opened this issue Jan 29, 2017 · 10 comments
Closed

section .text' will not fit in region iram1_0_seg' #2908

olileger opened this issue Jan 29, 2017 · 10 comments
Labels
waiting for feedback Waiting on additional info. If it's not received, the issue may be closed.

Comments

@olileger
Copy link

olileger commented Jan 29, 2017

Basic Infos

Hardware: ESP-8266
Core Version: 2.3.0

Description

I try to write my own firmware for my WeMos d1 mini.
I got a main *.ino file that calls a manager.
This manager handles all the application : setup, loop, calls to dependencies (DHT sensor, Wifi controller and so on).
I've written this manager in C++.
Today I tried to add few lines of code to add new features but I'm stopped by a linker error : section .text' will not fit in region iram1_0_seg'
I've ICACHE_FLASH_ATTR-ed all my function but unfortunately it has no solved my issue so I wonder to know what am I doing wrong.

Settings in IDE

Module: Generic ESP8266 Module
Flash Size: 4MB/3MB
CPU Frequency: 80Mhz
Upload Using: SERIAL (USB)
Compiling env : Windows 10, Arduino 1.6.13 (CLI mode)

Sketch

My firmware is available at https://github.com/olileger/iot/tree/master/esp/ESP8266_Firmware

Debug Messages

Loading configuration...
Initializing packages...
Preparing boards...
Verifying...
c:/users/XXXXXX/appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/../lib/gcc/xtensa-lx106-elf/4.8.2
/../../../../xtensa-lx106-elf/bin/ld.exe: C:\Users\XXXXXX\AppData\Local\Temp\arduino_build_110175/ESP8266_Firmware.ino.elf section `.text' will not fit in region `iram1_0_seg'
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board WeMos D1 R2 & mini.
@zgoda
Copy link

zgoda commented Jan 30, 2017

Compiling .pioenvs/d1_mini/src/main.o
Linking .pioenvs/d1_mini/firmware.elf
Calculating size .pioenvs/d1_mini/firmware.elf
Building .pioenvs/d1_mini/firmware.bin
text	   data	    bss	    dec	    hex	filename
319810	  10468	  30056	 360334	  57f8e	.pioenvs/d1_mini/firmware.elf

I guess you should make it a bit smaller to fit on ESP.

@olileger
Copy link
Author

olileger commented Jan 30, 2017

thanks for your feedback zgoda.
Should I use C instead of C++ ? Maybe using the STL is a wrong way.
Btw before having the error the compilation process told me using 49% of memory.

@zgoda
Copy link

zgoda commented Jan 30, 2017

I don't use too much C++ features in my code besides simple classes & compositions so I can't really recommend anything.

BTW 1: Arduino IDE is not that good in detecting memory usage on foreign chips & cores.

BTW 2: you don't need to call ICACHE_FLASH_ATTR when using Arduino core for ESP, this is done automatically.

@olileger
Copy link
Author

good to know many thanks @zgoda :)

@everslick
Copy link
Contributor

first of all, make sure you put all your constant strings into flash memory, by wrapping them in F() and PSTR() macros. example: String foo = F("foo"); this will free up space in the .text section.

@igrr
Copy link
Member

igrr commented Feb 17, 2017

Moving strings into flash should not change utilisation of .text, because strings are placed into .rodata by default. .rodata and .text are placed into different regions of memory (DRAM and IRAM), so freeing up space in DRAM will not make more room in IRAM.

@everslick
Copy link
Contributor

everslick commented Feb 17, 2017 via email

@devyte
Copy link
Collaborator

devyte commented Oct 3, 2017

@olileger is this still valid with 2.4.0-rc1 or latest git?
I don't think this is an issue with the repo. However, I looked at your code briefly, and despite certain bad practices, I don't really see anything obvious, so I have no idea why your .text is so big. I have an app with almost 10000 lines of C++ code myself, including use of std::vector and std::map, and I don't have a problem.
I suggest testing latest git, and also do a clean install of the entire Arduino IDE as well as the ESP boards and all libs. In other words, delete everything, and install from scratch.
Please report back here if the above works for you.

@devyte devyte added the waiting for feedback Waiting on additional info. If it's not received, the issue may be closed. label Oct 3, 2017
@igrr
Copy link
Member

igrr commented Oct 7, 2017

I think this should be fixed by #2804 (which is available in master and in 2.4.0-rc1).

@devyte
Copy link
Collaborator

devyte commented Dec 29, 2017

Closing due to no feedback in over 2 months, age, and likely already fixed in master.

@devyte devyte closed this as completed Dec 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for feedback Waiting on additional info. If it's not received, the issue may be closed.
Projects
None yet
Development

No branches or pull requests

5 participants