Skip to content

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
fredlcore authored Oct 21, 2024
1 parent 3e9fe91 commit 498b85a
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions scripts/dump_eeprom.pl
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/usr/bin/perl

# This Perl script extracts information from a binary dump of the EEPROM
# of a Zucchetti AM2000 motherboard. The EEPROM on the board is located in
# different positions, but can be read using a standard EEPROM reader and has
# a size of 2kB.
# Usage: ./dump_eeprom.pl <eeprom_binary.bin>

open (EEPROM, "$ARGV[0]");
while ($line = <EEPROM>) {
$dump .= $line;
Expand All @@ -8,13 +14,13 @@
$dump_layout = unpack("C", substr($dump, 1, 1));

@structure = (
"Model code", "0x%X", "C", 0x00, 1, 1,
"Password", "%04d", "n", 0x57, 2, 1,
"First charge (Y/M/D)", "20%02d/%02d/%02d", "CCC", 0x89,3, 1,
"Last service (Y/M/D)", "20%02d/%02d/%02d", "CCC", 0x83,3, 1,
"Model code", "0x%X", "C", 0x00, 1, 0,
"Password", "%04d", "n", 0x57, 2, 0,
"First charge (Y/M/D)", "20%02d/%02d/%02d", "CCC", 0x89,3, 0,
"Last service (Y/M/D)", "20%02d/%02d/%02d", "CCC", 0x83,3, 0,
"Total work time", "%d hours", "L>", 0x53, 4, 1/60,
"Last error (Y/M/D)", "20%d/%02d/%02d", "CCC", 0x4b,3, 1,
"Last Bluetooth device", "%02X:%02X:%02X:%02X:%02X:%02X","CCCCCC", 0x0f, 6, 1
"Last error (Y/M/D)", "20%d/%02d/%02d", "CCC", 0x4b,3, 0,
"Last Bluetooth device", "%02X:%02X:%02X:%02X:%02X:%02X","CCCCCC", 0x0f, 6, 0,
);

for ($x=0; $x<scalar @structure; $x=$x+6) {
Expand All @@ -27,5 +33,9 @@
if ($index > 0x6E && $dump_layout < 0x14) {
$index--;
}
print sprintf("$desc: $format\n", unpack($pattern, substr($dump, $index-$offset, $len)) * $factor);
@value = unpack($pattern, substr($dump, $index, $len));
if ($factor) {
$value[0] = $value[0] * $factor;
}
print sprintf("$desc: $format\n", @value);
}

0 comments on commit 498b85a

Please sign in to comment.