ERROR section`.text' will not fit in region `iram1_0_seg' with fastled (esp8266)

SO i am trying to make a led controller with the fastled library where the user can input wich led type they have and wich RGB arrangnement the led has.
So i did try this and it worked.

void setFastled()
{
String lt = ledType;
 if (lt == "WS2812B") {
      ws2812B ();
 }  

void ws2812B ()
{
  String la = ledArrange;
    if (la == "RGB") {
     FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, LED_NUMBER);
    } else if (la == "RBG") {
     FastLED.addLeds<WS2812B, DATA_PIN, RBG>(leds, LED_NUMBER);
    } else if (la == "GRB") {
    FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, LED_NUMBER);
    } else if (la == "GBR") {
    FastLED.addLeds<WS2812B, DATA_PIN, GBR>(leds, LED_NUMBER);
    } else if (la == "BRG") {
     FastLED.addLeds<WS2812B, DATA_PIN, BRG>(leds, LED_NUMBER);
    } else if (la == "BGR") {
     FastLED.addLeds<WS2812B, DATA_PIN, BGR>(leds, LED_NUMBER);
    }
    FastLED.setMaxPowerInVoltsAndMilliamps(5, LED_LIMIT_MILLIAMPS);
  }

But when i do add a few more.

void setFastled()
{
String lt = ledType;
 
 if (lt == "WS2812B") {
      ws2812 ();
 }  
    if (lt == "WS2812") {
      ws2812 ();
    }
    if (lt == "WS2811") {
      ws2811 ();
    }
    if (lt == "WS2811_400") {
      ws2811_400 ();
    }
    if (lt == "SM16703") {
      sm16703 ();
    }
    if (lt == "TM1829") {
      tm1829 ();
    }
    if (lt == "TM1812") {
      tm1812 ();
    }
    if (lt == "TM1809") {
      tm1809 ();
    }
    if (lt == "TM1804") {
      tm1804 ();
    }
  }




void ws2812B ()
{
  String la = ledArrange;
    if (la == "RGB") {
     FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, LED_NUMBER);
    } else if (la == "RBG") {
     FastLED.addLeds<WS2812B, DATA_PIN, RBG>(leds, LED_NUMBER);
    } else if (la == "GRB") {
    FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, LED_NUMBER);
    } else if (la == "GBR") {
    FastLED.addLeds<WS2812B, DATA_PIN, GBR>(leds, LED_NUMBER);
    } else if (la == "BRG") {
     FastLED.addLeds<WS2812B, DATA_PIN, BRG>(leds, LED_NUMBER);
    } else if (la == "BGR") {
     FastLED.addLeds<WS2812B, DATA_PIN, BGR>(leds, LED_NUMBER);
    }
    FastLED.setMaxPowerInVoltsAndMilliamps(5, LED_LIMIT_MILLIAMPS);
  }
  
  void ws2812 ()
{
  String la = ledArrange;
    if (la == "RGB") {
     FastLED.addLeds<WS2812, DATA_PIN, RGB>(leds, LED_NUMBER);
    } else if (la == "RBG") {
     FastLED.addLeds<WS2812, DATA_PIN, RBG>(leds, LED_NUMBER);
    } else if (la == "GRB") {
    FastLED.addLeds<WS2812, DATA_PIN, GRB>(leds, LED_NUMBER);
    } else if (la == "GBR") {
    FastLED.addLeds<WS2812, DATA_PIN, GBR>(leds, LED_NUMBER);
    } else if (la == "BRG") {
     FastLED.addLeds<WS2812, DATA_PIN, BRG>(leds, LED_NUMBER);
    } else if (la == "BGR") {
     FastLED.addLeds<WS2812, DATA_PIN, BGR>(leds, LED_NUMBER);
    }
    FastLED.setMaxPowerInVoltsAndMilliamps(5, LED_LIMIT_MILLIAMPS);
  }


void ws2811()
{
  String la = ledArrange;
    if (la == "RGB") {
     FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, LED_NUMBER);
    } else if (la == "RBG") {
     FastLED.addLeds<WS2811, DATA_PIN, RBG>(leds, LED_NUMBER);
    } else if (la == "GRB") {
     FastLED.addLeds<WS2811, DATA_PIN, GRB>(leds, LED_NUMBER);
    } else if (la == "GBR") {
     FastLED.addLeds<WS2811, DATA_PIN, GBR>(leds, LED_NUMBER);
    } else if (la == "BRG") {
     FastLED.addLeds<WS2811, DATA_PIN, BRG>(leds, LED_NUMBER);
    } else if (la == "BGR") {
     FastLED.addLeds<WS2811, DATA_PIN, BGR>(leds, LED_NUMBER);
    }
    FastLED.setMaxPowerInVoltsAndMilliamps(5, LED_LIMIT_MILLIAMPS);
  }

void ws2811_400()
{
  String la = ledArrange;
    if (la == "RGB") {
     FastLED.addLeds<WS2811_400, DATA_PIN, RGB>(leds, LED_NUMBER);
    } else if (la == "RBG") {
     FastLED.addLeds<WS2811_400, DATA_PIN, RBG>(leds, LED_NUMBER);
    } else if (la == "GRB") {
     FastLED.addLeds<WS2811_400, DATA_PIN, GRB>(leds, LED_NUMBER);
    } else if (la == "GBR") {
     FastLED.addLeds<WS2811_400, DATA_PIN, GBR>(leds, LED_NUMBER);
    } else if (la == "BRG") {
     FastLED.addLeds<WS2811_400, DATA_PIN, BRG>(leds, LED_NUMBER);
    } else if (la == "BGR") {
     FastLED.addLeds<WS2811_400, DATA_PIN, BGR>(leds, LED_NUMBER);
    }
    FastLED.setMaxPowerInVoltsAndMilliamps(12, LED_LIMIT_MILLIAMPS);
}

void sm16703()
{
  String la = ledArrange;
    if (la == "RGB") {
     FastLED.addLeds<SM16703, DATA_PIN, RGB>(leds, LED_NUMBER);
    } else if (la == "RBG") {
     FastLED.addLeds<SM16703, DATA_PIN, RBG>(leds, LED_NUMBER);
    } else if (la == "GRB") {
     FastLED.addLeds<SM16703, DATA_PIN, GRB>(leds, LED_NUMBER);
    } else if (la == "GBR") {
     FastLED.addLeds<SM16703, DATA_PIN, GBR>(leds, LED_NUMBER);
    } else if (la == "BRG") {
     FastLED.addLeds<SM16703, DATA_PIN, BRG>(leds, LED_NUMBER);
    } else if (la == "BGR") {
     FastLED.addLeds<SM16703, DATA_PIN, BGR>(leds, LED_NUMBER);
    }
    FastLED.setMaxPowerInVoltsAndMilliamps(24, LED_LIMIT_MILLIAMPS);
  }


void tm1829()
{
  String la = ledArrange;
    if (la == "RGB") {
     FastLED.addLeds<TM1829, DATA_PIN, RGB>(leds, LED_NUMBER);
    } else if (la == "RBG") {
     FastLED.addLeds<TM1829, DATA_PIN, RBG>(leds, LED_NUMBER);
    } else if (la == "GRB") {
     FastLED.addLeds<TM1829, DATA_PIN, GRB>(leds, LED_NUMBER);
    } else if (la == "GBR") {
     FastLED.addLeds<TM1829, DATA_PIN, GBR>(leds, LED_NUMBER);
    } else if (la == "BRG") {
      FastLED.addLeds<TM1829, DATA_PIN, BRG>(leds, LED_NUMBER);
    } else if (la == "BGR") {
      FastLED.addLeds<TM1829, DATA_PIN, BGR>(leds, LED_NUMBER);
    }
    FastLED.setMaxPowerInVoltsAndMilliamps(5, LED_LIMIT_MILLIAMPS);
  }


void tm1812()
{
 String la = ledArrange;
    if (la == "RGB") {
      FastLED.addLeds<TM1812, DATA_PIN, RGB>(leds, LED_NUMBER);
    } else if (la == "RBG") {
      FastLED.addLeds<TM1812, DATA_PIN, RBG>(leds, LED_NUMBER);
    } else if (la == "GRB") {
      FastLED.addLeds<TM1812, DATA_PIN, GRB>(leds, LED_NUMBER);
    } else if (la == "GBR") {
      FastLED.addLeds<TM1812, DATA_PIN, GBR>(leds, LED_NUMBER);
    } else if (la == "BRG") {
      FastLED.addLeds<TM1812, DATA_PIN, BRG>(leds, LED_NUMBER);
    } else if (la == "BGR") {
      FastLED.addLeds<TM1812, DATA_PIN, BGR>(leds, LED_NUMBER);
    }
    FastLED.setMaxPowerInVoltsAndMilliamps(12, LED_LIMIT_MILLIAMPS);
  }
  void tm1809()
{
 String la = ledArrange;
    if (la == "RGB") {
      FastLED.addLeds<TM1809, DATA_PIN, RGB>(leds, LED_NUMBER);
    } else if (la == "RBG") {
      FastLED.addLeds<TM1809, DATA_PIN, RBG>(leds, LED_NUMBER);
    } else if (la == "GRB") {
      FastLED.addLeds<TM1809, DATA_PIN, GRB>(leds, LED_NUMBER);
    } else if (la == "GBR") {
      FastLED.addLeds<TM1809, DATA_PIN, GBR>(leds, LED_NUMBER);
    } else if (la == "BRG") {
      FastLED.addLeds<TM1809, DATA_PIN, BRG>(leds, LED_NUMBER);
    } else if (la == "BGR") {
      FastLED.addLeds<TM1809, DATA_PIN, BGR>(leds, LED_NUMBER);
    }
    FastLED.setMaxPowerInVoltsAndMilliamps(12, LED_LIMIT_MILLIAMPS);
  }
  void tm1804()
{
 String la = ledArrange;
    if (la == "RGB") {
      FastLED.addLeds<TM1804, DATA_PIN, RGB>(leds, LED_NUMBER);
    } else if (la == "RBG") {
      FastLED.addLeds<TM1804, DATA_PIN, RBG>(leds, LED_NUMBER);
    } else if (la == "GRB") {
      FastLED.addLeds<TM1804, DATA_PIN, GRB>(leds, LED_NUMBER);
    } else if (la == "GBR") {
      FastLED.addLeds<TM1804, DATA_PIN, GBR>(leds, LED_NUMBER);
    } else if (la == "BRG") {
      FastLED.addLeds<TM1804, DATA_PIN, BRG>(leds, LED_NUMBER);
    } else if (la == "BGR") {
      FastLED.addLeds<TM1804, DATA_PIN, BGR>(leds, LED_NUMBER);
    }
    FastLED.setMaxPowerInVoltsAndMilliamps(12, LED_LIMIT_MILLIAMPS);
  }

i get this error message:

section .text' will not fit in region iram1_0_seg’

I tried this with a brand new sketch and also got the same error so it is not that my sketch is to big (my geuss).

Can someone explain me what is wrong here? maybe give a workaround or solution to this?
I already tried looking on google for like a whole day but i cant get it to work right

O ps. I am a noob and this is my first coding/project.

Thanks.

Googling your error message: it seems to be a RAM problem. Maybe you should reduce the number of global variables and use the F() macro whenever possible.

Does it still happen if you decrease the number of cases in your if (lt == "xxx") { tests series?

Also, you can use ICACHE_FLASH_ATTR for your functions: it will place them in flash.
Your functions are getting placed in the iRAM which is only a few KBs

If you’re wondering what the ICACHE_FLASH_ATTR means in earlier example; it’s an instruction for the linker, indicating that the function should be stored in flash memory instead of RAM. It is generally advisable to prefix most functions with ICACHE_FLASH_ATTR in order to save RAM.

More info here:

What about ICACHE_FLASH_ATTR in function declarations?
As you may have guessed, this indicates that the function so tagged should end up in one or the other of the two sections just mentioned. So we see a function declaration like the following (but variables can be designated in this way also).
static void ICACHE_FLASH_ATTR myfunct ( void )
{
return 0;
}

Hope this helps...

Thanks for the quick reply.
i found out myself that it had to do with memory but i found it a bit strange that even a fresh sketch with only that in it (and ofcourse included fastled library) also gave that error. The original sketch has a few libraries and on its own is like 3000 lines.

static void ICACHE_FLASH_ATTR
this did nothing (or maybe not enough) and i found this also but i also did read again that it is done on default, so no need to put in front of it.

i also used the F() a couple of times or should i also use it like this ?

if (la == F("XXX"))

The F function is described shortly here:

Version 1.0 of the Arduino IDE introduced the F() syntax for storing strings in flash memory rather than RAM. e.g.

Serial.println(F(“This string will be stored in flash memory”));