23
creating a USB gadget
(lemm.ee)
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.
Community icon by Alpár-Etele Méder, licensed under CC BY 3.0
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.
Edit: OK, I looked at the docs, and they sure do make a broken symlink there. I still think it's worth a try to create a non-broken link, maybe the docs are wrong. I would expect they would put a little note there, that yes, you really do want to create a broken symlink (if so, why not a regular file?), but then again its kernel docs and those aren't the most friendly.
I also thought you were OP for some reason, sorry.
Edit2: If you look at the file listing later in the docs, you can see this:
Which does look like a real non-broken symlink, so I maintain the docs are wrong and you're not supposed to make a broken symlink.
Original comment, silightly edited:
You misunderstand. I suspect OP cannot create the symlink, because it would be a broken symlink, not because the symlink is relative. Maybe you cannot create broken symlinks in the sysfs for some reason.
I was just trying to explain that a relative symlink is relative to the directory in which it resides. The target to the symlink should point to
../../functions/uvc.usb0
if you want it to point to something that exists. The ln command in OP's listing would result in a broken symlink, since the specified path is not relative to the c.1 directory. It is relative to the working directory, but that's wrong, that's not what ln expects you to put there.Maybe it needs to be a correct symlink, maybe that will solve the problem.
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.
OK I'm convinced, that's apparently how that works. I wonder why it's designed that way.
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).