Framebuffer size in PSRAM limited to around 2 MB
martinberlin opened this issue · comments
It seems so.
Doing it larger it will crash.
Recently got this one in Aliexpress:
ED115OC1 Eink Screen 2760x2070 EPD Display quite cheap and big actually.
Any framebuffer that it's higher than this:
w:2760 h:1502 FB size:2072760 -> around 2MB it crashes
I (771) epdiy: using resolution 345x1504
assert failed: 0x42009593
0x42009593: epd_hl_init at /home/martin/esp/projects/epdiy/src/highlevel.c:27 (discriminator 1)
Digging a bit deeper:
state.back_fb = heap_caps_aligned_alloc(16, fb_size, MALLOC_CAP_SPIRAM);
assert(state.back_fb != NULL);It seems that it fails allocating that kind of huge buffer:
2760/2*2070 = 2856600
@vroland any idea if it could be possible to drive this big thing with the S3?
Test memory alloc without epdiy works correctly:
int fb_size = 2760*2070/2; // 2072760 crashes epdiy Around 2MB
void app_main() {
//heap_caps_aligned_alloc what is used in epdiy framebuffer allocation
uint8_t back_fb = heap_caps_aligned_alloc(16, fb_size, MALLOC_CAP_SPIRAM);
//uint8_t back_fb = heap_caps_malloc(fb_size, MALLOC_CAP_SPIRAM);
// Is allocated?
assert(back_fb != NULL);
printf("%d bytes avail in PSRAM before framebuff alloc\n",heap_caps_get_free_size(MALLOC_CAP_SPIRAM));
if (back_fb != NULL) {
printf("%d bytes buffer allocated in SPIRAM\n\n", fb_size);
}
}
// 5529116 bytes avail in PSRAM before framebuff alloc
// 2856600 bytes buffer allocated in SPIRAM
Hm, how much RAM does the esp module you have have in total? Because the highlevel API is allocating a front buffer, a back buffer, and a difference buffer. In total, this would be 4x this calculated size:
Line 39 in 1bee9c3
So 4x ~2.7MB is almost 11 MB of space needed. This shouldn't be a problem with a 16MB PSRAM chip, but it doesn't fit into 8, which many modules have. Maybe that is the issue?
Thanks Valentin,
that seems to be the issue. But it should be possible also to use one framebuffer instead of front and back, right?
I mean if you just want to display a single image over white, that could be an option, to avoid using so much external RAM.
Alright it seems that I won’t have an easy way to deal with big framebuffers unless in the future there is an option to avoid 2 frame buffers and diff.