Page 1 of 5 123 ... LastLast
Results 1 to 10 of 43

Thread: HOWTO: Extend the Life of Your Thinkpad's Battery (tp_smapi)

  1. #1
    Join Date
    Jul 2007
    Location
    Austin, TX (formerly D.C)
    Beans
    359
    Distro
    Ubuntu 10.04 Lucid Lynx

    HOWTO: Extend the Life of Your Thinkpad's Battery (tp_smapi)

    ** EDIT: With newer versions of Ubuntu, the procedure for installing tm_smapi has gotten much easier. See Thinkwiki. Do not follow the instructions to the letter anymore... This thread is probably only useful for historical reference, debugging, and for motivating the problem. **

    You may or may not be aware that lithium ion batteries (like those present in the newer Thinkpad models) survive best when kept charged between 30%-85%. They should not be kept fully charged, and should be left off for long periods of time charged to ~%40. See here for more tips on Thinkpad battery treatment.

    One way to extend the life of your Thinkpad's battery is to control the way it charges -- that is, to make sure that you keep it in the 30%-85% charged range whenever possible. This is possible easily and quickly through the tp_smapi kernel module.

    Installing the tp_smapi Module:

    (1) Download the tp_smapi code here. For the examples presented here, let's assume that you download the tarball to your home directory (~/):

    Code:
     wget http://superb-east.dl.sourceforge.net/sourceforge/tpctl/tp_smapi-0.39.tgz ~/tp_smapi-0.39.tgz
    (2) Make sure that you have the necessary pre-requisites installed. You must have the necessary compiler and build tools (build-essentials), and the kernel source code for your kernel (linux-source-`uname -r`). For the example below, it is assumed that you are using the newest kernel in the repository:

    Code:
    sudo aptitude install build-essential linux-source-`uname -r`
    (2b) If you haven't gotten and extracted the kernel source code before, goto /usr/src, and extract the kernel source you got from the above step (which should be in a file called linux-source-2.6.2x.tar.bz2):

    Code:
    sudo -s
    cd /usr/src
    tar -xjf linux-source-2.6.2x.tar.bz2
    This should extract the source to linux-source-2.6.2x. Be patient... decompressing bzip2 files takes forever! (If you'd care to speed it up, however, there is a program in the Ubuntu repositories called pbzip2 which can decompress it with multiple threads, taking advantage of both CPU cores.)

    (2c) Now go into /lib/modules/`uname -r`. Both the "build" and "source" symbollic links should point to your source folder. You can check this by observing the output of ln -l, or just create it this way with the following:

    Code:
    sudo -s
    rm -i /lib/modules/`uname -r`/source /lib/modules/`uname -r`/build
    ln -s /usr/src/linux-source-2.6.22 /lib/modules/`uname -r`/source
    ln -s /usr/src/linux-source-2.6.22 /lib/modules/`uname -r`/build
    (3) Extract the tp_smapi code:

    Code:
    tar -xzf ~/tp_smapi-0.39.tgz
    (4) Change to the new directory, make and install tp_smapi:

    Code:
    cd tp_smapi-0.39 && make && sudo make install
    Should you want to use HDAPS (the IBM Active Protection System Linux Drive) in the future, include the HDAPS module in your build:

    Code:
    cd tp_smapi-0.32 && make && sudo make install HDAPS=1
    (5) Make sure that the tp_smapi module is loaded upon startup:

    Code:
    sudo -s;
    echo "tp_smapi" >> /etc/modules
    (6) Now reboot, or load the tp_smapi module:

    Code:
    sudo modprobe tp_smapi
    (7) To set the charge thresholds, edit the following files:

    /sys/devices/platform/smapi/BAT0/start_charge_thresh
    /sys/devices/platform/smapi/BAT0/stop_charge_thresh
    For example, to keep the charge constantly varying between 30 and 85% while plugged into AC, use the following commands:

    Code:
    sudo -s;
    echo "30" > /sys/devices/platform/smapi/BAT0/start_charge_thresh;
    echo "85" > /sys/devices/platform/smapi/BAT0/stop_charge_thresh;
    This may interfere with your ACPI battery charge reports, since it will technically report "charged" at 30% battery (even though it will continue to cycle between 30 and 85 while plugged in). Thus, for those who use a system monitor (such as Conky or GKrellM), the following may be a more practical solution:

    Code:
    sudo -s;
    echo "81" > /sys/devices/platform/smapi/BAT0/start_charge_thresh;
    echo "85" > /sys/devices/platform/smapi/BAT0/stop_charge_thresh;
    This will keep the charge below 85% when charged.

    Making the Change Permanent:


    Once it seems that you have charge control working on your laptop, it is possible to make the thresholds permanent. The way that I would recommend to do this is to use the sysfsutils, which should keep the battery set without any nastiness. To do so:

    (1) install sysfsutils, if they are not already installed
    Code:
    sudo aptitude install sysfsutils
    (2) add the appropriate lines to the end of /etc/sysfs.conf in the following format:

    Code:
    device=value
    For example, my sysfs.conf contains the following lines:

    Code:
    devices/platform/smapi/BAT0/start_charge_thresh=81
    devices/platform/smapi/BAT0/stop_charge_thresh=85
    Hope this helps! Please let me know if you have any problems.

    Mike

    Version History:
    1.0 (September, 2007) - Initial Post
    1.1 (November, 2008) - Updated Version Numbers and Added Permanent Insts
    1.2 (March, 2011) - Added disclaimer to top (deprecated)
    Last edited by mbsullivan; February 28th, 2011 at 07:42 PM.

  2. #2
    Join Date
    Oct 2007
    Location
    Germany
    Beans
    46

    Re: HOWTO: Extend the Life of Your Thinkpad's Battery (tp_smapi)

    Hi,

    do you know how you can make the settings permanent? After i remove the battery/unplug the cord they're gone.

    Greetings,
    Alex
    Last edited by t.alex; January 26th, 2008 at 08:40 PM.

  3. #3
    Join Date
    Jan 2008
    Beans
    1

    Re: HOWTO: Extend the Life of Your Thinkpad's Battery (tp_smapi)

    I keep receiving error message while trying to make and install tp_smapi:

    Code:
    sudo make install tp_smapi
    Makefile:25: *** This driver requires kernel 2.6.19 or newer, and matching kernel sources. 
    You may need to override KVER=2.6.22-14-generic or KSRC=/lib/modules/2.6.22-14-generic/source
     or KBUILD=/lib/modules/2.6.22-14-generic/build or
     MOD_DIR=/lib/modules/2.6.22-14-generic/kernel.  Stop.

    As far as I know I fulfilled any requirements mentioned in wiki page of the project - The outcome of suggested steps is as follows:

    1) apt-get install build-essential
    Code:
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    build-essential is already the newest version.
    0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    2) kernel version:
    Code:
    uname -r
    2.6.22-14-generic
    3) sources:
    Code:
    sudo apt-get install linux-source-2.6.22
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    linux-source-2.6.22 is already the newest version.
    0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded
    4) make & install:
    Code:
    sudo make install tp_smapi
    Makefile:25: *** This driver requires kernel 2.6.19 or newer, and matching kernel sources. 
    You may need to override KVER=2.6.22-14-generic or
     KSRC=/lib/modules/2.6.22-14-generic/source or
     KBUILD=/lib/modules/2.6.22-14-generic/build or
     MOD_DIR=/lib/modules/2.6.22-14-generic/kernel.  Stop.

    Also, the solution of above problem listed in wiki does not help:
    If you get an error that the kernel version isn't matching (or that you need to set KSRC/KBUILD), please check that there is a symlink from the modules dir to the kernel source


    And the proper symlink exists:
    Code:
     ls -l /lib/modules/2.6.22-14-generic
    total 1736
    lrwxrwxrwx  1 root root     40 2007-10-20 23:10 build -> /usr/src/linux-headers-2.6.22-14-generic
    drwxr-xr-x  2 root root   4096 2007-12-19 21:30 initrd
    drwxr-xr-x 10 root root   4096 2007-10-20 23:06 kernel
    drwxr-xr-x  2 root root   4096 2007-11-24 14:19 madwifi
    -rw-r--r--  1 root root 365097 2007-12-19 21:31 modules.alias
    -rw-r--r--  1 root root     69 2007-12-19 21:31 modules.ccwmap
    -rw-r--r--  1 root root 398630 2007-12-19 21:31 modules.dep
    -rw-r--r--  1 root root    813 2007-12-19 21:31 modules.ieee1394map
    -rw-r--r--  1 root root    527 2007-12-19 21:31 modules.inputmap
    -rw-r--r--  1 root root  17714 2007-12-19 21:31 modules.isapnpmap
    -rw-r--r--  1 root root     74 2007-12-19 21:31 modules.ofmap
    -rw-r--r--  1 root root 272826 2007-12-19 21:31 modules.pcimap
    -rw-r--r--  1 root root   1345 2007-12-19 21:31 modules.seriomap
    -rw-r--r--  1 root root 170462 2007-12-19 21:31 modules.symbols
    -rw-r--r--  1 root root 481106 2007-12-19 21:31 modules.usbmap
    lrwxrwxrwx  1 root root     28 2008-01-25 20:05 source -> /usr/src/linux-source-2.6.22
    drwxr-xr-x 10 root root   4096 2007-10-20 23:06 ubuntu
    drwxr-xr-x  2 root root    380 2008-01-26 19:30 volatile

    So, it seems that everything should work fine, but it is not.

    I would appreciate any help.

  4. #4
    Join Date
    Jan 2008
    Beans
    33

    Re: HOWTO: Extend the Life of Your Thinkpad's Battery (tp_smapi)

    Quote Originally Posted by t.alex View Post
    Hi,

    do you know how you can make the settings permanent? After i remove the battery/unplug the cord they're gone.

    Greetings,
    Alex

    Hi,

    I have the same problem and cant find any solution on the internet. If anybody had an idea i would love to hear about it!

  5. #5
    Join Date
    Aug 2007
    Beans
    4

    Smile Re: HOWTO: Extend the Life of Your Thinkpad's Battery (tp_smapi)

    Great How-to!

    Just out of curiosity, what kind of thinkpad do you have?

    Mine is a T61 and your how-to would be a great addition to the thinkwiki ubuntu install guide as this is not even mentioned there.

    http://www.thinkwiki.org/wiki/Instal...a_ThinkPad_T61

  6. #6
    Join Date
    Mar 2005
    Location
    Texas
    Beans
    1,675
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: HOWTO: Extend the Life of Your Thinkpad's Battery (tp_smapi)

    To make it use the settings, I made a script called battery.sh in the /etc/acpi directory with this in it:
    Code:
    echo 90 > /sys/devices/platform/smapi/BAT0/stop_charge_thresh
    echo 85 > /sys/devices/platform/smapi/BAT0/start_charge_thresh
    I made that executable, and then in the directories ac.d, battery.d, resume.d and start.d I did:
    Code:
    ln -s /etc/acpi/battery.sh 41-battery.sh
    Its kind of quick and dirty, but works great so far.
    100 buckets of bits on the bus,
    100 buckets of bits,
    Take one down, short it to ground,
    FF buckets of bits on the bus.

  7. #7
    Join Date
    Jul 2007
    Location
    MPLS
    Beans
    64
    Distro
    Ubuntu 7.04 Feisty Fawn

    Re: HOWTO: Extend the Life of Your Thinkpad's Battery (tp_smapi)

    Quick question-- I'm pretty stupid with batteries, but just out of curiosity, doesn't a battery(rechargeable) have a limited number of recharges? Like my Nintendo DS, reading the manual, I believe it has a li-ion battery, and it says it's good for about 500 charges... So wouldn't the cycling between ~30%-85% be bad for it while plugged in?

    Because, in essence, you are discharging it and charging it while plugged in, if that's what I'm reading...

    So wouldn't that reduce the number of full cycles that it's chargeable, effectively reducing the life of the battery?

    Just curious-- As I said, I'm pretty new to all this technology. (For being 18 years old and living in US, that's saying something. Heck, I just got a secondhand iPod a few weeks ago.)

    And, thirdly, but not lastly, would this work on any laptop, if it doesn't reduce said cycles of battery?

    Thanks for any feedback, I may start a new thread with a link to this if noone answers, just to see what the responses are.

    Lastly-- Does anyone have any ideas on how to reduce wakeups/second from acpi, kernel IPI, and kernel core? I get about 60 wakeups per second from those three processes(?) alone... I think that if I can reduce them, I can increase my battery life significantly as well.


    P.S.-- System specs. Acer Aspire 5630-6188 (kickbutt budget computer) with a 160 GB hd, Pentium Core 2 Duo Centrino 1.66 Ghz(usually in the 1000mhz range... ) 2 gigs of RAM, dvd-rw/ram drive-- After following all the recommendations in powertop, it still continues to have about 60-70 wakeups per second when not using the mouse.

    C3 state does manage to get to around 17 ms and 99.2% of the time it's in C3, however, I think it would be a lot longer without said interrupts.

    Thanks!!
    HP Mini 110 series w/10.04 32-bit

  8. #8
    Join Date
    Dec 2007
    Location
    Belgium
    Beans
    185

    Re: HOWTO: Extend the Life of Your Thinkpad's Battery (tp_smapi)

    Would this work on non-Thinkpad notebooks with lithium ion batteries?
    [Configuration files]
    Linux IS user-friendly, it's just picky about its friends.

  9. #9
    Join Date
    Mar 2005
    Location
    Texas
    Beans
    1,675
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: HOWTO: Extend the Life of Your Thinkpad's Battery (tp_smapi)

    Well, its not just the number of cycles that determines how long it will last. In general, fully charging it or fully draining is bad, with fully draining being more of a problem. IIRC, it causes chemical changes within the battery that reduce its capacity.

    I doubt the tp_smapi module will work on any laptop, but I wouldn't be surprised if these kinds of features were available on other laptops. You'll probably just have to spend some time with google to figure it out.
    100 buckets of bits on the bus,
    100 buckets of bits,
    Take one down, short it to ground,
    FF buckets of bits on the bus.

  10. #10
    Join Date
    Jul 2007
    Location
    Austin, TX (formerly D.C)
    Beans
    359
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: HOWTO: Extend the Life of Your Thinkpad's Battery (tp_smapi)

    Hey Everybody,

    Sorry for not responding before... this HOWTO was posted a while ago!

    Hi,

    do you know how you can make the settings permanent? After i remove the battery/unplug the cord they're gone.

    Greetings,
    Alex
    There are a number of ways to do it, such as the script that Whiffle created. As some of you are discovering, virtual file system devices don't tend to stay the way you set them, and scripts might not be the best way to keep them set (although making it an ACPI script will keep re-enabling it, so it's a start)!

    The way that I would recommend to do this is to use the sysfsutils, which are made for things handling sysfs devices, and thus will keep the battery set without any nastiness. To do so:

    (1) install sysfsutils, if they are not already installed
    Code:
    sudo aptitude install sysfsutils
    (2) add the appropriate lines to the end of /etc/sysfs.conf in the following format:

    Code:
    device=value
    For example, my sysfs.conf contains the following lines:

    Code:
    devices/platform/smapi/BAT0/start_charge_thresh=81
    devices/platform/smapi/BAT0/stop_charge_thresh=85
    This is also the appropriate place to set your CPU governor, for those of you who use speedstep.

    Would this work on non-Thinkpad notebooks with lithium ion batteries?
    Nope, sorry. As Whiffle said, there very well may be a way to do it on your laptop, though.

    Just out of curiosity, what kind of thinkpad do you have?
    I have an x61... I've really been meaning to fix up the thinkwiki pages, but sometimes they're really quite messy. The information's free if anybody should want to put it there!

    So, it seems that everything should work fine, but it is not.

    I would appreciate any help.
    Hmmm... it looks like everything's okay. Are you sure that the Linux source directory has been un-tar-bz2ed? i.e. /usr/src/linux-source-2.6.22 exists, and not just /usr/src/linux-source-2.6.22.tar.bz2?

    Quick question-- I'm pretty stupid with batteries, but just out of curiosity, doesn't a battery(rechargeable) have a limited number of recharges? Like my Nintendo DS, reading the manual, I believe it has a li-ion battery, and it says it's good for about 500 charges... So wouldn't the cycling between ~30%-85% be bad for it while plugged in?

    Because, in essence, you are discharging it and charging it while plugged in, if that's what I'm reading...

    So wouldn't that reduce the number of full cycles that it's chargeable, effectively reducing the life of the battery?
    The real limit on the life of lithium-ion batteries is not the number of times they have been charged, but rather the fact that they age over time. Even if not used, the battery will eventually die. That being said, there are some things that you should do to extend the life of your battery. These include:

    (1) Avoid keeping at maximum voltage for extended periods of time, which leads to corrosion, especially at elevated temperatures (such as in a running laptop).

    (2) Avoid storing the battery while in a depleted state, which can shorten battery life.

    (3) Store the battery at cool temperatures, charged to ~40%.

    So... keeping the battery charged between ~20-30% and ~80% won't magically make the battery last forever, but it does make sure that you are within the "safe operating guidelines" as often as possible. See this site if you want to know more than you ever wanted about batteries.

    It's understandable to be confused, because batteries are confusing! Much of this confusion might come from nickel-based batteries, which are subject to memory (requiring full periodic discharges to prevent greatly shortened lifespan) and have a limited number of discharge cycles in them (~1000 for nickel cadmium, less for nickel-metal-hydride). So... if the Thinkpad laptops had nickel-based batteries, tp_smapi definitely would not make much sense. Lithiom-ion and lithium polymer batteries don't have these shortcomings... they just have a limited life span, which can be extended to a certain degree.

    Lastly-- Does anyone have any ideas on how to reduce wakeups/second from acpi, kernel IPI, and kernel core? I get about 60 wakeups per second from those three processes(?) alone... I think that if I can reduce them, I can increase my battery life significantly as well.
    60 wakeups really isn't that bad... you could always halt the acpi daemon (acpid) from running if it's driving you that crazy, but it may seriously hamper the functionality of your laptop. There are kernel options that will reduce power usage (tickless timer, etc), but if you're not rolling your own, they're probably already as good as you're gonna get. The kernel will keep requiring fewer wakeups in the future, I'm sure. Have you tried other tweaks, such as putting your Wifi card in low-power mode, etc?

    Hope this helps!
    Mike
    Last edited by mbsullivan; February 7th, 2008 at 03:39 AM.

Page 1 of 5 123 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •