[Solved] Overflow region dram0_0_seg for big project ...

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

[Solved] Overflow region dram0_0_seg for big project ...

Postby kolban » Mon Nov 07, 2016 7:40 pm

I am trying to compile a lot of C source files and then link them together for a large application. My goal was to create a large library as an ESP-IDF component. So far, all the compiles are progressing cleanly but at the linkage step, it is failing with the following error:

Code: Select all

LD app-template.elf
/opt/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/4.8.5/../../../../xtensa-esp32-elf/bin/ld: /home/kolban/esp32/esptest/apps/workspace/jerryscript/build/app-template.elf section `.dram0.bss' will not fit in region `dram0_0_seg'
/opt/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/4.8.5/../../../../xtensa-esp32-elf/bin/ld: region `dram0_0_seg' overflowed by 267900 bytes
/home/kolban/esp32/esptest/esp-idf/make/project.mk:255: recipe for target '/home/kolban/esp32/esptest/apps/workspace/jerryscript/build/app-template.elf' failed
Somewhere in the depths of my memory I seem to remember something about the current state of our ESP-IDF environment as building code that is loaded into RAM as opposed to being kept in flash... but other than that little snippet, that's all I have.

Does anyone have experience in debugging or tweaking error areas such as this? I am using the out of the box ESP-IDF and latest app template.
Last edited by kolban on Tue Nov 08, 2016 12:04 am, edited 1 time in total.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Overflow region dram0_0_seg for big project ...

Postby WiFive » Mon Nov 07, 2016 10:47 pm

kolban wrote:I am trying to compile a lot of C source files and then link them together for a large application. My goal was to create a large library as an ESP-IDF component. So far, all the compiles are progressing cleanly but at the linkage step, it is failing with the following error:

Code: Select all

LD app-template.elf
/opt/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/4.8.5/../../../../xtensa-esp32-elf/bin/ld: /home/kolban/esp32/esptest/apps/workspace/jerryscript/build/app-template.elf section `.dram0.bss' will not fit in region `dram0_0_seg'
/opt/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/4.8.5/../../../../xtensa-esp32-elf/bin/ld: region `dram0_0_seg' overflowed by 267900 bytes
/home/kolban/esp32/esptest/esp-idf/make/project.mk:255: recipe for target '/home/kolban/esp32/esptest/apps/workspace/jerryscript/build/app-template.elf' failed
Somewhere in the depths of my memory I seem to remember something about the current state of our ESP-IDF environment as building code that is loaded into RAM as opposed to being kept in flash... but other than that little snippet, that's all I have.

Does anyone have experience in debugging or tweaking error areas such as this? I am using the out of the box ESP-IDF and latest app template.
Dram is data not code. Are you compiling with the jerryscript esp8266 options for low ram usage? See I told you you would run out of memory. :P

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Overflow region dram0_0_seg for big project ...

Postby kolban » Mon Nov 07, 2016 11:26 pm

When I look at the front page here:

http://jerryscript.net/

The project claims that it needs <64K of RAM and <200K of flash.

Given that (I think) my ESP32 has ~512K RAM and ~4MB of flash ... I'm missing something (I think).

What I believe I need to understand is how the ESP-IDF is generating "sections" and where it wants to put them.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

ESP_igrr
Posts: 2071
Joined: Tue Dec 01, 2015 8:37 am

Re: Overflow region dram0_0_seg for big project ...

Postby ESP_igrr » Mon Nov 07, 2016 11:47 pm

The way to debug such issues is as follows:
1. Increase the size of the offending memory region in the linker script
2. Link the application and examine the elf file: xtensa-esp32-elf-objdump -t -j .dram0.bss

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Overflow region dram0_0_seg for big project ...

Postby kolban » Tue Nov 08, 2016 12:04 am

Thank you guys ...

Again it was another false alarm on my part ... it seems that program I am compiling (jerryscript) wants to create a RAM heap to manage its own storage (JavaScript variables). The default heap size it wanted to allocate ... 512K. Ouch ... too much. Turning it down to a more managable size and all is now good. Here is the link to the definition in the jerryscript project:

https://github.com/Samsung/jerryscript/ ... nfig.h#L41
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: Overflow region dram0_0_seg for big project ...

Postby Ritesh » Fri May 26, 2017 1:52 pm

ESP_igrr wrote:The way to debug such issues is as follows:
1. Increase the size of the offending memory region in the linker script
2. Link the application and examine the elf file: xtensa-esp32-elf-objdump -t -j .dram0.bss
Hi,

We have also faced this type of issue while adding some external source to compile into application. I have also checked ESP32 LD script and found that length of dram0_0_seg is 0x50000 which is 320 KBytes of RAM.

So, I have following questions regarding that.

1) How-much we can extend that segment? upto 512 KBytes? But with that we can use any extra memory after that and it might be system not started if we allocate that much amount of memory. Basically system needs some RAM to up and running initially. let me correct if i am wrong.

2) " Link the application and examine the elf file: xtensa-esp32-elf-objdump -t -j .dram0.bss". This is just for debugging purpose. correct?

How to prevent above error? It seems most preferable solution is to store all functions into Flash memory instead of RAM. correct?

Also, On which location of flash memory the function will be defined as we are also planning to create some custom partitions into flash memory according to flash memory which we are planning to use.
Regards,
Ritesh Prajapati

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: Overflow region dram0_0_seg for big project ...

Postby Ritesh » Fri May 26, 2017 1:52 pm

kolban wrote:Thank you guys ...

Again it was another false alarm on my part ... it seems that program I am compiling (jerryscript) wants to create a RAM heap to manage its own storage (JavaScript variables). The default heap size it wanted to allocate ... 512K. Ouch ... too much. Turning it down to a more managable size and all is now good. Here is the link to the definition in the jerryscript project:

https://github.com/Samsung/jerryscript/ ... nfig.h#L41
Please suggest me the solution to solve this issue and its procedure as well
Regards,
Ritesh Prajapati

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: [Solved] Overflow region dram0_0_seg for big project ...

Postby Ritesh » Fri May 26, 2017 1:59 pm

Also, some more update that there are some large arrays defined into application code which are compulsory required for my application code.
Regards,
Ritesh Prajapati

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: [Solved] Overflow region dram0_0_seg for big project ...

Postby Ritesh » Sat May 27, 2017 11:23 am

I have tried with solution like increasing DRAM0 Segment but not able to generate binary after generating elf file.

Please find following error output

dram0_0_seg len = 0x5B000
A fatal error occurred: Segment loaded at 0x40115710 lands in same 64KB flash mapping as segment loaded at 0x40115598. Can't generate binary. Suggest changing linker script or ELF to merge sections.
Regards,
Ritesh Prajapati

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: [Solved] Overflow region dram0_0_seg for big project ...

Postby WiFive » Sat May 27, 2017 2:08 pm

There is only 2 solution: use less ram or add more external ram (wrover). Maybe can move some things to iram if you are close to the limit.

Who is online

Users browsing this forum: No registered users and 103 guests