Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By stanzlavos
#78377 Error :

Code: Select allc:/users/stanzlavos/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\STANZL~1\AppData\Local\Temp\arduino_build_739272/IRControl.ino.elf section `.data' will not fit in region `dram0_0_seg'

c:/users/stanzlavos/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: address 0x40009a98 of C:\Users\STANZL~1\AppData\Local\Temp\arduino_build_739272/IRControl.ino.elf section `.bss' is not within region `dram0_0_seg'

c:/users/stanzlavos/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: address 0x40009a98 of C:\Users\STANZL~1\AppData\Local\Temp\arduino_build_739272/IRControl.ino.elf section `.bss' is not within region `dram0_0_seg'

collect2.exe: error: ld returned 1 exit status


Is it because there are too many globals ?

This workspace has around 25 files. I have another workspace that has almost the exact same code with a few extra files that compiles just fine. I was manually moving some changes from one workspace to another when I ran into the problem.

In one of the cpp files, there is a function with a "switch" block. If I comment out the contents of just that switch block, there is no problem. I tried retaining that code and taking a few other files out of compilation but the problem persists...

When it does compile (after removing the switch block contents), the output shows :

Code: Select allSketch uses 376748 bytes (36%) of program storage space. Maximum is 1044464 bytes.
Global variables use 39504 bytes (48%) of dynamic memory, leaving 42416 bytes for local variables. Maximum is 81920 bytes.


UPDATE: From within the switch case, an API from another file was being called. The API references a global array with 8192 elements of struct :

Code: Select alltypedef struct
{
  int           type;
  int           bits;
  unsigned long value;
} ir_send_cmd_t;


If I reduce the size of this array, linking is fine. :P So, it is because my data segment is getting too huge ? Is there any workarounds available ? Move large allocations to heap ?
User avatar
By Pablo2048
#78378 Your struct ir_send_cmd_t is 4 + 4 + 4 = 12 bytes long (we are working with 32 bits CPU right?). So your 8192 elements array is 98304 bytes long. Whole ESP8266 has only 81920 bytes RAM...
User avatar
By Pablo2048
#78389 1. analyze your code and try to move all strings to PROGMEM to free more RAM
2. use minimal size of data types (uint8_t instead of plain int) where possible - you give no info about structure members so...
3. use packed structure to avoid compiler align to 32 bits
4. if this can be done (again - no info about your application) try to use SPIFFS (EEPROM is realized in flash and is too small to hold this array)