Fix self-provisioning: write INFO_LOCK_BYTE and EEPROM checksum

Self-provisioning wrote 0x00 to ADDR_INFO_LOCK instead of
INFO_LOCK_BYTE (0x73), causing eeprom_lock_set() to fail and
hw_ready to stay false after flash erase.

Also computes and writes the MD5 checksum over the first 11 EEPROM
bytes so eeprom_checksum_valid() passes without rnodeconf.
This commit is contained in:
GlassOnTin 2026-03-31 02:04:39 +01:00
commit c3ab57f484

View file

@ -137,8 +137,16 @@ void setup() {
EEPROM.write(eeprom_addr(ADDR_MADE+1), 0x00);
EEPROM.write(eeprom_addr(ADDR_MADE+2), 0x00);
EEPROM.write(eeprom_addr(ADDR_MADE+3), 0x00);
EEPROM.write(eeprom_addr(ADDR_INFO_LOCK), 0x00);
EEPROM.write(eeprom_addr(ADDR_INFO_LOCK), INFO_LOCK_BYTE);
EEPROM.write(eeprom_addr(ADDR_CONF_OK), CONF_OK_BYTE);
// Compute and write EEPROM checksum (MD5 of first CHECKSUMMED_SIZE bytes)
char chk_data[CHECKSUMMED_SIZE];
for (uint8_t i = 0; i < CHECKSUMMED_SIZE; i++)
chk_data[i] = EEPROM.read(eeprom_addr(i));
unsigned char *chk_hash = MD5::make_hash(chk_data, CHECKSUMMED_SIZE);
for (uint8_t i = 0; i < 16; i++)
EEPROM.write(eeprom_addr(ADDR_CHKSUM + i), chk_hash[i]);
free(chk_hash);
EEPROM.commit();
}
#endif