Quellcode durchsuchen

Fix broken EEPROM save/load

Brian vor 7 Jahren
Ursprung
Commit
3370329751
3 geänderte Dateien mit 12 neuen und 10 gelöschten Zeilen
  1. 8
    6
      Marlin/configuration_store.cpp
  2. 2
    2
      Marlin/configuration_store.h
  3. 2
    2
      Marlin/utility.cpp

+ 8
- 6
Marlin/configuration_store.cpp Datei anzeigen

625
     if (!eeprom_error) {
625
     if (!eeprom_error) {
626
       const int eeprom_size = eeprom_index;
626
       const int eeprom_size = eeprom_index;
627
 
627
 
628
+      const uint16_t tcrc = working_crc;
629
+
628
       // Write the EEPROM header
630
       // Write the EEPROM header
629
       eeprom_index = EEPROM_OFFSET;
631
       eeprom_index = EEPROM_OFFSET;
632
+
630
       EEPROM_WRITE(version);
633
       EEPROM_WRITE(version);
631
-      EEPROM_WRITE(working_crc);
634
+      EEPROM_WRITE(tcrc);
632
 
635
 
633
       // Report storage size
636
       // Report storage size
634
       SERIAL_ECHO_START;
637
       SERIAL_ECHO_START;
635
       SERIAL_ECHOPAIR("Settings Stored (", eeprom_size - (EEPROM_OFFSET));
638
       SERIAL_ECHOPAIR("Settings Stored (", eeprom_size - (EEPROM_OFFSET));
636
-      SERIAL_ECHOPAIR(" bytes; crc ", working_crc);
639
+      SERIAL_ECHOPAIR(" bytes; crc ", tcrc);
637
       SERIAL_ECHOLNPGM(")");
640
       SERIAL_ECHOLNPGM(")");
638
     }
641
     }
639
 
642
 
982
       }
985
       }
983
       else {
986
       else {
984
         SERIAL_ERROR_START;
987
         SERIAL_ERROR_START;
985
-        SERIAL_ERRORPGM("EEPROM checksum mismatch - (stored CRC)");
988
+        SERIAL_ERRORPGM("EEPROM CRC mismatch - (stored) ");
986
         SERIAL_ERROR(stored_crc);
989
         SERIAL_ERROR(stored_crc);
987
         SERIAL_ERRORPGM(" != ");
990
         SERIAL_ERRORPGM(" != ");
988
         SERIAL_ERROR(working_crc);
991
         SERIAL_ERROR(working_crc);
989
-        SERIAL_ERRORLNPGM(" (calculated CRC)!");
992
+        SERIAL_ERRORLNPGM(" (calculated)!");
990
         reset();
993
         reset();
991
       }
994
       }
992
 
995
 
1027
     return !eeprom_error;
1030
     return !eeprom_error;
1028
   }
1031
   }
1029
 
1032
 
1030
-
1031
   #if ENABLED(AUTO_BED_LEVELING_UBL)
1033
   #if ENABLED(AUTO_BED_LEVELING_UBL)
1032
 
1034
 
1033
     void ubl_invalid_slot(const int s) {
1035
     void ubl_invalid_slot(const int s) {
1051
         if (!WITHIN(slot, 0, a - 1)) {
1053
         if (!WITHIN(slot, 0, a - 1)) {
1052
           ubl_invalid_slot(a);
1054
           ubl_invalid_slot(a);
1053
           SERIAL_PROTOCOLPAIR("E2END=", E2END);
1055
           SERIAL_PROTOCOLPAIR("E2END=", E2END);
1054
-          SERIAL_PROTOCOLPAIR(" meshes_end=", (int)meshes_end);
1056
+          SERIAL_PROTOCOLPAIR(" meshes_end=", meshes_end);
1055
           SERIAL_PROTOCOLLNPAIR(" slot=", slot);
1057
           SERIAL_PROTOCOLLNPAIR(" slot=", slot);
1056
           SERIAL_EOL;
1058
           SERIAL_EOL;
1057
           return;
1059
           return;

+ 2
- 2
Marlin/configuration_store.h Datei anzeigen

67
       #if ENABLED(AUTO_BED_LEVELING_UBL) // Eventually make these available if any leveling system
67
       #if ENABLED(AUTO_BED_LEVELING_UBL) // Eventually make these available if any leveling system
68
                                          // That can store is enabled
68
                                          // That can store is enabled
69
         static int meshes_begin;
69
         static int meshes_begin;
70
-        const static int mat_end = E2END;            // Mesh allocation table; this may not end up being necessary
71
-        const static int meshes_end = mat_end - 128; // 128 is a placeholder for the size of the MAT
70
+        const static int meshes_end = E2END - 128; // 128 is a placeholder for the size of the MAT; the MAT will always
71
+                                                   // live at the very end of the eeprom
72
 
72
 
73
       #endif
73
       #endif
74
 
74
 

+ 2
- 2
Marlin/utility.cpp Datei anzeigen

37
 #if ENABLED(EEPROM_SETTINGS)
37
 #if ENABLED(EEPROM_SETTINGS)
38
 
38
 
39
   void crc16(uint16_t *crc, const void * const data, uint16_t cnt) {
39
   void crc16(uint16_t *crc, const void * const data, uint16_t cnt) {
40
-    uint8_t *ptr = (uint8_t*)data;
41
-    while (cnt-- > 0) {
40
+    uint8_t *ptr = (uint8_t *)data;
41
+    while (cnt--) {
42
       *crc = (uint16_t)(*crc ^ (uint16_t)(((uint16_t)*ptr++) << 8));
42
       *crc = (uint16_t)(*crc ^ (uint16_t)(((uint16_t)*ptr++) << 8));
43
       for (uint8_t x = 0; x < 8; x++)
43
       for (uint8_t x = 0; x < 8; x++)
44
         *crc = (uint16_t)((*crc & 0x8000) ? ((uint16_t)(*crc << 1) ^ 0x1021) : (*crc << 1));
44
         *crc = (uint16_t)((*crc & 0x8000) ? ((uint16_t)(*crc << 1) ^ 0x1021) : (*crc << 1));

Laden…
Abbrechen
Speichern