Skip to content

Commit eedf03a

Browse files
authored
Merge pull request #772 from RubenKelevra/bugfix/camtask_dma_overflow_detection
cam_hal: add guard in cam_task() so DMA transfers cannot exceed image slot size
2 parents 3ca876a + 309999a commit eedf03a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

driver/cam_hal.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ static void cam_task(void *arg)
193193
if (cam_obj->fb_size < (frame_buffer_event->len + pixels_per_dma)) {
194194
ESP_LOGW(TAG, "FB-OVF");
195195
ll_cam_stop(cam_obj);
196-
DBG_PIN_SET(0);
197196
continue;
198197
}
199198
frame_buffer_event->len += ll_cam_memcpy(cam_obj,
@@ -207,6 +206,14 @@ static void cam_task(void *arg)
207206
cam_obj->state = CAM_STATE_IDLE;
208207
}
209208
cnt++;
209+
// stop when too many DMA copies occur so the PSRAM
210+
// framebuffer slot doesn't overflow from runaway transfers
211+
if (cnt >= cam_obj->frame_copy_cnt) {
212+
ESP_LOGE(TAG, "DMA overflow");
213+
ll_cam_stop(cam_obj);
214+
cam_obj->state = CAM_STATE_IDLE;
215+
continue;
216+
}
210217

211218
} else if (cam_event == CAM_VSYNC_EVENT) {
212219
//DBG_PIN_SET(1);

0 commit comments

Comments
 (0)