Very large buffer on ESP32
Posted: 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 variable doesn't work. I get the following error:
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!
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];
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
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!