** 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:
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)
Bookmarks