UVC webcam gadget on i.MX8 HW

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

UVC webcam gadget on i.MX8 HW

跳至解决方案
7,032 次查看
sorenfriis
Contributor I

Hi

I have been searching through the forum to figure out if anyone has ever succeeded in successfully setting up a UVC gadget on i.MX8 HW to stream out video frames and make the i.MX8 act as a web-cam when plugged into a host PC.

There are multiple failed attempts:
- https://community.nxp.com/t5/i-MX-Processors/Issue-in-Video-Streaming-with-gadget-webcam-module-g-we...
https://community.nxp.com/t5/i-MX-Processors/Issue-in-Video-Streaming-with-gadget-webcam-module-g-we...
https://community.nxp.com/t5/i-MX-Processors/UVC-gadget-on-imx8mevk/m-p/931181
https://community.nxp.com/t5/i-MX-Processors/UVC-gadget-device/m-p/1180688

This discussion seems to indicate that someone did managed to make this work?
- https://community.nxp.com/t5/i-MX-Processors/Trigger-of-FRM-STRD-interrupt-on-I-MX8MP/m-p/1271588

Apparently it has been possible to setup this on i.MX53, i.MX7 and i.MX RT1050 HW:
https://community.nxp.com/t5/i-MX-Processors/linux-uvc-gadget-driver-yuv-streaming-in-windows-host-p...
https://community.nxp.com/t5/i-MX-Processors/Usb-UVC-webcam-gadget-bulk-transfer/m-p/1016177
https://www.nxp.com/docs/en/application-note/AN12103.pdf

Can anyone confirm that this is possible on i.MX8 HW and does any instructions exist anywhere on how to do this?

This project has been very helpful in getting similar functionality working on a Raspberry Pi 4 but it is not clear to me how much of it can be directly applied to i.MX8 HW:
https://github.com/showmewebcam/showmewebcam

0 项奖励
回复
1 解答
6,936 次查看
kshitij_shah
NXP Employee
NXP Employee

@sorenfriis Here are the steps verified with 5.10.52:

1,  Force USB to high speed USB 2.0, attached is patch for dts changes

2,  clone APP and patch uvc-gadget.diff.

        git clone https://github.com/wlhe/uvc-gadget.git

3,  put uvc-gadget, usb_uvc_only_yuv_mjpeg.sh and wallpaper.jpg into board. For example:

 

For 1080p yuyv

        # ./usb_uvc_only_yuv_mjpeg.sh

        # ./uvc-gadget -d -u /dev/videox -f 0 -r 2 &

 

        For 1080p mjpeg

# ./usb_uvc_only_yuv_mjpeg.sh

        # ./uvc-gadget -d -u /dev/videox -f 1 -r 2 -i ./wallpaper.jpg &

 

4, using potplayer on PC to preview according to frame format.

 

PS:

1, run_standalone is used in uvc-gadget to avoid the influence of camera.

2, There will be missIsoc events when using super-speed(USB3.0). So USB speed is forced to high-speed(USB2.0) in my demo.

在原帖中查看解决方案

0 项奖励
回复
8 回复数
6,998 次查看
sorenfriis
Contributor I

Thanks. It is good to know that what I am trying is not completely impossible. However, so-far, most of the trials with the configfs gadget either leads to kernel errors or the device freezing up completely.

Do you know if the exact set of kernel config flags and the exact configfs gadget structure is available somewhere, for this working example?

0 项奖励
回复
6,937 次查看
kshitij_shah
NXP Employee
NXP Employee

@sorenfriis Here are the steps verified with 5.10.52:

1,  Force USB to high speed USB 2.0, attached is patch for dts changes

2,  clone APP and patch uvc-gadget.diff.

        git clone https://github.com/wlhe/uvc-gadget.git

3,  put uvc-gadget, usb_uvc_only_yuv_mjpeg.sh and wallpaper.jpg into board. For example:

 

For 1080p yuyv

        # ./usb_uvc_only_yuv_mjpeg.sh

        # ./uvc-gadget -d -u /dev/videox -f 0 -r 2 &

 

        For 1080p mjpeg

# ./usb_uvc_only_yuv_mjpeg.sh

        # ./uvc-gadget -d -u /dev/videox -f 1 -r 2 -i ./wallpaper.jpg &

 

4, using potplayer on PC to preview according to frame format.

 

PS:

1, run_standalone is used in uvc-gadget to avoid the influence of camera.

2, There will be missIsoc events when using super-speed(USB3.0). So USB speed is forced to high-speed(USB2.0) in my demo.

0 项奖励
回复
4,568 次查看
WolfChen2
Contributor I

thanks for sharing information

I have question, I always got error message

"udc-core: couldn't find an available UDC or it's busy
sh: echo: write error: No such device"

when I execute "echo 38100000.usb > UDC"

is there anything need to modify?

i use imx-5.15.71-2.2.0.xml, just download and compile then burn into EVB 

use imx8mp EVB

0 项奖励
回复
6,918 次查看
sorenfriis
Contributor I

Thanks a lot, for these helpful hints. With this I was at able to establish a video device on the host PC. This is clearly a lot further than anything else I have managed to do so far.

The image from the JPEG was just a flicker mess when viewed in a video player application on the Ubuntu host but now when data is finally flowing from one end to the other, it should be possible to figure out what is wrong with that. I will continue to debug and develop on this to get this at the functionality level we need it.

BTW: The HW I am using is a Solidrun Hummingboard Mate with an i.MX8M+ SOM on it. You had added one extra line in the device tree file to define maximum-speed but the patch file shows two additional lines afterwards defining some u1 and u2 quirks, which were missing in the imx8mp-evk.dts file that I have. I added those lines as well, just to be sure. I still need to double check if the imx8mp-evk.dts file is used in the build that I am creating.

0 项奖励
回复
6,902 次查看
kshitij_shah
NXP Employee
NXP Employee

@sorenfriis  We were able to see clean image, the one provided as example. Also, you do need to add both the lines as per the patch. Please let us know if you still have issues.

0 项奖励
回复
6,896 次查看
sorenfriis
Contributor I

After double checking what I was doing, I have now also been able to get the still image correctly shown in a video player on the host PC.

And as an added bonus, I have been able to forward the live MJPEG image stream from a Logitech USB web-camera plugged into the i.MX8M+ board to the host PC.

Thank you very much for creating this example to show how to do this. I really appreciate it.

0 项奖励
回复
7,016 次查看
joanxie
NXP TechSupport
NXP TechSupport

yes,  i.MX8MM EVK Board can be detected as a uvc device, using the camera module AP1302+AR1335 with YUV422 720p30

 

0 项奖励
回复
3,848 次查看
vivek338
Contributor IV

Hi!

How u did that? I am stuck on imx8mm-evk for usb webcam project.

Please help!!

0 项奖励
回复