Friday, November 9, 2007

Adding power management to the Eee PC

Update: It's not particularly clear that mucking with the Eee PC's clock speed actually does anything to improve battery life. So consider everything that comes below to be an intellectual exercise.

Original Post: The Asus Eee PC uses a relatively low power 900 MHz Celeron processor to help cut down on costs and to help prolong battery life. Unlike newer Pentium chips, Celeron processors don't include SpeedStep technology, which means you generally don't get advanced power management features. But while you can't configure the Eee PC's processor to alter its voltage, you can alter the processor frequency, which should theoretically prolong your battery life.

SmallFootprint over at Eee User wrote up some great instructions for turning on CPU scaling using a command line process. I figured there was no way I was going to remember that command though, so I wanted to create some shortcuts to put in my start menu. Here's how I did it.

There are three commands you need to know:
  1. "echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" will turn on CPU scaling (which will automatically adjust your CPU speed from 112.5 to 900 MHz depending on your work load).
  2. "echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" will return you to full performance mode (where your CPU will run at 900 MHz all the time).
  3. "cat /proc/cpuinfo" will show you what your current CPU speed is.
You can type any of these commands into a terminal. You may need to type "sudo" at the start of each command so that your command will have root privileges. Or you might want to type "sudo bash" to bring up a root terminal so that you shouldn't have to type "sudo" before each command.

In order to add these commands to my start menu, I first created two executable files:
  1. Open File Manager
  2. Navigate to your Home/User folder or whatever folder you want to put these files in.
  3. Right click in the File Manager and select "Create New" and then "Text File."
  4. I named the first "Power Saver," and the second "Performance."
  5. Open up the first file using the Kate text editor by double-clicking on the file. Later, we'll make these files executable, so you'll need to right-click and select "open with text editor" to edit them.
  6. Enter "echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" (without the quotes) in your power saver file.
  7. Click Save and Exit.
  8. Enter ""echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" in your performance file.
  9. Click Save and Exit.
Now you'll want to make the files executable:
  1. Right-click on a file and select Properties
  2. Select the Permissions tab
  3. Make sure the box that says Exec is checked. For good measure, I check the boxes under Owner, Group and Others. I'm not sure is you need to click all three, but I don't think it hurts.
  4. Repeat the process with your other file.
Now you should be able to double-click on a file to execute it. To check and see if it worked, bring up a console and type "cat /proc/cpuinfo" and check the CPU speed. You might need to type this a few times to be certain. In power saver mode, you will sometimes get a 900MHz report, especially if you've just executed a series of commands.

Before adding the items to my start menu, I decided to hide them so I won't see them all the time and accidentally delete or modify them. All you have to do to make these hidden files is right-click the file, select "rename" and place a "." before each file. Now in order to see them you'll have to select "show hidden files" from the File Manager.

Okay, next up let's bring up the menu editor by selecting Applications/System/Menu Editor from the start menu. Select the folder you want to place the new icons in and either create a new item or a new subfolder from the File Menu. I decided to add my files to a new folder called Applications/System/CPU Speed.

Here's how to create your new shortcut:
  1. Type a name into the name field, and a description into the description field if you like.
  2. Click the folder icon next to the Command box and a window will pop up that lets you browse to find your executable files. If you've hidden them, you'll have to right-click on the white part of the window and select "show hidden files."
  3. Click on the icon section next to Name and Description and look through the system icons to see if you like any. You don't really need an icon, but it makes your start menu look prettier.
Now you should have a start menu that looks something like this:

When you select Power Saver or Performance, a little hourglass should pop up in your taskbar. It takes a few moments for the changes to kick in, which is odd because they're almost instantaneous in command line mode. But I think this solution is still a lot more convenient.

Note that when you reboot your PC, you will always wind up back in performance mode. But I'm pretty certain someone at the Eee User forum will come up with a way to fix that soon. And I haven't been using the new power saving trick long enough to know what if any impact it has on battery life. I'll keep you posted.

Update: OK, there seems to be a flaw in my brilliant plan. In order for the shortcuts to work, you need to make sure that scaling_governor is executable. I figured that doing this once would be enough. But it turns out that when you reboot your Eee PC, you have to reenable executable access. I'll let you know if I come up with a solution. Or if anyone has a better idea for creating a working power management shortcut, let me know.

3 comments:

Anonymous said...

Is /etc/init.d/rc.local and /etc/rc.local avaible ? Put your script into one of them .

eeehk said...

Changing the CPU freq in this way makes no difference to the power draw - I tested it out by monitoring the current (using a lab benc power supply) and found that the current, with wireless off and screen on dimmest brightness, was about 1.09 amps for both 112.5MHz and 900MHz apparent CPU frequency.

eeehk said...

Changing the CPU freq in this way makes no difference to the power draw - I tested it out by monitoring the current (using a lab benc power supply) and found that the current, with wireless off and screen on dimmest brightness, was about 1.09 amps for both 112.5MHz and 900MHz apparent CPU frequency.

acelebration of womens khong familys mi sitios de diseno my site cheap technology museum planners new cesar dubo weddings and hair styles sim flecks iphones chile new phones blog