I want to create a USB gadget with a raspberry pi zero 2W. I’m starting with imitating a webcam I already have to see how much of this I can figure out. I’ve used the online documentation and a couple AI bots to get this far quickly, but I’m hung up on a ln command. It’s telling me “ln: failed to create symbolic link ‘configs/c.1/uvc.usb0’: No such file or directory” when trying to create the link. This makes no sense to me though. I’m trying to create the link, of course it doesn’t exist yet. That’s what that command is supposed to do.

I’ve confirmed this problem in alpine linux and raspbian lite.

Below is the little script I have so far just to create the device:

#!/bin/bash
modprobe libcomposite
cd /sys/kernel/config/usb_gadget/
mkdir -p fauxcam
cd fauxcam
echo 0x046d > idVendor  # Logitech Vendor ID
echo 0x094b > idProduct # Brio 105 Product ID
echo 0x0200 > bcdUSB
echo 0x9914 > bcdDevice
mkdir -p strings/0x409
echo "111111111111" > strings/0x409/serialnumber
echo "Brio 105" > strings/0x409/product
mkdir -p configs/c.1/strings/0x409
echo "UVC Configuration" > configs/c.1/strings/0x409/configuration
echo 250 > configs/c.1/MaxPower
mkdir -p functions/uvc.usb0
ln -s functions/uvc.usb0 configs/c.1/
echo "usb0" > UDC
5 points
*

IDK how all that works but I will say that the result of this would (in a normal filesystem) create a link named configs/c.1/uvc.usb0 yes, but that link would point to functions/uvc.usb0 relative to its own dir. This doesn’t exist and your symlink would be broken, presumably the special file system there doesn’t like that.

Edit: Apparently that’s not the problem and you’re totally supposed to run an ln command that should logically result in a broken symlink, thanks to kernel driver sysfs abuse.

permalink
report
reply
4 points

Normally, you’d be right, but this special filesystem doesn’t care about that. I’ve done similar with different gadgets so many times, always with relativr symlinks, sometimes directly from the root of the special filesystem, sometimes from the gadgets own subdirectory, and it just works.

permalink
report
parent
reply
1 point

Do you mean you intend to create a broken symlink?

permalink
report
parent
reply
4 points

No, this is ConfigFS, the linux kernel’s special filesystem for configuring kernel stuff, and for some reason that I don’t really know, it doesn’t matter if the symlink is relative or not. The kernel documentation even creates a relative symlink from the same directory as OP did here.

permalink
report
parent
reply
1 point

You can check this project : https://github.com/showmewebcam/showmewebcam

It’s uses buildroot and it’s easy to change the sources for your need (I’ve added the wifi support)

permalink
report
parent
reply
2 points
*

Hey, you need to also modprobe usb_f_uvc at the beggining, right after modprobe libcomposite

permalink
report
reply
1 point

no change

ln: failed to create symbolic link 'configs/c.1/uvc.usb0': No such file or directory
./fauxcam-gadget.sh: line 19: echo: write error: Device or resource busy
permalink
report
parent
reply
1 point

Hmm, not sure then. It seems correct to me. Check out this repo, it has systemd services for all the USB gadgets, you can run uvc very easily with this: https://github.com/BigfootACA/systemd-gadget

I can write specific instructions how to get this working later today, if you’ll need them.

permalink
report
parent
reply
1 point

Looking at those units I noticed something… ExecStart=/usr/bin/ln -s ${GADGET}/functions/uvc.0 ${GADGET}/configs/a.1/

It’s an a.1 instead of a c.1. Surely it couldn’t be as simple as just using a different letter, could it?

permalink
report
parent
reply
1 point

Aren’t sysfs entries supposed to be created by kernel modules?

permalink
report
reply

Linux

!linux@lemmy.ml

Create post

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word “Linux” in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

  • Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
  • No misinformation
  • No NSFW content
  • No hate speech, bigotry, etc

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

Community stats

  • 7.3K

    Monthly active users

  • 5K

    Posts

  • 77K

    Comments