Wrong FIFO length received for the color bar test image

  1. Where did you get the camera module(s)?
    Amazon

  2. Model number of the product(s)?
    Arducam OV5642 5MP Plus

  3. What hardware/platform were you working on?
    STM32h7xx based hardware (based on Raspberry PI)

  4. Instructions you have followed. (link/manual/etc.)
    I’m working off one of the built-in examples from the GitHub

  5. Problems you were having?
    We’re facing issue wherein sometimes images are corrupted. To debug this further, i enabled the TEST_PATTERN (color bar). And for the image size of ov5642_1024x768, in normal working scenario, jpeg image size would be 31176 bytes. But sometimes, we get the large image size like 48k, 87k and so on. And in this failure scenario, image is corrupted.
    I connected the logic analyzer to the camera module SPI pins. And from the capture, could see that for FIFO_SIZE1, FIFO_SIZE2 and FIFO_SIZE3 return different values:

In working scenario:

And in failure scenario:

Ideally, FIFO size should be same since TEST_PATTERN is enabled. But in this case, it varies. Could you please let us know if something is missing here? As mentioned earlier, it does work most of the times where images are captured fine. But we do have quite a few number of cases where images are corrupted. So we’re trying to figure the root cause of it.

  1. The dmesg log from your hardware?

  2. Troubleshooting attempts you’ve made?
    See above!

  3. What help do you need?
    Why FIFO_SIZEs should vary for the same TEST_PATTERN?

@sitehive
Hi,
We have not tested it on STM32h7xx platform. You can refer to our demo in stm32f103 platform.

About the SPI read abnormal. Notice, the speed of the the spi clock should less than 4Mhz.

Hello,
Thank you for the inputs. However, as I mentioned earlier, we are able to get the correct images most of the times. It’s just that sometimes, it just returns corrupted images. And all the steps (i cross checked with the demo FW code link you’ve shared) seems to be okay. The only way FW can start reading the captured image is by first reading the FIFO length.
Is there any other way to figure out if capture has been successful or not?
If it helps, I am sharing the arducam module source file here arducam_source_code - Pastebin.com.

Please note we have 2 cameras in our device. So, camera module gets called in sequence like this:

Thread-1
Arducam_SemaphoreTake();
Arducam_TakePhoto(Exceedance_CurrentCamera);
Arducam_SemaphoreGive();

Thread-2
Arducam_SemaphoreTake();

				wait till (Arducam_IsCaptureDone(camera))

				size = Arducam_ReadImageSize(camera);

				Arducam_StartReadingImageData(camera);

				Arducam_ReceiveCameraData(data, size);

				Arducam_SemaphoreGive();

Regards,
Mahesh.

@sitehive
Please try to set the baud to a lower speed and ensure the SPI clock is less than 4Mhz.