What is the usb_gadget service?

Howdy,
I’ve been looking at the service list on my librem 5 trying to harden or disable anything not needed, and found the usb_gadget service is in failed state. What is this service? Should I care that it’s failed?

I’ve read online that there’s a kernel gadget api, is this it? Does anything on a stock install need this to function correctly? Looking at the script it’s calling it looks like it’s doing some librem 5 specific stuff.

● usb_gadget.service - Librem 5 USB gadget mode
Loaded: loaded (/lib/systemd/system/usb_gadget.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2023-03-15 07:53:02 MDT; 25min ago
Process: 1012 ExecStart=/usr/share/librem5/usb_gadget_start (code=exited, status=1/FAILURE)
Main PID: 1012 (code=exited, status=1/FAILURE)
CPU: 31ms

Mar 15 07:53:02 pureos systemd[1]: Starting Librem 5 USB gadget mode…
Mar 15 07:53:02 pureos usb_gadget_start[1012]: /usr/share/librem5/usb_gadget_start: 35: echo: echo: I/O error
Mar 15 07:53:02 pureos systemd[1]: usb_gadget.service: Main process exited, code=exited, status=1/FAILURE
Mar 15 07:53:02 pureos systemd[1]: usb_gadget.service: Failed with result ‘exit-code’.
Mar 15 07:53:02 pureos systemd[1]: Failed to start Librem 5 USB gadget mode.

This service makes the L5 available over USB: the serial console and the network device. It’s not required for basic functioning, but if you need it, it’s rather useful.

Would you mind checking if restarting the phone brings the service back to the living?

1 Like

Nope, still fails the same way after rebooting the phone

Could you post the output of sudo dmesg ?

Doesn’t look like I can post up a txt or log file, only allows images. I’ll make a ticket on the purism git

Do you have anything plugged into USB-C port?

The service had a bug that made it fail and never come back when USB-C was in host mode at boot. This has been fixed about a week ago, but the update hasn’t made it into the repositories yet.

1 Like

Yeah,
I had it on a usb hub. Rebooted without it plugged in and the service started fine. Thanks!