r3176 - trunk/src/host/devirginator
werner at sita.openmoko.org
werner at sita.openmoko.org
Mon Oct 15 16:22:33 CEST 2007
Author: werner
Date: 2007-10-15 16:22:30 +0200 (Mon, 15 Oct 2007)
New Revision: 3176
Modified:
trunk/src/host/devirginator/envedit.pl
Log:
envedit.pl: added option "-s size" to set environment size in bytes (for large
page NAND)
envedit.pl: added option "-I dir" to add a path name element to @INC, to allow
envedit.pl to be run from other directories than "."
envedit.pl: if there's a path in $0, automatically add it to @INC
Modified: trunk/src/host/devirginator/envedit.pl
===================================================================
--- trunk/src/host/devirginator/envedit.pl 2007-10-15 13:33:58 UTC (rev 3175)
+++ trunk/src/host/devirginator/envedit.pl 2007-10-15 14:22:30 UTC (rev 3176)
@@ -22,26 +22,38 @@
#
-do 'crc32.pl';
-
-
$ENV_SIZE = 0x4000;
sub usage
{
print STDERR
-"usage: $0 [-i file] [-o file|-p] [-f env_file] [var=[value] ...]\n".
+"usage: $0 [-I dir] [-s size] [-i file] [-o file|-p] [-f env_file]\n".
+" [var=[value] ...]\n".
" -i file read environment from file (default: use empty environment)\n".
" -o file write environment to file (default: write to stdout)\n".
" -p print environment in human-readable form to stdout\n".
+" -s bytes environment size in bytes (default: 16384)\n".
" -f env_file read changes from env_file\n".
+" -I dir add directory to INC path (to find crc32.pl)\n".
" var= remove the specified variable\n".
-" var=value set the specified variable\n";
+" var=value set the specified variable\n".
+"The options -I and -s, if present, must precede all other options.\n";
exit(1);
}
+
+sub do_crc32
+{
+ if (!defined $have_crc) {
+ do 'crc32.pl';
+ $have_crc = 1;
+ }
+ return &crc32(@_);
+}
+
+
sub readenv
{
local ($file) = @_;
@@ -62,7 +74,7 @@
$env .= '\000' x ($ENV_SIZE-length $env);
}
($crc, $env) = unpack("Va*", $env);
- $want = &crc32($env);
+ $want = &do_crc32($env);
if ($crc != $want) {
print STDERR sprintf("CRC error: expected 0x%08x, got 0x%08x\n",
$want, $crc);
@@ -113,6 +125,10 @@
}
+if ($0 =~ m#/[^/]*$#) {
+ push(@INC, $`);
+}
+
while (@ARGV) {
if ($ARGV[0] eq "-i") {
&usage unless defined $ARGV[1];
@@ -131,6 +147,18 @@
$printenv = 1;
shift(@ARGV);
}
+ elsif ($ARGV[0] eq "-s") {
+ &usage if $have_crc;
+ &usage unless defined $ARGV[1];
+ shift(@ARGV);
+ $ENV_SIZE = eval shift(@ARGV);
+ }
+ elsif ($ARGV[0] eq "-I") {
+ &usage if $have_crc;
+ &usage unless defined $ARGV[1];
+ shift(@ARGV);
+ push(@INC, shift @ARGV);
+ }
elsif ($ARGV[0] eq "-f") {
&usage unless defined $ARGV[1];
shift(@ARGV);
@@ -182,7 +210,7 @@
exit(1);
}
$env .= "\000" x ($ENV_SIZE-4-length $env);
- $crc = &crc32($env);
+ $crc = &do_crc32($env);
$env = pack("V", $crc).$env;
if (defined $outfile) {
open(FILE, ">$outfile") || die "$outfile: $!";
More information about the commitlog
mailing list