Page 1 of 2

DRAM segment data does not fit

Posted: Sun Dec 12, 2021 9:14 pm
by esp1979
Hi there,

i'm using the ESP8266 for two years now and decided to migrate a sketch (webserver with a few static html-pages) to the ESP32.

The sketch, which did work very well on the ESP8266 results in the following error message, when compiled for the ESP32:

Code: Select all

Arduino: 1.8.16 (Linux), Board: "ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, None"

Arduino: 1.8.16 (Linux), Board: "ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, None"

/home/esp1979/.arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/1.22.0-97-gc752ad5-5.2.0/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: mytestsketch.ino.elf section `.dram0.data' will not fit in region `dram0_0_seg'
/home/esp1979/.arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/1.22.0-97-gc752ad5-5.2.0/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: DRAM segment data does not fit.
/home/esp1979/.arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/1.22.0-97-gc752ad5-5.2.0/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: region `dram0_0_seg' overflowed by 82848 bytes
collect2: error: ld returned 1 exit status
exit status 1
Fehler beim Kompilieren für das Board ESP32 Dev Module.
The sketch uses four big char arrays which contain HTML/CSS/Javascript-Code and are declared as this

const char pageOne[] = R"=====(
Here are approx. 90000 characters...quite a lot but it worked very well with the ESP8266
)=====";

I noticed that the sketch compiles when I shorten the char arrays significantly.
But: on my Wemos D1 Mini ESP8266 everything compiled without problems.
And with the decision to change to the "bigger" ESP32 i thought, that things would get better and faster ;-(

So how can i get those big char arrays work as well as on the ESP8266?
Do i have to change the flash mode/size settings in the Arduino IDE?

Thanx for your help.

Best wishes

Re: DRAM segment data does not fit

Posted: Mon Dec 13, 2021 1:44 am
by ESP_Sprite
That is odd... consts should not end up being loaded in DRAM. Are you sure that all these arrays have 'const' on them?

Re: DRAM segment data does not fit

Posted: Mon Dec 13, 2021 5:15 am
by esp1979
Hi,

Yes, all char arrays are declared as const.
I don't know if this other Bug that came up using the Arduino_JSON.h library maybe plays a role in this DRAM thing:

Please see this within post from yesterday:
https://github.com/bxparks/AceTime/disc ... nt-1795027

Brian (creator of the AceTime.h library) writes that the Arduino_JSON.h redefines "typeof" as "typeof_" in the global namespace.

Can this cause the problem?
If no, do you have further ideas? I am totally helpless here.

Re: DRAM segment data does not fit

Posted: Mon Dec 13, 2021 8:13 am
by ESP_Sprite
It doesn't sound to me like that should affect const/non-const allocation, honestly, but it's hard to say.

Any chance you can share your code somewhere? I'm not an Arduino expert, but perhaps others can take a look at it.

Re: DRAM segment data does not fit

Posted: Mon Dec 13, 2021 9:55 am
by esp1979
Hi,

sharing is not possible as it is a project i develop for a customer.
But i wonder why the project worked/compiled without problems on ESP8266 platform but does only work on ESP32, if i reduce the size of the const char arrays.

Do i have to change something at the compiling settings in the Arduino IDE?

Or to put it in other words:
What is the typical cause of my posted error?
How can I proceed to determine the cause of the error?
Say: What exactly does this error mean and why does it disappear when I reduce the char array size?

What I can do:
I'll put together a sketch tonight where I just mimic my project with several large char arrays and dummy text. This I can then publish here

Re: DRAM segment data does not fit

Posted: Mon Dec 13, 2021 10:55 am
by chegewara
Please try

Code: Select all

static const char pageOne[] = 

Re: DRAM segment data does not fit

Posted: Mon Dec 13, 2021 4:30 pm
by esp1979
Hi all,

sorry, in deed there have been two char array which where not declared as const char (only char).

Now all char arrays are declared as the following:

static const char mychararray[] PROGMEM = R"=====(
a lot of code in here
)=====";


When compiling, no error message is shown now, but:
When i connect to the server two of the pages (the largest two of the char arrays) are not displayed.
When i call the corresponding server page, the screen is completely empty.

The pages which contain the content of the not so large char arrays are displayed correctly.

Re: DRAM segment data does not fit

Posted: Mon Dec 13, 2021 6:55 pm
by esp1979
OK, i've created a test-sketch, would be great, if you could check this on your system:
ramtest.ino.zip
(4.07 KiB) Downloaded 348 times
When

1. i comment out the ESP8266 Section
2. comment the ESP32-section.
3. compile and upload on ESP8266 (Wemos D1 Mini)
4. connect to AP and call 192.168.4.1

I see the complete server page (with all Lorem Ipsum Text).

When i
1. i comment the ESP8266 Section
2. comment out the ESP32-section.
3. compile and upload on ESP32 (tested on two different ESP32) Boards.
4. connect to AP and call 192.168.4.1

i see a blank page...

The char array uses 10000 Characters.
Why does this work on ESP8266 but not on the successor ESP32?
Would be great if you could help me getting this work.

Best wishes
Daniel

Re: DRAM segment data does not fit

Posted: Tue Dec 14, 2021 1:12 pm
by esp1979
Hi again,

just wanted to say, that i also have asked in the Arduino-Forum:

https://forum.arduino.cc/t/esp32-speich ... ays/935846

Hope this is ok and i get help here anyway.
If i get a solution in one of the forums, i will post it in the other forum.

Best wishes
Daniel

Re: DRAM segment data does not fit

Posted: Tue Dec 14, 2021 7:28 pm
by esp1979
Hi,

thanx to a member of the arduino forum i got the solution:

this works not (= empty page on server):

Code: Select all

void display_root() {
  server.send(200, "text/html", indexPage);
}
but this works

Code: Select all

void display_root() {
  const char * httpType PROGMEM = "text/html";
  server.send_P(200,  httpType, indexPage);
}
On ESP8266 BOTH works.

Best wishes
Daniel