Closed
Description
Hi, I am having trouble to get the maximum 256KB DMA block using the latest release. After some hardcoded debug print in a 6F03 C-Module, I found out that the maximum allocatable memory block is roughly at 247KB. This is the code I've used:
STATIC void frame_buffer_alloc(mp_lcd_rm67162_obj_t *self, int len) {
self->frame_buffer_size = len;
size_t free_size = heap_caps_get_largest_free_block(MALLOC_CAP_DMA);
self->frame_buffer = heap_caps_malloc(self->frame_buffer_size, MALLOC_CAP_DMA);
int threshold = free_size / 1024;
if (self->frame_buffer == NULL) {
if (threshold <= 247) {
mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("Failed to allocate DMA'able framebuffer,
Maiximum available DMA size: less than 247KB"));
}
if (threshold <= 248) {
mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("Failed to allocate DMA'able framebuffer,
Maiximum available DMA size: less than 248KB"));
}
if (threshold <= 249) {
mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("Failed to allocate DMA'able framebuffer,
Maiximum available DMA size: less than 249KB"));
} else {
mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("Failed to allocate DMA'able framebuffer,
Maiximum available DMA size: more than 249KB"));
}
}
memset(self->frame_buffer, 0, self->frame_buffer_size);
}
Now I don't know if this is a bug... But, if uPy is using roughly 16KB of RAM as it advertised (which I highly doubt on the esp32 port, because of wifi and stuff), and freeRTOS taking at most 10KB according to this (that being all the ROM has been loaded into the RAM), why isn't it possible to allocate 256KB of continous block? Is this caused by some bug or have I underestimate the memory usage of uPy by a huge margine?