Mar 26, 2013

Wake from USB

Trying to suspend and wake up your system again can be a little painfull with newest kernel under Linux. Thats mainly because ACPI directory under /proc is deprecated and changes made to /sys are cleared with a reboot. With this in mind, we're gonna see how can we set up an USB device to wake the PC from suspend and how to make that change so it won't be cleared on reboot or shutdown.

If you're using kernel 3+ its better if you compile the deprecated /proc/acpi into the kernel, to make things easier:

Power management and ACPI options  --->
  [*] Power Management support
    [*] ACPI (Advanced Configuration and Power Interface) Support  --->
      [*] Deprecated /proc/acpi files

Enabling a device to wake up the system
To enable a device to wake up the system, you need to set the device in both /proc/acpi/wakeup and /sys/bus/usb/devices/[usb_num]/power/wakeup. You can get the usb_num of your device by either testing one by one or by lsusb. Take note that if you swap your device or connect it to another USB port on your computer, you need to change here the number as well.

ZOTAC ~ # cat /proc/acpi/wakeup

Device  S-state   Status   Sysfs node
P0P8      S3    *disabled  pci:0000:00:1e.0
USB0      S3    *enabled   pci:0000:00:1d.0
USB1      S3    *enabled   pci:0000:00:1d.1
USB3      S3    *enabled   pci:0000:00:1d.3
echo enabled > /sys/bus/usb/devices/usb3/power/wakeup

Making the setting persistent
To make the settings persistent you can do two things: Use a local.d script or create a initscript. Since the script will be just one line, I've decided to go with the local.d option. The idea is to just set the enable flag in the device so it will be always enabled


echo enabled > /sys/bus/usb/devices/usb3/power/wakeup

No comments:

Post a Comment