View previous topic :: View next topic |
Author |
Message |
danomac l33t
Joined: 06 Nov 2004 Posts: 881 Location: Vancouver, BC
|
Posted: Mon Aug 20, 2012 3:45 am Post subject: HOWTO: USB keyboard wakeup on newer kernels w/script [v2.0] |
|
|
I recently update to 3.3.8 and discovered I couldn't wake up from sleep using my keyboard any more.
It turns out that the deprecated /proc/acpi in the kernel is no longer connected to /sys/devices/*. In my case /proc/acpi and acpitool showed everything enabled, but in the /sys/devices everything was disabled. So one side was enabled and the other disabled, and as it turned out the side that mattered was not affected when applying changes to the other. Bug? Who knows - it is deprecated after all. So now I've rebuilt my kernel without the deprecated /proc/acpi support and was left with finding a way to re-enable the devices.
I wondered how hard it would be to write a bash script to simply search /sys/devices/* and present this information, with an option for toggling them. I'm not the best script writer, but I cobbled something together that appears to work, at least on two machines I own.
I figured that this script may actually be useful for others bashing their heads against their desk with this, so I figured I'd post it here in case it can help someone.
Standard disclaimer:
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
Use at your own risk, it may blow up your computer!
Heck, this could even work on other distros. I use gentoo primarily, I do have Ubuntu in a test partition on my laptop, but I've not tried it there. Edit: Yep, works on ubuntu.
I don't see a way to attach something, so I'll just paste it here (~434 lines):
This script is way improved now, see the second post.
File: usbwakeup [version 2.0] pastebin link
Code: |
#!/bin/bash
# This script attempts to read /sys/devices/ and identify usb ports and devices
# that can be toggled to enable wakeup from sleep.
#
# Version: 2.0
# Date written: August 20, 2012
#
# Copyright (C) 2012 danomac @ gentoo forums
# Gentoo forum thread: http://forums.gentoo.org/viewtopic-t-933934.html
# The forum thread has instructions and examples on on how to use.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
# Return code documentation
#
# 1: No parameter / unknown parameter specified
# 2: Multiple actions requested, can only process one at a time
# 3: Effective user ID not root (root is required)
#
# 7: No action requested
# 8: Quiet and verbose requested at the same time! Use one or the other.
# 9: Kernel Dmesg` option requested with action other than list
#
# Internal errors:
#
# 10: toggleall() - first parameter missing (internal error)
# 11: toggleusbdevice() - first parameter not specified (internal error)
# 12: toggleusbdevice() - second parameter not specified (internal error)
# 13: toggleusbdevice() - third parameter needed but not specified! (internal error)
function listusbwakeup () {
# If quiet option is set, notify user it's being ignored
if $QUIET; then echo "Quiet option set; ignoring..."; echo ""; fi
# Initialize counter (to total items found later)
COUNT=0
echo "Listing USB hubs/devices and their wakeup status..."
# If verbose output is requested, switch to full detail view
if $VERBOSE
then
echo "
USB ID :: Device* :: Status
Device full path
Vendor :: Device Description
---------------------------------"
else
echo "
USB ID :: Device* :: Status :: Device Description
----------------------------------------------------"
fi
# Search for all wakeup files under /sys/devices
for i in `find /sys/devices -type f -name wakeup`;
do
# Extract the directory name where wakeup file resides
DEVDIRNAME=`dirname $i`
# Extract the actual device name (remove the power directory)
DEVNAME=`dirname $DEVDIRNAME`
# Now remove the directory path, leaving only the device's proper name (usb4, 4-1, etc)
DEVPROPERNAME=`basename $DEVNAME`
# Check for a product name. If none is found we most likely aren't interested in it.
if [ -e $DEVDIRNAME/../product ]
then
# We found one! Find other relevant information, if none found use a placeholder.
if [ -e $DEVDIRNAME/../product ]; then PRODUCT=`cat $DEVDIRNAME/../product`; else PRODUCT="No product name"; fi
if [ -e $DEVDIRNAME/../manufacturer ]; then VENDOR=`cat $DEVDIRNAME/../manufacturer`; else VENDOR="No vendor name"; fi
if [ -e $DEVDIRNAME/../idVendor ]; then IDVENDOR=`cat $DEVDIRNAME/../idVendor`; else IDVENDOR="No VendorID"; fi
if [ -e $DEVDIRNAME/../idProduct ]; then IDPRODUCT=`cat $DEVDIRNAME/../idProduct`; else IDPRODUCT="No Product ID"; fi
# If verbose output is selected, switch to full detail view
if $VERBOSE
then
echo "$IDVENDOR:$IDPRODUCT :: $DEVPROPERNAME :: `cat $i`"
echo " $DEVNAME"
echo " $VENDOR :: $PRODUCT"
echo ""
else
echo "$IDVENDOR:$IDPRODUCT :: $DEVPROPERNAME :: `cat $i` :: $PRODUCT"
fi
# Increment our totals counter
COUNT=`expr $COUNT + 1`
fi
done;
# Need to format the output differently for normal mode by adding an extra blank line
if ! $VERBOSE; then echo ""; fi
echo "*Use the Device column to identify hubs/devices to be toggled."
# If there's no results indiciate so
if [ $COUNT -eq 0 ]
then
echo ""
echo " NO USB hubs/devices found, or none are toggle-able!"
else
# Hey, we have results, show the total found
echo ""
echo "$COUNT USB hubs/devices listed."
fi
# If the dmesg hints were requested, show them
if $KERNELDMESG
then
echo "
Hints from dmesg (use this to try to identify your keyboard and mouse, you
may need to reboot to see anything relevant, see help for more info):
"
dmesg | grep ^input
fi
}
function toggleusbdevice () {
# toggleusbdevice (enabledevice:boolean, enableall:boolean, devname:string)
# First parameter is boolean. True to enable device; False to
# disable device.
# Second parameter is boolean. True to enable all relevant devices found,
# false to enable one device, specified in parameter 3.
# Third parameter is the name of the device from the Device column of list
# output
# Make sure both parameters are passed to this function!
if [ -z "$1" ]; then exit 11; fi
if [ -z "$2" ]; then exit 12; fi
# If specifying a single device to be changed, make sure parameter 3
# exists!
if ! $2
then
if [ -z "$3" ]; then exit 13; fi
fi
# Verbose detail is used throughout this function. Echo extra detail if
# requested
if $VERBOSE; then echo "Starting to parse wakeup devices found..."; fi
# Search for all wakeup files under /sys/devices
for i in `find /sys/devices -type f -name wakeup`;
do
# Extract the directory name where wakeup file resides
DEVDIRNAME=`dirname $i`
# Extract the actual device name (remove the power directory)
DEVNAME=`dirname $DEVDIRNAME`
# Now remove the directory path, leaving only the device's proper name (usb4, 4-1, etc)
DEVPROPERNAME=`basename $DEVNAME`
# Are we updating one specific device or all of them?
if ! $2
then
# Update individual device
if $VERBOSE; then echo "Is this device ($DEVPROPERNAME) the same as the requested device ($3)?"; fi
# Check for a product name. If none is found we most likely aren't interested in it.
if [ "$DEVPROPERNAME" == "$3" ]
then
if $VERBOSE; then echo "YES! Attempting to change."; fi
if $1
then
if $VERBOSE || ! $QUIET; then echo "Attempting to enable device ($DEVPROPERNAME)..."; fi
# Enable device
echo "enabled" > $i
if $VERBOSE || ! $QUIET
then
if [ $? -ne 0 ]; then echo "Failed."; else echo "Success!"; fi
fi
exit 0
else
# Disable device
if $VERBOSE || ! $QUIET; then echo "Attempting to disable device ($DEVPROPERNAME)..."; fi
# Enable device
echo "disabled" > $i
if $VERBOSE || ! $QUIET
then
if [ $? -ne 0 ]; then echo "Failed."; else echo "Success!"; fi
fi
exit 0
fi
else
if $VERBOSE; then echo "...no."; fi
fi
else
# Update all devices
if $VERBOSE; then echo "Does this device ($DEVPROPERNAME) look like a USB hub/device?"; fi
# Check for a product name. If none is found we most likely aren't interested in it.
if [ -e $DEVDIRNAME/../product ]
then
# If verbose output is selected, switch to full detail view
if $VERBOSE; then echo "YES!"; fi
if $1
then
if $VERBOSE || ! $QUIET; then echo "Attempting to enable device ($DEVPROPERNAME)..."; fi
# Enable device
echo "enabled" > $i
if $VERBOSE || ! $QUIET
then
if [ $? -ne 0 ]; then echo "Failed."; else echo "Success!"; fi
fi
else
# Disable device
if $VERBOSE || ! $QUIET; then echo "Attempting to disable device ($DEVPROPERNAME)..."; fi
# Enable device
echo "disabled" > $i
if $VERBOSE || ! $QUIET
then
if [ $? -ne 0 ]; then echo "Failed."; else echo "Success!"; fi
fi
fi
else
if $VERBOSE; then echo "...no."; fi
fi
fi
done;
# If updating only one device and we get this far it wasn't found.
if ! $2; then echo "Device not found."; fi
}
function showhelp () {
# If quiet option is passed notify user it's being ignored
if $QUIET; then echo "Quiet option set; ignoring..."; fi
echo "
$0: a script that lists and toggles wakeup on usb hubs
Usage: $0 [options] [action] [parameters]
Actions:
-l : list available usb hubs/devices that can be toggled and their
current status (enabled/disabled)
-a : enable wakeup on all discovered usb hubs/devices
Use caution with this; it's better to identify individual
hubs/devices rather than enable them all. You might find
your computer woke itself unintentionally.
-x : disable wakeup on all discovered usb hubs/devices
-e : enable wakeup on specific hub/device (requires parameter,
see below.)
-d : disable wakeup on specific hub/device (requires parameter,
see below.)
-h : this screen
Options:
-q : Quiet mode for all but help and list actions
-v : Enable verbose output
-k : Try to show hints from dmesg (list action only)
This dmesg option will show lines starting with input
in order to try to identify devices.
It is usually presented as /sys/devices/*/usb?/*/input/input?.
If nothing useful is displayed, try rebooting as relevant
information can be out of the buffer if the PC has been on for
some time.
Parameters:
Both -e and -d actions require a parameter to search for, use -l to list.
The parameter needed is in the Device column.
Sample output of $0 -l:
Listing USB devices and their wakeup status...
USB ID :: Device* :: Status :: Device Description
----------------------------------------------------
1d6b:0001 :: usb4 :: enabled :: UHCI Host Controller
046d:c508 :: 4-1 :: enabled :: USB Receiver
046d:c221 :: 4-2.1 :: enabled :: Gaming Keyboard
The identifier needed for the parameter is usb4, 4-1, or 4-2.1.
No arguments will show this screen.
"
}
# Start of "main" routine
# Make sure user is root (script will not work as user)
if [ $EUID -ne 0 ]; then echo "This script must be run as root."; exit 3; fi
# Initialize variables:
# QUIET=quiet mode (no echo) - default false. Toggled with -q option.
# KERNELDMESG=dmesg list option in list mode. Default false, toggled with
# -k option
# ACTION=default 0; used to make sure more than one action are not
# specified at the same time.
# VERBOSE=default false. Extra detail in some actions.
QUIET=false
KERNELDMESG=false
VERBOSE=false
ACTION=0
# Show help if no arguments provided at all
if [ $# -eq 0 ]; then showhelp; exit 1; fi
# Process arguments passed, setting environment appropriately.
while getopts “hkqvlaxe:d:” OPTION
do
case $OPTION in
h) # Help action
# Make sure multiple actions are not chosen.
if [ $ACTION -ne 0 ]; then echo "You can only declare one action at a time."; echo ""; showhelp; exit 2; fi
ACTION=1
;;
q) # Quiet option
QUIET=true
;;
k) # Kernel dmesg in list mode option
KERNELDMESG=true
;;
v) # Verbose option
VERBOSE=true
;;
l) # List action
# Make sure multiple actions are not chosen.
if [ $ACTION -ne 0 ]; then echo "You can only declare one action at a time."; echo ""; showhelp; exit 2; fi
ACTION=2
;;
a) # Enable all USB hubs/devices action
# Make sure multiple actions are not chosen.
if [ $ACTION -ne 0 ]; then echo "You can only declare one action at a time."; echo ""; showhelp; exit 2; fi
ACTION=3
;;
x) # Disable all USB hubs/devices action
# Make sure multiple actions are not chosen.
if [ $ACTION -ne 0 ]; then echo "You can only declare one action at a time."; echo ""; showhelp; exit 2; fi
ACTION=4
;;
e) # Enable specific hub/device via find command action
# Make sure multiple actions are not chosen.
if [ $ACTION -ne 0 ]; then echo "You can only declare one action at a time."; echo ""; showhelp; exit 2; fi
ACTION=5
# Save arguments passed for later
ENABLEUSB=$OPTARG
;;
d) # Disable specific hub/device via find command action
# Make sure multiple actions are not chosen.
if [ $ACTION -ne 0 ]; then echo "You can only declare one action at a time."; echo ""; showhelp; exit 2; fi
ACTION=6
# Save arguments passed for later
DISABLEUSB=$OPTARG
;;
?) # Unknown parameter
showhelp
exit 1
;;
esac
done
# Some sanity checks
# Quiet and verbose can't be set at the same time
if $QUIET && $VERBOSE; then echo "You can't specify quiet (-q) and verbose (-v) at the same time."; echo ""; exit 8; fi
# Kernel DMESG can only be used with the list action
if $KERNELDMESG && (( $ACTION != 2 )); then echo "The hints from dmesg option (-k) can only be used with the list (-l) action."; echo ""; exit 9; fi
# Make sure an action was selected!
if (($ACTION == 0 )); then echo "You haven't requested an action!"; exit 7; fi
# We seem to be safe, so actually perform the request
case $ACTION in
1) # help action
showhelp
exit
;;
2) # list action
listusbwakeup
exit
;;
3) # enable all devices
toggleusbdevice true true
exit
;;
4) # disable all devices
toggleusbdevice false true
exit
;;
5) # enable one device
toggleusbdevice true false $ENABLEUSB
exit
;;
6) # disable one device
toggleusbdevice false false $DISABLEUSB
exit
;;
esac
|
Save it to /usr/bin/usbwakeup and chmod +x it.
Last edited by danomac on Sun Nov 11, 2012 3:52 pm; edited 10 times in total |
|
Back to top |
|
|
danomac l33t
Joined: 06 Nov 2004 Posts: 881 Location: Vancouver, BC
|
Posted: Mon Aug 20, 2012 3:45 am Post subject: |
|
|
Continued...
Edit: This script has improved dramatically. It now lists USB devices as well as hubs through some educated guessing in /sys/devices.
This script does multiple things:
Code: |
# usbwakeup
/usr/bin/usbwakeup: a script that lists and toggles wakeup on usb hubs
Usage: /usr/bin/usbwakeup [options] [action] [parameters]
Actions:
-l : list available usb hubs/devices that can be toggled and their
current status (enabled/disabled)
-a : enable wakeup on all discovered usb hubs/devices
Use caution with this; it's better to identify individual
hubs/devices rather than enable them all. You might find
your computer woke itself unintentionally.
-x : disable wakeup on all discovered usb hubs/devices
-e : enable wakeup on specific hub/device (requires parameter,
see below.)
-d : disable wakeup on specific hub/device (requires parameter,
see below.)
-h : this screen
Options:
-q : Quiet mode for all but help and list actions
-v : Enable verbose output
-k : Try to show hints from dmesg (list action only)
This dmesg option will show lines starting with input
in order to try to identify devices.
It is usually presented as /sys/devices/*/usb?/*/input/input?.
If nothing useful is displayed, try rebooting as relevant
information can be out of the buffer if the PC has been on for
some time.
Parameters:
Both -e and -d actions require a parameter to search for, use -l to list.
The parameter needed is in the Device column.
Sample output of /usr/bin/usbwakeup -l:
Listing USB devices and their wakeup status...
USB ID :: Device* :: Status :: Device Description
----------------------------------------------------
1d6b:0001 :: usb4 :: enabled :: UHCI Host Controller
046d:c508 :: 4-1 :: enabled :: USB Receiver
046d:c221 :: 4-2.1 :: enabled :: Gaming Keyboard
The identifier needed for the parameter is usb4, 4-1, or 4-2.1.
No arguments will show this screen.
|
Sample list output:
Code: |
#
# usbwakeup -kl
Listing USB hubs/devices and their wakeup status...
USB ID :: Device* :: Status :: Device Description
----------------------------------------------------
1d6b:0001 :: usb3 :: disabled :: UHCI Host Controller
051d:0002 :: 3-1 :: disabled :: Back-UPS RS 1200 FW:8.g1 .D USB FW:g1
1d6b:0001 :: usb4 :: enabled :: UHCI Host Controller
046d:c508 :: 4-1 :: enabled :: USB Receiver
046d:c221 :: 4-2.1 :: enabled :: Gaming Keyboard
1d6b:0001 :: usb5 :: disabled :: UHCI Host Controller
1d6b:0002 :: usb1 :: disabled :: EHCI Host Controller
1d6b:0001 :: usb6 :: disabled :: UHCI Host Controller
1d6b:0001 :: usb7 :: disabled :: UHCI Host Controller
1d6b:0001 :: usb8 :: disabled :: UHCI Host Controller
1d6b:0002 :: usb2 :: disabled :: EHCI Host Controller
*Use the Device column to identify hubs/devices to be toggled.
11 USB hubs/devices listed.
Hints from dmesg (use this to try to identify your keyboard and mouse, you
may need to reboot to see anything relevant, see help for more info):
input: Sleep Button as /devices/LNXSYSTM:00/device:00/PNP0C0E:00/input/input0
input: Power Button as /devices/LNXSYSTM:00/device:00/PNP0C0C:00/input/input1
input: Power Button as /devices/LNXSYSTM:00/LNXPWRBN:00/input/input2
input: Logitech USB Receiver as /devices/pci0000:00/0000:00:1a.1/usb4/4-1/4-1:1.0/input/input3
input: Gaming Keyboard as /devices/pci0000:00/0000:00:1a.1/usb4/4-2/4-2.1/4-2.1:1.0/input/input4
input: Gaming Keyboard as /devices/pci0000:00/0000:00:1a.1/usb4/4-2/4-2.1/4-2.1:1.1/input/input5
input: G15 Keyboard G15 Keyboard as /devices/pci0000:00/0000:00:1a.1/usb4/4-2/4-2.4/4-2.4:1.0/input/input6
input: PC Speaker as /devices/platform/pcspkr/input/input7
|
So it lists usb hubs it finds and searches dmesg with lines starting with 'input' to give hints. It also lists the USB ID so you can even use lsusb to cross reference:
lsusb:
Quote: |
# lsusb
Bus 004 Device 002: ID 046d:c508 Logitech, Inc. Cordless Trackball
Bus 004 Device 004: ID 046d:c221 Logitech, Inc. G11/G15 Keyboard / Keyboard
|
usbwakeup -l:
Quote: |
USB ID :: Device* :: Status :: Device Description
----------------------------------------------------
046d:c508 :: 4-1 :: enabled :: USB Receiver
046d:c221 :: 4-2.1 :: enabled :: Gaming Keyboard
|
It also has a more "verbose" output:
Code: |
# usbwakeup -vl
Listing USB hubs/devices and their wakeup status...
USB ID :: Device* :: Status
Device full path
Vendor :: Device Description
---------------------------------
1d6b:0001 :: usb3 :: disabled
/sys/devices/pci0000:00/0000:00:1a.0/usb3
Linux 3.3.8-gentoo uhci_hcd :: UHCI Host Controller
051d:0002 :: 3-1 :: disabled
/sys/devices/pci0000:00/0000:00:1a.0/usb3/3-1
American Power Conversion :: Back-UPS RS 1200 FW:8.g1 .D USB FW:g1
1d6b:0001 :: usb4 :: enabled
/sys/devices/pci0000:00/0000:00:1a.1/usb4
Linux 3.3.8-gentoo uhci_hcd :: UHCI Host Controller
046d:c508 :: 4-1 :: enabled
/sys/devices/pci0000:00/0000:00:1a.1/usb4/4-1
Logitech :: USB Receiver
046d:c221 :: 4-2.1 :: enabled
/sys/devices/pci0000:00/0000:00:1a.1/usb4/4-2/4-2.1
No vendor name :: Gaming Keyboard
1d6b:0001 :: usb5 :: disabled
/sys/devices/pci0000:00/0000:00:1a.2/usb5
Linux 3.3.8-gentoo uhci_hcd :: UHCI Host Controller
1d6b:0002 :: usb1 :: disabled
/sys/devices/pci0000:00/0000:00:1a.7/usb1
Linux 3.3.8-gentoo ehci_hcd :: EHCI Host Controller
1d6b:0001 :: usb6 :: disabled
/sys/devices/pci0000:00/0000:00:1d.0/usb6
Linux 3.3.8-gentoo uhci_hcd :: UHCI Host Controller
1d6b:0001 :: usb7 :: disabled
/sys/devices/pci0000:00/0000:00:1d.1/usb7
Linux 3.3.8-gentoo uhci_hcd :: UHCI Host Controller
1d6b:0001 :: usb8 :: disabled
/sys/devices/pci0000:00/0000:00:1d.2/usb8
Linux 3.3.8-gentoo uhci_hcd :: UHCI Host Controller
1d6b:0002 :: usb2 :: disabled
/sys/devices/pci0000:00/0000:00:1d.7/usb2
Linux 3.3.8-gentoo ehci_hcd :: EHCI Host Controller
*Use the Device column to identify hubs/devices to be toggled.
11 USB hubs/devices listed.
|
From my example above you can see my keyboard is on the usb4 hub:
Quote: |
input: Gaming Keyboard as /devices/pci0000:00/0000:00:1a.1/usb4/4-2/4-2.1/4-2.1:1.0/input/input4
input: Gaming Keyboard as /devices/pci0000:00/0000:00:1a.1/usb4/4-2/4-2.1/4-2.1:1.1/input/input5
|
Code: |
USB ID :: Device* :: Status :: Device Description
----------------------------------------------------
1d6b:0001 :: usb4 :: disabled :: UHCI Host Controller
046d:c508 :: 4-1 :: disabled :: USB Receiver
046d:c221 :: 4-2.1 :: disabled :: Gaming Keyboard
*Use the Device column to identify hubs/devices to be toggled.
|
So to toggle just the keyboard, mouse, and hub:
Code: |
# usbwakeup -e usb4
Attempting to enable device (usb4)...
Success!
# usbwakeup -e 4-1
Attempting to enable device (4-1)...
Success!
# usbwakeup -e 4-2.1
Attempting to enable device (4-2.1)...
Success!
|
You can also enable all usb hubs and devices the script finds:
Warning: As the script does make educated guesses make sure you use the list action to see what it finds first!
Code: |
# usbwakeup -a
Attempting to enable device (usb3)...
Success!
Attempting to enable device (3-1)...
Success!
Attempting to enable device (usb4)...
Success!
Attempting to enable device (4-1)...
Success!
Attempting to enable device (4-2.1)...
Success!
Attempting to enable device (usb5)...
Success!
Attempting to enable device (usb1)...
Success!
Attempting to enable device (usb6)...
Success!
Attempting to enable device (usb7)...
Success!
Attempting to enable device (usb8)...
Success!
Attempting to enable device (usb2)...
Success!
|
To make this happen at boot time, create /etc/local.d/enableusbwakeup.start:
Code: |
#!/bin/sh
/usr/bin/usbwakeup -qe usb4
/usr/bin/usbwakeup -qe 4-1
/usr/bin/usbwakeup -qe 4-2.1
|
to enable one, or just use
Code: |
#!/bin/sh
/usr/bin/usbwakeup -qa
|
to enable everything.
To illustrate the problem I'm having, compare the outputs of above script vs. acpitool -w, which were ran before setting usb4 with my script:
Code: |
# acpitool -w
Device S-state Status Sysfs node
---------------------------------------
1. P0P1 S3 *disabled pci:0000:00:01.0
2. UAR1 S3 *disabled pnp:00:03
3. P0P2 S4 *disabled pci:0000:00:1e.0
4. USB0 S3 *enabled pci:0000:00:1d.0
5. USB1 S3 *enabled pci:0000:00:1d.1
6. USB2 S3 *enabled pci:0000:00:1d.2
7. USB5 S3 *disabled
8. USB6 S3 *enabled pci:0000:00:1a.2
9. EUSB S3 *enabled pci:0000:00:1d.7
10. USB3 S3 *enabled pci:0000:00:1a.0
11. USB4 S3 *enabled pci:0000:00:1a.1 <-- this one, which is enabled here
12. USBE S3 *enabled pci:0000:00:1a.7
13. PEX0 S4 *disabled pci:0000:00:1c.0
14. PEX1 S4 *disabled pci:0000:00:1c.1
15. PEX2 S4 *disabled pci:0000:00:1c.2
16. PEX3 S4 *disabled pci:0000:00:1c.3
17. PEX4 S4 *disabled pci:0000:00:1c.4
18. PEX5 S4 *disabled pci:0000:00:1c.5
19. SLPB S4 *enabled
20. PWRB S3 *enabled
|
Code: |
# # usbwakeup -kl
Listing USB hubs/devices and their wakeup status...
USB ID :: Device* :: Status :: Device Description
----------------------------------------------------
1d6b:0001 :: usb3 :: disabled :: UHCI Host Controller
051d:0002 :: 3-1 :: disabled :: Back-UPS RS 1200 FW:8.g1 .D USB FW:g1
1d6b:0001 :: usb4 :: disabled :: UHCI Host Controller <-- this one, but it's disabled here
046d:c508 :: 4-1 :: disabled :: USB Receiver
046d:c221 :: 4-2.1 :: disabled :: Gaming Keyboard
1d6b:0001 :: usb5 :: disabled :: UHCI Host Controller
1d6b:0002 :: usb1 :: disabled :: EHCI Host Controller
1d6b:0001 :: usb6 :: disabled :: UHCI Host Controller
1d6b:0001 :: usb7 :: disabled :: UHCI Host Controller
1d6b:0001 :: usb8 :: disabled :: UHCI Host Controller
1d6b:0002 :: usb2 :: disabled :: EHCI Host Controller
*Use the Device column to identify hubs/devices to be toggled.
11 USB hubs/devices listed.
|
Last edited by danomac on Wed Aug 22, 2012 2:28 am; edited 5 times in total |
|
Back to top |
|
|
depontius Advocate
Joined: 05 May 2004 Posts: 3509
|
Posted: Mon Aug 20, 2012 1:04 pm Post subject: |
|
|
I had similar problems, when wakeup-from-LIRC failed when I moved my dedicated myth frontend to 3.3.8. I guess I found what you did, and solved it with some ugly system-specific hacks in "/etc/local.d/baslayout1.start" instead of attempting a complete script, as you did.
I'll have to take a good look at your work, as it appears to be a more general solution than mine. _________________ .sigs waste space and bandwidth |
|
Back to top |
|
|
avx Advocate
Joined: 21 Jun 2004 Posts: 2152
|
Posted: Mon Aug 20, 2012 2:37 pm Post subject: |
|
|
Thank you, works great.
(minor hickup, first tried foolishly without root Quote: | > usbwakeup -a
Enabling wakeup on all found USB devices...
/usr/local/bin/usbwakeup: line 89: /sys/devices/pci0000:00/0000:00:1a.0/usb3/power/wakeup: Permission denied
/usr/local/bin/usbwakeup: line 89: /sys/devices/pci0000:00/0000:00:1a.1/usb4/power/wakeup: Permission denied
/usr/local/bin/usbwakeup: line 89: /sys/devices/pci0000:00/0000:00:1a.2/usb5/power/wakeup: Permission denied
/usr/local/bin/usbwakeup: line 89: /sys/devices/pci0000:00/0000:00:1a.7/usb1/power/wakeup: Permission denied
/usr/local/bin/usbwakeup: line 89: /sys/devices/pci0000:00/0000:00:1d.0/usb6/power/wakeup: Permission denied
/usr/local/bin/usbwakeup: line 89: /sys/devices/pci0000:00/0000:00:1d.1/usb7/power/wakeup: Permission denied
/usr/local/bin/usbwakeup: line 89: /sys/devices/pci0000:00/0000:00:1d.2/usb8/power/wakeup: Permission denied
/usr/local/bin/usbwakeup: line 89: /sys/devices/pci0000:00/0000:00:1d.7/usb2/power/wakeup: Permission denied
8 USB devices changed. | Nothing enabled but said so) _________________ ++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>. |
|
Back to top |
|
|
danomac l33t
Joined: 06 Nov 2004 Posts: 881 Location: Vancouver, BC
|
Posted: Mon Aug 20, 2012 3:08 pm Post subject: |
|
|
Whoops!
Maybe I'll add a line to check for root. I was writing it while root, so I never thought to check!
I'll do that after work.
So you can wake with your keyboard now? That's great. You should be able to build your kernel without the deprecated /proc/acpi stuff now, I did and have no issues. |
|
Back to top |
|
|
avx Advocate
Joined: 21 Jun 2004 Posts: 2152
|
Posted: Mon Aug 20, 2012 4:11 pm Post subject: |
|
|
danomac wrote: | So you can wake with your keyboard now? That's great. | Yeah, works again. What doesn't, but which IIRC used to work, is waking up via mouse movement/clicking, but then again, I've got a new mouse since the last time I used that and since it's wireless (Logitech Performance MX) that might be the problem.
Quote: | You should be able to build your kernel without the deprecated /proc/acpi stuff now, I did and have no issues. | Now? I'm not using this for years now _________________ ++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>. |
|
Back to top |
|
|
danomac l33t
Joined: 06 Nov 2004 Posts: 881 Location: Vancouver, BC
|
Posted: Mon Aug 20, 2012 4:31 pm Post subject: |
|
|
avx wrote: | Yeah, works again. What doesn't, but which IIRC used to work, is waking up via mouse movement/clicking, but then again, I've got a new mouse since the last time I used that and since it's wireless (Logitech Performance MX) that might be the problem.
Quote: | You should be able to build your kernel without the deprecated /proc/acpi stuff now, I did and have no issues. | Now? I'm not using this for years now |
I remember my old Asus boards had fits when trying to make them wake up from sleep. I had so much trouble with those boards. I have an Intel board now, it's not nearly as picky. I don't remember trying to use my mouse to wake my computer - it's plugged into the same hub, maybe I'll try it at lunchtime.
I usually left the deprecated crap in the kernel because acpid needed it. It doesn't now (checked yesterday) so I finally removed it.
Edit: Nope, I can't wake up with the mouse either. I'll bet it's because the device itself is disabled. I'll look into that later. |
|
Back to top |
|
|
danomac l33t
Joined: 06 Nov 2004 Posts: 881 Location: Vancouver, BC
|
Posted: Tue Aug 21, 2012 1:13 am Post subject: |
|
|
I've updated the script with a root check. If the effective uid is not root, the script will not execute.
Also, I've been poking in to the mouse not working, and I think it's because the actual device is not enabled. udev sets the keyboard automatically now, but it apparently does not set the usb hub or mice. Strange.
I have an idea for a better script, I just have to work out details on the implementation - the script could be expanded to devices it finds that can be toggled (not necessarily just USB hubs/devices.) Not sure on the implementation part right now though.
Edit: Yep, the mouse wasn't enabled. I found it in the /sys/devices/* tree and enabled it manually and it works now.
Edit2: I've been tweaking the script to see if I can show actual USB devices (not just the hubs themselves) so they can be toggled on and off too. Making some progress. |
|
Back to top |
|
|
danomac l33t
Joined: 06 Nov 2004 Posts: 881 Location: Vancouver, BC
|
Posted: Wed Aug 22, 2012 2:12 am Post subject: |
|
|
I've more or less completely rewritten the script. It does some educated guessing and shows actual devices as well as the hubs themselves.
I was able to enable my trackball using the script. Although I don't normally use it to wake the computer, I can move the trackball or click the button on it to wake the computer up now. |
|
Back to top |
|
|
avx Advocate
Joined: 21 Jun 2004 Posts: 2152
|
Posted: Wed Aug 22, 2012 2:36 am Post subject: |
|
|
Will try that later, thanks for your continued efforts.
In the meantime, since this forum doesn't allow attachments, please consider posting updates to some pastebin service, c&p here is quite tiresome.
Works, great. Only downside is it also passes the event on mouse-movement, while clicking would be my prefered way. _________________ ++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>. |
|
Back to top |
|
|
danomac l33t
Joined: 06 Nov 2004 Posts: 881 Location: Vancouver, BC
|
Posted: Wed Aug 22, 2012 5:53 pm Post subject: |
|
|
avx wrote: | Works, great. Only downside is it also passes the event on mouse-movement, while clicking would be my prefered way. |
That's not anything to do with my script or linux - the computer will wake from any activity on the USB bus, so mouse movement will wake the computer. We have loads of machines at work that behave like that. |
|
Back to top |
|
|
avx Advocate
Joined: 21 Jun 2004 Posts: 2152
|
Posted: Wed Aug 22, 2012 6:17 pm Post subject: |
|
|
No biggie, just found out this morning, that at least for my hardware the problem is "auto-solved". After not moving the mouse for some time, it automatically goes to standby so moving it doesn't work, but clicking does _________________ ++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>. |
|
Back to top |
|
|
danomac l33t
Joined: 06 Nov 2004 Posts: 881 Location: Vancouver, BC
|
Posted: Thu Aug 23, 2012 2:36 am Post subject: |
|
|
avx wrote: | In the meantime, since this forum doesn't allow attachments, please consider posting updates to some pastebin service, c&p here is quite tiresome. |
I didn't see this comment earlier, sorry. I've created a pastebin account and uploaded it there with a link in the first post. |
|
Back to top |
|
|
MGX-122 n00b
Joined: 11 Nov 2012 Posts: 4
|
Posted: Sun Nov 11, 2012 2:14 pm Post subject: Still problems with waking it up |
|
|
Looking for some more information I've found this thread - maybe someone of you could make a tip:
I've got a rules in /etc/udev/rules.d/90-keyboardwakeup.rules
Quote: |
SUBSYSTEM=="usb", ATTRS{idVendor}=="1241", ATTRS{idProduct}=="1503" RUN+="/bin/sh -c 'echo enabled > /sys$env{DEVPATH}/../power/wakeup'"
|
Well, it works perfectly, since using the script by danomac I was able to check, that my keyboard is supposed to do "resume from suspend":
Quote: |
USB ID :: Device* :: Status :: Device Description
----------------------------------------------------
1d6b:0001 :: usb2 :: disabled :: OHCI Host Controller
1241:1503 :: 1-5.1 :: enabled :: USB Keyboard
05e3:0608 :: 1-5 :: enabled :: USB2.0 Hub
1d6b:0002 :: usb1 :: disabled :: EHCI Host Controller
|
There's no problem with suspending the system on keypress - a very basic script does "echo -n 'standby' >/sys/power/state" on XF86Sleep event, and that's it. Unfortunately, I'm not able to make the keyboard wake the machine up.
Having in BIOS "USB Resume from Suspend" set to "Enable" (be it together with "USB Keyboard Support" set to "Enabled" or "Disabled", it doesn't seem to matter), trying every single USB port available - still I can't wake it up (of course, any keypress on ordinary PS/2 keyboard wakes computer instantly). Maybe I'm missing some very esoteric option in kernel configuration? Maybe I could somehow bind appropriate phrase to XF86WakeUp event (but does it trigger on keypress on USB keyboard, while in "sleep" state?) - but which one, actually?
Not sure, is USB keyboard powered during "sleep", since "number lock" LED fades out while suspending. It's Omega "OK 203 Sagitta" keyboard, recognized by Linux as "Belkin". I'm using kernel 3.6.0. My USB ports are 2.0/1.1.
Any ideas, how it could be fixed?
P.S. I forgot: I noticed, that after I trigger "sleep" and wake the system up then, the "power button" doesn't switch off the system gracefully anymore. I can shut it down issuing a command - e.g. "poweroff" - but not with power button. |
|
Back to top |
|
|
danomac l33t
Joined: 06 Nov 2004 Posts: 881 Location: Vancouver, BC
|
Posted: Sun Nov 11, 2012 3:56 pm Post subject: |
|
|
You've enabled the devices themselves, but not the hub on the computer.
Try
Code: |
$ usbwakeup -e usb1
|
and try it again.
Make sure stuff under /proc/acpi/wakeup are also set to enabled. My script only checks /sys/devices.
Regarding the power switch, that's likely ACPI related. |
|
Back to top |
|
|
MGX-122 n00b
Joined: 11 Nov 2012 Posts: 4
|
Posted: Sun Nov 11, 2012 4:18 pm Post subject: |
|
|
I tried it earlier, before I started to look for some more clues.
Nevertheless, I made it again - "enabling" USB1, as you wrote, no desired effect, then also USB0, still doesn't work as expected. Now it looks like this:
Quote: |
USB ID :: Device* :: Status :: Device Description
----------------------------------------------------
1d6b:0001 :: usb2 :: enabled :: OHCI Host Controller
1241:1503 :: 1-5.1 :: enabled :: USB Keyboard
05e3:0608 :: 1-5 :: enabled :: USB2.0 Hub
1d6b:0002 :: usb1 :: enabled :: EHCI Host Controller
|
Well, if I'm correct, /proc/acpi/wakeup has been marked as "obsolete" - anyway tried it again, enabling even "just for reason" HUB0 ("/bin/echo HUB0 > /proc/acpi/wakeup"); now it looks like:
Quote: |
Device S-state Status Sysfs node
HUB0 S5 *enabled pci:0000:00:08.0
XVR0 S5 *disabled
XVR1 S5 *disabled
XVR2 S5 *disabled pci:0000:00:0d.0
XVR3 S5 *disabled
UAR1 S5 *disabled pnp:00:09
USB0 S3 *enabled pci:0000:00:02.0
USB2 S3 *enabled pci:0000:00:02.1
AZAD S5 *disabled pci:0000:00:07.0
MMAC S5 *disabled pci:0000:00:06.0
|
But still I can't wake OS up with USB keyboard.
BTW: in addition noticed interesting thing: I can bind "firefox" to XF86WWW event - and it's working flawlessly - but not "opera". It just isn't starting at all. |
|
Back to top |
|
|
MGX-122 n00b
Joined: 11 Nov 2012 Posts: 4
|
Posted: Sun Nov 11, 2012 5:52 pm Post subject: Rtfm |
|
|
Well, "if all else fails - read the docs"; found in "Power Management for USB":
Quote: |
Note: Dynamic PM support for USB is present only if the kernel was built with CONFIG_USB_SUSPEND enabled
|
...which wasn't enabled in my kernel-config. Most probably this made the problem.
Started the compilation right now - I'll let you know in circa 3 hours, whether it was the culprit. |
|
Back to top |
|
|
danomac l33t
Joined: 06 Nov 2004 Posts: 881 Location: Vancouver, BC
|
Posted: Sun Nov 11, 2012 6:17 pm Post subject: |
|
|
Sounds like that is the problem. You will still need to enable both the devices and the hub though. |
|
Back to top |
|
|
MGX-122 n00b
Joined: 11 Nov 2012 Posts: 4
|
Posted: Sun Nov 11, 2012 8:05 pm Post subject: |
|
|
Yes, exactly. BTW: I'm not sure, does there exist (with newer kernels) any need to mess with /proc/acpi/wakeup. It seems, that it goes properly set "on automatic", when the rest of settings (kernel configuration and most probably udev rules) is proper. I didn't need to touch it right now, got there USB0 and USB2 "enabled", not setting anything "by hand".
Solved, anyway.
Well, solved one problem - and got two new riddles to solve after suspending and waking it up just once, it doesn't want to react on "power button" press, neither on "power off" (the one on keyboard) anymore. |
|
Back to top |
|
|
danomac l33t
Joined: 06 Nov 2004 Posts: 881 Location: Vancouver, BC
|
Posted: Sun Nov 11, 2012 8:34 pm Post subject: |
|
|
The /proc/acpi/wakeup should have all USB devices enabled. Still a good idea to check to make sure it is working as intended.
The script I wrote is an easy way to check /sys/devices... I could modify it to show USB stuff in /proc/acpi/wakeup as well. |
|
Back to top |
|
|
sipingal n00b
Joined: 12 May 2008 Posts: 62 Location: China
|
|
Back to top |
|
|
danomac l33t
Joined: 06 Nov 2004 Posts: 881 Location: Vancouver, BC
|
Posted: Fri Nov 30, 2012 4:39 pm Post subject: |
|
|
That prevents devices from automatically suspending after a timeout. This thread is about putting the whole system in standby and being able to resume from using an input device. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|