Difference between revisions of "How to use UltraBay batteries"

From ThinkWiki
Jump to: navigation, search
(Charging and discharging)
(Reading the battery status under Linux)
Line 9: Line 9:
 
* Keep an eye on the charge in the UltraBay battery and physically remove it from the bay when it gets too low.
 
* Keep an eye on the charge in the UltraBay battery and physically remove it from the bay when it gets too low.
 
* Use the [[SMAPI support for Linux#Using_the_tp_smapi_module|tp_smapi]] module to control which battery is charged (<tt>inhibit_charge</tt> on the other battery) or discharged (<tt>force_discharge</tt>). This only works on some ThinkPad models - see the [[SMAPI support for Linux#Model-specific_status|model-specific status]].
 
* Use the [[SMAPI support for Linux#Using_the_tp_smapi_module|tp_smapi]] module to control which battery is charged (<tt>inhibit_charge</tt> on the other battery) or discharged (<tt>force_discharge</tt>). This only works on some ThinkPad models - see the [[SMAPI support for Linux#Model-specific_status|model-specific status]].
 +
 +
===Reading the battery status under Linux===
 +
The second battery is correctly detected by either the APM or ACPI subsystem. 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}}.
 +
 +
With kernel 2.6.14.2 (possibly only with [[ibm-acpi]]) there is a sysfs file: {{path|/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/EC/BAT1/eject}}. There isn't one for BAT0, but {{cmdroot|cat /proc/acpi/battery/BAT0/*}} shows {{cmdresult|not present}} when there is no internal battery.
 +
 +
For BAT1 all the states go to 0, critical, etc. .
 +
 +
{{cmdroot|echo 1 > /sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/EC/BAT1/eject}} will remove {{path|/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), {{path|/proc/acpi/battery/BAT1}} is still there, while after {{cmdroot|rmmod battery && modprobe battery}} {{path|/proc/acpi/battery/BAT1}} is gone (BAT0 is back). Put the battery back in and {{path|/proc/acpi/battery/BAT1}} is still missing, do {{cmdroot|rmmod battery && modprobe battery}} and {{path|/proc/acpi/battery/BAT1}} is back.
 +
 +
If you boot without the second battery <tt>BAT1</tt> never appears in {{path|/proc}} or {{path|/sys}}.
 +
 +
If you eject using the sysfs file above, <tt>BAT1</tt> disappears from both {{path|/proc}} and {{path|/sys}} and never comes back.
 +
 +
Fortunately, the battery status is accessible independently of the ACPI system. The [[SMAPI support for Linux|tp_smapi]] module gives battery status (and other features) via the sysfs interface in {{path|/sys/devices/platform/smapi/BAT<nowiki>{</nowiki>0,1<nowiki>}</nowiki>}}. 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.
 +
 +
Unfortunately, all battery monitor scripts/applets currently use the ACPI interface to get battery status information.

Revision as of 09:35, 11 January 2006

ThinkPad laptops only charges/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

Switching between the batteries is 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).

Charging and discharging

When charging, the system will completely charge the main battery before it starts on the UltraBay 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.
  • Use the tp_smapi module to control which battery is charged (inhibit_charge on the other battery) or discharged (force_discharge). This only works on some ThinkPad models - see the model-specific status.

Reading the battery status under Linux

The second battery is correctly detected by either the APM or ACPI subsystem. 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 ibm-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.

Fortunately, the battery status is accessible independently of the ACPI system. The tp_smapi module gives battery status (and other features) via the sysfs interface in /sys/devices/platform/smapi/BAT{0,1}. 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.

Unfortunately, all battery monitor scripts/applets currently use the ACPI interface to get battery status information.