[FX3+ov7670:] UVC: Completed 25 frames and 0 buffers

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
AKS
Level 4
Level 4
100 sign-ins 10 questions asked 50 replies posted

Hi, I am working on interfacing ov7670 with CYUSB3KIT-003 as per this blog:

https://www.circuitvalley.com/2019/12/diy-cypress-fx3-usb3-usb-3-uvc-camera-ov7670.html?showComment=...

Checked all the signals like PCLK,HREF,VSYNC,XCLK, all looks fine. firmware loaded to FX-3 but failed to display anything on vlc/webcamoid application. Here s the frame/buffer log...

Please help to resolve this issue. What more I should figure out.

 
 

Ash_2-1639380286325.png

Best Regards,

/Ash

 

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
AKS
Level 4
Level 4
100 sign-ins 10 questions asked 50 replies posted

@AliAsgar @JayakrishnaT_76 @Ajeethkumar_P  Thank you all for your suggestions and guidance.

I figured it out and I can see the data streaming is there. But I did not understand why it takes VGA(640x483) (even not mentioned in attached DS) instead of VGA(640x480). when I apply 480 there is nothing comes up on host application.

Also, how can I cross check the total number of bytes from sensor to send to host? since there are lot of data is coming on wireshark log through USBCap, where and how can I cross check the 1 frame data? any way to check.....

Please suggest~

Best Regards,

/Ash

View solution in original post

0 Likes
58 Replies
AliAsgar
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 750 replies posted

Hi Ash,

In the UART prints shared previously, there were full buffers coming in.

But in the recent post of yours, full buffers are zero. Could you please let us know what is done different in the two cases. 

Also wireshark traces are required when the buffer count = 16384.

Have you received video data in any of the cases?

I would advise you to do a reconnection of hardware with stronger and shorter connections between FX3 and the UVC camera.

Best Regards,
AliAsgar

0 Likes
lock attach
Attachments are accessible only for community members.
AKS
Level 4
Level 4
100 sign-ins 10 questions asked 50 replies posted

@AliAsgar Hi.

  • case 1:
    • #define FRAME_TIMER_ENABLE
    • /* #define DEBUG_PRINT_FRAME_COUNT */
    • I didnt see any thing on AmCap
    • reconnected wiring from sensor to FX3 connector.
    • wireshark traces attached.

Ash_1-1640924458903.png 

Ash_2-1640924521193.png

Ash_0-1640924677431.png

Ash_1-1640924724737.png

Ash_2-1640924770037.png

Ash_3-1640924807416.png Ash_4-1640924838502.png 

Ash_5-1640924879119.png

Please suggest~

Thanks

Best Regards,

/Ash

0 Likes
JayakrishnaT_76
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hello,

The logs shared in your last 2 responses seem to be different. In one of the snapshot, I can find that the video data is received properly and sent to the host. But in the second snapshot, I find that there is a timer overflow. The timer overflow generally occurs when the sensor is not sending the data properly to FX3. Please confirm that both the logs were taken by commenting out "DEBUG_PRINT_FRAME_COUNT".

Best Regards,
Jayakrishna
0 Likes

@JayakrishnaT_76 @AliAsgar @Ajeethkumar_P Happy New Year 😊!

@JayakrishnaT_76 Hi, Thanks for your suggestion. Yes, I tested it again while commented out "DEBUG_PRINT_FRAME_COUNT". But this time I am not getting any thing in 'Full Buf' as per below log....

Ash_0-1641176925381.png

 

Could you please let me know the reason of getting Full Buf sometimes as per the previous posts but sometimes not....like 0. What I should check more to get 'Full Buf'?

Please suggest~

Thanks

Best Regards,

/Ash

0 Likes
AliAsgar
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 750 replies posted

Hi Ash,

The github repo which you have referred for this project is not official and we have not tried or tested that project at our end. We recommend you not to follow that.

Instead use the firmware project given in the AN75779 application note. Modify the sensor.c, sensor .h files and the uvc.c files according to the OV7670 sensor datasheet and then try programming FX3 with the resultant firmware image. You may have to go through the uvc.c file to get an overview of the firmware flow and then program the sensor files accordingly.

Best Regards,
AliAsgar

0 Likes
AKS
Level 4
Level 4
100 sign-ins 10 questions asked 50 replies posted

@AliAsgar  Hi. Thanks.

I am referring the UVC_AN75779, which is shared by you and modified it and added sensor (ov7670) configuration after changing in uvc.c, uvc.h, sensor.c, sensor.h accordingly.

I am rechecking the configuration and debugging to check what parameter causes this occurrence. I will update.

Thanks,

Best Regards,

/Ash

 

0 Likes
lock attach
Attachments are accessible only for community members.
AKS
Level 4
Level 4
100 sign-ins 10 questions asked 50 replies posted

@AliAsgar @JayakrishnaT_76 @Ajeethkumar_P  Thank you all for your suggestions and guidance.

I figured it out and I can see the data streaming is there. But I did not understand why it takes VGA(640x483) (even not mentioned in attached DS) instead of VGA(640x480). when I apply 480 there is nothing comes up on host application.

Also, how can I cross check the total number of bytes from sensor to send to host? since there are lot of data is coming on wireshark log through USBCap, where and how can I cross check the 1 frame data? any way to check.....

Please suggest~

Best Regards,

/Ash

0 Likes
AliAsgar
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 750 replies posted

Hi Ash,

One frame data can be calculated by the formula:
(Width in pixel * Height in pixel*2).
This gives one frame data. 16KB buffers are used in the DMA channels.
Hence diving the above formula by (16*1024)-16 will give you the total number of full buffers.

In wireshark check for that many amount of full buffers and then a partial buffer following it.  This will help you in verifying the frame data.

Please share with us the amount of data in the partial buffer and number of full buffers you see in the wireshark

Note: Every packet in Wireshark has 27 bytes of data due to the wireshark application offset. So, make sure to subtract that from each packet when calculating the data.

Best Regards,
AliAsgar

 

 

Best Regards,
AliAsgar

0 Likes
lock attach
Attachments are accessible only for community members.
AKS
Level 4
Level 4
100 sign-ins 10 questions asked 50 replies posted

@AliAsgar  Thanks for your prompt reply with well explanation.

I calculated accordingly as...
1 frame = 640*483*2 = 618,240 bytes          //since I used 483 as height
Full buffer = 618,240 / ((16*1024)-16) = 37.77

In wireshark log, I can see as...

Ash_0-1641537066489.png

Ash_1-1641537132045.png

I attached the data stream-wireshark log. seems, it showing as 2084,28, 36...Could you please mark which data refers to what?

Thanks,

Best Regards,

/Ash

0 Likes
AliAsgar
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 750 replies posted

Hi Ash,

Kindly look at the wireshark traces shared by you from transfer no. 3571. We can see that there are 37 packets of size 16407, followed by a partial packet of size 12663.

Capture1.PNG

There is a USBPCap psuedoheader length from the wireshark side of 27 bytes, and there is a 12 byte header added in the firmware for every buffer.
Hence, ((16407-12-27)*37)+(12663-27-12) = 618240.
The total frame size is 640*483*2 = 618240.
The frame size in wireshark trace is in accordance with the resolution.

Best Regards,
AliAsgar

0 Likes
lock attach
Attachments are accessible only for community members.
AKS
Level 4
Level 4
100 sign-ins 10 questions asked 50 replies posted

@AliAsgar Hi, Thanks for your well explanation.
Though I understood this well, but I didn't get it that  when I configure it for 640x480, the calculated full buffer value is 37.77 (fraction) which is almost same for 640x483.
I also captured wireshark log for 640x480, and it gives me same result as with 640x483. (16407 and 12663) But...
1. in case of 640x480, I can not see any data stream on host application.
2. in case of 640x483, I can see data stream on host application.

Ash_0-1641807079293.png

even the data log is same for both the cases, where is the difference? Please suggest~

0 Likes
AliAsgar
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 750 replies posted

Hi Ash,

As the wireshark traces is same for both 640*480 and 640*483, both corresponding to the 640*483 resolution. It means that the camera itself is giving data in the 640*483 resolution. Please check with the camera vendor on this issue.

Best Regards,
AliAsgar

0 Likes
AKS
Level 4
Level 4
100 sign-ins 10 questions asked 50 replies posted

@AliAsgar Hi, Thanks for the suggestion.

I checked in the data sheet and it is mentioned that this sensor supports VGA (640x480) but there is nothing mentioned like '640x483' anywhere.

Also even if I changes anything to WIDTH/HEIGHT, the wireshark traces give me always the same '16407' bytes, no matter what I set to WIDTH/HEIGHT. Is it not related?

It is hard to set the WIDTH/HEIGHT to any set pixels value where the data is visible  on host application until it is mentioned in the DS.

any suggestion on this?

Thanks.

0 Likes
AliAsgar
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 750 replies posted

Hi Ash,

16407 is the size of a full buffer. This amount of data is regardless of the resolution of the video. 
If resolution is to be calculated using wireshark traces, calculate the total number of full buffers and the partial buffer size. 

If there are 37 full buffers coming in followed by a partial packet of 12663 regardless of the resolution configured in the descriptor files, it means that the camera is producing video of 640*483 resolution. The reason for this anomaly has to be enquired by the camera vendor, or you can check the same sensor with some other controller  to verify the cause of this issue.

Best Regards,
AliAsgar

0 Likes
AKS
Level 4
Level 4
100 sign-ins 10 questions asked 50 replies posted

 

@AliAsgar Hi, Thank you.

I tried to understand it but get confused a bit. I understood it like.....

Full buffer (bytes) = 16407*37
partial buffer  (bytes) = followed by 'Full buffer'

Total buffers (bytes) = full buffers + partial buffers   //-offset (-12-27) default

So, 1 frame size = total buffers (bytes). Is this correct?

if yes, then for example, If I change the camera config to QVGA (for ex.) 340x240

then full buffer and partial buffer would be definitely changed, right?

in that case, total buffs = 163,200 bytes (1 frame)    //QVGA case

where, total buffs = (full buff - offset)+(part buff-offset)

Please correct me, if I understood wrong...

Thanks,

Best Regards,

/Ash

0 Likes
AliAsgar
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 750 replies posted

Hi Ash,

A DMA is of size 16KB in FX3 for the AN75779 firmware. After the camera fills up this buffer, it is committed to the USB, and the host application reads it. This is what I call as full buffer. One 16407 byte data in the wireshark is known as one full buffer.

One frame of camera usually has several KB of data. So one frame of data fills many buffers of size 16KB fully and then fills one buffer partially, as one frame data is not divisible by 16KB.

Hence if the DMA buffer size in the firmware remains as 16KB, full buffer size wont change. 

But depending on the resolution of the video, the number of full buffers (not the size) and size of partial buffer can vary.

Best Regards,
AliAsgar

0 Likes
AKS
Level 4
Level 4
100 sign-ins 10 questions asked 50 replies posted

@AliAsgar , Hi. Thanks for your well explanation. really appreciated. 🙂
Yes, I do understand it. 🙂
So the total resolution defined = n* 16kb buffs + partial buffs  //n is number of (16kb) full buffers.

well, Is it possible to change the streaming encoding format? seems, Its default to YUV2, what GUID I should define to encode format in case of  raw16/y16 (mono)?

any suggestion please~

Thanks,

Best Regards/

0 Likes
AliAsgar
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 750 replies posted

Hi Ash,

You can ask these questions in this thread : https://community.infineon.com/t5/USB-superspeed-peripherals/RAW-mono-data-streaming-from-FX3/td-p/3...

Best Regards,
AliAsgar

0 Likes
AKS
Level 4
Level 4
100 sign-ins 10 questions asked 50 replies posted

@AliAsgar Hi,

Okay. Thank You. I do so.

Since I already created the related post, could you please suggest something there?

best regards,

/Ash

0 Likes