No internet connection
  1. Home
  2. Technical Support

usb-gadget keeps exiting

By @pika
    2023-01-17 16:57:08.294Z

    I have a TinyPilot Voyager 2 and it seemed to be working fine for a while. One day, it apparently stopped sending USB input. I tried running:

    echo -ne "\0\0\0\0\0\0\0\0" > /dev/hidg0

    and got an error saying: echo: write error: Cannot send after transport endpoint shutdown
    So I checked the status of the usb-gadget service sudo service usb-gadget status and noticed the following output:

    pilot@tinypilot:~ $ sudo service usb-gadget status
    ā— usb-gadget.service - Initialize USB gadgets
       Loaded: loaded (/lib/systemd/system/usb-gadget.service; enabled; vendor preset: enabled)
       Active: active (exited) since Tue 2023-01-17 16:53:26 GMT; 2s ago
      Process: 2585 ExecStart=/opt/tinypilot-privileged/init-usb-gadget (code=exited, status=0/SUCCESS)
     Main PID: 2585 (code=exited, status=0/SUCCESS)
    Jan 17 16:53:26 tinypilot init-usb-gadget[2585]: + CONFIGS_STRINGS_DIR=configs/c.1/strings/0x409
    Jan 17 16:53:26 tinypilot init-usb-gadget[2585]: + mkdir -p configs/c.1/strings/0x409
    Jan 17 16:53:26 tinypilot init-usb-gadget[2585]: + echo 'Config 1: ECM network'
    Jan 17 16:53:26 tinypilot init-usb-gadget[2585]: + ln -s functions/hid.keyboard configs/c.1/
    Jan 17 16:53:26 tinypilot init-usb-gadget[2585]: + ln -s functions/hid.mouse configs/c.1/
    Jan 17 16:53:26 tinypilot init-usb-gadget[2585]: + usb_gadget_activate
    Jan 17 16:53:26 tinypilot init-usb-gadget[2585]: + ls /sys/class/udc
    Jan 17 16:53:26 tinypilot init-usb-gadget[2585]: + chmod 777 /dev/hidg0
    Jan 17 16:53:26 tinypilot init-usb-gadget[2585]: + chmod 777 /dev/hidg1
    Jan 17 16:53:26 tinypilot systemd[1]: Started Initialize USB gadgets.

    I'm not sure what is causing it to exit. The log seems to just cut off at "Started initialize USB gadgets". I've tried restarting the service but it still seems to have the same exact issue.

    • 8 replies
    1. C

      Hi @pika - thank you for reaching out, I'm sorry to hear your TinyPilot keyboard is having issues.

      The service status text that you've pasted is normal and shows that the usb-gadget has been initialised correctly, so it's likely that the issue is elsewhere. Can you please try connecting your TinyPilot device to a different computer and checking if the same issue happens? Could you please also send a link to your debug logs, which you can obtain by going to System, then Logs and then clicking on Get Sharable URL?

      1. P@pika
          2023-01-18 20:56:24.258Z

          Hi @cghague. Got it. I tried connecting it to other machines and it seems to work. It also seems to work on the original machine (Macbook Pro with M1 Max) after it wakes up. The issue only seems to only occur when the machine is sleeping. Using other external keyboards and the built-in keyboard seems to successfully wake it up, however. And in the past, the tinypilot device was able to wake it up as well.

          1. Thanks for getting back to me!

            We've seen issues in the past where Mac devices don't accept certain types of USB input at boot. A number of improvements were made in TinyPilot 2.3.1 which should help with this. Can you please check which version of TinyPilot you are running and upgrade if necessary?

            1. P@pika
                2023-01-19 23:35:12.576Z

                No problem--Thanks for looking into it! I am on TinyPilot version 2.4.1. And I think it's not just at boot. After it's booted and has been accepting input, if the machine goes to sleep, it will stop accepting input from tinypilot.

                1. Thanks for confirming. 2.4.1 is a fairly old version now, so I'd recommend updating to the latest version of TinyPilot when it's convenient to ensure you've got all the latest improvements and bugfixes.

                  I believe the Macbook Pro with M1 Max only has USB-C ports. Can you please advise how your TinyPilot device is connected? For example, are you using a USB-A port on a hub or dock, a USB-C to USB-A adapter or a direct USB-C to USB-C cable?

                  1. P@pika
                      2023-01-20 18:22:58.042Z

                      Okay, I will try and update and get back to you if there's any improvement. I am connecting to it using a usb hub that has USB-A ports.

                      1. In reply tocghagueā¬†:
                          2023-01-22 07:43:33.267Z

                          So I upgraded to the latest version. It looks like it still isn't able to wake the computer up from sleep. However, the error message changed. Now its says:

                          -bash: echo: write error: Resource temporarily unavailable
                          1. Thanks for the update, I'm sorry to hear that upgrading didn't solve the issue.

                            It's possible that the Macbook is shutting off the USB ports as a power saving measure. I can see that the USB hub has an Ethernet port with status lights - are you able to confirm if they (or any other lights on the hub) remain lit when the laptop is in sleep mode?

                            Could you please send me a link to your full debug logs? You can obtain this by going to System, then Logs and then clicking on Get Sharable URL.