How to Turn On or Off USB Remotely via Software (No Unplugging)

2021 January 21

Connecting and Disconnecting USB Device Power

The problem USB devices often need to be disconnected and reconnected (plug-cycled) or reset. The reasons for plug-cycling a USB device are as varied as types of USB devices themselves. In service, the simplest solution to many USB-related problems is to reset the errant host machine or USB device.

USB devices can experience memory leaks, firmware instability, or other operating failures for which the only solution is power cycling. Since few USB devices have power switches, the only method to power cycle the device is by unplugging and reconnecting it. Even still, accessing these devices in the field or IT closet can be time-consuming and tedious.

In the lab or in a production environment, devices also need to be disconnected, often frequently:

  • For testing purposes
  • To stress USB device firmware and/or host operating system (OS) USB drivers
  • To replicate obscure USB device problems which manifest only at power-on or plug-in
  • Overcurrent or other failures (disconnect, probably not reconnected)
  • Errant devices or unstable device firmware can cause a USB system to fail, creating issues for the upstream hub, host or other connected devices

The ideal solution is a method to disconnect and re-connect a USB device such that it powers off or on - while leaving the USB device physically connected to the host system - and do so using simple software commands.

Why Disconnecting USBs are Hard

If you are physically present next to the USB connectors, and only need to plug-cycle one connector one time, managing connection status is trivial. In fact, most port plug/unplug activities are performed manually by an individual with ease.

Difficulty arises when:

  • A test or problem requires hundreds or thousands of cycles to duplicate
  • Devices or ports are far away, perhaps even on another continent
  • Several devices need to be reconnected
  • The amount of connections required would physically wear out connectors on either device or hub

Historically, individuals are tasked with the simple unplug/plug cycle or even sometimes hired specifically to conduct highly repetitive plug-cycling tasks or tests.

We recently worked with an engineer working to find a firmware problem that could only be replicated when the device under test was plug-cycled over 300 times. He spent two nights in a hotel room near a factory just plugging and unplugging a USB cable.

Host operating systems (OSes) also can experience issues during the USB reset process, especially when using traditional consumer-grade USB hubs. Specifically, when the system or hub is powered up, multiple ports enumerating to the host OS simultaneously can overload some host OS USB drivers, creating connection failures or even driver crashes.

Most modern OSes allow a USB device to be disabled from the operating system and then re-enabled. Commands for these actions are not easy to implement for those uninitiated with lower level OS operations. In addition, these commands merely stop the host OS from communicating with the USB device, then restart USB communications. They do not truly plug-cycle or power-cycle the USB device, so device-related firmware instabilities that require a power-cycle cannot be remedied with this method.

Some engineers have solved this issue using hobbyist-style USB breakout boards and relays, providing a switch to assert or remove USB VBUS power and/or ground connections of a USB port and the connected device. This approach is inexpensive, but is not robust and may not be practical for USB 2.0 data link speeds of 480Mbps.

It most certainly cannot be used USB 3.1 SuperSpeed devices which have data links of up to 10 Gbps. In addition, such breakout/relay solutions may work to exercise a single port, but are usually not easily controlled with standard software commands and certainly do not scale well for automated testing environments and larger deployments where dozens or hundreds of USB devices may need to be port-cycled.

The Solution? Let the Hardware do the Work

The ideal solution is to leave a USB device or cable connector physically connected, while using specialized hardware to programmatically switch ports on and off.

To achieve just this functionality, test engineers and IT personnel frequently use Acroname programmable USB products, and most often the commercial off-the-shelf (COTS) 8-port USBHub3+, to accomplish programmatic reset or port cycling anywhere: in the same room, in the next room, rack-mounted in an IT closet, or for devices across the world using a Secure Shell (ssh) or some other form of remote desktop connection.

Simply put, Acroname programmable USB hubs provide an elegant and trusted method to turn a USB port on and off - using straight-forward software commands - and without physical remove or insertion actions.

Port cycling is performed by issuing a simple software command to the Acroname hardware, which then electrically disconnects the both USB power (VBUS) and data lines from the port connector in question - without impacting USB data integrity. This effectively creates a plug or unplug operation with no physical/mechanical interaction.

Acroname Programmable Hubs can Help

Port reset or port cycling with our hubs can be accomplished by issuing software commands via these methods:

  • HubTool: a GUI dashboard representation of the BrainStem API, for fastest evaluation of Acroname hardware or simple, quick port-cycling
  • BrainStem API: a license-free, cross-platform API for common development environments, including Python, LabVIEW, C, C++, C# / .NET
  • Reflex: an onboard Real Time Operating System (RTOS) that can autonomously control hub behaviors or Brainstem API calls without a host machine

Unlike consumer-grade or industrial USB hubs, where all ports are enabled at power-on, Acroname hubs are able to save customized default settings for each port. As an example, it may be useful in some environments to have all ports default to disabled, so they can be selectively enabled; or default to ports 2 and 6 being enabled and all other ports disabled. Acroname programmable hubs with software control allow unprecedented levels of flexibility and customization that standard off-the-shelf USB hubs cannot provide.

The powerful combination of elegant, flexible Acroname software and robust, trusted hardware offers several benefits, including:

  • Not requiring travel or physical access to the device
  • Robust set-and-forget hardware
  • Connector life extension
  • Saving time/labor from tedious manual plug/unplug testing
  • High assurance connection and enumeration
  • Control or sequence device enumeration to assist host OS USB driver stability
  • Creating custom hot-plug cycle routines to stress USB device firmware or host OS USB drivers
  • Reducing battery swelling in mobile device or application testing labs

No matter the number of ports or devices you need control of, Acroname hubs are up to the task. Since Acroname hubs are individually serialized, multiple hubs can be present in the same system with individual control of each port on each hub. Just as useful, Acroname’s BrainStem APIs are architected to be simple for single hub implementations or scalable to large installations.

If you have additional questions or a specific challenge you are working through, we are pleased to advise. Please contact the Acroname sales at sales@acroname.com, Acroname’s technical team at support@acroname.com or reach out to us via phone at: +1 720-564-0373.

 

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.