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
).