0

Is there a terminal command that resets the USB port without having to unplug and plug the device? Sometimes my USB hub (HDMI, Ethernet, USB3) malfunctions, and the only fix is to unplug/plug or reboot the computer.

In my case, my external monitor connected by HDMI will sometimes fail to be detected when waking from sleep. What happens is that my MacBook Air M1 still thinks the external is connected, but the monitor is black. The built-in display still behaves as the extended monitor. I have tried to detect displays in the Display options or scaling to try and force the system to redetect the monitor. The fix is always to restart or unplug the USB hub.

There is an app called "uhubctl", but that did not work on the port for HDMI. I had similar issues when I used Linux with USB hubs. Sometimes Ethernet would not be detected on boot, but there was a terminal command that reset the port which I wrote into a script and hot keyed. Therefore I am trying to do the same with my Mac.

2 Answers 2

1

No, there's no such Terminal Command on macOS.

uhubctl is used to command an external USB hub to power off/on one or more of its USB ports. It cannot be used to power off/on an HDMI port, nor to power on/off the hub itself.

If you could remember the Terminal command you had used in the past, it would perhaps be possible to find a macOS equivalent for that - but if you have no idea what it could be then it is ofcourse difficult. The manufacturer of your dock might have added all sorts of proprietary features to it, but without knowing which dock you have, or the details of the Linux command, it is not possible to give you more guidance here.

UPDATE:

In the comments you indicate that you have used this command on Linux for this purpose:

echo -n "0000:00:00" | tee /sys/bus/pci/drivers/ehci_hcd/unbind

This does not turn off a USB port however, it actually resets (turns off) the whole USB2 controller - i.e. this kills all the USB2 ports.

You can probably do something similar on macOS although I don't know how practical it would be. According to the description you have given in your question, you're not using USB2 ports there, but instead have USB3 ports. So it's no longer the EHCI controller, but rather the XHCI controller, that you potentially want to reset.

You might be able to do that using commands such as:

kmutil unload -b com.apple.driver.AppleUSBXHCI
kmutil load -b com.apple.driver.AppleUSBXHCI

Depending on what kind of hardware you have and what you have plugged in, there might be other kernel extensions that you want to unload in advance. For example it might be com.apple.driver.usb.AppleUSBXHCIPCI. Take a look at the output from running kextstat to see what you have running before doing anything.

6
  • Thanks for the response. On linux, I used this command echo -n "0000:00:00" | tee /sys/bus/pci/drivers/ehci_hcd/unbind
    – fr_awd
    Mar 27 at 21:04
  • That command does not reset a single port - it resets the whole USB2 controller - so quite a bit different.
    – jksoegaard
    Mar 27 at 21:45
  • I have updated the answer with something similar for macOS.
    – jksoegaard
    Mar 27 at 21:54
  • Sorry my comment got cut off. With that command, I would edit the hardware identifier "0000:00:00" for the specific port. The identifier rarely changed for my setup. If it changed, I would look up the new identifier and edit my script. I am trying to find a similar command on macOS, but it's probably not easy to implement.
    – fr_awd
    Mar 27 at 22:22
  • That's not how Linux works - I know you have to use the ID specific to your hardware configuration, but it is still an ID for a controller - not a specific port. I have given you the similar commands on macOS in my answer - have you tried them?
    – jksoegaard
    Mar 28 at 0:06
0

I can confirm that the UHUBCTL solution works for Dell D6000 usb issues. Macbook air M1

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .