Using the new Arduino IDE for ESP8266 and found bugs, report them here

Moderator: igrr

User avatar
By aaronneal
#26593 The title is a bit vague, however,

I have modified a library for some external module that communicates over UART. I have finally got it working after many issues with this error from the IDE:
Code: Select allsection `.text' will not fit in region `iram1_0_seg'
, I overcame this by adding
Code: Select all TMR_Status ICACHE_FLASH_ATTR
in front of all the functions in the library. (Please let me know if this is a bad mistake, it seems to work for now).

I can compile this fine, without ESP8266wifi.h and it leaves me with quite a lot of space left:

Code: Select allSketch uses 291,160 bytes (27%) of program storage space. Maximum is 1,044,464 bytes.
Global variables use 43,340 bytes (52%) of dynamic memory, leaving 38,580 bytes for local variables. Maximum is 81,920 bytes.


however by simply adding in #include <ESP8266WiFi.h>, this error returns:

Code: Select allsection `.text' will not fit in region `iram1_0_seg'
collect2.exe: error: ld returned 1 exit status
Error compiling.


Any help would be massively appreciated, I would like to debug this device over MQTT, but I cant at the moment.

No suggestion is too silly, I have been at this for a few days now :roll:

Many Thanks, Aaron
User avatar
By igrr
#26620 When Arduino tells you
Code: Select allSketch uses 291,160 bytes (27%) of program storage space

it doesn't tell the whole story. More accurate info would look like
Code: Select allSketch uses 31,000 bytes (97%) of RAM program storage and 260,160 bytes (25%) of Flash program storage space.

Unfortunately, Arduino IDE is not flexible enough in this respect, so we can only display the "total" size, even though it is in fact composed of two separate segments.
My guess is that your library is filling up almost all the instruction RAM space, so when you add ESP8266WiFi there is no more space for the few functions which it needs to put there.
To verify that, build your sketch without ESP8266WiFi library and run objdump on the output ELF file:
Code: Select all/path/to/xtensa-lx106-elf-objdump -h /path/to/temp/folder/Sketch.cpp.elf

Enable verbose compiler output in Arduino prefrences to get the path to objdump and the path to the build folder.
This should give you something like this:
Code: Select all
Sketch.cpp.elf:     file format elf32-xtensa-le

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .data         00000434  3ffe8000  3ffe8000  000000d8  2**3
                  CONTENTS, ALLOC, LOAD, DATA
  1 .rodata       00000028  3ffe8438  3ffe8438  00000510  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  2 .text         000011e5  40100000  40100000  00000538  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  3 .debug_frame  00000038  00000000  00000000  00001720  2**2
                  CONTENTS, READONLY, DEBUGGING
  4 .debug_info   0000077c  00000000  00000000  00001758  2**0
                  CONTENTS, READONLY, DEBUGGING
.... more output skipped


This should tell you how much space out of the 32k IRAM your .text segment is using.