Power Management v0.9

This folder holds slightly modified versions of powerMgr, the start.sh startup script, and the battery.o kernel module.  These are intended to support arbitrarily large batteries in the iLiad, almost seamlessly.

This version eliminates the old BatteryManager and CPUManager programs.  Instead, I have slightly modified the iRex powerMgr and battery kernel module.  So all of the original powerMgr functions are intact, and your iLiad will now behave normally.

INSTALLATION

It is HIGHLY RECOMMENDED that you backup affected original files before installing this software.  It is also recommended that you backup personal files and be prepared to reflash your iLiad if necessary.  I take no responsibility if you brick your iLiad with this modification.  I have tested it and it works for me, but it may not work for you.

Installation should be fairly simple.  Backup your original powerMgr and start.sh files.  Three new files are provided.  Simply copy them to the following locations on the iLiad:

/usr/bin/powerMgr
/home/root/start.sh
/lib/modules/2.4.19-rmk7-pxa2-irex1/kernel/drivers/irex/battery.o

You will need to create the directory "/lib/modules/2.4.19-rmk7-pxa2-irex1/kernel/drivers/irex".

Reboot your iLiad, and everything should be good.


WHAT'S DIFFERENT?

How does this affect the user experience?  Here's what works differently:

 - The battery icon may not decrease evenly over time.  (That is, it may start slow and finish fast, or vice-versa.)  This is a limitation of the program that will be fixed with a future update.
 - The battery status icon may occasionally jump up one bar due to uncertainty measuring the voltage.
 - While charging, the battery icon will always read higher than its real charge, because the battery is being held at a higher, charging voltage.
 - No matter the battery capacity, the iLiad will always turn off when the battery is almost empty, thus ensuring the fullest possible use of the battery.
 - The iLiad will never over-drain the battery, even if the battery loses capacity with age.
 
Major differences from version 0.12:

 - You no longer need to turn on the iLiad while charging.
 - You no longer need to fully charge the iLiad after installation.

Basically, with version 0.90, you can charge your iLiad normally again, and it will behave normally.  Easy!


HOW IT WORKS

The Gas Gauge chip on the iLiad battery circuit board keeps a running real-time total of how many amp-hours are left in the batteries, based on the actual electrical current drain.  This is very precise and useful, but it is limited because the Gas Gauge assumes that the iLiad batteries have a set size.  If you want to upgrade your batteries, the Gas Gauge will not know, and it will treat your batteries as if they still have the limited capacity of the originals.  Thus the iLiad will shut down when it "thinks" the batteries are low, even if they are still quite full.  However, the Gas Gauge also monitors and reports a wide array of other data, including the realtime current drain and the battery voltage.

Happily, battery voltage can also be used to estimate battery charge.  Lithium-ion batteries range from about 4.15 volts when full to 3.4 volts when nearly empty.  The iLiad has two batteries in series for a range of 8300 mV (full) to 6800 mV (empty).

So I have modified the battery.o kernel module to provide the Gas Gauge battery voltage.  The powerMgr program has been modified to request the voltage from the kernel module.  I have measured my batteries to produce a reference table of voltage vs. % charge, and the new powerMgr uses the measured battery voltage with this reference table to estimate the remaining battery life.

Future versions will be able to automatically measure the battery characteristics and continuously update the reference table.


TECHNICAL NOTES

The kernel module has been modified.  Previously, signal 03 requested the battery temperature.  Now, requesting 03 from the battery.o module will return the battery voltage.  As far as I know, none of the iLiad's programs ever request or use the battery temperature for anything, so this change should not cause any problems.

Similarly, powerMgr has been modified to request the battery voltage rather than the battery charge.  Because a battery charge request returns a percentage value from 0-100%, which is only meaningful for the original iLiad batteries, I decided simply to replace it with a voltage request.  This minimized code changes.  Thus powerMgr no longer monitors or cares about the reported battery charge.

The battery charge state is estimated NONLINEARLY from the voltage, as it should be.  I ran a full calibration curve of my batteries measuring voltage vs. current drain over time.  This curve was then used to pinpoint voltages corresponding to proportional charge states, as follows:

Icon    Voltage (mV)    Charge %
======  ============    ===========
Full    7850 -- 8300    82 -- 100%
4 bars  7650 -- 7850    64 -- 82%
3 bars  7500 -- 7650    45 -- 64%
2 bars  7430 -- 7500    27 -- 45%
1 bar   7295 -- 7430    9 -- 27%
empty   7000 -- 7295    0 -- 9%
Warning     7000
Shutdown    6800
Emergency   6500

Thus each bar represents about 18% of total runtime, and the "empty" icon appears with 9% runtime remaining before the low battery warning.  This table is currently hard-coded into powerMgr.

Finally, the start.sh script has been changed by adding these lines at the beginning:

    depmod
    modprobe -r battery
    modprobe battery

This was necessary because the original iRex battery.o kernel module is preloaded from the ramdisk at boot time.  It cannot be replaced without a firmware upgrade.  In a horrible kluge to work around the problem, I have the iLiad rescan the kernel modules, remove the original preloaded battery module, and then load the new module.

One word for developers:  Originally, when powerMgr sent low-charge warnings to contentLister, it also sent the charge state of the battery.  Now, powerMgr sends the _voltage_ of the battery instead of the charge.  This doesn't affect anything because the contentLister doesn't actually USE the charge for anything except printing a log message.  However, if you intend to modify this part of the contentLister you should be aware of the change.

Enjoy!

