At the moment, the Librem 5 uses the g_multi (Multifunction Composite Gadget module). The g_* modules are legacy, hardcoded configurations in the kernel. They have fixed USB vendor/device IDs, device strings and more which means the device will show up as Multifunction Composite Gadget instead of Librem 5.
The USB Gadget configfs allows configuring an arbitrary number of USB gadgets through the file system. We use this for all other mainline devices, and should use the same for the Librem 5 (IMO).
Actually it should work out of the box once the necessary kernel options are enabled.
Edited
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items 0
Show closed items
No child items are currently assigned. Use child items to break down this issue into smaller parts.
Linked items 0
Link issues together to show that they're related.
Learn more.
which seem to be both enabled in linux-purism-librem5 (as modules) already. At some point I added something to support having them as modules: !673 (merged)
Everything should work out of the box actually. Weird.
I can get the usb net iface if I write the usb device controller to /sys/kernel/config/usb_gadget/g1/UDC (verified vendor, etc strings are correct on the host), and it seems like all symlinks, etc are being created from init_functions.sh:setup_usb_network_configfs so it seems like the last step (writing to UDC) is not working perhaps because the usb controller is not up yet when setup_usb_network_configfs runs in initramfs? /sys/kernel/config/usb_gadget/g1/UDC is an empty file on boot, which seems to align with this theory.
Oh I know, I'll build these into the kernel and not have them be lkms that might not load fast enough! Yeah, that didn't work. I see this spammed in dmesg over and over as the usb controller driver tries/retries probing. Eventually it finishes, but this seems to be well past initramfs (which is why usb net doesn't get enabled properly).
[ +0.000012] platform 38100000.usb: Retrying from deferred list[ +0.000288] bus: 'platform': driver_probe_device: matched device 38100000.usb with driver dwc3[ +0.000013] bus: 'platform': really_probe: probing driver dwc3 with device 38100000.usb[ +0.000020] dwc3 38100000.usb: no pinctrl handle[ +0.000174] dwc3 38100000.usb: adding to PM domain usb-otg1[ +0.000009] dwc3 38100000.usb: genpd_add_device()[ +0.000294] dwc3 38100000.usb: Configuration mismatch. dr_mode forced to gadget[ +0.007401] dwc3 38100000.usb: removing from PM domain usb-otg1[ +0.000010] dwc3 38100000.usb: genpd_remove_device()[ +0.000045] platform 38100000.usb: Driver dwc3 requests probe deferral[ +0.000010] platform 38100000.usb: Added to deferred list[ +0.000142] devices_kset: Moving 38200000.usb to end of list[ +0.000009] PM: Moving platform:38200000.usb to end of list[ +0.000012] platform 38200000.usb: Retrying from deferred list[ +0.000310] bus: 'platform': driver_probe_device: matched device 38200000.usb with driver dwc3[ +0.000013] bus: 'platform': really_probe: probing driver dwc3 with device 38200000.usb[ +0.000019] dwc3 38200000.usb: no pinctrl handle[ +0.000173] dwc3 38200000.usb: adding to PM domain usb-otg2[ +0.000010] dwc3 38200000.usb: genpd_add_device()[ +0.000240] dwc3 38200000.usb: Configuration mismatch. dr_mode forced to gadget[ +0.007389] dwc3 38200000.usb: removing from PM domain usb-otg2[ +0.000009] dwc3 38200000.usb: genpd_remove_device()[ +0.000061] platform 38200000.usb: Driver dwc3 requests probe deferral[ +0.000010] platform 38200000.usb: Added to deferred list
TBH I think I've taken this as far as I care to go for now with the librem 5 kernel in its current state (i.e. lots of out of tree patches for usb/otg, and at least one open issue @ purism regarding usb instabilities). The legacy gadget config (g_multi, etc) gets us a usable usb serial connection to the device (@bshah used it to debug plasma mobile today..), and that seems more useful than breaking this support to conform to "every device uses configfs, so you should too" where currently nothing works on this device.
I see this spammed in dmesg over and over as the usb controller driver tries/retries probing. Eventually it finishes, but this seems to be well past initramfs (which is why usb net doesn't get enabled properly).
That sounds like some dependency of dwc3 is built as module. I think it's quite likely that you just need to make some more modules built-in (or alternatively, if you would prefer to use Purism's config mostly as-is, add them to deviceinfo_modules_initfs).
Hard for me to guess which one that would be, but it should be possible to guess it based on dmesg+lsmod.
The legacy gadget config (g_multi, etc) gets us a usable usb serial connection to the device (bshah used it to debug plasma mobile today..), and that seems more useful than breaking this support to conform to "every device uses configfs, so you should too" where currently nothing works on this device
I don't mind temporary workarounds. We can just keep this issue open and tackle it later. But eventually it should be made consistent IMO.