Need to configure RPi as a USB UVC (video camera gadget). As far as I understand here is how it can be done. Then I need to test this application. Instructions on how to do it located here.


  1. How can I add Virtual Video Driver to the Raspberry PI image?
  2. How can I cross compile this code on my host, for it later to be copied to the RPi. I need this option just in case I would not be able to compile it directly on RPi. Just a precaution.

Any help is appreciated.

1 Answer 1


I assume this is with a Pi Zero (or old Pi model A/A+). OTG won't work on a Pi 3 or most other models.

I'll answer your second question first because it'll come in handy for question 1).

For 2), once you are set up to cross-compile the kernel--having retrieved the tools and set up your PATH--you'll be ready to compile uvc-gadget similarly:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-

uvc-gadget is a small application so I actually find it more convenient to to make changes and build on the Pi Zero. Unfortunately, the same is not true for the kernel.

The latest Raspbian 9 Stretch defaults to a gcc 6 toolchain/libc while the tools repo is apparently still gcc 4.9. You may have to revert to Raspbian 8 Jessie to avoid getting a segfault even on a hello world application, or find an updated toolchain.

For 1), you'll need to configure the kernel for CONFIG_VIDEO_VIVID and recompile. After you have gotten the hang of building the kernel + modules and uploading it to your Pi,

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig

Device Drivers -> Multimedia Support -> Media test drivers -> Virtual Video Test Driver (set to M)

then recompile the kernel + modules and it should generate a vivid.ko file. I have only confirmed that it compiles, not necessarily loads or runs properly. To date my testing with uvc-gadget on a Pi zero has relied on synthetic image data (-d).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.