Difference between revisions of "How to use Ultrabay batteries"

From ThinkWiki
Jump to: navigation, search
m (Using ACPI)
(Added a link to my bat balancing gnome applet)
 
(3 intermediate revisions by 2 users not shown)
Line 6: Line 6:
  
 
===Battery hot-swapping===
 
===Battery hot-swapping===
 +
{{NOTE|As of kernel 2.6.27 the standard in kernel ACPI Bay support should be used, and not the thinkpad-acpi provided Bay support. The thinkpad-acpi bay and dock support was removed from the kernel as of 2.6.31 in favour of the standard ACPI bay and dock drivers. With these there is no need any more to first issue a soft eject as hotplug is fully handled in the kernel by the ACPI bay driver.}}
 
Switching between the batteries is almost instant, so if you pull the Ultrabay battery from the bay when it is being discharged, the system will instantly switch to the main battery. You can therefore use the Ultrabay battery to hot-swap the system battery (i.e., replace it without the need to reboot, hibernate or use an external power adapter).
 
Switching between the batteries is almost instant, so if you pull the Ultrabay battery from the bay when it is being discharged, the system will instantly switch to the main battery. You can therefore use the Ultrabay battery to hot-swap the system battery (i.e., replace it without the need to reboot, hibernate or use an external power adapter).
  
Line 18: Line 19:
 
* Use the [[SMAPI support for Linux#Using_the_tp_smapi_module|tp_smapi]] module to control which battery is discharged (via <tt>force_discharge</tt>) or charged (via <tt>inhibit_charge_minutes</tt> on the other battery). This only works on some ThinkPad models - see the [[tp_smapi#Model-specific_status|tp_smapi model-specific status]].
 
* Use the [[SMAPI support for Linux#Using_the_tp_smapi_module|tp_smapi]] module to control which battery is discharged (via <tt>force_discharge</tt>) or charged (via <tt>inhibit_charge_minutes</tt> on the other battery). This only works on some ThinkPad models - see the [[tp_smapi#Model-specific_status|tp_smapi model-specific status]].
  
 +
The following script uses tp_smapi to balance the battery discharging: {{CodeRef|tp-bat-balance}}
  
 +
TPBattStat-Applet is a gnome applet for integrating battery balancing with a graphics and/or text display of both batteries in a panel. Battery balancing improves battery life by not leaving one battery empty while the other discharges.
 +
It has configurable strategies for charging and discharging, and a configurable display in the panel. Its gpl-ed, so as always, use at your own risk.
 +
For the latest alpha release, see https://github.com/teleshoes/tpbattstat-applet
  
 
===Ultrabay eject lever===
 
===Ultrabay eject lever===
Line 32: Line 37:
  
 
====Using ACPI====
 
====Using ACPI====
 
+
{{NOTE|The information provided here is outdated, hotplugged batteries will be automatically detected and used at least as of 2.6.27 kernels using the standard ACPI Bay driver.}}
 
The second battery is correctly detected by the ACPI subsystem (if activated). However, the Linux ACPI subsystem only scans for batteries on boot. This means that the second battery must be present at boot time, or you will not be able to get any info for it via {{path|/proc/acpi/battery/BAT1}}.
 
The second battery is correctly detected by the ACPI subsystem (if activated). However, the Linux ACPI subsystem only scans for batteries on boot. This means that the second battery must be present at boot time, or you will not be able to get any info for it via {{path|/proc/acpi/battery/BAT1}}.
  

Latest revision as of 20:58, 10 February 2011

ThinkPad laptops only charge/discharge one battery at a time. If you have two batteries present (a system battery and an Ultrabay battery), the laptop will completely deplete the Ultrabay battery before using the main battery.

Battery hot-swapping

NOTE!
As of kernel 2.6.27 the standard in kernel ACPI Bay support should be used, and not the thinkpad-acpi provided Bay support. The thinkpad-acpi bay and dock support was removed from the kernel as of 2.6.31 in favour of the standard ACPI bay and dock drivers. With these there is no need any more to first issue a soft eject as hotplug is fully handled in the kernel by the ACPI bay driver.

Switching between the batteries is almost instant, so if you pull the Ultrabay battery from the bay when it is being discharged, the system will instantly switch to the main battery. You can therefore use the Ultrabay battery to hot-swap the system battery (i.e., replace it without the need to reboot, hibernate or use an external power adapter).

You should issue # echo eject > /proc/acpi/ibm/bay before removing the battery from the bay, especially if you are replacing it with a different device (requires thinkpad-acpi). See How to hotswap Ultrabay devices.

Charging and discharging

When charging, the system will completely charge the main battery before it starts on the Ultrabay battery. However, if you change a full main battery for an empty one, the system will finish charging the ultrabay battery before charging the second main battery.

When discharging, the system will completely discharge the Ultrabay battery before it discharges the main battery. This greatly reduces the lifetime of the Ultrabay battery, and also reduces its usefulness for enabling hot-swapping of the system battery. There are two ways to prevent this:

  • Keep an eye on the charge in the Ultrabay battery and physically remove it from the bay when it gets too low (or release the eject lever- see below).
  • Use the tp_smapi module to control which battery is discharged (via force_discharge) or charged (via inhibit_charge_minutes on the other battery). This only works on some ThinkPad models - see the tp_smapi model-specific status.

The following script uses tp_smapi to balance the battery discharging: tp-bat-balance (download)

TPBattStat-Applet is a gnome applet for integrating battery balancing with a graphics and/or text display of both batteries in a panel. Battery balancing improves battery life by not leaving one battery empty while the other discharges. It has configurable strategies for charging and discharging, and a configurable display in the panel. Its gpl-ed, so as always, use at your own risk. For the latest alpha release, see https://github.com/teleshoes/tpbattstat-applet

Ultrabay eject lever

It seems that you don't have to completely remove the Ultrabay battery from the bay to stop using it. If you release the eject lever, but don't actually pull the battery from the bay, the battery is still visible to the system, but the BIOS reverses the order of use and will completely deplete the main battery before using the Ultrabay battery. While the BIOS can switch to the Ultrabay battery when the main battery runs out, it cannot switch fast enough when the main battery is pulled. Make sure you push the eject lever in before swapping the main battery or the system will lose power. Likewise, if you have the ultrabay lever pushed in: while the system can switch to the main battery when the ultrabay battery is empty, it cannot switch to the main battery fast enough if the ultrabay battery slips out of the bay without the lever being released- the system will lose power.

The order of charging is not affected by the state of the eject lever. Works on: T23, T40p. May or may not work on other models.

Reading the battery status under Linux

Using APM

The second battery is correctly detected by the APM subsystem (if activated).

Using ACPI

NOTE!
The information provided here is outdated, hotplugged batteries will be automatically detected and used at least as of 2.6.27 kernels using the standard ACPI Bay driver.

The second battery is correctly detected by the ACPI subsystem (if activated). However, the Linux ACPI subsystem only scans for batteries on boot. This means that the second battery must be present at boot time, or you will not be able to get any info for it via /proc/acpi/battery/BAT1.

With kernel 2.6.14.2 (possibly only with thinkpad-acpi) there is a sysfs file: /sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/EC/BAT1/eject. There isn't one for BAT0, but # cat /proc/acpi/battery/BAT0/* shows not present when there is no internal battery.

For BAT1 all the states go to 0, critical, etc. .

# echo 1 > /sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/EC/BAT1/eject will remove /proc/acpi/battery/BAT1 and turn off the Ultrabay led. Interestingly the battery will still be discharging (charging not tested) until it is physically removed.

Also, if you compile the battery module of ACPI as a module, boot with the Ultrabay battery present, remove the Ultrabay battery (without doing the eject above), /proc/acpi/battery/BAT1 is still there, while after # rmmod battery && modprobe battery /proc/acpi/battery/BAT1 is gone (BAT0 is back). Put the battery back in and /proc/acpi/battery/BAT1 is still missing, do # rmmod battery && modprobe battery and /proc/acpi/battery/BAT1 is back.

If you boot without the second battery BAT1 never appears in /proc or /sys.

If you eject using the sysfs file above, BAT1 disappears from both /proc and /sys and never comes back.

Please note, that applications, like Gnome Power Manager (don't know about others) automatically sums both battery capacities and display the status together

Using tp_smapi

Independently of APM or ACPI, the battery status is also accessible through the tp_smapi driver. The tp_smapi kernel module provides battery status (and other features) via the sysfs interface in /sys/devices/platform/smapi/BAT{0,1}, and includes some information not accessible through APM or ACPI (e.g., cycle count and momentary power draw). The BAT1 interface is always present, regardless of whether the battery is present, was present on boot, or was ejected using the sysfs interface above.

For a GUI interface, you can use the KThinkBat applet or Gkrellm-ThinkBat plug-in.