Very large buffer on ESP32

yasapir
Posts: 5
Joined: Thu Jul 11, 2019 3:32 am

Very large buffer on ESP32

Postby yasapir » Fri Jul 19, 2019 1:25 pm

Hi,

I'd like to set up a 480KB buffer to use as a graphics framebuffer. (Actually a dual buffer of 240KB each.) Splitting it to several smaller buffers that add up to 480KB would also be OK. Writing this, I now realize that the ESP32 doesn't actually have 480KB of data memory available, so I may try to compress some of it, or do without the dual buffering, or simply use external memory - but still I'd like to see how much memory I can use without resorting to external memory.

Of course, simply compiling code that has a global

Code: Select all

char buf[480000];
variable doesn't work. I get the following error:

Code: Select all

xtensa-esp32-elf/bin/ld: esp-hello-world/build/hello-world.elf section `.dram0.bss' will not fit in region `dram0_0_seg'
xtensa-esp32-elf/bin/ld: DRAM segment data does not fit.
xtensa-esp32-elf/bin/ld: region `dram0_0_seg' overflowed by 311288 bytes
I see that esp32.ld sets dram0_0_seg to map around 176KB of memory at 0x3ffb0000-0x3ffdc1ff. The technical reference calls this Internal SRAM 2, saying that it can contain 200KB. The ldscript mentions something about some of the memory being used by static ROM. What is this and might I be able to use this as regular RAM instead?

Also, the reference says that Internal SRAM 2 starts 8KB before the mapped address, at 0x3ffae000. Can those 8KB at 0x3ffae000-0x3ffb0000 be used?

And would mapping Internal SRAM 1 as an extra segment work? That might get me to around 300KB.

Finally, Internal SRAM 0 is described as instruction memory. Would it be possible to store some data there anyway?

Thanks!

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

Re: Very large buffer on ESP32

Postby WiFive » Sat Jul 20, 2019 4:04 am

Run the hello world example and check the heap info that's printed.

jcsbanks
Posts: 305
Joined: Tue Mar 28, 2017 8:03 pm

Re: Very large buffer on ESP32

Postby jcsbanks » Sat Jul 20, 2019 9:35 am

How about adding PSRAM?

yasapir
Posts: 5
Joined: Thu Jul 11, 2019 3:32 am

Re: Very large buffer on ESP32

Postby yasapir » Sat Jul 20, 2019 8:17 pm

Run the hello world example and check the heap info that's printed.

Code: Select all

I (184) heap_init: Initializing. RAM available for dynamic allocation:
I (191) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (197) heap_init: At 3FFB2EF8 len 0002D108 (180 KiB): DRAM
I (203) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (210) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (216) heap_init: At 40089584 len 00016A7C (90 KiB): IRAM
So the heap fills up all the unused RAM. Does that mean the IRAM can be used normally?
How about adding PSRAM?
I'd still like to see if I can get by without adding external memory.

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

Re: Very large buffer on ESP32

Postby WiFive » Sun Jul 21, 2019 12:12 am


yasapir
Posts: 5
Joined: Thu Jul 11, 2019 3:32 am

Re: Very large buffer on ESP32

Postby yasapir » Thu Jul 25, 2019 9:56 pm

Thanks!

Who is online

Users browsing this forum: zzx666666 and 108 guests