r4788 - in developers/werner: . fake-calup fake-calup/bin fake-calup/fw
werner at docs.openmoko.org
werner at docs.openmoko.org
Sat Nov 15 21:08:35 CET 2008
Author: werner
Date: 2008-11-15 21:08:34 +0100 (Sat, 15 Nov 2008)
New Revision: 4788
Added:
developers/werner/fake-calup/
developers/werner/fake-calup/Makefile
developers/werner/fake-calup/bin/
developers/werner/fake-calup/bin/cal-backup
developers/werner/fake-calup/bin/cal-flash
developers/werner/fake-calup/bin/cal-id-file
developers/werner/fake-calup/bin/cal-id-installed
developers/werner/fake-calup/bin/cal-poweroff
developers/werner/fake-calup/bin/cal-sum-file
developers/werner/fake-calup/bin/cal-sum-installed
developers/werner/fake-calup/bin/calup.sh
developers/werner/fake-calup/bin/gui.py
developers/werner/fake-calup/current.start
developers/werner/fake-calup/fw/
developers/werner/fake-calup/fw/gsm_blah_moko8.m0
developers/werner/fake-calup/fw/gsm_blah_moko9_beta2.m0
developers/werner/fake-calup/fw/gsm_blah_moko9beta1.m0
Log:
Calypso FW updating environment. (Wrapper script and templates.)
Added: developers/werner/fake-calup/Makefile
===================================================================
--- developers/werner/fake-calup/Makefile (rev 0)
+++ developers/werner/fake-calup/Makefile 2008-11-15 20:08:34 UTC (rev 4788)
@@ -0,0 +1,5 @@
+test:
+ rm -rf bck
+ mkdir -p bck
+ cp current.start current
+ PATH=$$PATH:$$PWD/bin calup.sh
Added: developers/werner/fake-calup/bin/cal-backup
===================================================================
--- developers/werner/fake-calup/bin/cal-backup (rev 0)
+++ developers/werner/fake-calup/bin/cal-backup 2008-11-15 20:08:34 UTC (rev 4788)
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+#
+# cal-backup <file>
+#
+# Backups the current GSM Flash content to <file>
+#
+
+cp current "$1"
+
+exit 0
Property changes on: developers/werner/fake-calup/bin/cal-backup
___________________________________________________________________
Name: svn:executable
+ *
Added: developers/werner/fake-calup/bin/cal-flash
===================================================================
--- developers/werner/fake-calup/bin/cal-flash (rev 0)
+++ developers/werner/fake-calup/bin/cal-flash 2008-11-15 20:08:34 UTC (rev 4788)
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+#
+# cal-flash <file>
+#
+
+Installs the firmware <file> on the Calypso.
+
+echo "$1" >current
+
+exit 0
Property changes on: developers/werner/fake-calup/bin/cal-flash
___________________________________________________________________
Name: svn:executable
+ *
Added: developers/werner/fake-calup/bin/cal-id-file
===================================================================
--- developers/werner/fake-calup/bin/cal-id-file (rev 0)
+++ developers/werner/fake-calup/bin/cal-id-file 2008-11-15 20:08:34 UTC (rev 4788)
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+#
+# cal-id-file <file>
+#
+# Prints the human-readable name of the GSM firmware in <file>.
+#
+
+id="`basename "$1" | sed 's/^gsm_.*_\(moko[^.]*\)\.m0$/\1/p;d'`"
+[ ! -z "$id" ] && echo "$id"
Property changes on: developers/werner/fake-calup/bin/cal-id-file
___________________________________________________________________
Name: svn:executable
+ *
Added: developers/werner/fake-calup/bin/cal-id-installed
===================================================================
--- developers/werner/fake-calup/bin/cal-id-installed (rev 0)
+++ developers/werner/fake-calup/bin/cal-id-installed 2008-11-15 20:08:34 UTC (rev 4788)
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+#
+# cal-id-installed
+#
+# Prints the human-readable name of the current GSM firmware.
+#
+
+cal-id-file "`cat current`"
Property changes on: developers/werner/fake-calup/bin/cal-id-installed
___________________________________________________________________
Name: svn:executable
+ *
Added: developers/werner/fake-calup/bin/cal-poweroff
===================================================================
--- developers/werner/fake-calup/bin/cal-poweroff (rev 0)
+++ developers/werner/fake-calup/bin/cal-poweroff 2008-11-15 20:08:34 UTC (rev 4788)
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+echo "Powering down."
+
+# /sbin/halt -f
Property changes on: developers/werner/fake-calup/bin/cal-poweroff
___________________________________________________________________
Name: svn:executable
+ *
Added: developers/werner/fake-calup/bin/cal-sum-file
===================================================================
--- developers/werner/fake-calup/bin/cal-sum-file (rev 0)
+++ developers/werner/fake-calup/bin/cal-sum-file 2008-11-15 20:08:34 UTC (rev 4788)
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+#
+# cal-sum-file <file>
+#
+# Prints a unique checksum of the firmware file <file>. This number must be
+# identical to the one cal-sum-installed produces for the same firmware.
+#
+
+cal-id-file "$1" | md5sum
Property changes on: developers/werner/fake-calup/bin/cal-sum-file
___________________________________________________________________
Name: svn:executable
+ *
Added: developers/werner/fake-calup/bin/cal-sum-installed
===================================================================
--- developers/werner/fake-calup/bin/cal-sum-installed (rev 0)
+++ developers/werner/fake-calup/bin/cal-sum-installed 2008-11-15 20:08:34 UTC (rev 4788)
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+#
+# cal-sum-installed
+#
+# Prints a unique checksum of the installed firmware. This number must be
+# identical to the one cal-sum-file produces for the same firmware.
+#
+
+cat current | md5sum
Property changes on: developers/werner/fake-calup/bin/cal-sum-installed
___________________________________________________________________
Name: svn:executable
+ *
Added: developers/werner/fake-calup/bin/calup.sh
===================================================================
--- developers/werner/fake-calup/bin/calup.sh (rev 0)
+++ developers/werner/fake-calup/bin/calup.sh 2008-11-15 20:08:34 UTC (rev 4788)
@@ -0,0 +1,114 @@
+#!/bin/sh -x
+
+# ----- Configuration ---------------------------------------------------------
+
+
+#FW_DIR=$HOME/fw
+#BCK_DIR=$HOME/bck
+FW_DIR=$PWD/fw
+BCK_DIR=$PWD/bck
+
+
+# ----- Global variables ------------------------------------------------------
+
+
+# Item to add to the list of available firmware images (for unknown installed
+# firmware)
+add=
+
+# Human-readable name of the current firmware.
+curr=
+
+
+# ----- Try to identify the current firmware image ----------------------------
+
+
+identify()
+{
+ local n sum
+
+ add=
+ if ! curr=`cal-sum-installed`; then
+ echo "cannot get checksum of installed firmware" 1>&2
+ exit 1
+ fi
+
+ for n in $FW_DIR/*.m0; do
+ if ! sum=`cal-sum-file "$n"`; then
+ echo "cannot get checksum of $n" 1>&2
+ exit 1
+ fi
+ if [ "$sum" = "$curr" ]; then
+ if ! curr=`cal-id-file "$n"`; then
+ echo "cannot identify $n" 1>&2
+ exit 1
+ fi
+ return
+ fi
+ done
+
+ if ! curr=`cal-id-installed`; then
+ echo "cannot identify installed firmware" 1>&2
+ exit 1
+ fi
+
+ add="$curr"
+}
+
+
+# ----- Run the GUI -----------------------------------------------------------
+
+
+run_gui()
+{
+ local n id
+
+ set -- -t "$title" -c "$curr" -o
+ if [ ! -z "$add" ]; then
+ set -- "$@" "$add" XXX
+ fi
+ for n in $FW_DIR/*.m0; do
+ if ! id=`cal-id-file "$n"`; then
+ echo "cannot identify $n" 1>&2
+ exit 1
+ fi
+ set -- "$@" "$id" "$n"
+ done
+ if ! gui.py "$@"; then
+ echo "gui failed" 2>&1
+ exit 1
+ fi
+}
+
+
+title="GSM FW UPDATER"
+while true; do
+ identify || exit
+
+ cmd=`run_gui` || exit
+ if [ "$cmd" = off ]; then
+ cal-poweroff
+ exit 0
+ fi
+ if [ "${cmd#install }" = "$cmd" ]; then
+ echo "unrecognized command \"$cmd\"" 1>&2
+ exit 1
+ fi
+ file=`echo "${cmd#install }"`
+
+ n=1
+ while [ -e "$BCK_DIR/$n" ]; do
+ n=`expr $n + 1`
+ done
+ if ! cal-backup "$BCK_DIR/$n"; then
+ title="CANNOT BACKUP"
+ continue
+ fi
+
+ if ! cal-flash "$file"; then
+ title="FLASH FAILED"
+ continue
+ fi
+
+ title="FIRMWARE UPDATED"
+done
Property changes on: developers/werner/fake-calup/bin/calup.sh
___________________________________________________________________
Name: svn:executable
+ *
Added: developers/werner/fake-calup/bin/gui.py
===================================================================
--- developers/werner/fake-calup/bin/gui.py (rev 0)
+++ developers/werner/fake-calup/bin/gui.py 2008-11-15 20:08:34 UTC (rev 4788)
@@ -0,0 +1,160 @@
+#!/usr/bin/python
+
+#
+# Usage example:
+#
+# Available images are moko 8-beta3 and moko 9-omega666. The currently
+# installed version is moko 8-beta3.
+#
+# ./gui.py \
+# -t "TITLE" \
+# -o "moko 8-beta3" "my_data/gsm_foo_blah_moko8beta3.m0" \
+# "moko 9-omega666" "my_data/gsm_blargh.m0" \
+# -c "moko 8-beta3"
+#
+# Exits with command on stdout, e.g.,
+# off
+# or
+# install my_data/gsm_blargh.m0
+#
+# The already installed version cannot be selected. Note that, if the currently
+# installed version is not among the list of available items, it is not shown.
+# (So if you want to include it for indication purposes, add it explicitly.)
+#
+# The title can be used to indicate the status of the previous operation, e.g.,
+# -t "FAILED"
+# or
+# -t "UPDATED" (and change -c)
+#
+# Known issues:
+# - there's a "old" and a "new" list. They have no functional differences,
+# except that "old" items are shown before "new" items.
+#
+
+from Tkinter import *
+from sys import argv
+
+font = "-*-helvetica-bold-r-*-*-32-*-*-*-*-*-*-*"
+pady = 24
+
+g_cmd = ""
+g_current = None
+g_but = {}
+
+def mark(button):
+ button.config(bg = "#800080", activebackground = "#800080", state = NORMAL)
+
+def unmark(button):
+ button.config(bg = "black", activebackground = "black", state = NORMAL)
+
+def desarrayize(var):
+ if len(var) == 0:
+ return None
+ if isinstance(var[0], str):
+ return var[0]
+ return var[0][0]
+
+def select(label, arg):
+ global g_cmd, g_current
+ g_cmd = "install "+arg
+ if g_current:
+ unmark(g_current)
+ g_current = g_but[label]
+ mark(g_current)
+ if label == curr:
+ bi.config(state = DISABLED, text = "INSTALLED",
+ bg = "black", activebackground = "black")
+ else:
+ bi.config(state = NORMAL, text = "INSTALL",
+ bg = "red", activebackground = "red")
+
+def power_off():
+ global g_cmd
+ g_cmd = "off"
+ root.quit()
+
+def button(w, label, arg):
+ #f = Frame(w, bg = "black")
+ #l = Label(f, text = type, fg = "white", bg = "green")
+ #l.pack(side = LEFT, expand = 0)
+ #b.pack(expand = 1, fill = "x")
+ b = Button(f, relief = FLAT, anchor = W, text = label,
+ font = font, fg = "white", bg = "black",
+ activeforeground = "white", activebackground = "black",
+ disabledforeground = "yellow",
+ pady = pady, command = lambda: select(label, arg))
+ if label == curr:
+ b.config(fg = "yellow")
+ b.pack(side = TOP, fill = "x")
+ g_but[label] = b
+
+def buttons(w, list):
+ for b in list:
+ button(w, b[0], b[1])
+
+old = []
+new = []
+curr = []
+title = []
+
+# parse command line:
+#
+# -o [label argument] ...
+# -n [label argument] ...
+# -c label
+
+set = new
+for arg in argv[1:]:
+ if arg == "-o":
+ set = old
+ elif arg == "-n":
+ set = new
+ elif arg == "-c":
+ set = curr
+ elif arg == "-t":
+ set = title
+ elif len(set) and isinstance(set[-1], str):
+ set[-1] = (set[-1], arg)
+ else:
+ set.append(arg)
+
+curr = desarrayize(curr)
+title = desarrayize(title)
+
+if title is None:
+ title = "GSM FW UPDATER"
+
+root = Tk()
+root.overrideredirect(1)
+w, h = root.winfo_screenwidth(), root.winfo_screenheight()
+root.geometry("%dx%d+0+0" % (w, h))
+
+f = Frame(root, bg = "black")
+l = Label(f, text = title, fg = "white", bg = "blue", font = font)
+l.pack(expand = 1, fill = "x")
+f.pack(expand = 1, fill = "both")
+
+buttons(f, old)
+buttons(f, new)
+
+fa = Frame(f, bg = "black")
+bi = Button(fa, text = "", width = 9,
+ fg = "white", bg = "black", font = font,
+ activeforeground = "white", activebackground = "black",
+ pady = pady, state = DISABLED, command = root.quit)
+bp = Button(fa, text = "POWER OFF",
+ fg = "white", bg = "blue", font = font,
+ activeforeground = "white", activebackground = "blue",
+ pady = pady, command = power_off)
+bi.pack(side = LEFT)
+bp.pack(side = LEFT)
+
+if curr is not None and curr in g_but:
+ g_current = g_but[curr]
+ mark(g_current)
+ bi.config(text = "INSTALLED")
+
+fa.pack(expand = 1, side = TOP)
+
+root.mainloop()
+print g_cmd
Property changes on: developers/werner/fake-calup/bin/gui.py
___________________________________________________________________
Name: svn:executable
+ *
Added: developers/werner/fake-calup/current.start
===================================================================
--- developers/werner/fake-calup/current.start (rev 0)
+++ developers/werner/fake-calup/current.start 2008-11-15 20:08:34 UTC (rev 4788)
@@ -0,0 +1 @@
+gsm_blabla_moko4.m0
Added: developers/werner/fake-calup/fw/gsm_blah_moko8.m0
===================================================================
Added: developers/werner/fake-calup/fw/gsm_blah_moko9_beta2.m0
===================================================================
Added: developers/werner/fake-calup/fw/gsm_blah_moko9beta1.m0
===================================================================
More information about the commitlog
mailing list