|
@@ -40,6 +40,10 @@
|
40
|
40
|
#define EEPROM_VERSION "V48"
|
41
|
41
|
#define EEPROM_OFFSET 100
|
42
|
42
|
|
|
43
|
+// Check the integrity of data offsets.
|
|
44
|
+// Can be disabled for production build.
|
|
45
|
+//#define DEBUG_EEPROM_READWRITE
|
|
46
|
+
|
43
|
47
|
#include "configuration_store.h"
|
44
|
48
|
#include "endstops.h"
|
45
|
49
|
#include "planner.h"
|
|
@@ -323,7 +327,17 @@ void MarlinSettings::postprocess() {
|
323
|
327
|
#define EEPROM_WRITE(VAR) HAL::PersistentStore::write_data(eeprom_index, (uint8_t*)&VAR, sizeof(VAR), &working_crc)
|
324
|
328
|
#define EEPROM_READ(VAR) HAL::PersistentStore::read_data(eeprom_index, (uint8_t*)&VAR, sizeof(VAR), &working_crc, !validating)
|
325
|
329
|
#define EEPROM_READ_ALWAYS(VAR) HAL::PersistentStore::read_data(eeprom_index, (uint8_t*)&VAR, sizeof(VAR), &working_crc)
|
326
|
|
- #define EEPROM_ASSERT(TST,ERR) if (!(TST)) do{ SERIAL_ERROR_START(); SERIAL_ERRORLNPGM(ERR); eeprom_read_error = true; }while(0)
|
|
330
|
+ #define EEPROM_ASSERT(TST,ERR) if (!(TST)) do{ SERIAL_ERROR_START(); SERIAL_ERRORLNPGM(ERR); eeprom_error = true; }while(0)
|
|
331
|
+
|
|
332
|
+ #if ENABLED(DEBUG_EEPROM_READWRITE)
|
|
333
|
+ #define _FIELD_TEST(FIELD) \
|
|
334
|
+ EEPROM_ASSERT( \
|
|
335
|
+ eeprom_error || eeprom_index == offsetof(SettingsData, FIELD), \
|
|
336
|
+ "Field " STRINGIFY(FIELD) " mismatch." \
|
|
337
|
+ )
|
|
338
|
+ #else
|
|
339
|
+ #define _FIELD_TEST(FIELD) NOOP
|
|
340
|
+ #endif
|
327
|
341
|
|
328
|
342
|
const char version[4] = EEPROM_VERSION;
|
329
|
343
|
|
|
@@ -363,6 +377,8 @@ void MarlinSettings::postprocess() {
|
363
|
377
|
|
364
|
378
|
working_crc = 0; // clear before first "real data"
|
365
|
379
|
|
|
380
|
+ _FIELD_TEST(esteppers);
|
|
381
|
+
|
366
|
382
|
const uint8_t esteppers = COUNT(planner.axis_steps_per_mm) - XYZ;
|
367
|
383
|
EEPROM_WRITE(esteppers);
|
368
|
384
|
|
|
@@ -377,6 +393,9 @@ void MarlinSettings::postprocess() {
|
377
|
393
|
EEPROM_WRITE(planner.min_travel_feedrate_mm_s);
|
378
|
394
|
EEPROM_WRITE(planner.min_segment_time_us);
|
379
|
395
|
EEPROM_WRITE(planner.max_jerk);
|
|
396
|
+
|
|
397
|
+ _FIELD_TEST(home_offset);
|
|
398
|
+
|
380
|
399
|
#if !HAS_HOME_OFFSET
|
381
|
400
|
const float home_offset[XYZ] = { 0 };
|
382
|
401
|
#endif
|
|
@@ -426,6 +445,8 @@ void MarlinSettings::postprocess() {
|
426
|
445
|
for (uint8_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_WRITE(dummy);
|
427
|
446
|
#endif // MESH_BED_LEVELING
|
428
|
447
|
|
|
448
|
+ _FIELD_TEST(zprobe_zoffset);
|
|
449
|
+
|
429
|
450
|
#if !HAS_BED_PROBE
|
430
|
451
|
const float zprobe_zoffset = 0;
|
431
|
452
|
#endif
|
|
@@ -470,6 +491,8 @@ void MarlinSettings::postprocess() {
|
470
|
491
|
for (uint16_t q = grid_max_x * grid_max_y; q--;) EEPROM_WRITE(dummy);
|
471
|
492
|
#endif // AUTO_BED_LEVELING_BILINEAR
|
472
|
493
|
|
|
494
|
+ _FIELD_TEST(planner_leveling_active);
|
|
495
|
+
|
473
|
496
|
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
474
|
497
|
EEPROM_WRITE(planner.leveling_active);
|
475
|
498
|
EEPROM_WRITE(ubl.storage_slot);
|
|
@@ -482,6 +505,7 @@ void MarlinSettings::postprocess() {
|
482
|
505
|
|
483
|
506
|
// 11 floats for DELTA / [XYZ]_DUAL_ENDSTOPS
|
484
|
507
|
#if ENABLED(DELTA)
|
|
508
|
+ _FIELD_TEST(delta_height);
|
485
|
509
|
EEPROM_WRITE(delta_height); // 1 float
|
486
|
510
|
EEPROM_WRITE(delta_endstop_adj); // 3 floats
|
487
|
511
|
EEPROM_WRITE(delta_radius); // 1 float
|
|
@@ -491,6 +515,7 @@ void MarlinSettings::postprocess() {
|
491
|
515
|
EEPROM_WRITE(delta_tower_angle_trim); // 3 floats
|
492
|
516
|
|
493
|
517
|
#elif ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || ENABLED(Z_DUAL_ENDSTOPS)
|
|
518
|
+ _FIELD_TEST(x_endstop_adj);
|
494
|
519
|
// Write dual endstops in X, Y, Z order. Unused = 0.0
|
495
|
520
|
dummy = 0.0f;
|
496
|
521
|
#if ENABLED(X_DUAL_ENDSTOPS)
|
|
@@ -518,6 +543,8 @@ void MarlinSettings::postprocess() {
|
518
|
543
|
for (uint8_t q = 11; q--;) EEPROM_WRITE(dummy);
|
519
|
544
|
#endif
|
520
|
545
|
|
|
546
|
+ _FIELD_TEST(lcd_preheat_hotend_temp);
|
|
547
|
+
|
521
|
548
|
#if DISABLED(ULTIPANEL)
|
522
|
549
|
constexpr int lcd_preheat_hotend_temp[2] = { PREHEAT_1_TEMP_HOTEND, PREHEAT_2_TEMP_HOTEND },
|
523
|
550
|
lcd_preheat_bed_temp[2] = { PREHEAT_1_TEMP_BED, PREHEAT_2_TEMP_BED },
|
|
@@ -567,6 +594,8 @@ void MarlinSettings::postprocess() {
|
567
|
594
|
EEPROM_WRITE(thermalManager.bedKd);
|
568
|
595
|
#endif
|
569
|
596
|
|
|
597
|
+ _FIELD_TEST(lcd_contrast);
|
|
598
|
+
|
570
|
599
|
#if !HAS_LCD_CONTRAST
|
571
|
600
|
const uint16_t lcd_contrast = 32;
|
572
|
601
|
#endif
|
|
@@ -592,6 +621,7 @@ void MarlinSettings::postprocess() {
|
592
|
621
|
//
|
593
|
622
|
// Volumetric & Filament Size
|
594
|
623
|
//
|
|
624
|
+ _FIELD_TEST(parser_volumetric_enabled);
|
595
|
625
|
#if DISABLED(NO_VOLUMETRICS)
|
596
|
626
|
|
597
|
627
|
EEPROM_WRITE(parser.volumetric_enabled);
|
|
@@ -614,6 +644,7 @@ void MarlinSettings::postprocess() {
|
614
|
644
|
//
|
615
|
645
|
// Save TMC2130 or TMC2208 Configuration, and placeholder values
|
616
|
646
|
//
|
|
647
|
+ _FIELD_TEST(tmc_stepper_current);
|
617
|
648
|
uint16_t currents[11] = {
|
618
|
649
|
#if HAS_TRINAMIC
|
619
|
650
|
#if X_IS_TRINAMIC
|
|
@@ -702,7 +733,7 @@ void MarlinSettings::postprocess() {
|
702
|
733
|
//
|
703
|
734
|
// Linear Advance
|
704
|
735
|
//
|
705
|
|
-
|
|
736
|
+ _FIELD_TEST(planner_extruder_advance_k);
|
706
|
737
|
#if ENABLED(LIN_ADVANCE)
|
707
|
738
|
EEPROM_WRITE(planner.extruder_advance_k);
|
708
|
739
|
EEPROM_WRITE(planner.advance_ed_ratio);
|
|
@@ -722,7 +753,7 @@ void MarlinSettings::postprocess() {
|
722
|
753
|
//
|
723
|
754
|
// CNC Coordinate Systems
|
724
|
755
|
//
|
725
|
|
-
|
|
756
|
+ _FIELD_TEST(coordinate_system);
|
726
|
757
|
#if ENABLED(CNC_COORDINATE_SYSTEMS)
|
727
|
758
|
EEPROM_WRITE(coordinate_system); // 27 floats
|
728
|
759
|
#else
|
|
@@ -733,7 +764,7 @@ void MarlinSettings::postprocess() {
|
733
|
764
|
//
|
734
|
765
|
// Skew correction factors
|
735
|
766
|
//
|
736
|
|
-
|
|
767
|
+ _FIELD_TEST(planner_xy_skew_factor);
|
737
|
768
|
#if ENABLED(SKEW_CORRECTION)
|
738
|
769
|
EEPROM_WRITE(planner.xy_skew_factor);
|
739
|
770
|
EEPROM_WRITE(planner.xz_skew_factor);
|
|
@@ -746,6 +777,7 @@ void MarlinSettings::postprocess() {
|
746
|
777
|
//
|
747
|
778
|
// Advanced Pause filament load & unload lengths
|
748
|
779
|
//
|
|
780
|
+ _FIELD_TEST(filament_change_unload_length);
|
749
|
781
|
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
750
|
782
|
for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) {
|
751
|
783
|
if (q < COUNT(filament_change_unload_length)) dummy = filament_change_unload_length[q];
|