C++11 lambda = SECTION `.TEXT' WILL NOT FIT IN REGION `IRAM1

Stational
Posts: 42
Joined: Sat Jul 02, 2016 10:54 pm

C++11 lambda = SECTION `.TEXT' WILL NOT FIT IN REGION `IRAM1

Postby Stational » Sun Mar 03, 2019 9:34 pm

I work with the latest NONOS_SDK from github (https://github.com/espressif/ESP8266_NONOS_SDK), so no Arduino.

I also work with C++, which worked fine for me so far. Until recently I wasn't using any new features of C++11 (which the compiler is capable of I think). But I tried to do this:

Code: Select all

int32_t ICACHE_FLASH_ATTR Util::get_lowest_value(int32_t *values) {
  return Util::get_value_with_compare(values, [](int32_t v1, int32_t v2) -> bool { return v1 < v2; });
}

int32_t ICACHE_FLASH_ATTR Util::get_highest_value(int32_t *values) {
  return Util::get_value_with_compare(values, [](int32_t v1, int32_t v2) -> bool { return v1 > v2; });
}

int32_t ICACHE_FLASH_ATTR Util::get_value_with_compare(int32_t *values, std::function<bool (int32_t, int32_t)> compare) {
  int32_t value = values[0];
  for(uint16_t i = 1; i < sizeof(values); i++) {
    if(compare(values[i], value))
      value = values[i];
  }

  return value;
}


It compiles fine (this is an example for how the compiler is called for one of my classes:

Code: Select all

xtensa-lx106-elf-g++ -Os -std=c++11 -g -Wpointer-arith -Wundef -Werror -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -ffunction-sections -fdata-sections -fno-builtin-printf  -DICACHE_FLASH -DGLOBAL_DEBUG_ON -DSPI_FLASH_SIZE_MAP=4   -I include -I ../user/ -I ./ -I . -I . -I /opt/esp/sdk/include  -o .output/eagle/debug/obj/Wifi.o -c Wifi.cpp


), but the linker now gives me this error:

xtensa-lx106-elf-gcc -L../lib -nostdlib -T../ld/eagle.app.v6.ld -Wl,--no-check-sections -Wl,--gc-sections -u call_user_start -Wl,-static -Wl,--start-group -lc -lgcc -lhal -lphy -lpp -lnet80211 -lm -llwip -lwpa -lcrypto -lmain -ljson -lupgrade -lmbedtls -lpwm -ldriver -Wl,-Map -Wl,"mapfile.map" -Wl,--cref -lsmartconfig user/.output/eagle/debug/lib/user.a BMP280/.output/eagle/debug/lib/BMP280.a Soft_I2C/.output/eagle/debug/lib/I2C.a SSD1306_OLED/.output/eagle/debug/lib/OLED.a WIFI/.output/eagle/debug/lib/WIFI.a Util/.output/eagle/debug/lib/Util.a Buffer/.output/eagle/debug/lib/Buffer.a -Wl,--end-group -o .output/eagle/debug/image/eagle.app.v6.out

/opt/esp/crosstool-NG/builds/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: .output/eagle/debug/image/eagle.app.v6.out section `.text' will not fit in region `iram1_0_seg'


I attached the generated mapfile, but unfortunately I am not really familiar with the format and therefore don't know what I have to look for to solve this problem.

Anyone here who knows why suddenly '.text' won't fit into 'iram1_0_seg' anymore? If I replace those lambdas with functions and function-pointers, everything works fine.

Any help is greatly appreciated.
Attachments
mapfile.zip
(71.99 KiB) Downloaded 48 times

Her Mary
Posts: 394
Joined: Mon Oct 27, 2014 11:09 am

Re: C++11 lambda = SECTION `.TEXT' WILL NOT FIT IN REGION `IRAM1

Postby Her Mary » Wed Mar 06, 2019 2:17 pm

Maybe you should use the latest RTOS SDK, it is much more active than the nonOS SDK. https://github.com/espressif/ESP8266_RTOS_SDK

Who is online

Users browsing this forum: Bing [Bot] and 9 guests