]> spindle.queued.net Git - xodist/commitdiff
bootable attempt
authorJames Cameron <quozl@laptop.org>
Tue, 28 Oct 2008 22:32:31 +0000 (09:32 +1100)
committerJames Cameron <quozl@laptop.org>
Tue, 28 Oct 2008 22:32:31 +0000 (09:32 +1100)
README
README.approx
mkbootable.sh [new file with mode: 0755]

diff --git a/README b/README
index 317f4fd2e59d65d1b8b46edc0637d1963ecbbe0d..843d3c145c82159f4227431461aa2bc3e000328e 100644 (file)
--- a/README
+++ b/README
@@ -1,10 +1,15 @@
 xodist - Debian image builder for OLPC XO
 
+Why is this needed?  Because the OLPC XO has exceptional and flexible
+firmware support unlike an ordinary PC.  The usual Debian boot CDs do
+not work, yet.  xodist builds a Debian system image in the format
+required by the firmware.
+
 See *.packages for other image flavours, and change "kde" below to the
 flavour.  See README.approx before starting if you would like to cache
 the packages downloaded.
 
-How to use xodist to generate a Debian KDE image:
+How to use xodist to generate a Debian KDE image for an OLPC XO:
 
 1.  build the root filesystem,
 
@@ -16,10 +21,24 @@ How to use xodist to generate a Debian KDE image:
 
 3.  copy the files to a thumb drive,
 
-       cp kde.{dat,crc,img} /mnt/
+       sudo ./mkbootable.sh --output /mnt kde
+
+4.  ensure the XO is unlocked, by obtaining a Developer Key, and using
+the OpenFirmware command,
+
+       disable-security
+
+5.  shut down the XO,
+
+6.  insert the thumb drive,
+
+7.  power up, when prompted press Enter, and the image will be copied
+to the NAND flash, and then booted,
 
-4.  boot an XO into OFW (note: OFW q2e14 or newer is required), then type:
+Warning: this erases everything on the XO, including any Developer
+Key, but if you have followed step 4 above that should not matter so
+much.
 
-        update-nand u:\kde.img
+8.  remove the thumb drive before the next reboot or power up.
 
-Warning: this erases everything on the XO.
+Note: Firmware Q2E14 or newer is required.
index f93bb4a42891313d339bf76d70309caf119bbebf..7b67cf4da7e3efd03ec9de8e50bfe1c04d8c229e 100644 (file)
@@ -16,10 +16,9 @@ security        http://security.debian.org/
 
        % sudo /etc/init.d/approx restart
 
-4.  during the creation of the root filesystem described in README,
-add the --mirror option, like this:
+4.  follow README, but during the creation of the root filesystem, add
+the --mirror option, like this:
 
         sudo ./initchroot.sh \
             --package-list kde.packages \
             --mirror http://localhost:9999/debian kde.root
-
diff --git a/mkbootable.sh b/mkbootable.sh
new file mode 100755 (executable)
index 0000000..ec6b076
--- /dev/null
@@ -0,0 +1,127 @@
+#!/bin/sh
+set -e
+
+IMAGE_DEFAULT=
+INTERACTIVE=yes
+OUTPUT=${IMAGE_DEFAULT}.bootable
+
+. functions.sh
+
+images()
+{
+       echo "Available images:" 1>&2
+       echo -n "  " 1>&2
+       ls *.img | cut -f1 -d. | tr '\n' ' ' 1>&2
+}
+
+usage()
+{
+       echo "" 1>&2
+       echo "Usage: $0 [<options>] <image-name>" 1>&2
+       echo "" 1>&2
+       echo "Options:" 1>&2
+       echo "  --no-interactive    in the generated media, during boot, do not prompt" 1>&2
+       echo "  --output dir        directory in which to create the structure" 1>&2
+       echo "" 1>&2
+       echo "Argument:" 1>&2
+       echo "  <image-name>       an image name, default $IMAGE_DEFAULT" 1>&2
+       echo "" 1>&2
+       images
+       echo "" 1>&2
+       exit 1
+}
+
+if test $# == 0; then
+       usage
+fi
+
+IMAGE="$IMAGE_DEFAULT"
+while test $# != 0
+do
+       case $1 in
+       --no-interactive)
+               INTERACTIVE=no
+               ;;
+       --interactive)
+               INTERACTIVE=yes
+               ;;
+       --output)
+               OUTPUT=$2
+               shift
+               ;;
+       *)
+               if [ "$#" != "1" ]; then
+                       echo "Unknown option $1" 1>&2
+                       usage
+               else
+                       IMAGE="$1"
+                       if [ "${OUTPUT}" == "" ]; then
+                               OUTPUT=${IMAGE}.bootable
+                       fi
+               fi
+               ;;
+       esac
+       shift
+done
+
+if ! test -f ${IMAGE}.img; then
+       echo "*** No such image ${IMAGE}"
+       exit 1
+fi
+
+if ! test -d ${OUTPUT}; then
+       mkdir ${OUTPUT}
+fi
+
+cp ${IMAGE}.{dat,crc,img} ${OUTPUT}
+
+mkdir -p ${OUTPUT}/boot
+
+# create essential header required by OpenFirmware
+cat <<EOF >${OUTPUT}/boot/olpc.fth
+\ OLPC boot script
+
+cr
+." This is a debxo bootable install script." cr
+cr
+." `md5sum ${IMAGE}.img`" cr
+." `md5sum ${IMAGE}.dat`" cr
+." `md5sum ${IMAGE}.crc`" cr
+cr
+EOF
+
+# create either an interactive or non-interactive section
+case $INTERACTIVE in
+       no)
+               cat <<EOF >>${OUTPUT}/boot/olpc.fth
+
+\ --no-interactive was used, so we do not prompt
+." Erasing everything here and installing debxo ${IMAGE}" cr
+EOF
+               ;;
+       yes|*)
+               cat <<EOF >>${OUTPUT}/boot/olpc.fth
+
+\ --interactive was used, so we prompt before erasing
+." Power off to abort, or" cr
+." press Enter to erase everything here and install debxo ${IMAGE} ?"
+begin
+    key 13 =
+until
+EOF
+               ;;
+esac
+
+cat <<EOF >>${OUTPUT}/boot/olpc.fth
+
+cr
+." Starting"
+
+\ erase the NAND flash and fill it with the image
+update-nand u:\\${IMAGE}.img
+
+\ boot from the NAND flash
+boot n:\boot\olpc.fth
+EOF
+
+# TODO: avoid reflashing if already flashed