r4126 - in trunk/src/host/devirginator: . tests
werner at sita.openmoko.org
werner at sita.openmoko.org
Thu Feb 28 10:43:04 CET 2008
Author: werner
Date: 2008-02-28 10:42:58 +0100 (Thu, 28 Feb 2008)
New Revision: 4126
Added:
trunk/src/host/devirginator/tests/recurse
Modified:
trunk/src/host/devirginator/envedit.pl
trunk/src/host/devirginator/environment.in
trunk/src/host/devirginator/mknor
trunk/src/host/devirginator/setup.sh
Log:
mknor: we don't need to set "mtdids" and "usbtty"
mknor: reduced boot_menu_timeout from 20 hours to 1 minute
environment.in, mknor: unified NOR and NAND environment in environment.in
environment.in: added boot from SD/MMC with a combined FAT+ext2 setup
environment.in: moved "Power off" to the end of the menu
environment.in: abstracted u-boot MMC device number
environment.in: let user override init=... (e.g., with -D INIT=/bin/sh) and the name of the kernel file when booting from SD/MMC (e.g., with
-D SD_KERNEL=uImage.bin)
setup.sh: added option -l to use local files without accessing the network
setup.sh (usage): added description of options
envedit.pl: added comment that just "#define MACRO" is also valid
envedit.pl, tests/recurse: added support for cpp-like handling of recursive
macros
Modified: trunk/src/host/devirginator/envedit.pl
===================================================================
--- trunk/src/host/devirginator/envedit.pl 2008-02-28 04:20:40 UTC (rev 4125)
+++ trunk/src/host/devirginator/envedit.pl 2008-02-28 09:42:58 UTC (rev 4126)
@@ -33,6 +33,7 @@
#
# Macro expansion:
#
+# #define MACRO
# #define MACRO TEXT ...
# MACRO
# MACRO##TOKEN
@@ -151,6 +152,35 @@
}
+sub expand
+{
+ local ($s, @key) = @_;
+ local ($tmp, $pre, $exp, $post);
+ local ($i, @tmp);
+
+ $tmp = "";
+ while (length $s) {
+ $pre = $s;
+ $exp = "";
+ $post = "";
+ for ($i = 0; $i <= $#key; $i++) {
+ @tmp = @key;
+ splice(@tmp, $i, 1);
+ if ($s =~ /(##)?\b$key[$i]\b(##)?/) {
+ if (length $` < length $pre) {
+ $pre = $`;
+ $post = $';
+ $exp = &expand($def{$key[$i]}, @tmp);
+ }
+ }
+ }
+ $tmp .= $pre.$exp;
+ $s = $post;
+ }
+ return $tmp;
+}
+
+
if ($0 =~ m#/[^/]*$#) {
push(@INC, $`);
}
@@ -254,24 +284,7 @@
$def{$1} = $3;
}
- $tmp = "";
- while (length $_) {
- $pre = $_;
- $exp = "";
- $post = "";
- for $def (keys %def) {
- if (/(##)?\b$def\b(##)?/) {
- if (length $` < length $pre) {
- $pre = $`;
- $exp = $def{$def};
- $post = $';
- }
- }
- }
- $tmp .= $pre.$exp;
- $_ = $post;
- }
- $_ = $tmp;
+ $_ = &expand($_, keys %def);
s/#.*//;
s/\s*$//;
Modified: trunk/src/host/devirginator/environment.in
===================================================================
--- trunk/src/host/devirginator/environment.in 2008-02-28 04:20:40 UTC (rev 4125)
+++ trunk/src/host/devirginator/environment.in 2008-02-28 09:42:58 UTC (rev 4126)
@@ -12,22 +12,38 @@
#define CONSOLE ttySAC2
#define ROOTDEV /dev/mtdblock6
#define FRAMEBUFFER 0x8800000
+#define MMC_NUM 1
#else # GTA01
#define CONSOLE ttySAC0
#define ROOTDEV /dev/mtdblock4
#define FRAMEBUFFER 0x33d00000
+#define MMC_NUM 0
#endif
+#ifdef INIT
+#define INIT_OPT init=INIT
+#else
+#define INIT_OPT
+#endif
+#ifndef SD_KERNEL
+#define SD_KERNEL uImage
+#endif
+
+
+##### Common settings #########################################################
+
+
bootargs_base=
rootfstype=jffs2
root=ROOTDEV
console=CONSOLE,115200
console=tty0
loglevel=8
+ INIT_OPT
regular_boot
bootcmd=
@@ -35,6 +51,23 @@
nand read.e 0x32000000 kernel 0x200000;
bootm 0x32000000
+stdout=usbtty
+stderr=usbtty
+stdin=usbtty
+
+sd_image_name=SD_KERNEL
+
+
+##### Appearance and mode of interaction ######################################
+
+
+#ifdef NOR
+
+bootdelay=5
+boot_menu_timeout=60
+
+#else
+
bootdelay=1
quiet=1
@@ -43,39 +76,67 @@
nand read.e 0x32000000 splash 0x5000;
unzip 0x32000000 FRAMEBUFFER 0x96000
-stdout=usbtty
-stderr=usbtty
-stdin=usbtty
+#endif
-sd_image_name=uImage
+##### Menu items ##############################################################
+
+
menu_1=
- Boot from microSD:
+ Boot from microSD (FAT+ext2):
setenv bootargs
+ ${bootargs_base} rootfstype=ext2 rootfs=/dev/mmcblk0p2 rootdelay=5
+ ${mtdparts} ro;
+ mmcinit;
+ fatload mmc MMC_NUM 0x32000000 ${sd_image_name};
+ bootm 0x32000000
+
+menu_2=
+ Boot from microSD (ext2):
+ setenv bootargs
${bootargs_base} rootfstype=ext2 rootfs=/dev/mmcblk0p1 rootdelay=5
${mtdparts} ro;
mmcinit;
- ext2load mmc 0 0x32000000 /boot/${sd_image_name};
+ ext2load mmc MMC_NUM 0x32000000 /boot/${sd_image_name};
bootm 0x32000000
-menu_2=
+#ifdef NOR
+
+menu_3=
+ Copy u-boot from NOR to NAND:
+ cp.l 0x18000000 0x32000000 0x10000;
+ mw.l 0x32000040 0 2;
+ nand write.e 0x32000000 0 0x40000;
+ dynenv set u-boot_env
+
+#endif
+
+menu_4=
Set console to USB:
setenv stdin usbtty;
setenv stdout usbtty;
setenv stderr usbtty
-menu_3=
+menu_5=
Set console to serial:
setenv stdin serial;
setenv stdout serial;
setenv stderr serial
-menu_4=
- Power off:
- neo1973 power-off
+menu_6=
+ Reset:
+ reset
-menu_5=
+#ifdef UNUSED
+
+menu_7=
Factory reset:
defaultenv;
dynpart;
bootd
+
+#endif
+
+menu_8=
+ Power off:
+ neo1973 power-off
Modified: trunk/src/host/devirginator/mknor
===================================================================
--- trunk/src/host/devirginator/mknor 2008-02-28 04:20:40 UTC (rev 4125)
+++ trunk/src/host/devirginator/mknor 2008-02-28 09:42:58 UTC (rev 4126)
@@ -58,60 +58,8 @@
../splash/splashimg.pl -pnm - |
gzip -9 >_splash
-./envedit.pl -f - -o _env <<EOF
-mtdids=nor0=physmap-flash,nand0=neo1973-nand
+./envedit.pl -D GTA02 -D NOR -f environment.in -o _env
-stdin=usbtty
-stdout=usbtty
-stderr=usbtty
-
-bootdelay=5
-
-usbtty=cdc_acm
-
-boot_menu_timeout=72000
-
-bootargs_base=
- rootfstype=jffs2
- root=/dev/mtdblock6
- console=ttySAC2,115200
- console=tty0
- loglevel=8
- regular_boot
-
-bootcmd=
- setenv bootargs \${bootargs_base} \${mtdparts};
- nand read.e 0x32000000 kernel 0x200000;
- bootm 0x32000000
-
-menu_1=
- Copy u-boot from NOR to NAND:
- cp.l 0x18000000 0x32000000 0x10000;
- mw.l 0x32000040 0 2;
- nand write.e 0x32000000 0 0x40000;
- dynenv set u-boot_env
-
-menu_2=
- Set console to USB:
- setenv stdin usbtty;
- setenv stdout usbtty;
- setenv stderr usbtty
-
-menu_3=
- Set console to serial:
- setenv stdin serial;
- setenv stdout serial;
- setenv stderr serial
-
-menu_4=
- Reset:
- reset
-
-menu_5=
- Power off:
- neo1973 power-off
-EOF
-
./blink.pl \
/home/moko/2624/u-boot/u-boot.udfu at 0 \
_splash at 0x40000 \
Modified: trunk/src/host/devirginator/setup.sh
===================================================================
--- trunk/src/host/devirginator/setup.sh 2008-02-28 04:20:40 UTC (rev 4125)
+++ trunk/src/host/devirginator/setup.sh 2008-02-28 09:42:58 UTC (rev 4126)
@@ -26,6 +26,8 @@
USB_ID_GTA01=-d1457:5119
USB_ID_GTA02=-d1d50:5119
+DEFAULT_CONFIG=config
+
mkdir -p tmp
@@ -34,15 +36,25 @@
download()
{
+ base="`basename \"$2\"`"
+
+ # if it is a local file, just use it
if [ -r "$2" ]; then
if $tarball; then
- base="`basename \"$2\"`"
cp "$2" "tmp/$base"
eval $1=\"tmp/$base\"
add_file "tmp/$base"
fi
return
fi
+
+ # don't look for updates if we can use cached files
+ if [ -r "tmp/$base" ] && $local; then
+ eval $1=\"tmp/$base\"
+ add_file "tmp/$base"
+ return
+ fi
+
index=tmp/index-${SNAPSHOT}.html
rm -f $index
wget -O $index "`dirname \"$2\"`/"
@@ -108,13 +120,20 @@
usage()
{
- echo "usage: $0 [-c config_file] [-t] [variable=value ...]" 1>&2
+cat <<EOF 1>&2
+usage: $0 [-c config_file] [-l] [-t] [variable=value ...]
+
+ -c config_file use the specified file (default: $DEFAULT_CONFIG)
+ -l use locally cached files (in tmp/), if present
+ -t make a tarball of all the downloaded and generated files
+EOF
exit 1
}
tarball=false
-config=config
+local=false
+config=$DEFAULT_CONFIG
while [ ! -z "$*" ]; do
case "$1" in
@@ -122,6 +141,7 @@
[ ! -z "$1" ] || usage
config=$1;;
-t) tarball=true;;
+ -l) local=true;;
*=*) eval "$1";;
*) usage;;
esac
Added: trunk/src/host/devirginator/tests/recurse
===================================================================
--- trunk/src/host/devirginator/tests/recurse 2008-02-28 04:20:40 UTC (rev 4125)
+++ trunk/src/host/devirginator/tests/recurse 2008-02-28 09:42:58 UTC (rev 4126)
@@ -0,0 +1,62 @@
+#!/bin/sh
+. Common
+
+# -----------------------------------------------------------------------------
+
+setup "macro within macro" <<EOF
+EOF
+
+edit -D bar=blah -p <<EOF
+#define foo bar
+a=foo
+EOF
+
+expect <<EOF
+a=blah
+EOF
+
+# -----------------------------------------------------------------------------
+
+setup "macro within macro within macro" <<EOF
+EOF
+
+edit -p <<EOF
+#define a b
+#define c d
+#define b c
+a=foo
+EOF
+
+expect <<EOF
+d=foo
+EOF
+
+# -----------------------------------------------------------------------------
+
+setup "self-recursive macro" <<EOF
+EOF
+
+edit -p <<EOF
+#define foo foo
+a=foo
+EOF
+
+expect <<EOF
+a=foo
+EOF
+
+# -----------------------------------------------------------------------------
+
+setup "two-macro recursion" <<EOF
+EOF
+
+edit -p <<EOF
+#define foo bar
+#define bar blah
+#define blah bar
+a=foo
+EOF
+
+expect <<EOF
+a=bar
+EOF
Property changes on: trunk/src/host/devirginator/tests/recurse
___________________________________________________________________
Name: svn:executable
+ *
More information about the commitlog
mailing list