AC Power Control by USB Hub

AC Power Control by USB Hub

1. Purpose

Rebooting remote system, AC Power Control is only reliable way.

  • Kernel sometime hangs, no way to reboot by command line.
  • Hardware RESET feature would be unreliable, especially for evaluation boards in testing phase. While CPU core will get reset signal, some other peripheral chips will not be get reset.

2. Constraints/Requirements

Any hacker around embedded system has his/her own solution for AC Power Control, so, there are bunch of home-brewed solutions out there. Besides, there are some expensive products.

Those solutions and products don't match general use. For general use, here are constraints/requirements:

  • Cheap, Common, and Convenient
  • Thus, by Off-the-shelf hardware
  • No Soldering Iron (or Black Magic), Please

3. The Definite Solution

It is TANAKA Akira who invented this solution, that is:

USB-coupled AC Power Tap
         +
USB port power control
         =
AC Power Control through USB

NIIBE Yutaka implemented it on GNU/Linux, as hub-ctrl.c.

It's cheap:

USD$35 (Power Tap) + USD$25 (USB Hub) = USD$60.

It's common (available at any large computer shops in Japan), and convenient (just plug in USB hub into your computer and connect AC Power Tap). No Soldering Iron or any magic is required.

4. USB-coupled AC Power Tap

In Japan, people cares power consumption, and there are two kinds of products which have automatic power-OFF feature.

  • AC Power Tap with AC Power Consumption Detection:

    It checks power consumption of PC by AC power line. When it detects no consumption of a main socket, it disables power of other sockets.

  • USB-coupled AC Power Tap:

    It checks voltage of USB port. When it detects no valtage of USB port, it disables power sockets.

The latter, USB-coupled AC Power Tap, is the product for our purpose.

List of USB-coupled AC Power Tap:

5. USB Port Power Control

This feature is defined in USB 2.0 Specification. USB Hub has feature to control port power. If it supports this feature, it's 'Hub Descriptor' should have relevant value at wHubCharacteristic field.

Using lsusb utilities with -v option, you can inspect 'Hub Descriptor', such like:

Hub Descriptor:
[...]
  wHubCharacteristic 0x0089
    Per-port power switching
    Per-port overcurrent protection
    Port indicators
[...]

CAUTION: Although many chips implemented this feature, many products omit the circuit of power control, unfortunately.

List of USB keyboard with Hub known to support USB Port Power Control:

  • Elecom: TK-UF2BH, USB ten key pad with 2-port USB 1.1 Hub
  • Happy Hacking Keyboard

List of USB Hubs known to support USB Port Power Control:

  • D-Link-DUB-H7-High-Speed-7-Port (Old version: Silver)
  • Elecom: U2H-G4S
  • Sanwa Supply: USB-HUB14GPH
  • Targus, Inc.: PAUH212
  • Hawking Technology: UH214

List of USB Hub reference designs:

List of USB Hubs known to NOT support USB Port Power Control:

  • D-Link-DUB-H7-High-Speed-7-Port (New version: Black)
  • Intel 82801 (Root Hub)
  • Dick Smith Electronics XH6777 Chip supports individual port switching, but circuit is omitted.
  • Dick Smith Electronics 4-Port USB 1.1 HUB XH7931 Chip supports gang port switching, but circuit is omitted.
  • Manhattan USB 2.0 Hub Chip supports gang port switching, but circuit is omitted.
  • Rosewill RHUB-300
  • Macally TRIHUB7 Mini Adapter
  • CyberPower High Speed 7 Port USB Hub

6. Implementation

My implementation in C is available at: oitoite

Besides, I implemented it in Python. It is available in Gnuk distribution, as I always use it for the developemnt of Gnuk Token.

See: https://gitorious.org/gnuk/gnuk/source/tool/hub_ctrl.py

7. Retrospect

The idea of USB-coupled AC power tap seemed old (more than 15 years). Here are the products information (which are not available any more).