Skip to content

Commit 36121e1

Browse files
authored
Merge pull request espressif#419 from jason-mao/bugfix/change_fb_to_aligned_buffer
Change the fb buffer as 16 bytes aligned
2 parents 2ae2623 + 03b1eab commit 36121e1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

driver/cam_hal.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,13 @@ static esp_err_t cam_dma_config(const camera_config_t *config)
296296
cam_obj->frames[x].fb_offset = 0;
297297
cam_obj->frames[x].en = 0;
298298
ESP_LOGI(TAG, "Allocating %d Byte frame buffer in %s", alloc_size, _caps & MALLOC_CAP_SPIRAM ? "PSRAM" : "OnBoard RAM");
299+
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 3, 0)
300+
// In IDF v4.2 and earlier, memory returned by heap_caps_aligned_alloc must be freed using heap_caps_aligned_free.
301+
// And heap_caps_aligned_free is deprecated on v4.3.
302+
cam_obj->frames[x].fb.buf = (uint8_t *)heap_caps_aligned_alloc(16, alloc_size, _caps);
303+
#else
299304
cam_obj->frames[x].fb.buf = (uint8_t *)heap_caps_malloc(alloc_size, _caps);
305+
#endif
300306
CAM_CHECK(cam_obj->frames[x].fb.buf != NULL, "frame buffer malloc failed", ESP_FAIL);
301307
if (cam_obj->psram_mode) {
302308
//align PSRAM buffer. TODO: save the offset so proper address can be freed later

0 commit comments

Comments
 (0)