Freescale USB Stack and Vybrid

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Freescale USB Stack and Vybrid

Jump to solution
1,831 Views
kef2
Senior Contributor IV

Hello

 

There's no dedicated community for this USB stack. There's also no support for Vybrid (yet?). In case anyone wants to try it now (footprint or something else), here's my attempt to port virtual_camera demo for kinetis_K70 to Vybrid A5 core, DS-5. Seems working with WinXP machine. Driver detects ant installs from windows update on Win7 too, but I don't know what to use for camera application on Win7. Unfortunately camera app is not built in in Win 7 like it is(was) in WinXP.

 

Code as is attached below

Original Attachment has been moved to: Vcam.zip

Labels (5)
1 Solution
931 Views
kef2
Senior Contributor IV


Well, it is getting more and more clear. Either USB stack should be modified to tell application level what is current connection speed and what is current microframe in case of high speed mode. Or, device should have two configuration descriptors, one for full speed, and another one for high speed. Full speed descriptor may specify bInterval=1 in Standard VC Interrupt Endpoint Descriptor. In high speed mode bInterval should be changed to 4 to have the same isochronous transfer period of 1ms. Anyway it would be nice if USB stack had some API function to report current connection speed. For now I need to read USB registers to determine connection speed.

Thanks for help and sorry for noise. Certainly I'm on the right track and see no problems completing design on time, unless I fail interfacing CMOS camera on first attempt :-)

Regards

View solution in original post

10 Replies
931 Views
juangutierrez
NXP Employee
NXP Employee

This camera app that you mentioned for is an standard application or is some executable provided for the demo that works only on WinXP?

0 Kudos
931 Views
juangutierrez
NXP Employee
NXP Employee

Check Built in Webcam Viewer like XP? - Windows Forums, at the end there are some links to some software that might work on Win7

931 Views
kef2
Senior Contributor IV

Dear Juan Antonio,

thank you very much for useful URl. I found there simple and nice camera apps.

WinXP supports USB UVC cameras in Windows Explorer, where you can watch video and take screenshots from camera. See below.

I've just found one problem with FSL USB stack. I was fighting some artifacts watching video. I decided to reduce frame rate, which could help finding max frame rate or shed some light on problem. Reading UVC class specs, I figured that video frame rate is (or should be) controlled changing data packet size, which is send every millisecond over isochronous endpoint in full speed mode. I was trying to lower packet size, but frame rate was changing minimallyin uncontrolled manner until minimum packet size of 36bytes. Probably it is some special number, but no packets are send if I further lower packet size, but video frame rate was still about 20-30fps!Camera demo uses USB_App_Callback() to prepare buffer and send USB packet on USB_APP_SEND_COMPLETE event. And that was the problem. As a workaround for now I synced packed prepare and send to microframe counter period (each 8 microframes). Works well, but certainly this is not a right approach. Looks like stack should be modified to support isochronous transfers in high speed mode. Perhaps MQX USB supports it already, but it doesn't support UVC class.

winXP-usbcam1.PNG

winXP-usbcam2.JPG

0 Kudos
932 Views
kef2
Senior Contributor IV


Well, it is getting more and more clear. Either USB stack should be modified to tell application level what is current connection speed and what is current microframe in case of high speed mode. Or, device should have two configuration descriptors, one for full speed, and another one for high speed. Full speed descriptor may specify bInterval=1 in Standard VC Interrupt Endpoint Descriptor. In high speed mode bInterval should be changed to 4 to have the same isochronous transfer period of 1ms. Anyway it would be nice if USB stack had some API function to report current connection speed. For now I need to read USB registers to determine connection speed.

Thanks for help and sorry for noise. Certainly I'm on the right track and see no problems completing design on time, unless I fail interfacing CMOS camera on first attempt :-)

Regards

931 Views
juangutierrez
NXP Employee
NXP Employee

Glad to hear you find a way to make it working so far. I'm not familiar with this demo on Kinetis but I would like to try your code on Vybrid. So, does the camera is connected in the vybrid board and then you can see it in the PC as a camera device through usb. What kind of camera is connected, is a web cam or a cmos sensor?

0 Kudos
931 Views
kef2
Senior Contributor IV

Hi Juan Antonio,

FSL USB stack contains 3 single SUB function demos for USB Video Class (UVC). Demo above ("virtual_camera" from FSL USb stack) has small video sample included in program code. Instead of streaming data from camera, it streams data from memory. There are more demos. "virtual_camera_SD" streams data from SD card. "virtual_camera_SD_and_loader" included mass storage class, so that one may write video data to SD card, and then stream to PC using UVC class.

I'm still investigating UVC nuances (burden of hardcoded descriptors, UVC probe/commit negotiation structs, etc). After I make it all clear for myself, I'll start debugging with CMOS camera unit. VIU module should pump data from camera to RAM, then modified USB_Prepare_Data() routine in virtual_camera.c should supply USB stack with video data. Uncompressed data stream should be OK for my task.

0 Kudos
931 Views
jimma
Contributor I

Hi Edward,

I'm actually trying to run examples of the FSL USB stack for video applications. I saw your Vcam project modified for VF6xx, (I also have this board and my computer under Win7),

Did you manage to make everything work and did you had to do a lot of changes for Vybrid ?

For the moment I am trying to send images from Vybrid through USB and then I would like, as you, to connect a camera module to the VIU with the VIU pumping data from camera to ram with the DMA then send it through USB.

Regards

0 Kudos
931 Views
kef2
Senior Contributor IV

Hi

Yes, I made it working as required. It was a lot of work. Kinetis K70 driver, in which I just changed some register names and bit masks to make it compileable and working on Vybrid, in fact had some hard to debug bugs. Another problem was semiworking and buggy implementation of usb_descriptor.c in FSL USB "virtual_camera" demo. All functions starting down from USB_Desc_Set_Cur_Video_Probe() are wrong and need to be redone according to UVC class specification requirements for probe-commit negotiation. Code may work on WinXP and not work on Win7 or vice versa, or work for first time insertion or not work at all. Wrong probe-commit negotiation caused all this. The biggest problem with usb_descriptor.c was its bad coding. Someone has to be punished for magic constants without explanation! :-)

I don't know who from FSL USB stack guys to communicate problems in Kinetis driver. Another problem is I don't remember all what was wrong with it. I can provide my driver as is and someone would need to compare and look for differences :-(.

uvc_descriptor.c is application specific file, but probe - commit part of my (not necessarily right) implementation can be provided also as is.

Unfortunately I have no updates for vcam.zip attached above. I'm busy with different Vybrid app with Linux.

My idea was to imlement UVC Uncompressed Payload, so that data from vybrid could go over USB without computations required to compress video. This allows to keep A5 crunching more important data. UVC Uncrompressed Payload allows transmiting up to ~24MB/sec ( (1024*3  -12) * 8000) of video data in isochronous mode. For VGA video one frame in uncompressed payload is 640*480*2=614400 bytes. Thats up to 39.8Hz. Bigger frames - less Hz, smaller frames - more Hz.

Edward

0 Kudos
931 Views
jimma
Contributor I

Hi,

Indeed that's weird we have no information about this. I was looking through the virtual camera demo and it seems that I'll have to change a lot of things and some things have no clear descriptions.

I tried to request support for this FSL usb stack on difference places, still waiting.

If you are ok with this, as you said about your driver, I'm ok with checking differences with the original demo and I'll try to figure it out, hopefully that will work also for me, and I'll share if I have any feedback from requests or something else,

Regards,

Jim

0 Kudos
931 Views
kef2
Senior Contributor IV

Hi Jim,

I collected modified FSL USB stack files, which are not my application specific. See attached.

Regards

Edward