Waking up USB ports on Ubuntu Hardy

Here is another one of my ‘reminder-to-self’ fixes for my Ubuntu 8.04 machines.

I’ve installed Hardy on a good few machines now including Intel C2D/Nvidia chipset desktops and various laptops and discovered that, to my delight, the machines will go in and out of S3 suspend (suspend to ram) in just a few seconds.

There was just one problem which seemed universal though; the USB ports were not reinitializing correctly. It seemed that although the +5v power was coming back, they weren’t being polled for devices or data.

I stumbled across a partial solution by typing lsusb (in an attempt to poll connected devices). Sure enough, the USB data communication came back to life and I was able to use my devices as normal. Obviously, all I needed now was a way to make this happen automatically when the machine comes back out of S3.

User aidave on this post at ubuntuforums came up with a quick bit of hackery to make this happen which I have adapted here:

Fire up a terminal and issue:

cd /usr/lib/pm-utils/sleep.d
sudo touch 98usb
sudo chmod +x 98usb
sudo nano 98usb

You should now have a blank file open in nano (in the console)

Cut and paste the following into nano:

#!/bin/sh

case “$1” in
resume|thaw)
lsusb
;;
*)
;;
esac

It doesn’t fix the issue directly but it qulifies as a work around in that it wakes up the usb ports by polling the with the lsusb command as the machine resumes from ACPI S3 suspend.

Hopefully there will be a proper fix for the issue in a future Ubuntu Hardy patch.