r1094 - in trunk/src/host: . devirginator

werner at sita.openmoko.org werner at sita.openmoko.org
Sat Feb 24 08:11:28 CET 2007


Author: werner
Date: 2007-02-24 08:10:50 +0100 (Sat, 24 Feb 2007)
New Revision: 1094

Added:
   trunk/src/host/devirginator/
   trunk/src/host/devirginator/Makefile
   trunk/src/host/devirginator/README
   trunk/src/host/devirginator/config.example
   trunk/src/host/devirginator/scriptify.pl
   trunk/src/host/devirginator/setup.sh
   trunk/src/host/devirginator/smiley.fig
   trunk/src/host/devirginator/u-boot.in
Log:
First experimental version of the device bringup tool.



Added: trunk/src/host/devirginator/Makefile
===================================================================
--- trunk/src/host/devirginator/Makefile	2007-02-24 05:42:28 UTC (rev 1093)
+++ trunk/src/host/devirginator/Makefile	2007-02-24 07:10:50 UTC (rev 1094)
@@ -0,0 +1,41 @@
+#
+# Makefile - Setup and handling of prerequisites
+#
+# Copyright (C) 2006-2007 by OpenMoko, Inc.
+# Written by Werner Almesberger <werner at openmoko.org>
+# All Rights Reserved
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+
+devirginate:	config setup.sh smiley.gz
+		mkdir -p tmp
+		./setup.sh
+
+smiley.ppm:	smiley.fig
+		fig2dev -L ppm -m 2 $< >$@ || { rm -f $@; exit 1; }
+
+smiley.png:	smiley.ppm
+		pnmpad -white -width 480 -height 640 $< | \
+		  ppmchange '#ffffff' '#00ff00' | \
+		  pnmtopng >$@ || { rm -f $@; exit 1; }
+
+smiley.gz:	smiley.png
+		../splash/splashimg.pl $< | gzip -9 >$@
+
+config:
+		@echo 'Please provide a "config" file.' 1>&2
+		@echo 'See "config.example" for details.' 1>&2
+		@exit 1

Added: trunk/src/host/devirginator/README
===================================================================
--- trunk/src/host/devirginator/README	2007-02-24 05:42:28 UTC (rev 1093)
+++ trunk/src/host/devirginator/README	2007-02-24 07:10:50 UTC (rev 1094)
@@ -0,0 +1,41 @@
+Devirginator
+============
+
+This collection of scripts initializes a "virgin" device. At the moment, this
+goes as far as allowing it to boot into u-boot, from where the rest will be
+done with DFU.
+
+First,
+% cp config.example config
+and may changes as needed. Then
+% make
+This requires Netpbm and transfig. Finally, make sure that openocd runs,
+power device up and run
+% ./devirginate
+
+The first few messages should look like this:
+Open On-Chip Debugger
+> script /home/moko/om/trunk/src/host/devirginator/tmp/script.ocd
+reset halt
+wait_halt
+waiting for target halted...
+Target 0 halted
+target halted in ARM state due to debug request, current mode: Supervisor
+cpsr: 0x400000d3 pc: 0x00000000
+[...]
+
+The "pc: 0x00000000" is important. If the number is different, e.g.,
+something like "pc: 0xffffffed", the device is probably not turned
+on. In this case, you can try to restart, or, if openocd is stuck,
+
+- kill openocd
+- pull and then replace the USB plug of the JTAGkey or debug v2 board
+- start openocd
+
+The whole procedure takes a bit longer than two minutes. Rough timeline
+(numbers are guessed and may be off by some 30 seconds):
+
+00:00  screen goes dark
+00:35  small tux logo with superimposed u-boot version string appears
+02:00  screen briefly goes dark
+02:02  smiley on green background appears

Added: trunk/src/host/devirginator/config.example
===================================================================
--- trunk/src/host/devirginator/config.example	2007-02-24 05:42:28 UTC (rev 1093)
+++ trunk/src/host/devirginator/config.example	2007-02-24 07:10:50 UTC (rev 1094)
@@ -0,0 +1,9 @@
+#
+# config - devirginator configuration
+#
+# This is a shell script sourced by "setup.sh".
+#
+
+OPENOCD_HOST=fs
+LOWLEVEL=$OMDIR/u-boot/board/neo1973/lowlevel_foo.bin
+UBOOT=$OMDIR/u-boot/u-boot.bin

Added: trunk/src/host/devirginator/scriptify.pl
===================================================================
--- trunk/src/host/devirginator/scriptify.pl	2007-02-24 05:42:28 UTC (rev 1093)
+++ trunk/src/host/devirginator/scriptify.pl	2007-02-24 07:10:50 UTC (rev 1094)
@@ -0,0 +1,55 @@
+#!/usr/bin/perl
+#
+# scriptify.pl - Convert a text file to a script image for u-boot's "autoscr"
+#
+# Copyright (C) 2006-2007 by OpenMoko, Inc.
+# Written by Werner Almesberger <werner at openmoko.org>
+# All Rights Reserved
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+
+use Archive::Zip;
+
+while (<>) {
+    s/#.*//;
+    next if /^\s*$/;
+    $cmd .= $_;
+}
+
+$cmd .= pack("c",0);
+$cmd = pack("NN",length $cmd,0).$cmd;
+
+$crc = Archive::Zip::computeCRC32($cmd,0);
+
+$hdr = pack("NNNNNNNcccca32",
+  0x27051956,	# ih_magic (IH_MAGIC)
+  0,		# ih_crc
+  time, 	# ih_time
+  length $cmd,	# ih_size
+  0,		# ih_load
+  0,		# ih_ep 
+  $crc,		# ih_dcrc
+  17,		# ih_os (IH_OS_U_BOOT)
+  2,		# ih_arch (IH_CPU_ARM)
+  6,		# ih_type (IH_TYPE_SCRIPT)
+  0,		# ih_comp (IH_COMP_NONE)
+  "script");	# ih_name
+
+$crc = Archive::Zip::computeCRC32($hdr,0);
+
+substr($hdr,4,4) = pack("N",$crc);
+
+print $hdr.$cmd;


Property changes on: trunk/src/host/devirginator/scriptify.pl
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/src/host/devirginator/setup.sh
===================================================================
--- trunk/src/host/devirginator/setup.sh	2007-02-24 05:42:28 UTC (rev 1093)
+++ trunk/src/host/devirginator/setup.sh	2007-02-24 07:10:50 UTC (rev 1094)
@@ -0,0 +1,85 @@
+#!/bin/sh -e
+#
+# setup.sh - Set up the devirginator
+#
+# Copyright (C) 2006-2007 by OpenMoko, Inc.
+# Written by Werner Almesberger <werner at openmoko.org>
+# All Rights Reserved
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+
+OPENOCD_HOST=localhost
+OPENOCD_PORT=4444
+UBOOTDIR=${OMDIR:-/home/moko}/u-boot
+LOWLEVEL=$UBOOTDIR/board/neo1973/lowlevel_foo.bin
+UBOOT=$UBOOTDIR/u-boot.bin
+
+. config
+
+cat <<EOF >tmp/script.ocd
+reset halt
+wait_halt
+load_binary $LOWLEVEL 0
+bp 0x33f80000 4 hw
+resume
+wait_halt
+rbp 0x33f80000
+load_binary $UBOOT 0x32000000
+load_binary $PWD/tmp/preboot_override 0x32100000
+load_binary $PWD/tmp/u-boot.out 0x32200000
+load_binary $PWD/tmp/smiley.gz 0x32300000
+mww 0x32000040 0x32100000
+resume 0x32000000
+exit
+EOF
+
+sed 's/#.*//;/^ *$/d' <<EOF | tr '\n' ';' | tr '!' '\000' >tmp/preboot_override
+autoscr 0x32200000!
+EOF
+
+perl ./scriptify.pl u-boot.in >tmp/u-boot.out
+
+export OMDIR
+make smiley.gz
+mv smiley.gz tmp/
+rm -f smiley.png smiley.ppm
+
+cat <<EOF >devirginate
+#!/bin/sh
+# MACHINE-GENERATED. DO NOT EDIT !
+echo ===== STARTING ===========================================================
+{
+    echo script $PWD/tmp/script.ocd
+    sleep 120
+} | telnet $OPENOCD_HOST $OPENOCD_PORT
+echo ===== CONTINUING IN THE BACKGROUND =======================================
+EOF
+chmod +x devirginate
+
+cat <<EOF
+-------------------------------------------------------------------------------
+
+Your devirginator is now ready.
+
+To set up a device,
+
+- connect it to power and JTAG
+- switch it on
+- run ./devirginate
+- wait until the smiley appears (takes about one minute)
+
+-------------------------------------------------------------------------------
+EOF


Property changes on: trunk/src/host/devirginator/setup.sh
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/src/host/devirginator/smiley.fig
===================================================================
--- trunk/src/host/devirginator/smiley.fig	2007-02-24 05:42:28 UTC (rev 1093)
+++ trunk/src/host/devirginator/smiley.fig	2007-02-24 07:10:50 UTC (rev 1094)
@@ -0,0 +1,13 @@
+#FIG 3.2
+Landscape
+Center
+Inches
+Letter  
+100.00
+Single
+-2
+1200 2
+5 1 0 10 0 0 50 0 -1 0.000 0 1 0 0 5100.000 3975.000 4200 3975 5100 4875 6000 3975
+1 3 0 0 0 0 50 0 20 0.000 1 0.0000 4500 3375 225 225 4500 3375 4725 3375
+1 3 0 10 0 0 50 0 -1 0.000 1 0.0000 5100 3900 1500 1500 5100 3900 6600 3900
+1 3 0 0 0 0 50 0 20 0.000 1 0.0000 5700 3375 225 225 5700 3375 5925 3375

Added: trunk/src/host/devirginator/u-boot.in
===================================================================
--- trunk/src/host/devirginator/u-boot.in	2007-02-24 05:42:28 UTC (rev 1093)
+++ trunk/src/host/devirginator/u-boot.in	2007-02-24 07:10:50 UTC (rev 1094)
@@ -0,0 +1,45 @@
+#
+# Initial setup of a "virgin" device.
+#
+# Note that this yields a fairly unusual setup. The main goal is to prepare for
+# uploading the rest through DFU (JTAG would be far too slow for this), or any
+# interactive testing one may wish to do.
+#
+
+# we're non-interactive
+
+setenv dontask y
+
+# remove any pre-existing bad block table and create a new one
+
+nand scrub 0x3ff0000 0x10000
+nand createbbt
+
+# create the partition table
+
+dynpart
+
+# unset preboot command
+
+mw.l 0x32000040 0 1
+
+# write u-boot
+
+nand write.e 0x32000000 u-boot 0x40000
+
+# set up the pre-DFU environment (604800 seconds is one week)
+
+dynenv set u-boot_env
+setenv bootcmd
+setenv bootdelay 604800
+setenv splashimage nand read.e 0x32000000 splash 0x1000\; unzip 0x32000000 0x33d00000 0x96000
+setenv usbtty cdc_acm
+saveenv
+
+# write the smiley last
+
+nand write.e 0x32300000 splash 0x1000
+
+# reset to get the smiley
+
+reset





More information about the commitlog mailing list