AVRISP-MKII Clone: Add EEPROM magic number validation
authorSergey Vlasov <sigprof@gmail.com>
Sun, 26 Sep 2021 09:58:48 +0000 (12:58 +0300)
committerSergey Vlasov <sigprof@gmail.com>
Sun, 26 Sep 2021 13:25:33 +0000 (16:25 +0300)
commit24e03fb4d1ec3337bfdf14ae5a08ba96841eaaa9
treeffbeafe25a1c784280f4c4cd325093e0e9bb15ff
parent15bc1eeb6641ee0fbeded91c3e87e1844b5559ac
AVRISP-MKII Clone: Add EEPROM magic number validation

If the compiled AVRISP-MKII Clone firmware is flashed into a previously
used chip without writing the corresponding initial EEPROM data, the
code could not detect that the stored parameter data was not valid, and
blindly used whatever values were left in the EEPROM.  This was
especially problematic when the reset polarity happened to be set
wrongly, because avrdude does not have any options to set that parameter
(it sends the corresponding commands only if it detects STK500 or
STK600, and does not send that command for AVRISP-MKII).

Add a check for a 4-byte magic number in the EEPROM, so that any data
which was left there by some different code could be properly ignored
and erased before using the EEPROM storage for AVRISP-MKII Clone data.
Projects/AVRISP-MKII/Lib/V2ProtocolParams.c