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
  • dafta@lemmy.blahaj.zone
    link
    fedilink
    English
    arrow-up
    3
    ·
    2 days ago

    I’ve got some experience with Linux USB gadgets, and can confirm that the docs definitely aren’t wrong, as I’ve used them myself to write gadgets using the same symlink commands that the docs mention and that OP used here.

    I’ve got a working USB ethernet gadget and MTP gadget for the Steam Deck that make the same link that should be broken, and here’s a repo that implements every USB gadget with almost every gadget making the same symlink, one directory up from where OP does it. I’ve tested all the gadgets from that repo and they all work, and because they work, I’ve forked the repo here for future use in the above mentioned Steam Deck plugin.

    I can pretty confidently say that it’s not a broken symlink. I’m not 100% sure why this doesn’t work for OP, but I think it’s most likely an issue with not loading the correct driver for the UVC function.

    • gnuhaut@lemmy.ml
      link
      fedilink
      arrow-up
      1
      ·
      2 days ago

      OK I’m convinced, that’s apparently how that works. I wonder why it’s designed that way.

      • dafta@lemmy.blahaj.zone
        link
        fedilink
        English
        arrow-up
        2
        ·
        2 days ago

        Yeah, it’s a bit weird that it works like that. I’ll be honest, in the last three or four years that I’ve been tinkering with USB gadgets, I’ve never noticed that those symlinks you create should be broken until you mentioned it. I just kinda took it for granted that it works (probably because I never had issues with this part of the process).