Power Log Collector: Difference between revisions

From OLPC
Jump to navigation Jump to search
No edit summary
Line 73: Line 73:
visible
visible
no-page
." Power Log Collection" cr
dir int:2,\home\olpc\power-logs\pwr*
dir int:2,\home\olpc\power-logs\pwr*
: force-overwrite ( path$ -- continue? ) type cr true ;
patch force-overwrite ?delete-file $copy1
." Copying, please standby." cr
copy int:2,\home\olpc\power-logs\pwr* u:\
copy int:2,\home\olpc\power-logs\pwr* u:\
." Power Logs Recovered" cr
." Power Logs Recovered" cr
." Shutting down in 10 seconds" cr
." Shutting down in 10 seconds" cr
." You may remove the USB drive now or later" cr
." You may remove the USB drive now" cr
green-screen
d# 10000 ms
d# 10000 ms
power-off
power-off

Revision as of 05:44, 21 March 2012


This Power Log Collector boots an XO-1 or XO-1.5 and copies the power logs to itself before shutting the laptop down.

Note: will not work on secured laptops without signing.

Does not work for XO-1.75 yet.

How to Use

The XO will collect the power logs, print a message saying has done so and then shut down.

Theory of Operation

  • Based on Tiny Core Linux,
  • An Open Firmware Boot Script selects the XO-1 or XO-1.5 kernel,
  • The initial ramdisk mounts /dev/sda (which should be the first USB drive), and
  • executes rc.local on that drive, which does the collection.

How it was Made

It was made by remastering Tiny Core Linux.

Unpack the initial ramdisk to the current directory:

# gunzip <../initrd.gz | cpio -i

Modify the files as needed, then repack the initial ramdisk:

# find | sudo cpio -o -H newc --quiet | gzip -2 > ../initrd.gz

Then assemble into a .tar.bz2 for download.

rc.local

The script that does the collection:

#!/bin/sh

uname -a | grep _xo1-
if [ $? -eq 0 ]
then
       echo detected xo-1.0
       XO_ROOT=mtdblock0
       XO_FS=jffs2
else
       echo detected xo-1.5
       XO_ROOT=mmcblk0p2
       XO_FS=ext3
fi

mkdir -p /mnt/$XO_ROOT

mount -t $XO_FS -o ro /dev/$XO_ROOT /mnt/$XO_ROOT
mkdir -p /mnt/sda1/power-logs
cp /mnt/$XO_ROOT/home/olpc/power-logs/* /mnt/sda1/power-logs
umount /mnt/$XO_ROOT
mount /dev/sda1 /mnt/sda1 -o remount,ro
sync
echo Power Logs Recovered
echo Shutting down in 10 seconds
echo You may remove the USB now
sleep 10
poweroff

OpenFirmware Alternative

Place this as boot/olpc.fth on an ext2 USB drive:

\ OLPC Power Log Collection Script

visible
no-page
." Power Log Collection" cr
dir int:2,\home\olpc\power-logs\pwr*

: force-overwrite  ( path$ -- continue? )  type cr  true  ;
patch force-overwrite ?delete-file $copy1

." Copying, please standby." cr
copy int:2,\home\olpc\power-logs\pwr* u:\

." Power Logs Recovered" cr
." Shutting down in 10 seconds" cr
." You may remove the USB drive now" cr
green-screen
d# 10000 ms
power-off