Fix broken EEPROM save/load
This commit is contained in:
parent
f0fe26c411
commit
3370329751
@ -625,15 +625,18 @@ void MarlinSettings::postprocess() {
|
||||
if (!eeprom_error) {
|
||||
const int eeprom_size = eeprom_index;
|
||||
|
||||
const uint16_t tcrc = working_crc;
|
||||
|
||||
// Write the EEPROM header
|
||||
eeprom_index = EEPROM_OFFSET;
|
||||
|
||||
EEPROM_WRITE(version);
|
||||
EEPROM_WRITE(working_crc);
|
||||
EEPROM_WRITE(tcrc);
|
||||
|
||||
// Report storage size
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOPAIR("Settings Stored (", eeprom_size - (EEPROM_OFFSET));
|
||||
SERIAL_ECHOPAIR(" bytes; crc ", working_crc);
|
||||
SERIAL_ECHOPAIR(" bytes; crc ", tcrc);
|
||||
SERIAL_ECHOLNPGM(")");
|
||||
}
|
||||
|
||||
@ -982,11 +985,11 @@ void MarlinSettings::postprocess() {
|
||||
}
|
||||
else {
|
||||
SERIAL_ERROR_START;
|
||||
SERIAL_ERRORPGM("EEPROM checksum mismatch - (stored CRC)");
|
||||
SERIAL_ERRORPGM("EEPROM CRC mismatch - (stored) ");
|
||||
SERIAL_ERROR(stored_crc);
|
||||
SERIAL_ERRORPGM(" != ");
|
||||
SERIAL_ERROR(working_crc);
|
||||
SERIAL_ERRORLNPGM(" (calculated CRC)!");
|
||||
SERIAL_ERRORLNPGM(" (calculated)!");
|
||||
reset();
|
||||
}
|
||||
|
||||
@ -1027,7 +1030,6 @@ void MarlinSettings::postprocess() {
|
||||
return !eeprom_error;
|
||||
}
|
||||
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
||||
|
||||
void ubl_invalid_slot(const int s) {
|
||||
@ -1051,7 +1053,7 @@ void MarlinSettings::postprocess() {
|
||||
if (!WITHIN(slot, 0, a - 1)) {
|
||||
ubl_invalid_slot(a);
|
||||
SERIAL_PROTOCOLPAIR("E2END=", E2END);
|
||||
SERIAL_PROTOCOLPAIR(" meshes_end=", (int)meshes_end);
|
||||
SERIAL_PROTOCOLPAIR(" meshes_end=", meshes_end);
|
||||
SERIAL_PROTOCOLLNPAIR(" slot=", slot);
|
||||
SERIAL_EOL;
|
||||
return;
|
||||
|
@ -67,8 +67,8 @@ class MarlinSettings {
|
||||
#if ENABLED(AUTO_BED_LEVELING_UBL) // Eventually make these available if any leveling system
|
||||
// That can store is enabled
|
||||
static int meshes_begin;
|
||||
const static int mat_end = E2END; // Mesh allocation table; this may not end up being necessary
|
||||
const static int meshes_end = mat_end - 128; // 128 is a placeholder for the size of the MAT
|
||||
const static int meshes_end = E2END - 128; // 128 is a placeholder for the size of the MAT; the MAT will always
|
||||
// live at the very end of the eeprom
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -37,8 +37,8 @@ void safe_delay(millis_t ms) {
|
||||
#if ENABLED(EEPROM_SETTINGS)
|
||||
|
||||
void crc16(uint16_t *crc, const void * const data, uint16_t cnt) {
|
||||
uint8_t *ptr = (uint8_t*)data;
|
||||
while (cnt-- > 0) {
|
||||
uint8_t *ptr = (uint8_t *)data;
|
||||
while (cnt--) {
|
||||
*crc = (uint16_t)(*crc ^ (uint16_t)(((uint16_t)*ptr++) << 8));
|
||||
for (uint8_t x = 0; x < 8; x++)
|
||||
*crc = (uint16_t)((*crc & 0x8000) ? ((uint16_t)(*crc << 1) ^ 0x1021) : (*crc << 1));
|
||||
|
Loading…
Reference in New Issue
Block a user