r4032 - trunk/src/host/devirginator
werner at sita.openmoko.org
werner at sita.openmoko.org
Sun Feb 10 07:34:37 CET 2008
Author: werner
Date: 2008-02-10 07:34:32 +0100 (Sun, 10 Feb 2008)
New Revision: 4032
Added:
trunk/src/host/devirginator/blink.pl
trunk/src/host/devirginator/mknor
Log:
devirginator/blink.pl: linker for binary data of unknown structure
devirginator/mknor: example script that composes a GTA02 NOR image
Added: trunk/src/host/devirginator/blink.pl
===================================================================
--- trunk/src/host/devirginator/blink.pl 2008-02-09 15:36:23 UTC (rev 4031)
+++ trunk/src/host/devirginator/blink.pl 2008-02-10 06:34:32 UTC (rev 4032)
@@ -0,0 +1,97 @@
+#!/usr/bin/perl
+#
+# blink.pl - Binary Linker
+#
+# Copyright (C) 2008 by OpenMoko, Inc.
+# Written by Werner Almesberger <werner at openmoko.org>
+# All Rights Reserved
+#
+
+#
+# usage: blink.pl item ...
+#
+# Build an image containing the items specified on the command line and print
+# the resulting data to stdout. Any gaps in the data are filled with zero
+# bytes.
+#
+# "item" is
+#
+# object[@[=]address]
+#
+# - if no address is specified, the new object the places after the previous
+# one
+# - the address can be decimal, hex, or octal, following the usual C
+# conventions
+# - if the address is lower than the current position, it must be prefixed with
+# an equal sign
+#
+# "object" is one of
+#
+# filename
+# "string"
+# value[/bytes]
+#
+# - the default value size is four bytes
+# - note that the double quotes of a string must be protected from the shell
+#
+# E.g.,
+# blink.pl foo.bin /tmp/bar.bin at 0x1000 0x1000/4@=0x10 '"hello"'@0x2000
+#
+
+
+$addr = 0;
+
+
+sub put
+{
+ $data .= "\000" x ($addr-length $data) if $addr > length $data;
+ substr($data, $addr, length $_[0], $_[0]);
+ $addr += length $_[0];
+}
+
+
+for (@ARGV) {
+ if (/@(=?)(0[Xx][0-9a-fA-F]+|[0-9]+)$/) {
+ $obj = $`;
+ $new = eval $2;
+ die "new address $2 before current address"
+ if $new < $addr && $1 ne "=";
+ $addr = $new;
+ }
+ else {
+ $obj = $_;
+ }
+ if ($obj =~ m#^(0[xX][0-9a-fA-F]+|0-9+)(/[124])?$#) {
+ $val = pack(!defined $2 || $2 == 4 ? "V" : $2 == 2 ? "v" : "c",
+ eval $1);
+ &put($val);
+ }
+ elsif ($obj =~ /^"(.*)"$/) {
+ ($in, $out) = ($1, "");
+ while ($in =~ /\\([0-7]{1,3}|[^0-7])/) {
+ $out .= $`;
+ if (index("01234567", substr($1, 0, 1)) == -1) {
+ $n = index("bnrt", $1);
+ if ($n == -1) {
+ $out .= $1;
+ }
+ else {
+ $out .= substr("\b\n\r\t", $n, 1);
+ }
+ }
+ else {
+ $out .= pack("c", oct $1);
+ }
+ $in = $';
+ }
+ &put($out.$in."\000");
+ }
+ else {
+ open(FILE, $obj) || die "$obj: $!";
+ defined read(FILE, $data, -s FILE, $addr) || die "$obj: $!";
+ close FILE;
+ $addr += -s FILE;
+ }
+}
+
+die "print: $!" unless print $data;
Property changes on: trunk/src/host/devirginator/blink.pl
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/src/host/devirginator/mknor
===================================================================
--- trunk/src/host/devirginator/mknor 2008-02-09 15:36:23 UTC (rev 4031)
+++ trunk/src/host/devirginator/mknor 2008-02-10 06:34:32 UTC (rev 4032)
@@ -0,0 +1,121 @@
+#!/bin/sh
+#
+# mknor - Make a GTA02 NOR binary (containing u-boot and a new environment)
+#
+# Copyright (C) 2008 by OpenMoko, Inc.
+# Written by Werner Almesberger <werner at openmoko.org>
+# All Rights Reserved
+#
+
+#
+# WARNING * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING
+#
+# This isn't the final version of NOR image creation yet, and some things may
+# not work as expected.
+#
+# WARNING * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING
+#
+
+#
+# Write to NOR with the following commands:
+#
+# flash_unlock /dev/mtd0
+# flash_eraseall /dev/mtd0
+# cat nor.bin >/dev/mtd0
+#
+
+#
+# NOR map:
+#
+# Physical address in MCU address space
+# | Offset in NOR
+# | | Description
+# | | |
+# 0x18 00 0000 beginning of NOR, u-boot (256kB)
+# 0x18 04 0000 splash image
+# 0x18 05 0000 preboot command
+# 0x18 05 0100 preboot script
+# 0x18 05 1000 environment
+# 0x18 1F FFFF end of NOR (2MB)
+#
+
+#unzip 0x18070000 0x8800000 0x96000
+
+./scriptify.pl <<EOF >_script
+neo backlight off
+neo backlight on
+unzip 0x18040000 0x885dc00 0x38400
+dynpart
+echo READY.
+EOF
+
+pngtopnm tmp/System_boot.png |
+ pamcut 0 145 480 240 |
+ ../splash/splashimg.pl -pnm - |
+ gzip -9 >_splash
+
+./envedit.pl -f - -o _env <<EOF
+mtdids=nor0=physmap-flash,nand0=neo1973-nand
+
+stdin=usbtty
+stdout=usbtty
+stderr=usbtty
+
+bootdelay=5
+
+usbtty=cdc_acm
+
+boot_menu_timeout=72000
+
+bootargs_base=
+ rootfstype=jffs2
+ root=/dev/mtdblock5
+ 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/fr/u-boot/u-boot.udfu at 0 \
+ _splash at 0x40000 \
+ '"autoscr 0x18050100"'@0x50000 \
+ _script at 0x050100 \
+ _env at 0x51000 \
+ 0x18050000@=0x40 \
+ 0x18051004 at 0x44 \
+ >nor.bin || { rm -rf nor.bin; exit 1; }
+
+rm -f _splash _script _env
Property changes on: trunk/src/host/devirginator/mknor
___________________________________________________________________
Name: svn:executable
+ *
More information about the commitlog
mailing list