Enabling suspend/resume with XBMC in Ubuntu 9.10

Had issues after upgrading to Karmic with suspend/resume on my media box (Shuttle SN78S) where the system would suspend and then immediately resume (xbmc forum thread). After ruling out the nvidia blob as the culprit (my usual suspect), I did a bit more digging and found people able to make it work by disabling usb autosuspend but that didn’t make a difference at all for me. I did find some older documentation pointing to an oddity with the ehci driver and acpi wakeup causing this issue so I disabled it (via /proc/acpi/wakeup) and was able to suspend successfully. Wakeup via WOL succeeded as well, but not being able to resume via remote is a showstopper for me so I poked a bit more and enabled wakeup only for the USB device my remote sensor was attached to and voila!

To determine the USB device:

[email protected]:~#lsusb
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 002: ID 1784:0008 TopSeed Technology Corp.
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

In this case it’s easy as my remote sensor is the only device attached and it’s on bus 004.


[email protected]:~#cat /proc/acpi/wakeup |grep ^USB
USB0 S3 disabled pci:0000:00:02.0
USB1 S3 enabled pci:0000:00:04.0
USBB S3 disabled pci:0000:00:04.1
USB2 S3 disabled pci:0000:00:02.1

Now I have both the USB1 and USBB devices that show up on 04, but USB1 is the first so that was the one I enabled via:
echo "USB1" > /proc/acpi/wakeup

To make it persistent I added the following to /etc/rc.local (the ethtool command enables WOL and isn’t needed unless you want to wake your machine over the network):

# Enable wakeup for the remote
status=`cat /proc/acpi/wakeup | grep "USB1" | awk {'print $3}'`
if [ "$status" = "disabled" ]; then
echo "USB1" > /proc/acpi/wakeup
fi

/usr/sbin/ethtool -s eth0 wol g > /dev/null

The only other step I took was to work around the standard lirc borkage by disabling lirc and unloading the modules. This requires two files:
/etc/pm/config.d/01lirc_module

SUSPEND_MODULES="lirc_mceusb lirc_dev"

/etc/pm/sleep.d/10-lirc (must be executable, requires installing curl – apt-get install curl)

#!/bin/sh
# Disconnect XBMC from lirc and stop the daemon

case "$1" in
hibernate|suspend)
service lirc stop
;;
thaw|resume)
service lirc start
;;
*) exit $NA
;;
esac

As of 9.11 alpha 2, XBMC uses ConsoleKit in the Karmic packages so you need to make sure your session gets auth’d properly or you’ll end up with permission denied messages in the xbmc logs when it tries to suspend. If you’re using GDM or KDM it should Just Work. In my case I’m just starting x on tty1 for my xbmc user so I had to update my .xsession file to launch xbmc like so:
ck-launch-session /usr/bin/xbmc --standalone

Edit: As of 9.11 alpha2, XBMC takes care of connecting/disconnecting from the LIRC daemon so no need to do it in the lirc script. Also added info about the new ConsoleKit integration in alpha2.
Edit2: Maverick requires a few other tweaks to work properly, updates are here.

5 thoughts on “Enabling suspend/resume with XBMC in Ubuntu 9.10

  1. Can you explain how you made the leap from:

    “Bus 004 Device 002: ID 1784:0008 TopSeed Technology Corp.” to knowing which USB to enable?

    USB1 S3 enabled pci:0000:00:04.0
    USBB S3 disabled pci:0000:00:04.1

    How do you know your remote receiver is not USBB?

  2. Basically trial and error. I’m sure you could be more precise if you ran lsusb with the verbose flag (-v) and sifted through that output, but in this case I tried the first one and it worked so I didn’t dig any further.

  3. I have a weird one.. Running on stable Karmic-64, with GDM.. Under stock configuration, it will suspend when I press the power button on the remote, but it won’t resume. When I edited rc.local (the only difference being was that my remote is on USB2), rebooted and tried to suspend from within xbmc it wouldn’t suspend at all, so waking up is a moot point. Any ideas? Any help would be appreciated 🙂

  4. Try starting xmbc in debug mode and check the logs to see what’s going on. If you are running xbmc from gdm it should be setting you up under a local session so it should be working. The debug log tho should clarify what’s going on.

  5. How do you keep your device from waking from other IR traffic? My XBMC HTPC is part of my home theater system; and I can’t figure out a way to prevent it from waking from other traffic… assuming I can ever get it to wake properly anyways (I got Suspend and Lirc working, it’s waking and the fear of false waking I’m working on now). I’ve only got USB0 and USB2 listed and neither seem to wake it. Obviously my device is the top one list.

    Bus 002 Device 004: ID 045e:0284 Microsoft Corp. Xbox DVD Playback Kit
    Bus 002 Device 003: ID 045e:00b0 Microsoft Corp. Digital Media Pro Keyboard
    Bus 002 Device 002: ID 046d:c051 Logitech, Inc. G3 (MX518) Optical Mouse
    Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 001 Device 004: ID 0bc2:3101 Seagate RSS LLC
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Leave a Reply