DRAM segment data does not fit

esp1979
Posts: 21
Joined: Sun Dec 12, 2021 8:55 pm

DRAM segment data does not fit

Postby esp1979 » Sun Dec 12, 2021 9:14 pm

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

ESP_Sprite
Posts: 9730
Joined: Thu Nov 26, 2015 4:08 am

Re: DRAM segment data does not fit

Postby ESP_Sprite » Mon Dec 13, 2021 1:44 am

That is odd... consts should not end up being loaded in DRAM. Are you sure that all these arrays have 'const' on them?

esp1979
Posts: 21
Joined: Sun Dec 12, 2021 8:55 pm

Re: DRAM segment data does not fit

Postby esp1979 » Mon Dec 13, 2021 5:15 am

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.

ESP_Sprite
Posts: 9730
Joined: Thu Nov 26, 2015 4:08 am

Re: DRAM segment data does not fit

Postby ESP_Sprite » Mon Dec 13, 2021 8:13 am

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.

esp1979
Posts: 21
Joined: Sun Dec 12, 2021 8:55 pm

Re: DRAM segment data does not fit

Postby esp1979 » Mon Dec 13, 2021 9:55 am

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

chegewara
Posts: 2364
Joined: Wed Jun 14, 2017 9:00 pm

Re: DRAM segment data does not fit

Postby chegewara » Mon Dec 13, 2021 10:55 am

Please try

Code: Select all

static const char pageOne[] = 

esp1979
Posts: 21
Joined: Sun Dec 12, 2021 8:55 pm

Re: DRAM segment data does not fit

Postby esp1979 » Mon Dec 13, 2021 4:30 pm

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.

esp1979
Posts: 21
Joined: Sun Dec 12, 2021 8:55 pm

Re: DRAM segment data does not fit

Postby esp1979 » Mon Dec 13, 2021 6:55 pm

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

esp1979
Posts: 21
Joined: Sun Dec 12, 2021 8:55 pm

Re: DRAM segment data does not fit

Postby esp1979 » Tue Dec 14, 2021 1:12 pm

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
Last edited by esp1979 on Tue Dec 14, 2021 1:14 pm, edited 1 time in total.

esp1979
Posts: 21
Joined: Sun Dec 12, 2021 8:55 pm

Re: DRAM segment data does not fit

Postby esp1979 » Tue Dec 14, 2021 7:28 pm

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

Who is online

Users browsing this forum: No registered users and 55 guests