UVC gadget on imx8mevk

cancel
Showing results for 
Search instead for 
Did you mean: 

UVC gadget on imx8mevk

1,433 Views
Contributor I

Hello community,

We're trying to get UVC gadget working on imx8m-evk, without any success.
The system is initialized using "repo init -u https://source.codeaurora.org/external/imx/imx-manifest -b imx-linux-sumo -m imx-4.14.98-2.0.0_ga.xml"
  1. mipi cameras are verified using gstreamer
  2. usb gadget's configured with configfs:  mkdir /sys/kernel/config/usb_gadget/g1
    cd /sys/kernel/config/usb_gadget/g1
    mkdir configs/c.1
    mkdir strings/0x409
    mkdir configs/c.1/strings/0x409
    echo 0x3290 > idProduct
    echo 0x18ec > idVendor
    echo 0x0310 > bcdUSB
    echo serial > strings/0x409/serialnumber
    echo manufacturer > strings/0x409/manufacturer
    echo UVC Gadget > strings/0x409/product
    echo "Conf 1" > configs/c.1/strings/0x409/configuration
    echo 120 > configs/c.1/MaxPower
    mkdir functions/uvc.usb0
    mkdir -p functions/uvc.usb0/streaming/uncompressed/u/480p
    cat <<EOF > functions/uvc.usb0/streaming/uncompressed/u/480p/dwFrameInterval
    333333
    1000000
    5000000
    EOF
    echo 480 > functions/uvc.usb0/streaming/uncompressed/u/480p/wHeight
    echo 333333 > functions/uvc.usb0/streaming/uncompressed/u/480p/dwDefaultFrameInterval
    echo 614400 > functions/uvc.usb0/streaming/uncompressed/u/480p/dwMaxVideoFrameBufferSize
    echo 73728000 > functions/uvc.usb0/streaming/uncompressed/u/480p/dwMaxBitRate
    echo 24576000 > functions/uvc.usb0/streaming/uncompressed/u/480p/dwMinBitRate
    mkdir functions/uvc.usb0/streaming/header/h
    cd functions/uvc.usb0/streaming/header/h
    ln -s ../../uncompressed/u
    cd ../../class/fs
    ln -s ../../header/h
    cd ../../class/hs
    ln -s ../../header/h
    cd ../../class/ss
    ln -s ../../header/h
    cd ../../../control
    mkdir header/h
    ln -s header/h class/fs
    ln -s header/h class/hs
    ln -s header/h class/ss
    cd /sys/kernel/config/usb_gadget/g1
    echo 1024 > functions/uvc.usb0/streaming_maxpacket
    echo 15 > functions/uvc.usb0/streaming_maxburst
    ln -s functions/uvc.usb0 configs/c.1
    echo 38100000.dwc3 > UDC
  3. After running user space testing app(https://github.com/wlhe/uvc-gadget, with changes from 640x360 to 640x480 to match supported formats in ov5640_mipi_v2.c), imx8m-evk can be detected as a uvc device.
However, once I opened the UVC with VLC player, there's no video streaming.
After further investigation, I discovered that UVC video payload packets were not sent out successfully by ISO endpoints, usb_request.complete was never called.
dwc3_send_gadget_ep_cmd(dwc3/gadget.c) returns -EAGAIN, indicating an error status of 'Bus Expiry'. Data flow is: dwc3_endpoint_interrupt() => dwc3_gadget_start_isoc() => __dwc3_gadget_kick_transfer() => dwc3_send_gadget_ep_cmd()
We're running out of lead,
any help or information would be appreciated.
0 Kudos
4 Replies

87 Views
Contributor I

I already fail on the step "mkdir functions/uvc.usb0":

> mkdir: cannot create directory 'uvc.usb0': Operation not permitted

I listed directory with gadget modules:

>>ls /lib/modules/4.14.98-imx_4.14.98_2.0.0_ga+g5d6cbea/kernel/drivers/usb/gadget/legacy

g_audio.ko g_ether.ko g_ncm.ko g_zero.ko
g_cdc.ko g_mass_storage.ko g_serial.ko

Don't I have required module in my image? I googled during 1 hour and couldn't find any answers, how to activate UVC gadget.

I tried modprobe uvcvideo and I have this module now, but it still not working. It seems to be another module.

0 Kudos

87 Views
Contributor I

For people that running into the same problem, it seems to be a dwc3 usb controller(driver) problem.

There's another post about this from 2018, but I guess he didn't dig that deep:

Issue in Video Streaming with gadget webcam module g_webcam in i.MX8 EVK 

I've seen people having this problem on RK3399 which also integrate dwc3 as its usb controller.

firefly rk3399 uvc-gadget 无法正常工作 · Issue #167 · rockchip-linux/kernel · GitHub 

I hope in the future someone would be more committed to solving this, and this post would give him some useful information.

I'm currently done with this, not a big issue, I think most customer can accept not having uvc gadget feature.

After all no one cares about uvc gadget on a platform like imx8, it simply isn't designed for that purpose.

0 Kudos

87 Views
NXP Employee
NXP Employee

Hi Han,
You could take a look to the following Community thread for reference information:

i.MX 6,7,8 support USB device mode support to UVC 

Also, on application note AN12103 is implemented a UVC, but based on a i.MX RT processor:

https://www.nxp.com/docs/en/application-note/AN12103.pdf 

Hope this will be useful for you.
Best regards!
/Carlos
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

-------------------------------------------------------------------------------

0 Kudos

87 Views
Contributor I

Thanks for you reply, Carlos.

But we know that isn't helping with this particular problem, no one's ever successfully verified UVC gadget on imx8 as far as I know.

0 Kudos