"DRAM segment data does not fit" after splitting Files into .h and .cpp

Posts: 1
Joined: Fri Jun 19, 2020 3:48 pm

"DRAM segment data does not fit" after splitting Files into .h and .cpp

Postby J.Klink » Fri Jun 19, 2020 4:49 pm


I'm encountering a really stupid problem at the moment i really cannot wrap my head around.
The Project is a PlatformIO project, here is the platformio.ini:

  1. [env:esp32cam]
  2. platform = espressif32
  3. board = esp32cam
  4. framework = arduino
  5. monitor_speed = 115200
  6. lib_deps =
  7.     IRremoteESP8266
  8.     Adafruit NeoPixel
  9.     ArduinoJson
  10.     PubSubClient
  11.     EEPROM
  12.     NeoPixelBus
  13. build_flags =
  14.     -D MQTT_MAX_PACKET_SIZE=512
  15.     -D MQTT_KEEPALIVE=5
I am working on a project to use ESP32s as smarthome devices. Beeing a newbie in C++ at the time i simply threw all of the code into the .h files.
Learning more about C++, i decided to properly structure the project, moving method implementations to .cpp files. After a few Files i ran into the following error:

Code: Select all

/Users/jklink/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: .pio/build/esp32cam/firmware.elf section `.dram0.bss' will not fit in region `dram0_0_seg'
/Users/jklink/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: DRAM segment data does not fit.
/Users/jklink/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: region `dram0_0_seg' overflowed by 4896 bytes
The error disappears when i revert the changes (remove one .cpp and move the code back into the .h).
It reappears when splitting up ANY other file.

What kinda wonders me is that after building the project it displays the following message:
RAM: [==== ] 37.0% (used 121328 bytes from 327680 bytes)
Flash: [=== ] 27.1% (used 852254 bytes from 3145728 bytes)
esptool.py v2.6

The RAM usage looks all good there.
The PlatformIO Home Inspection Tool tells me there are 100% (347.9kb) RAM used, but only 22% Flash.

There is not a single additional line Code written, so the compiled code should not be longer than the original one only stored in .h Files.
The complete src directory has a size of 246kb.

Has anyone a suggestion how to handle that?

Thanks in advance,
J. Klink
Bildschirmfoto 2020-06-19 um 18.20.08.png
Bildschirmfoto 2020-06-19 um 18.20.08.png (54.38 KiB) Viewed 392 times

Who is online

Users browsing this forum: Baidu [Spider], sraposo and 19 guests