Description
Checklist
- Checked the issue tracker for similar issues to ensure this is not a duplicate
- Read the documentation to confirm the issue is not addressed there and your configuration is set correctly
- Tested with the latest version to ensure the issue hasn't been fixed
How often does this bug occurs?
always
Expected behavior
When esp32-camera/target/esp32s3/ll_cam.c: ll_cam_deinit() is invoked, the GDMA resources associated with the camera peripheral (LCD_CAM) should be deinitialized and disconnected cleanly without any errors reported by the GDMA driver. Specifically, the gdma_disconnect() call within ll_cam_deinit() should successfully complete, reflecting that the GDMA channel has been properly disconnected from the peripheral it was using for camera data transfers. No errors like "no peripheral is connected to the channel" should occur.
Actual behavior (suspected bug)
Actual behavior (suspected bug):
esp_err_t ll_cam_deinit(cam_obj_t *cam)
{
if (cam->cam_intr_handle) {
esp_intr_free(cam->cam_intr_handle);
cam->cam_intr_handle = NULL;
}
if (cam->dma_intr_handle) {
esp_intr_free(cam->dma_intr_handle);
cam->dma_intr_handle = NULL;
}
gdma_disconnect(cam->dma_channel_handle);
gdma_del_channel(cam->dma_channel_handle);
cam->dma_channel_handle = NULL;
// GDMA.channel[cam->dma_num].in.link.addr = 0x0;
LCD_CAM.cam_ctrl1.cam_start = 0;
LCD_CAM.cam_ctrl1.cam_reset = 1;
LCD_CAM.cam_ctrl1.cam_reset = 0;
return ESP_OK;
}
When ll_cam_deinit()
is called, typically as part of the camera disabling sequence, the system logs an error originating from the GDMA driver:
E (timestamp) gdma: gdma_disconnect(line_num): no peripheral is connected to the channel
This error indicates that the gdma_disconnect()
function, called within ll_cam_deinit()
, believes the DMA channel was not properly connected to a peripheral via the GDMA driver's API.
Further investigation of the components/esp32-camera/target/esp32s3/ll_cam.c
driver reveals that:
- During DMA initialization (
ll_cam_dma_init
andll_cam_dma_reset
), the GDMA channel is associated with the LCD_CAM peripheral by directly writing to theGDMA.channel[dma_num].in.peri_sel.sel
register (e.g.,GDMA.channel[cam->dma_num].in.peri_sel.sel = 5;
). - The corresponding
gdma_connect()
driver API function is never called for the allocatedcam->dma_channel_handle
. - However, during deinitialization in
ll_cam_deinit()
,gdma_disconnect(cam->dma_channel_handle)
is called.
This mismatch—connecting to the peripheral via direct register manipulation but attempting to disconnect via the driver's API which expects a prior gdma_connect()
call—is the suspected cause of the error. The GDMA driver layer is unaware of the manual connection, leading to the "no peripheral is connected" error upon disconnection.
Error logs or terminal output
E (34820) gdma: gdma_disconnect(319): no peripheral is connected to the channel
Steps to reproduce the behavior
Steps to reproduce the behavior:
- Initialize the ESP32-S3 camera module using the standard
esp_camera_init()
function with a valid configuration. This will internally callll_cam_config()
, which subsequently callsll_cam_dma_init()
. - Perform at least one camera operation that involves data transfer, for example:
- Take a single picture using
esp_camera_fb_get()
followed byesp_camera_fb_return()
. - Alternatively, start an MJPEG stream which involves continuous frame capture.
- Take a single picture using
- Disable or deinitialize the camera using
esp_camera_deinit()
. This will internally callll_cam_deinit()
. - Monitor the ESP-IDF system logs (e.g., via serial monitor).
- Observe that after the camera deinitialization sequence, the error message
E (timestamp) gdma: gdma_disconnect(line_num): no peripheral is connected to the channel
appears in the logs.
Project release version
v2.0.15
System architecture
Intel/AMD 64-bit (modern PC, older Mac)
Operating system
Linux
Operating system version
Ubuntu 22.04.3 LTS
Shell
CMD
Additional context
Additional context:
- ESP-IDF Version: v5.4.0. The GDMA header file involved is
esp_private/gdma.h
from this ESP-IDF version. - Target Board/SoC: ESP32-S3 (specifically, an
esp32s3_wroom_1u_n8r2
based board). The issue is within the ESP32-S3 specific low-level camera driver (components/esp32-camera/target/esp32s3/ll_cam.c
). - Camera Module: OV5640.
- Build System: PlatformIO.
- Nature of the bug: The root cause appears to be an API misuse or a missing step in the GDMA driver interaction within the
esp32-camera
component's ESP32-S3 target code. Thegdma_connect()
function, which is expected to be called to associate a DMA channel with a peripheral, is seemingly not called during the camera DMA initialization (ll_cam_dma_init
). Instead, the peripheral selection (LCD_CAM, which is peripheral ID 5) is done by directly writing toGDMA.channel[cam->dma_num].in.peri_sel.sel = 5;
withinll_cam_dma_reset()
, which is called byll_cam_dma_init()
. Consequently, whenll_cam_deinit()
is later invoked, thegdma_disconnect()
call correctly reports that no peripheral was formally "connected" via the driver's API, leading to the "no peripheral is connected to the channel" error. - Observed Error Log:
E (timestamp) gdma: gdma_disconnect(line_num): no peripheral is connected to the channel
(e.g.,E (409873) gdma: gdma_disconnect(319): no peripheral is connected to the channel
).