Archive

Quick guide to saving power with USB devices

I have a laptop with some USB stuff built in. Some devices (such as Bluetooth) can be made to entirely disappear from the USB bus, however, the fingerprint reader and webcam can't, but they sit on the USB bus and draw power. Fortunately the USB specs allow devices to be put to sleep if they're not being used and support that feature. Unfortunately many devices advertise they support it when they really don't, so Linux is unable to automatically put every USB device to sleep. Fortunately you can control the setting by hand, and this is how. Firstly, start off with a Terminal and run the command "lsusb":

cmsj@kodachi:~$ lsusbBus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hubBus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hubBus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hubBus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hubBus 002 Device 002: ID 0483:2016 SGS Thomson Microelectronics Fingerprint ReaderBus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hubBus 004 Device 002: ID 17ef:4807 LenovoBus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hubBus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hubcmsj@kodachi:~$ You can ignore the "root hub" entries, the interesting two are "SGS Thomson Microelectronics Fingerprint Reader" (guess which device that is ;), and "Lenovo" (this is the webcam). So now we need to poke at those devices to enable their autosleeping. If we look at the entry for the webcam:

Bus 004 Device 002: ID 17ef:4807 Lenovo

I've highlighted "4807". This is the Product value for this USB device (if you're curious, the "17ef" part is the Vendor value and uniquely identifies the maker of this device). Now we need to find out where abouts the webcam lives in the /sys/ filesystem (which is something the kernel provides to give applications lots of information about the hardware in your system). The following command will put us on the right path:

grep 4807 /sys/devices/*/*/usb*/*/idProduct

Which, on my laptop, returns:

/sys/devices/pci0000:00/0000:00:1d.7/usb4/4-5/idProduct:4807

Take that information you get, and chop the "idProduct:4807" bit off the end, just leaving "/sys/devices/pci0000:00/0000:00:1d.7/usb4/4-5/" (yours will look a little different to this) and add "power/level" to the end. You should now have something that looks pretty much like "/sys/devices/pci0000:00/0000:00:1d.7/usb4/4-5/power/level" and if you get the current setting:

cmsj@kodachi:~/Desktop$ cat /sys/devices/pci0000:00/0000:00:1d.7/usb4/4-5/power/level
on
cmsj@kodachi:~/Desktop$

you can see it is "on", which means it will not be automatically put to sleep. To change that, run:

echo "auto" | sudo tee /sys/devices/pci0000:00/0000:00:1d.7/usb4/4-5/power/level

and test if your device still works (so if it's a webcam, fire up "cheese", or if it's a fingerprint scanner that you use, test if it still accepts your finger). If everything is good then you can put something in /etc/rc.local so the power saving will be set up every time you reboot your computer:

echo "auto" > /sys/devices/pci0000:00/0000:00:1d.7/usb4/4-5/power/level

and that's it! Repeat this for all the USB devices in your laptop and enjoy the power saving (run "powertop" about 10 minutes before you start doing this so it has time to get a good average of your power usage, then see how much difference this makes. It could be up to 0.5Watts per device). Note that this won't work particularly well for external USB devices you plug in, becuase the /sys/ path won't exist until you plug the device in, so you'd need to do the above steps every time you connect it. Hopefully HAL will start whitelisting devices which can be suspended, but I don't know of any work in this direction at the moment.


Ubuntu 8.10 (Intrepid) power performance

In one word: wow. Out of sheer curiosity last night I fired up the excellent powertop and decided to see how my system was doing. It was producing a couple of hundred fewer interrupts per second than it did in 8.04 (Hardy), and was using 1-2Watts less power. Previously I have always resisted applying tweaks to my laptop that would attempt to reduce power, but since things were improving, the temptation was simply too great and I started digging out all the resources on this (by far the most useful being the tips on Intel's grammatically horrific http://www.lesswatts.org/. I had two reasons for not doing this previously - firstly I didn't want to deviate too much from a default install of Ubuntu (if only because it makes it much harder to reproduce bugs), but secondly I kept running into little weirdnesses. The most inconvenient of these was enabling AHCI link power management (which basically puts the hard disk bus to sleep when there is no IO); Enabling this and then suspending the laptop produced a 5 second delay on resuming because the kernel was forgetting it had put the bus to sleep and so had to wait for it to time out and be reset. This particular niggle is fixed in 2.6.27 and so my 3-4 second resume times are preserved and I can save power! \o/ After a little while tweaking disk, AHCI, USB, filesystem, wireless, sound and ethernet options I ended up with a system which runs between 8 and 9 Watts when idle, down from 10-14 Watts, which I think is a pretty impressive saving and I'm very curious to find out from other Thinkpad X300 owners how well Windows performs in the power usage stakes - we always hear that Linux is a bit worse, but I'd be really quite surprised if the machine can run with very much less - it's spending (when idle, obviously) 99% of its time in the deepest processor sleep state and is only generating about a hundred interrupts per second (about 70-80% of which are due to my using a 3D desktop and wireless).


Terminator 0.11 released!

Head over to the Terminator Homepage to get the goodness that is version 0.11. Mostly just bugfixes this time, for things which hurt 0.10 users. Also present is support for X Session Management, although until we have proper profiling support, this is of limited use. The source tarball is up, of course, and the Hardy/Intrepid PPAs should have packages by the time you read this.


Terminator 0.11 released!

The only new feature this time is X Session Management support, but there are also a few important bug fixes for things that crept into 0.10, and some updated/new translations.


Script for funky SSH titles in GNU Screen

I just uploaded a script that I've been using and refining for some while, with help from a variety of people too numerous to mention. Basically the deal is that when you ssh somewhere from inside a GNU Screen session, the screen's title is set to the hostname you ssh'd to. Simple. The page for the script is here


Terminator 0.10 released

It's been a week or so shy of two months since we pushed 0.9 out of the door and originally we planned on following up with a 0.9.1 release shortly after to clear up some bugs, but for a variety of not particularly good reasons this never happened. Instead we've got a new release for you... 0.10. It doesn't have any shiny whizz-bang features like 0.9 had, but it does bring a bunch of bug fixes and the groundwork necessary for our 1.0 release. As usual, head over to the homepage, or Launchpad to get the goodness.


Terminator 0.10 released!

Another release rolls in and this time it's not very exciting for you, but we have a bunch of bug fixes and the groundwork of the config/layout editing/saving work we want to do for 1.0. Please let us know if you find any bugs in this.


Software fail

Update: It has been suggested that it is not productive or collaborative to talk negatively about some developers releasing software for unixy operating systems without really trying to integrate it with the versions of widely deployed software available in those operating systems. It is a fair point. It's not productive or collaborative. It may be true, but ranting about it doesn't help anyone but me. More productive and collaborative would be to nicely ask these ISVs to establish a less isolated packaging process with our communities and companies (but I don't mean LSB or a new package format). Clearly some people won't work with them on ethical grounds, but a more pragmatic position will accept that commercial software exists, so it might as well not make our lives unnecessarily hard. And the companies shifting Linux are hot on ISVs. Jorge: No, I don't like having multiple JVMs, but I have been in corporate situations before where it has been necessary because specific applications have required different versions :(


Iphone shortcomings

There's no doubting that the iphone is a hugely capable machine. It's powerful yet easy to use, but it's not perfect. Here are some things which I think are missing: * DAAP - it would be great to be able to play music via wifi since the thing is a bit low on storage. * Background apps - I understand the huge problems implied by this, but certain apps could be blessed with the ability. Either that or the excellent last.fm client should be integrated with the iPod app. Not everything can be made a push app (the api for which isn't even available yet) * IMAP subscriptions - I have loads of mail folders I don't want to see, which is dead easy in most mail clients, because of the ability to only subscribe to certain mailboxes. I would like to see this in the iPhone mail client. * IMAP new mail checking - I don't have all my new mail go to my inbox, some gets filtered to other folders an I would like to be able to tell the mail client to check these too.


More iphone

Still liking this excellent toy. I have now had most of the commonly seen bugs, and a couple of crashes, which sucks, but my N95 was pretty unstable too, and not even slightly as nice!