On Sep 14, 2005, at 11:21 AM, Joerg Wunsch wrote:
"E. Weddington" <[EMAIL PROTECTED]> wrote:
I would strongly suggest looking at the SRecord utilities.
I think his point was to avoid calling another utility, and have
avrdude write something directly to a certain memory location.
Otherwise you're right, if you want to use a separate load file, it's
quite easy. It doesn't even need srecord-style tools, it probably
takes some kind of scripting language to manage the serial number
database anyway, so that scripting language could as well drop out an
ihex file directly.
Here's a little perl program that generates a single S3 record at a
given address.
So for instance, if you wanted the serial number 1234 embedded as a 4-
byte little-endian value at address 0x800000, you'd do:
$ perl srecord.pl 0x800000 V 1234
and you'd get the single line:
S30900800000d2040000a9
It might be useful as an example, but I haven't tried it with avrdude.
#/usr/bin/perl -w
#
# Generator of single S3 records for EEPROM branding
#
# author: Ned Konz <[EMAIL PROTECTED]>
# date: Fri Nov 18 11:56:20 PST 2005
# license: public domain
#
sub usage
{
print STDERR "usage:
perl srecord.pl <start-address> <typeflags> <data> [...]
where start-address is a C number literal (1234, 0x1234, or 01234)
and typeflags is a string of one or more Perl pack() codes, including:
c 1 byte integer
v unsigned short (2 byte) integer, little-endian
V unsigned long (4 byte) integer, little-endian
H* hex string of arbitrary length
if data is '-' then number/hex string is read from stdin
";
}
# Main program
if ($#ARGV < 2)
{
usage();
exit(1);
}
our $startAddress = shift();
$startAddress= oct($startAddress) if $startAddress =~ /^0/;
our $typeFlag = shift();
our @data = ();
foreach my $arg (@ARGV)
{
if ($arg eq '-') { $arg = <STDIN>; }
else { $arg = oct($arg) if $arg =~ /^0/; }
push @data, $arg;
}
if ($type = ($typeFlag =~ m/[a-zA-Z]/))
{
# first, pack both the data and start address
my $packed = pack($typeFlag, @data);
my $packedAddress = pack("V*", $startAddress);
# so we can generate the checksum
my $checksum = (~ unpack("%*A*", $packedAddress . $packed)) & 0xff;
my $sLength = 5 + length($packed);
printf("S3%02x%08x%s%02x\n", $sLength, $startAddress, unpack("H*", $packed), $checksum);
}
else
{
usage();
exit(2);
}
_______________________________________________
AVR-chat mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/avr-chat