1

I'm working with a board which has Linux installed. Eventually it will be used as a USB webcam. I built the kernel and added a UVC driver to it.

I'm following these instructions to test it. Unfortunately when I connect my host and run the application, I get the following error:

v4l2_core: (jpeg decoder) error while decoding frame

I'd like to test the application that I'm using on my host machine. There are several issues with that.

On the linux board that I use, when I execute modrobe g_webcam, I get a new video device appears in /dev, /dev/video0. When I execute it on my host, Linux ubuntu 4.10.0-32-generic #36~16.04.1-Ubuntu SMP Wed Aug 9 09:19:02 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux, nothing happens. I google around but I wasn't able to find an answer to why this is happening.

  1. So how do I create a video device on linux and bind it to UVC gadget with g_webcam?
  2. Let's say we figured out step 1. After I execute uvc-gadget -u /dev/video<uvc video node #> -v /dev/video<vivid video node #>, how would I read data from the gadget?

Any help is appreciated.

flashburn
  • 4,180
  • 7
  • 54
  • 109

1 Answers1

1

When I execute it [modprobe g_webcam] on my host, Linux ubuntu 4.10.0-32-generic #36~16.04.1-Ubuntu SMP Wed Aug 9 09:19:02 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux, nothing happens

That's expected. Your x86_64 host likely doesn't have an OTG UDC, so there is no way to enable a gadget on there. You can check dmesg on the host to confirm this, but in any case you shouldn't run modprobe g_webcam on the host.

So how do I create a video device on linux and bind it to UVC gadget with g_webcam?

Your modprobe g_webcam command created the output video device. When you run uvc-gadget it knows to bind to /dev/video0 as you can tell from the source code.

After I execute uvc-gadget -u /dev/video<uvc video node #> -v /dev/video<vivid video node #>, how would I read data from the gadget?

On the host, first confirm that /dev/videoX enumerates properly (run dmesg). Next, use a UVC camera viewer such as guvcview: sudo apt install guvcview

Unfortunately when I connect my host and run the application, I get the following error: v4l2_core: (jpeg decoder) error while decoding frame

Are you getting that error on the device, rather than the host? I haven't used vivid myself, but unfortunately there's a lot that can go wrong with UVC on both ends. I recommend you isolate problems by first running with synthetic data (./uvc-gadget -d) rather than vivid, as well as uncompressed YUYV rather than JPEG (-f 0). You could have many debugging steps ahead but this could at least bring you to a starting point where the host can see images streaming.

jdonald
  • 670
  • 7
  • 15