Closed dsyleixa closed 1 year ago
Yes too much static ram usage. This is the wrong place to post
Read this https://github.com/espressif/arduino-esp32/issues/1163 Ask for help here https://esp32.com/viewforum.php?f=19
hmmm - that's weird:
ESP32: 4 MByte flash, 520 KB SRAM https://learn.adafruit.com/adafruit-huzzah32-esp32-feather/overview
M4: 512 KB flash, 192 KB RAM https://learn.adafruit.com/adafruit-huzzah32-esp32-feather/overview
if ESP32 RAM is so restricted, then that is big drawback and that issue should be fixed ASAP!
from https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/system/mem_alloc.html
"Note: Due to a technical limitation, the maximum statically allocated DRAM usage is 160KB. The remaining 160KB (for a total of 320KB of DRAM) can only be allocated at runtime as heap."
OMG, that should have been made absolutely clear BEFORE I had purchased that thing! OTOH, Adafruit advertises the ESP by 520 KB SRAM
Can that "technical limitation" be reworked and fixed?
Hi @dsyleixa,
The total SRAM is 520KB but this is DRAM+IRAM, and only DRAM (320KB) is normally used for data, IRAM is normally used for executable instructions. It is possible to store data in IRAM but there are restrictions.
Regarding how Adafruit advertise the ESP32, you'll have to take this up with them. But they are technically correct.
Working around the static memory limitation should be possible without too much work. If you have some larger buffer like this:
static uint8_t framebuffer[131072];
Then change it to a pointer, and allocate it during setup with malloc() or calloc(). This makes it dynamic memory not static memory:
static uint8_t *framebuffer;
void setup() {
framebuffer = calloc(1, 131072);
assert(framebuffer != NULL);
// do other setup stuff
}
Also, as @negativekelvin mentions, for Arduino issues please post on the Arduino issue tracker or the Arduino forum of esp32.com.
sorry, but I can't handle pointer and allocates, that is far beyond my skills :(
I don't post to Arduino.cc forum, because there are too many outrageous and insulting users.
There is an Arduino subforum on esp32.com, that's the one I was referring to: https://esp32.com/viewforum.php?f=19
ok, perhaps in future. As to now, to me it's an ESP32 hardware issue which should be reworked and fixed, not discussed ;)
There's no hardware issue. This is a software issue in ESP-IDF that the amount of statically assigned DRAM in an app is limited to 160KB. We don't have a GitHub issue tracking this, so we can start tracking it here.
We don't have an ETA for fixing this issue as it's complex to fix (for architectural reasons) and it's generally easy to work around by assigning large buffers dynamically (see above post with suggestion). But we do plan to fix it at some point.
(There is also the related but different issue #3211 )
I'm also looking for a solution for that, dynamic allocation makes my code much more error-prone.
The DRAM limitations are now clearly stated in the documentation.
closing the issue
my point is to change 2x160kB to 1x320kB to be able to address it as a unit in its entirety. My point is not about documentation or discussion.
please reopen this issue because it is not fixed yet.
Hi @dsyleixa,
I am sorry we closed the issue after more than 2 years of inactivity without giving out more information about why we closed it.
The reason why ~2x160KB
of DRAM is available instead of the ~1x320KB
on esp32
is because some functions used during startup are stored starting from the address 0x3ffexxxx which happens to be in the middle of the DRAM section starting at 0x3ffbxxxx making it not continuous and preventing you from creating static arrays bigger than approx. 160KB.
Fixing the problem would require moving said functions at the end of the DRAM memory but as @projectgus mentioned more than 2 years ago this is far from being a trivial fix and it would require a lot of architectural changes which explains why as of now it has not been addressed.
As I can't guaranty that this issue will ever be fixed, I would encourage you to consider (or reconsider) the following workaround:
esp32
board.160000 bytes
, it is however possible to allocate 2 arrays of 80000 bytes
instead.We have an internal ticket reporting this issue so it won't be forgotten and we don't want you to rely on this issue being fixed to continue with your project development. For those reason I would recommend against reopening it but feel free to let me know if you disagree with this decision now that I provided more information about it.
I am sorry again that this issue was left unaddressed for so long.
code compiles and works for M4 plus TFT HX8357, but fails for ESP32; Arduino IDE 1.8.8 Board: Adafruit Feather ESP32
core: ESP32 espressive 1.0.2
compile errors (when linking) for my code
complete error msg in attachement compileError.txt
source code also attached ConwayGoL_M4_Logic_NOR.zip