Solved Ubuntu 16.04: Wake on USB?
#1
Hey all,

I have a Kodi/Openbox (no desktop environment) setup in Ubuntu 16.04 as described in Fritsch's thread here.

Wake on USB is one of those thorny things I've never been able to get to work. There are a bunch of guides out there for older versions of Ubuntu, but none of them ever wound up working for me, and now that 16.04 is out, the methods may even be different.

Has anyone gotten wake on USB (preferably with WMC remote, but keyboard would help too) to work properly?

My desired outcome is as follows:

1.) System is put in sleep (not hibernate) mode either manually using keyboard/remote or automatically by system timeout.
2.) Keyboard and remote can be used to wake the system again without having to press the power button.

I know it can seem lazy to not want to get up and press the power button, but my Kodi box is actually two floors down in the basement, displaying on the TV with remove HDMI over Ethernet and USB over Ethernet adapters. It would be nice to be able to save power, and allow it to go to sleep, but I can only do that if I can get remote wake to work.

Appreciate any help, or suggestions!

--Matt
Livingroom: 65" Panasonic Plasma, Denon AVR-x3300w, Parasound A31, Fronts: RBH SX-6300 Towers, Center: RBH 441-se, Surrounds: RBH 41-se Sub: Dual SVS PC13-Ultra, Source: Custom Kodi Box
Desk: DAC: Schiit Modi Multibit,Headphones: Schiit Jotunheim -> Sennheiser HD650 & Beyerdynamic DT770 Pro, Speakers: Parasound 275v2-> RBH 41-se & SVS SB12-NSD
Reply
#2
run lsbusb to identify your usb remote, then in a startup file (like /etc/rc.local) add this, changing the device id:

Code:
echo enabled > /sys/bus/usb/devices/2-4/power/wakeup

this is my mce clone:

Code:
$ lsusb
Bus 002 Device 004: ID 1784:0011 TopSeed Technology Corp. eHome Infrared Transceiver

wake-on-lan works for me too:

Code:
/sbin/ethtool -s enp0s10 wol g

works for 12.04 and 16.04 although with 16.04 (17a2) i find that kodi seems to lock up the machine sometimes when suspending
Reply
#3
(2016-06-12, 21:31)sej7278 Wrote: run lsbusb to identify your usb remote, then in a startup file (like /etc/rc.local) add this, changing the device id:

Code:
echo enabled > /sys/bus/usb/devices/2-4/power/wakeup

this is my mce clone:

Code:
$ lsusb
Bus 002 Device 004: ID 1784:0011 TopSeed Technology Corp. eHome Infrared Transceiver

wake-on-lan works for me too:

Code:
/sbin/ethtool -s enp0s10 wol g

works for 12.04 and 16.04 although with 16.04 (17a2) i find that kodi seems to lock up the machine sometimes when suspending

Appreciate the response.

I went to try this, but immediately ran into a problem. Here is what my lsusb looks like:

Code:
Bus 002 Device 002: ID 8087:8000 Intel Corp.
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:8008 Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 004: ID 1784:0011 TopSeed Technology Corp. eHome Infrared Transceiver
Bus 003 Device 003: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 003 Device 002: ID 05e3:0608 Genesys Logic, Inc. Hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Ideally I'd like to be able to wake it both with my keyboard and with my remote, but I decided to try the remote first.

This appears to be the remote:
Code:
Bus 003 Device 004: ID 1784:0011 TopSeed Technology Corp. eHome Infrared Transceiver

Based on this, I would expect to issue the echo command to the 3-4 device as follows from your example, right?

Code:
echo enabled > /sys/bus/usb/devices/3-4/power/wakeup

3-4, since it is bus 3, device 4, correct?

Only problem is, no such device appears to exist in /sys/bus/usb/devices:

Code:
$ ls -l /sys/bus/usb/devices/
total 0
lrwxrwxrwx 1 root root 0 Jun 12 23:05 1-0:1.0 -> ../../../devices/pci0000:00/0000:00:1a.0/usb1/1-0:1.0
lrwxrwxrwx 1 root root 0 Jun 12 23:05 1-1 -> ../../../devices/pci0000:00/0000:00:1a.0/usb1/1-1
lrwxrwxrwx 1 root root 0 Jun 12 23:05 1-1:1.0 -> ../../../devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1:1.0
lrwxrwxrwx 1 root root 0 Jun 12 23:05 2-0:1.0 -> ../../../devices/pci0000:00/0000:00:1d.0/usb2/2-0:1.0
lrwxrwxrwx 1 root root 0 Jun 12 23:05 2-1 -> ../../../devices/pci0000:00/0000:00:1d.0/usb2/2-1
lrwxrwxrwx 1 root root 0 Jun 12 23:05 2-1:1.0 -> ../../../devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1:1.0
lrwxrwxrwx 1 root root 0 Jun 12 23:05 3-0:1.0 -> ../../../devices/pci0000:00/0000:00:14.0/usb3/3-0:1.0
lrwxrwxrwx 1 root root 0 Jun 12 23:05 3-2 -> ../../../devices/pci0000:00/0000:00:14.0/usb3/3-2
lrwxrwxrwx 1 root root 0 Jun 12 23:05 3-2:1.0 -> ../../../devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.0
lrwxrwxrwx 1 root root 0 Jun 12 23:05 3-2.3 -> ../../../devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2.3
lrwxrwxrwx 1 root root 0 Jun 12 23:05 3-2.3:1.0 -> ../../../devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2.3/3-2.3:1.0
lrwxrwxrwx 1 root root 0 Jun 12 23:05 3-2.3:1.1 -> ../../../devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2.3/3-2.3:1.1
lrwxrwxrwx 1 root root 0 Jun 12 23:05 3-2.3:1.2 -> ../../../devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2.3/3-2.3:1.2
lrwxrwxrwx 1 root root 0 Jun 12 23:05 3-2.4 -> ../../../devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2.4
lrwxrwxrwx 1 root root 0 Jun 12 23:05 3-2.4:1.0 -> ../../../devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2.4/3-2.4:1.0
lrwxrwxrwx 1 root root 0 Jun 12 23:05 4-0:1.0 -> ../../../devices/pci0000:00/0000:00:14.0/usb4/4-0:1.0
lrwxrwxrwx 1 root root 0 Jun 12 23:05 usb1 -> ../../../devices/pci0000:00/0000:00:1a.0/usb1
lrwxrwxrwx 1 root root 0 Jun 12 23:05 usb2 -> ../../../devices/pci0000:00/0000:00:1d.0/usb2
lrwxrwxrwx 1 root root 0 Jun 12 23:05 usb3 -> ../../../devices/pci0000:00/0000:00:14.0/usb3
lrwxrwxrwx 1 root root 0 Jun 12 23:05 usb4 -> ../../../devices/pci0000:00/0000:00:14.0/usb4

Any suggestions?

Also, since my device is plugged into a powered hub, woudl I also have to use this echo line to enable the powered hub?

Much appreciated!

--Matt
Livingroom: 65" Panasonic Plasma, Denon AVR-x3300w, Parasound A31, Fronts: RBH SX-6300 Towers, Center: RBH 441-se, Surrounds: RBH 41-se Sub: Dual SVS PC13-Ultra, Source: Custom Kodi Box
Desk: DAC: Schiit Modi Multibit,Headphones: Schiit Jotunheim -> Sennheiser HD650 & Beyerdynamic DT770 Pro, Speakers: Parasound 275v2-> RBH 41-se & SVS SB12-NSD
Reply
#4
Alright, to follow up, I think I located the device. Judging by the idProduct and idVendor files in those usb folders, it appears to be:

Code:
/sys/bus/usb/devices/3-2.4/

So, I try using your echo command as above, and get a "Permission Denied" error, regardless of whether I sudo:

Code:
$ echo enabled > /sys/bus/usb/devices/3-2.4/power/wakeup
-bash: /sys/bus/usb/devices/3-2.4/power/wakeup: Permission denied
$ sudo echo enabled > /sys/bus/usb/devices/3-2.4/power/wakeup
-bash: /sys/bus/usb/devices/3-2.4/power/wakeup: Permission denied

Any ideas?
Livingroom: 65" Panasonic Plasma, Denon AVR-x3300w, Parasound A31, Fronts: RBH SX-6300 Towers, Center: RBH 441-se, Surrounds: RBH 41-se Sub: Dual SVS PC13-Ultra, Source: Custom Kodi Box
Desk: DAC: Schiit Modi Multibit,Headphones: Schiit Jotunheim -> Sennheiser HD650 & Beyerdynamic DT770 Pro, Speakers: Parasound 275v2-> RBH 41-se & SVS SB12-NSD
Reply
#5
echo enabled | sudo tee /sys/bus/usb/devices/3-2.4/power/wakeup
Reply
#6
(2016-06-13, 09:23)wsnipex Wrote: echo enabled | sudo tee /sys/bus/usb/devices/3-2.4/power/wakeup

Ahh, so what you are saying is that my command was running echo as sudo, but not writing to the file in sys as sudo?

Do you know if I need to do this for the powered USB hub I am using as well, or only the end device?
Livingroom: 65" Panasonic Plasma, Denon AVR-x3300w, Parasound A31, Fronts: RBH SX-6300 Towers, Center: RBH 441-se, Surrounds: RBH 41-se Sub: Dual SVS PC13-Ultra, Source: Custom Kodi Box
Desk: DAC: Schiit Modi Multibit,Headphones: Schiit Jotunheim -> Sennheiser HD650 & Beyerdynamic DT770 Pro, Speakers: Parasound 275v2-> RBH 41-se & SVS SB12-NSD
Reply
#7
yes.
You most probably need it for the hub as well. Also note that those commands do not persist across reboots, so you need a script to do it on every boot(or put it in rc.local).
Reply
#8
(2016-06-13, 16:54)wsnipex Wrote: yes.
You most probably need it for the hub as well. Also note that those commands do not persist across reboots, so you need a script to do it on every boot(or put it in rc.local).

Much appreciated. I have a queue of things to fix on my three kodi boxes, but I will definitely try this in the next few days.
Livingroom: 65" Panasonic Plasma, Denon AVR-x3300w, Parasound A31, Fronts: RBH SX-6300 Towers, Center: RBH 441-se, Surrounds: RBH 41-se Sub: Dual SVS PC13-Ultra, Source: Custom Kodi Box
Desk: DAC: Schiit Modi Multibit,Headphones: Schiit Jotunheim -> Sennheiser HD650 & Beyerdynamic DT770 Pro, Speakers: Parasound 275v2-> RBH 41-se & SVS SB12-NSD
Reply
#9
Hmm.

This might be a problem.

The device number does not appear to be persistent across reboots.

My infrared receiver was Bus 003, Device 004 before reboot. Now it is Bus 003, Device 003...

yea, /sys/bus/usb/devices/3-2.4/ no longer exists...

No rc.local commands are going to work, if these things keep moving around Sad

I'm guessing the use of a hub has something to do with this, but I don't have a choice in that regard on this setup...
Livingroom: 65" Panasonic Plasma, Denon AVR-x3300w, Parasound A31, Fronts: RBH SX-6300 Towers, Center: RBH 441-se, Surrounds: RBH 41-se Sub: Dual SVS PC13-Ultra, Source: Custom Kodi Box
Desk: DAC: Schiit Modi Multibit,Headphones: Schiit Jotunheim -> Sennheiser HD650 & Beyerdynamic DT770 Pro, Speakers: Parasound 275v2-> RBH 41-se & SVS SB12-NSD
Reply
#10
Here is the script I wrote to disable my dinovo edge keyboard on openelec (keyboard is stupid - it wakes the PC as soon as it starts charging....).

By replacing the hardwareid & disabled by enabled you shall be able to get it working properly for your use case.

As I was not sure whether the wakeup status would persist after a suspend, I did put this code in the sleep.d (/etc/pm/sleep.d in your case I guess). This way this code is executed everytime the computer goes to sleep.

Code:
#!/bin/sh
. /etc/profile
case "$1" in
        hibernate|suspend|pre)
                for d in "/sys/bus/usb/devices/"*
                do
                        if [ -f $d/idVendor ] && [ -f $d/idProduct ] && grep -lq '046d' "$d/idVendor" && grep -lq 'c713' "$d/idProduct"
                        then
                                echo 'disabled' > "$d/power/wakeup"
                        fi
                done
        ;;
        *) exit $NA
        ;;
esac

It might be possible to do that in a better way using udev, but this is beyond my skills.
Reply
#11
(2016-06-18, 21:59)FuN_KeY Wrote: Here is the script I wrote to disable my dinovo edge keyboard on openelec (keyboard is stupid - it wakes the PC as soon as it starts charging....).

By replacing the hardwareid & disabled by enabled you shall be able to get it working properly for your use case.

As I was not sure whether the wakeup status would persist after a suspend, I did put this code in the sleep.d (/etc/pm/sleep.d in your case I guess). This way this code is executed everytime the computer goes to sleep.

Code:
#!/bin/sh
. /etc/profile
case "$1" in
        hibernate|suspend|pre)
                for d in "/sys/bus/usb/devices/"*
                do
                        if [ -f $d/idVendor ] && [ -f $d/idProduct ] && grep -lq '046d' "$d/idVendor" && grep -lq 'c713' "$d/idProduct"
                        then
                                echo 'disabled' > "$d/power/wakeup"
                        fi
                done
        ;;
        *) exit $NA
        ;;
esac

It might be possible to do that in a better way using udev, but this is beyond my skills.


Thank you, that is awesome!

I was actually in the process of modifying this script I found on askubuntu.com to do the same thing:

Code:
#!/bin/bash

if [ $# -ne 2 ];then
  echo "Usage: `basename $0` idVendor idProduct"
  exit 1
fi


for X in /sys/bus/usb/devices/*; do
    if [ "$1" == "$(cat "$X/idVendor" 2>/dev/null)" -a "$2" == "$(cat "$X/idProduct" 2>/dev/null)" ]
    then
        echo "$X"
    fi
done

Being able to reference (ans possibly use) yours will definitely save some time!
Livingroom: 65" Panasonic Plasma, Denon AVR-x3300w, Parasound A31, Fronts: RBH SX-6300 Towers, Center: RBH 441-se, Surrounds: RBH 41-se Sub: Dual SVS PC13-Ultra, Source: Custom Kodi Box
Desk: DAC: Schiit Modi Multibit,Headphones: Schiit Jotunheim -> Sennheiser HD650 & Beyerdynamic DT770 Pro, Speakers: Parasound 275v2-> RBH 41-se & SVS SB12-NSD
Reply
#12
I'm neither a programmer nor very good at writing scripts, but I THINK this should do the trick:

Code:
#!/bin/bash

if [ $# -ne 2 ];then
  echo "Usage: `basename $0` idVendor idProduct"
  exit 1
fi

for X in /sys/bus/usb/devices/*; do
    if [ "$1" == "$(cat "$X/idVendor" 2>/dev/null)" -a "$2" == "$(cat "$X/idProduct" 2>/dev/null)" ]
    then
        y="echo enabled > $X/power/wakeup"
        echo $y
        eval "$y"
    fi
done

...at least as long as it is not run on a system with two or more identical USB devices. No idea what might happen then...
Livingroom: 65" Panasonic Plasma, Denon AVR-x3300w, Parasound A31, Fronts: RBH SX-6300 Towers, Center: RBH 441-se, Surrounds: RBH 41-se Sub: Dual SVS PC13-Ultra, Source: Custom Kodi Box
Desk: DAC: Schiit Modi Multibit,Headphones: Schiit Jotunheim -> Sennheiser HD650 & Beyerdynamic DT770 Pro, Speakers: Parasound 275v2-> RBH 41-se & SVS SB12-NSD
Reply
#13
(2016-06-18, 22:33)mattlach Wrote: I'm neither a programmer nor very good at writing scripts, but I THINK this should do the trick:

Code:
#!/bin/bash

if [ $# -ne 2 ];then
  echo "Usage: `basename $0` idVendor idProduct"
  exit 1
fi

for X in /sys/bus/usb/devices/*; do
    if [ "$1" == "$(cat "$X/idVendor" 2>/dev/null)" -a "$2" == "$(cat "$X/idProduct" 2>/dev/null)" ]
    then
        y="echo enabled > $X/power/wakeup"
        echo $y
        eval "$y"
    fi
done

...at least as long as it is not run on a system with two or more identical USB devices. No idea what might happen then...

And it's a success.

Now I just have to figure out where this mystical rc.local is, and add the commands to it.
Livingroom: 65" Panasonic Plasma, Denon AVR-x3300w, Parasound A31, Fronts: RBH SX-6300 Towers, Center: RBH 441-se, Surrounds: RBH 41-se Sub: Dual SVS PC13-Ultra, Source: Custom Kodi Box
Desk: DAC: Schiit Modi Multibit,Headphones: Schiit Jotunheim -> Sennheiser HD650 & Beyerdynamic DT770 Pro, Speakers: Parasound 275v2-> RBH 41-se & SVS SB12-NSD
Reply
#14
(2016-06-18, 22:48)mattlach Wrote:
(2016-06-18, 22:33)mattlach Wrote: I'm neither a programmer nor very good at writing scripts, but I THINK this should do the trick:

Code:
#!/bin/bash

if [ $# -ne 2 ];then
  echo "Usage: `basename $0` idVendor idProduct"
  exit 1
fi

for X in /sys/bus/usb/devices/*; do
    if [ "$1" == "$(cat "$X/idVendor" 2>/dev/null)" -a "$2" == "$(cat "$X/idProduct" 2>/dev/null)" ]
    then
        y="echo enabled > $X/power/wakeup"
        echo $y
        eval "$y"
    fi
done

...at least as long as it is not run on a system with two or more identical USB devices. No idea what might happen then...

And it's a success.

Now I just have to figure out where this mystical rc.local is, and add the commands to it.

Success.

Here's what I did, if anyone in the future reads this and needs help:

I enabled rc.local (only needed on 16.04 and newer, due to systemd) with the following command:

Code:
sudo systemctl enable rc-local.service

Then I copied my script above into /root/wakeup_basename.sh and made it executable using "chmod 755 wakeup_basename"

then I edited /etc/rc.local and added my script for each device I want to be able to use to wake the system from suspend:

Code:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
/root/wakeup_basename.sh 05e3 0608
/root/wakeup_basename.sh 1784 0011
/root/wakeup_basename.sh 046d c52b
exit 0

I added three, as I need my remote, my logitech keyboard/trackpad combo and the USB hub they are connected to to be enabled for wakeup. (obviously edit the above to match the devices you need from lsusb)
Livingroom: 65" Panasonic Plasma, Denon AVR-x3300w, Parasound A31, Fronts: RBH SX-6300 Towers, Center: RBH 441-se, Surrounds: RBH 41-se Sub: Dual SVS PC13-Ultra, Source: Custom Kodi Box
Desk: DAC: Schiit Modi Multibit,Headphones: Schiit Jotunheim -> Sennheiser HD650 & Beyerdynamic DT770 Pro, Speakers: Parasound 275v2-> RBH 41-se & SVS SB12-NSD
Reply

Logout Mark Read Team Forum Stats Members Help
Ubuntu 16.04: Wake on USB?0