XO battery/performance [Devel Digest, Vol 76, Issue 4]

Richard Smith richard at laptop.org
Sat Jun 2 08:27:19 EDT 2012

> This battery is really strange...
> After an O/N with the battery out of the XO tried to run it down and suddenly none of the info in /sys/devices/0.baterry/power_supply/olpc-battery/ was changing after an hour of CPU burn and the battery was showing as "Full"
> Shutdown and removing the battery to reset the EC, made it behaved. The battery started from 35% and dropped normally thereafter.

Hmm... Perhaps there is some intermittent communication fail between
the EC and the battery.  Next time things get all messed up reboot
into OFW and run 'see-bstate'.   Do not remove the battery for a
complete power cycle. Just reboot.
(It helps if you have serial port connected so you can capture the output)

see-bstate will spew a bunch of numbers. From those numbers we can see
if the EC is talking to the battery.

> As per the suggested test, indeed after shutting down at 9% with the red led on, pressing a game key lights up the red led for ~2 sec.

Ok.  Well its not the EC failing to go into stop mode then.  Do you
have a XO-1.5 or 1.75? Something with an EC serial connector loaded?

>> > What was striking was that the XO-1.75 used 25% of the
>> battery for 1 run while the XO-1.5 used 65% of the battery!
>> If you are going to do more of this then you really need a
>> better tool
>> than just the battery SOC measurement.
> I usually look either at the ~/power-logs/pwr-* or directly at /sys/..../power_supply/olpc-battery/* to check battery status
>> olpc-pwr-log
>> can sample the
>> information on a periodic basis and then my processing
>> scripts can run

The data in the powerd power log file is a super-set of the data
captured by olpc-pwr-log.  powerd also captures data on events like
when the machine goes to sleep, External power connected/disconnected.
 If no events happen then its samples the battery info every 300

olpc-pwr-log samples much more frequently and only samples on a time
basis.  Its every 20 seconds right now but can be changed by editing
the script.  20 seconds is about the minimum you want though or the
average power computation has lots of error.

running olpc-pwr-log is easy.  Grab the one from my repository and
copy it over the one that is included in the build.  Then just open a
terminal or VT and run it.  It will generate a log file in the
directory you run it.

if powerd is running and the machine goes to sleep it won't hurt
olpc-pwr-log but you times will be irregular so most of the time I use
it I stop powerd first.

My python processing tool can also process powerd log files.  One
difference between them is that the processing tool does not have any
statefull analysis (yet) so it doesn't do any thing different when you
go from charging to discharging.  When looking at summary data such as
average power over a run if you have both charging and discharging
then the average includes all of them.   The graph output will show
you the data over time and you can see the ups and down.

If I use powerd to log normally force it to generate a new file or I
reboot first so a new log file is started.

> Sure.
> I can understand some bash scripting but python is out of my league, so please advise.

Its not necessary to hack python to use the processing tools.  You do
need some some python dependencies installed though.  You need
python-dateutils, and pymatplotlib installed and configured.
pymatplot lib needs the backend rendering engine set for your system.
(The default is Tk, but it has gtk, and QT).

The tools have lots of different options and can tell you many
different things but most of those options you probably would not use.

To you you just feed the tools the power logs on the command line.

process-pwr_log.py <logfile> will give you a summary of that run.  If
you feed it multiple files on the command line (such as pwr-* ) then
it will produce one line of summary output for each logfile processed.

graphy-pwr_log.py can show you lots of different graphs.  By default
it just shows you voltage and current over time. --avgpwr includes a
power graph.

graph-pwr_log.py --avgpwr <logfile>

If you feed it multiple log files then you will a graph with multiple
traces one trace per log file.

Each graph lives in its own window right now so you have to close each
one before it exits.

If you can't get the python stuff to run then you can always send me
your log files and I can process them.

Richard A. Smith
One Laptop per Child

More information about the Devel mailing list