diff --git a/driver/cam_hal.c b/driver/cam_hal.c index b65cdac8d0..147af5a872 100644 --- a/driver/cam_hal.c +++ b/driver/cam_hal.c @@ -489,6 +489,10 @@ static esp_err_t cam_dma_config(const camera_config_t *config) } else { _caps |= MALLOC_CAP_SPIRAM; } + size_t fb_align = dcache_line_size(); + if (fb_align == 0) { + fb_align = 32; + } for (int x = 0; x < cam_obj->frame_cnt; x++) { cam_obj->frames[x].dma = NULL; cam_obj->frames[x].fb_offset = 0; @@ -497,7 +501,7 @@ static esp_err_t cam_dma_config(const camera_config_t *config) #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 3, 0) // In IDF v4.2 and earlier, memory returned by heap_caps_aligned_alloc must be freed using heap_caps_aligned_free. // And heap_caps_aligned_free is deprecated on v4.3. - cam_obj->frames[x].fb.buf = (uint8_t *)heap_caps_aligned_alloc(16, alloc_size, _caps); + cam_obj->frames[x].fb.buf = (uint8_t *)heap_caps_aligned_alloc(fb_align, alloc_size, _caps); #else cam_obj->frames[x].fb.buf = (uint8_t *)heap_caps_malloc(alloc_size, _caps); #endif