Created
June 21, 2020 18:49
-
-
Save mstratman/d541932adb592097963afa8c9aeca4c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
input=$1 | |
if [ ! -f "$input" ]; then | |
echo "Usage: ./label-burn.sh path/labels.txt" | |
exit | |
fi | |
output=${input%.txt}.bin | |
./make-labels.pl $input $output | |
echo "Erasing eeprom" | |
ch341eeprom -v -s 24c32 -e | |
echo "Writing EEPROM" | |
ch341eeprom -v -s 24c32 -w $output | |
echo "Checking:" | |
ch341eeprom -v -s 24c32 -r /tmp/eeprom.bin | |
echo "--------look for problem here-------" | |
diff /tmp/eeprom.bin $output | |
echo "---------------------" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use 5.010001; | |
our $PAGE_SIZE = 32; | |
our $NUM_BANKS = 8; | |
our $NUM_STRINGS = 5; | |
our $NUM_PAGES = 128; | |
my $in = shift; | |
my $out = shift; | |
unless ($in && $out) { | |
die "usage: ./make-labels.pl labels.txt labels.hex"; | |
} | |
open(my $fh, '<:encoding(UTF-8)', $in) | |
or die "Could not open file '$in' $!"; | |
my @rows = (); | |
while (my $row = <$fh>) { | |
chomp $row; | |
push @rows, $row; | |
} | |
close $fh; | |
die "Wrong number of lines" unless scalar(@rows) == $NUM_BANKS * $NUM_STRINGS; | |
open $fh, '>', $out or die; | |
binmode $fh; | |
for my $s (@rows) { | |
my @chars = split //, $s; | |
for (my $i = 0; $i < $PAGE_SIZE; $i++) { | |
my $char = shift @chars; | |
$char = "\0" unless length($char); | |
print $fh $char; | |
} | |
} | |
for (my $addr = $NUM_BANKS * $NUM_STRINGS * $PAGE_SIZE; $addr < $NUM_PAGES * $PAGE_SIZE; $addr++) { | |
print $fh "\0"; | |
} | |
close $fh; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment