-->
Page 1 of 1

8266/NODEMCU: "`.text’ will not fit in region `iram1_0_seg’"

PostPosted: Sun Jan 19, 2020 5:46 pm
by RayLivingston
I have a large-ish Arduino application running on a NODEMCU. It all works perfectly. I added an I2C A/D converter to the hardware, but now when I try to compile, I get the error:

"`.text’ will not fit in region `iram1_0_seg’"

The I2C (Wire/twi) code itself increases the size of the .text1 segment from 0x7dec bytes to 0x8088 bytes in size, with much of the size seemingly taken up by one of my classes, "GaugeBase.cpp". Here is, I believe, the relevent section of the map file:

.text1 0x40100174 0x8088
*(.literal .text .iram.literal .iram.text .iram.text.* .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
.iram.text.FastLED/platforms/esp/8266/clockless_esp8266.h.73.0
0x40100174 0x14c1 E:\Users\RayL\Documents\Arduino\Build\sketch\src\Gauge\GaugeBase.cpp.o
0x15fd (size before relaxing)
0x40100180 _ZN19ClocklessControllerILi8ELi20ELi50ELi30EL6EOrder66ELi0ELb0ELi50EE15showRGBInternalE15PixelControllerILS0_66ELi1ELj4294967295EE
0x401003c8 _ZN19ClocklessControllerILi7ELi20ELi50ELi30EL6EOrder66ELi0ELb0ELi50EE15showRGBInternalE15PixelControllerILS0_66ELi1ELj4294967295EE
0x40100610 _ZN19ClocklessControllerILi6ELi20ELi50ELi30EL6EOrder66ELi0ELb0ELi50EE15showRGBInternalE15PixelControllerILS0_66ELi1ELj4294967295EE
0x40100858 _ZN19ClocklessControllerILi5ELi20ELi50ELi30EL6EOrder66ELi0ELb0ELi50EE15showRGBInternalE15PixelControllerILS0_66ELi1ELj4294967295EE
0x40100a98 _ZN19ClocklessControllerILi4ELi20ELi50ELi30EL6EOrder66ELi0ELb0ELi50EE15showRGBInternalE15PixelControllerILS0_66ELi1ELj4294967295EE
0x40100cd4 _ZN19ClocklessControllerILi3ELi20ELi50ELi30EL6EOrder66ELi0ELb0ELi50EE15showRGBInternalE15PixelControllerILS0_66ELi1ELj4294967295EE
0x40100f10 _ZN19ClocklessControllerILi2ELi20ELi50ELi30EL6EOrder66ELi0ELb0ELi50EE15showRGBInternalE15PixelControllerILS0_66ELi1ELj4294967295EE
0x4010114c _ZN19ClocklessControllerILi1ELi20ELi50ELi30EL6EOrder66ELi0ELb0ELi50EE15showRGBInternalE15PixelControllerILS0_66ELi1ELj4294967295EE
0x40101394 _ZN19ClocklessControllerILi0ELi20ELi50ELi30EL6EOrder66ELi0ELb0ELi50EE15showRGBInternalE15PixelControllerILS0_66ELi1ELj4294967295EE
*fill* 0x40101635 0x3

I have no clue what to look for in that class to explain it's large iram usage. That class does not use any interrupts, and does nothing unusual - mostly serial I/O and parsing.

What should I be looking for? How do I reduce the iram usage?

Regards,
Ray L.

Re: 8266/NODEMCU: "`.text’ will not fit in region `iram1_0_s

PostPosted: Sun Jan 19, 2020 9:03 pm
by RayLivingston
Found it! It's FastLED. Each pin you attach a FastLED string to creates a "ClocklessController" object to control it. Each of these grabs 584 bytes of iRAM! My code supports on-the-fly re-configuration of the pins, and that mechanism created a ClocklessController object for every pin that MIGHT someday have LEDs actually attached to it. There were nine such pins. I commented out all but the ones actually used in the current projects, which means 4 ClocklessControllers instead of 9, saving ~2.5K. Total iRAM usage is reduced from 0x8088(32,904) bytes, to 0x72b0(29,360) bytes, leaving 3,408 bytes free. I can live with that...

Regards,
Ray L.