Open mmadela opened 1 month ago
so the problem is inside
static int jpeg2avi_add_frame(jpeg2avi_data_t *j2a, uint8_t *data, uint32_t len)
adding console output
--- a/components/avi_video_process/avi_recorder.c
+++ b/components/avi_video_process/avi_recorder.c
@@ -152,6 +152,7 @@ static int jpeg2avi_add_frame(jpeg2avi_data_t *j2a, uint8_t *data, uint32_t len)
memcpy(&j2a->buffer[j2a->write_len], &frame_head, sizeof(AVI_CHUNK_HEAD)); // Copy the header data to the back of the current data to be processed
j2a->write_len += sizeof(AVI_CHUNK_HEAD);
int _len = CHUNK_SIZE - last_remain - sizeof(AVI_CHUNK_HEAD);
+ printf("_len %d\n", _len);
memcpy(&j2a->buffer[j2a->write_len], data, _len);
j2a->write_len += _len;
data += _len;
gives after a while a negative length
and this is not the only problem in this function looking further
--- a/components/avi_video_process/avi_recorder.c
+++ b/components/avi_video_process/avi_recorder.c
@@ -175,6 +176,7 @@ static int jpeg2avi_add_frame(jpeg2avi_data_t *j2a, uint8_t *data, uint32_t len)
// the remain is [last remain data + chunk_head + new frame data]
memcpy(&j2a->buffer[j2a->write_len], &frame_head, sizeof(AVI_CHUNK_HEAD)); // add the avi_chunk_header
j2a->write_len += sizeof(AVI_CHUNK_HEAD);
+ // see line 139, var **remain** includes already j2a->write_len, so the line below might overflow the buffer twice in worst case
memcpy(&j2a->buffer[j2a->write_len], data, remain - sizeof(AVI_CHUNK_HEAD)); // add the new frame data
j2a->write_len += remain - sizeof(AVI_CHUNK_HEAD);
remain = 0;
This may be a hardware power supply issue. When the brightness of the environment decreases, the sensor requires a larger current to achieve greater gain.
The problem is clearly software problem, see the comment above the only HW correlation is that the dark images are smaller and causes the bug to rise faster
Answers checklist.
IDF version.
v5.2.2
Espressif SoC revision.
ESP32-S3
Operating System used.
Windows
How did you build your project?
Eclipse IDE
If you are using Windows, please specify command line type.
CMD
Development Kit.
ESP32-S3-Eye and ESP-S3-Korvo2
Power Supply used.
USB
What is the expected behavior?
the example works in every light conditions
What is the actual behavior?
there is a watchdog reset, especially in dark environment
Steps to reproduce.
Debug Logs.
More Information.
I’ve tried the video recorder example, the code crashes in a strange way, there is a watchdog reset, but typical information (like backtrace or coredump, if enabled) is not available. I’ve tested the S3 Eye and S3 Korvo 2 board with 3 OV2640 cameras. Always the same problem, the crashes are somehow related to light conditions, if bright, then sometimes works, but if darken (or with lens cover), then fails every time. I’ve tried also different SD cards, clock speeds, camera resolutions, etc. No changes. The complete source (even with managed components) attached, however the alterations from original are just adjustments for the boards I have. video_recorder_full_source.zip