fix(esp_board_manager): drive DVP XCLK via LEDC before esp_video_init (AUD-7254) - #48
fix(esp_board_manager): drive DVP XCLK via LEDC before esp_video_init (AUD-7254)#48ymzhang0319 wants to merge 1 commit into
Conversation
On ESP32-S3, the DVP controller does not output XCLK on the mapped GPIO until CAM transfer starts, so OV-family sensors cannot respond to SCCB at boot and detection fails with "get sensor ID failed". Drive XCLK via LEDC before esp_video_init when xclk_io >= 0 and xclk_freq > 0. Mask xclk_io to GPIO_NUM_NC and pass xclk_freq = 0 to esp_video so it does not re-route the GPIO and kill the LEDC output. Stop LEDC on deinit. Tested on ESP32-S3 SparkBot with OV3660 DVP (SCCB 0x3C, XCLK 20 MHz).
|
Hello, thank you for reporting the issue! I tested using the configuration file you submitted in: My test results show that both OV3660 and OV2640 can be initialized directly through My test environment is:
Test project:
Is there any other environment information we should sync as well? |
|
Really appreciate you taking the time to investigate this on your side and for laying out the environment details so clearly — that's very helpful, thank you. I can confirm your finding: The reason that minimal test misses it is that In the application path (esp-claw
Suggested reproduction
What the patch doesDrives XCLK via LEDC on the configured GPIO before Happy to provide a minimal repro outside esp-claw if that helps — the main barrier to reproducing in |
|
Hi. Actually, there is already a camera test in the bmgr test apps: And from the initialization logs, we can also clearly see that the sensor initialization succeeds correctly: So at the moment, it seems the issue may not simply be whether However, it does seem completely possible that unstable XCLK timing could cause SCCB configuration/probing failures during sensor initialization. If you’re able to provide a minimal reproducible case outside of esp-claw, we’d also be very happy to do further testing and investigation on our side. |
|
Thanks for the reply! Here's a minimal reproducible case outside esp-claw, as you suggested — could you give it a try on your side? Minimal reproduction project (a new example under Reproduction After flashing the firmware:
On a true cold start, the boot log shows: and any subsequent attempt to open the camera from application code fails with: |
|
This might be a bug in |
|
Thanks for providing the minimal reproducible case. Under a cold boot condition, it does seem that the OV3660 is not behaving correctly. However, this issue may need to be fixed on the esp_video driver side. I’ve already reported it to the relevant colleagues, and I’ll share any further updates here once I have more information. |
|
I got some feedback from the esp_video team. They think the SCCB probe failure may be related to I2C access happening before XCLK becomes stable after power-on. They provided a patch suggestion that delays the sensor I2C access until after XCLK is stable. Could you help test it and see whether it improves the cold boot behavior? |
|
Thanks for the patch! It does resolve the However, with this patch applied on my board, The minimal-repro persists the cold-start outcome to where Happy to test any follow-up patch. |
|
When providing the XCLK clock to the sensor via the SOC, it is recommended to run Alternatively, adding a delay in Providing the clock via LEDC is also worth trying. The correct usage of this method is to configure the XCLK pin to -1 and then generate the XCLK clock using the xclk generator API. |
Problem
On ESP32-S3, the DVP controller does not output XCLK until CAM transfer begins.
esp_videoroutes the GPIO to the DVP peripheral at init time, but no clock is emitted. OV-family sensors need a live XCLK to respond to SCCB, so sensor probing fails at boot:Any board using an OV-family DVP camera on ESP32-S3 through
esp_board_manager 0.5.10hits this out of the box.Fix
In
dev_camera_sub_dvp_init, before callingesp_video_init:xclk_io >= 0 && xclk_freq > 0, start LEDC on that GPIO at the requested frequency (1-bit resolution, 50% duty).xclk_iotoGPIO_NUM_NCand passxclk_freq = 0toesp_videoso it does not re-route the pin.On deinit,
ledc_stopto release the channel.The guard
xclk_io >= 0 && xclk_freq > 0makes this a no-op for boards that don't use DVP XCLK via GPIO (e.g. MIPI-CSI).Note on long-term direction
The SPI path already uses
esp_cam_sensor_xclk_*for this purpose viainit_spi_clk_func. Adding anxclk_sourcefield to the DVP YAML schema so DVP can use the same API is the symmetrical refactor. Happy to do that in a follow-up PR if preferred — this PR keeps scope minimal to unblock users.Test
ESP32-S3 SparkBot + OV3660 DVP:
get sensor ID failedat boot.ov3660: Detected Camera sensor PID=0x3660,/dev/video2opens from Lua,camera.capture()writes a ~30 KB JPEG.Tested against ESP-IDF v5.5.4.