Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TinyPilot's USB not recognized on macOS #1848

Open
db39 opened this issue Oct 2, 2024 · 9 comments
Open

TinyPilot's USB not recognized on macOS #1848

db39 opened this issue Oct 2, 2024 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@db39
Copy link
Contributor

db39 commented Oct 2, 2024

Description

Disconnecting and then reconnecting TinyPilot to a macOS-based machine via its USB cable causes TinyPilot to stop being recognized as a USB device. To restore functionality, you must reboot your TinyPilot. Alternatively, you can run sudo /opt/tinypilot-privileged/remove-usb-gadget and then sudo /opt/tinypilot-privileged/init-usb-gadget.

This behavior may only be present on Apple Silicon-based Macs. I could not reproduce this behavior on an Intel-based Mac running OS X 10.14 (very old).

This behavior was originally reported on a 2021 MacBook Pro M1 Pro running 14.6.1. I reproduced this behavior on a MacBook Air M2 running 14.4.1.

This behavior doesn't change when adjusting the Mac's USB accessory behavior. i.e., changing "Allow accessories to connect" to "Always", "Ask Every Time", "Ask for New Accessories", or "Automatically When Unlocked" doesn't affect the behavior.

There's a discussion thread on Apple's support forums related to USB hubs not working on macOS 14.4. So it may instead be an OS issue.

There are also similar Reddit threads reporting that some USB hubs no longer work correctly. Some users suggest that version 14.4.1 resolves these USB issues, but my machine on 14.4.1, and the TinyPilot forum user's machine on 14.6.1, both have this issue.

I haven't yet tried updating to Sequoia (15.0) - the user on the TinyPilot forum suggests the latest version of macOS also has this behavior.

What's the behavior that you expect?

I'd expect TinyPilot to successfully connect to the Mac's USB and correctly send mouse and keyboard input whenever you connect the USB cable.

What's happening instead?

When reconnecting TinyPilot's USB cable, the Mac no longer recognizes it as a USB device, causing a state where you cannot use TinyPilot's mouse or keyboard without rebooting TinyPilot.

What are the steps to reproduce this behavior?

  1. Connect your TinyPilot to a Mac (possibly only Apple Silicon-based or running macOS >= 14.4)
  2. Move TinyPilot's mouse or use the keyboard to show it's working
  3. Disconnect the USB cable from the Mac
  4. Reconnect the USB cable to the Mac
  5. Attempt to move TinyPilot's mouse or type characters on TinyPilot's keyboard
    a. Nothing happens

Screenshots

The Mac's USB System Information after connecting TinyPilot initially:

system-information1

The Mac's USB System Information after disconnecting and reconnecting TinyPilot's USB cable (this is identical to not having a connected USB device):

system-information2

@jotaen4tinypilot & @jdeanwallace - Do you have any suggestions for additional tests I can perform here?

@db39 db39 added the bug Something isn't working label Oct 2, 2024
@jotaen4tinypilot
Copy link
Contributor

This is pretty weird: I am able to reproduce this issue – however, only with a USB-C<>USB-C cable. If I’m using a USB-C<>USB-A cable along with a USB-A<>USB-C adaptor, then replugging the cable works just fine. I.e.:

  • TinyPilot deviceUSB-C<>USB-C cableTarget Machine (M2 / macOS 14.6.1)
    • I can reproduce the issue, so the USB connection doesn’t recover after replugging the data cable.
    • Screenshot 2024-10-02 at 15 15 23
  • TinyPilot deviceUSB-C<>USB-A cableUSB-A<>USB-C adaptorTarget Machine (M2 / macOS 14.6.1)
    • I cannot reproduce the issue, so the USB connection recovers immediately after replugging the data cable, as expected.
    • Screenshot 2024-10-02 at 15 16 43

I have no immediate idea what might be going on here, but my hunch would be that it could potentially be some low-levelled hardware/interface issue related to the involved USB versions/standards?

To assess the severity of this issue, it might also be worth to check whether this is an issue specific to Apple/macOS, or whether this also happens on other target machine kinds (i.e., operating systems and hardware vendors). Unfortunately, though, I don’t have any other non-macOS target machines at hand with USB-C ports to verify this.

@db39
Copy link
Contributor Author

db39 commented Oct 2, 2024

@jotaen4tinypilot - thanks for those tests!

I tried to reproduce your USB-C/USB-A behavior, and I can get it work, but only with specific steps.

If I disconnect and reconnect the USB cable on the TinyPilot side (Data port), the mac recognizes TinyPilot again.

If I disconnect and reconnect the USB cable while leaving the USB-A -> USB-C adapter connected to the mac, the mac recognizes TinyPilot again. Maybe this is because the USB-C connection never gets completely severed?

If I disconnect and reconnect the USB-A -> USB-C adapter (still connected to the USB-A side of the cable) from the mac, the mac doesn't recognize TinyPilot when reconnecting.

Using USB-C/USB-C directly doesn't work regardless of which side I disconnect/reconnect.

The only machine I have with working USB-C ports is my Mac, so I can't test USB-C/USB-C on a different machine, unfortunately. I may be able to try and get a USB-C port working on my testbench PC, but I may have to open up the machine and diagnose the issue, so it might not be worth it time-wise if someone else has access to one.

It sounds like a USB-A -> USB-C adapter is a usable workaround for now.

I think my next tests would be to either test USB-C -> USB-C on a non-mac machine, or try and find the underlying issue by looking at the Mac's logs when connecting / disconnecting (something like log stream but filtering USB?).

@jotaen4tinypilot
Copy link
Contributor

I think it would be good if we’d manage to verify whether or not the pure USB-C<>USB-C connection is also an issue on non-macOS machines. My worry would be that the issue only surfaced in the context of macOS so far, just because USB-C ports happen to be more common on Apple devices. If it would turn out to be an issue strictly related to the cable and not strictly related to macOS, then this might change the priority of this issue for us. @jdeanwallace / @shalver-tp would you be able to help out here? (I.e., testing the reconnection behaviour on a non-Apple/non-macOS target device that provides a native USB-C port?)

Regardless of that, I think investigating the internal system logs sounds like a good idea, maybe that provides helpful clues.

In case we don’t manage to fix the issue, another workaround that we could consider providing would be some sort of shortcut/functionality for users to re-initialize the USB gadget via the web UI.

@scott-tp
Copy link

scott-tp commented Oct 2, 2024

@jotaen4tinypilot

I just tested this setup:

TinyPilot Voyager 2a running 2.6.4

Plugged via USB-C <-> USB-C into an ASUS Laptop running Windows 10

I disconnected the USB-C from the ASUS multiple times, I always got control back immediately and heard the "ding" of a new USB device being connected.

@scott-tp
Copy link

scott-tp commented Oct 2, 2024

@jotaen4tinypilot @db39 I also just ran this test:

TinyPilot Voyager 2a running 2.6.4

Plugged via USB-C <-> USB-C into an M3 Macbook Air running MacOS 14.5

I disconnected the USB-C from the Macbook multiple times and I always got control back immediately when reconnecting. I also tried disconnecting from the TinyPilot side, the behavior was the same - I got control back immediately.

When I first plugged it in, I was prompted to give control/access to this USB accessory.

@db39
Copy link
Contributor Author

db39 commented Oct 2, 2024

Thanks for testing all that, @shalver-tp!

This is pretty odd behavior. It seems like it's specific to certain Macs or OS versions. It doesn't seem like this issue is widespread since we've only had one report from TinyPilot users.

I wonder if different USB-C cables would make a difference?

I'll take a deeper look at how my Mac behaves when connecting / disconnecting TinyPilot and see if there's any information I can find that would point to an underlying issue an if there's anything we can do on the TinyPilot side to fix this.

@scott-tp
Copy link

scott-tp commented Oct 2, 2024

As a note, the USB-C cable I was using came with an SSD hard drive.

@db39 db39 self-assigned this Oct 21, 2024
@jdeanwallace
Copy link
Contributor

Sorry for my radio silence on this issue. I don't have an Apple Silicon-based Mac (only the old Intel-based Mac) and I don't have any target machines with a native USB-C port (only USB-A ports).

@cghague
Copy link
Contributor

cghague commented Oct 22, 2024

I'm not in a position to test this, but I've got a lot of experience with macOS and Mac hardware. I suspect this isn't a USB-C versus USB-A issue, but rather that there's something amiss between using a USB 3.0 Type C port, a Thunderbolt Type C port, and either of those ports running in USB 2.0 mode. That might explain why only some Macs are affected and why using hubs and adapter cables might avoid the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants