|
@@ -36,7 +36,7 @@
|
36
|
36
|
*/
|
37
|
37
|
|
38
|
38
|
// Change EEPROM version if the structure changes
|
39
|
|
-#define EEPROM_VERSION "V85"
|
|
39
|
+#define EEPROM_VERSION "V86"
|
40
|
40
|
#define EEPROM_OFFSET 100
|
41
|
41
|
|
42
|
42
|
// Check the integrity of data offsets.
|
|
@@ -198,20 +198,32 @@ static const feedRate_t _DMF[] PROGMEM = DEFAULT_MAX_FEEDRATE;
|
198
|
198
|
*/
|
199
|
199
|
typedef struct SettingsDataStruct {
|
200
|
200
|
char version[4]; // Vnn\0
|
|
201
|
+ #if ENABLED(EEPROM_INIT_NOW)
|
|
202
|
+ uint32_t build_hash; // Unique build hash
|
|
203
|
+ #endif
|
201
|
204
|
uint16_t crc; // Data Checksum
|
202
|
205
|
|
203
|
206
|
//
|
204
|
207
|
// DISTINCT_E_FACTORS
|
205
|
208
|
//
|
206
|
|
- uint8_t esteppers; // DISTINCT_AXES - LINEAR_AXES
|
|
209
|
+ uint8_t e_factors; // DISTINCT_AXES - LINEAR_AXES
|
207
|
210
|
|
|
211
|
+ //
|
|
212
|
+ // Planner settings
|
|
213
|
+ //
|
208
|
214
|
planner_settings_t planner_settings;
|
209
|
215
|
|
210
|
216
|
xyze_float_t planner_max_jerk; // M205 XYZE planner.max_jerk
|
211
|
217
|
float planner_junction_deviation_mm; // M205 J planner.junction_deviation_mm
|
212
|
218
|
|
|
219
|
+ //
|
|
220
|
+ // Home Offset
|
|
221
|
+ //
|
213
|
222
|
xyz_pos_t home_offset; // M206 XYZ / M665 TPZ
|
214
|
223
|
|
|
224
|
+ //
|
|
225
|
+ // Hotend Offset
|
|
226
|
+ //
|
215
|
227
|
#if HAS_HOTEND_OFFSET
|
216
|
228
|
xyz_pos_t hotend_offset[HOTENDS - 1]; // M218 XYZ
|
217
|
229
|
#endif
|
|
@@ -649,13 +661,24 @@ void MarlinSettings::postprocess() {
|
649
|
661
|
|
650
|
662
|
const char version[4] = EEPROM_VERSION;
|
651
|
663
|
|
|
664
|
+ #if ENABLED(EEPROM_INIT_NOW)
|
|
665
|
+ constexpr uint32_t strhash32(const char *s, const uint32_t h=0) {
|
|
666
|
+ return *s ? strhash32(s + 1, ((h + *s) << (*s & 3)) ^ *s) : h;
|
|
667
|
+ }
|
|
668
|
+ constexpr uint32_t build_hash = strhash32(__DATE__ __TIME__);
|
|
669
|
+ #endif
|
|
670
|
+
|
652
|
671
|
bool MarlinSettings::eeprom_error, MarlinSettings::validating;
|
653
|
672
|
int MarlinSettings::eeprom_index;
|
654
|
673
|
uint16_t MarlinSettings::working_crc;
|
655
|
674
|
|
656
|
675
|
bool MarlinSettings::size_error(const uint16_t size) {
|
657
|
676
|
if (size != datasize()) {
|
658
|
|
- DEBUG_ERROR_MSG("EEPROM datasize error.");
|
|
677
|
+ DEBUG_ERROR_MSG("EEPROM datasize error."
|
|
678
|
+ #if ENABLED(MARLIN_DEV_MODE)
|
|
679
|
+ " (Actual:", size, " Expected:", datasize(), ")"
|
|
680
|
+ #endif
|
|
681
|
+ );
|
659
|
682
|
return true;
|
660
|
683
|
}
|
661
|
684
|
return false;
|
|
@@ -675,13 +698,17 @@ void MarlinSettings::postprocess() {
|
675
|
698
|
// Write or Skip version. (Flash doesn't allow rewrite without erase.)
|
676
|
699
|
TERN(FLASH_EEPROM_EMULATION, EEPROM_SKIP, EEPROM_WRITE)(ver);
|
677
|
700
|
|
678
|
|
- EEPROM_SKIP(working_crc); // Skip the checksum slot
|
|
701
|
+ #if ENABLED(EEPROM_INIT_NOW)
|
|
702
|
+ EEPROM_SKIP(build_hash); // Skip the hash slot
|
|
703
|
+ #endif
|
|
704
|
+
|
|
705
|
+ EEPROM_SKIP(working_crc); // Skip the checksum slot
|
679
|
706
|
|
680
|
707
|
working_crc = 0; // clear before first "real data"
|
681
|
708
|
|
682
|
|
- const uint8_t esteppers = COUNT(planner.settings.axis_steps_per_mm) - LINEAR_AXES;
|
683
|
|
- _FIELD_TEST(esteppers);
|
684
|
|
- EEPROM_WRITE(esteppers);
|
|
709
|
+ const uint8_t e_factors = DISTINCT_AXES - (LINEAR_AXES);
|
|
710
|
+ _FIELD_TEST(e_factors);
|
|
711
|
+ EEPROM_WRITE(e_factors);
|
685
|
712
|
|
686
|
713
|
//
|
687
|
714
|
// Planner Motion
|
|
@@ -1494,6 +1521,9 @@ void MarlinSettings::postprocess() {
|
1494
|
1521
|
eeprom_index = EEPROM_OFFSET;
|
1495
|
1522
|
|
1496
|
1523
|
EEPROM_WRITE(version);
|
|
1524
|
+ #if ENABLED(EEPROM_INIT_NOW)
|
|
1525
|
+ EEPROM_WRITE(build_hash);
|
|
1526
|
+ #endif
|
1497
|
1527
|
EEPROM_WRITE(final_crc);
|
1498
|
1528
|
|
1499
|
1529
|
// Report storage size
|
|
@@ -1527,9 +1557,6 @@ void MarlinSettings::postprocess() {
|
1527
|
1557
|
char stored_ver[4];
|
1528
|
1558
|
EEPROM_READ_ALWAYS(stored_ver);
|
1529
|
1559
|
|
1530
|
|
- uint16_t stored_crc;
|
1531
|
|
- EEPROM_READ_ALWAYS(stored_crc);
|
1532
|
|
-
|
1533
|
1560
|
// Version has to match or defaults are used
|
1534
|
1561
|
if (strncmp(version, stored_ver, 3) != 0) {
|
1535
|
1562
|
if (stored_ver[3] != '\0') {
|
|
@@ -1543,14 +1570,25 @@ void MarlinSettings::postprocess() {
|
1543
|
1570
|
eeprom_error = true;
|
1544
|
1571
|
}
|
1545
|
1572
|
else {
|
|
1573
|
+
|
|
1574
|
+ // Optionally reset on the first boot after flashing
|
|
1575
|
+ #if ENABLED(EEPROM_INIT_NOW)
|
|
1576
|
+ uint32_t stored_hash;
|
|
1577
|
+ EEPROM_READ_ALWAYS(stored_hash);
|
|
1578
|
+ if (stored_hash != build_hash) { EEPROM_FINISH(); return true; }
|
|
1579
|
+ #endif
|
|
1580
|
+
|
|
1581
|
+ uint16_t stored_crc;
|
|
1582
|
+ EEPROM_READ_ALWAYS(stored_crc);
|
|
1583
|
+
|
1546
|
1584
|
float dummyf = 0;
|
1547
|
1585
|
working_crc = 0; // Init to 0. Accumulated by EEPROM_READ
|
1548
|
1586
|
|
1549
|
|
- _FIELD_TEST(esteppers);
|
|
1587
|
+ _FIELD_TEST(e_factors);
|
1550
|
1588
|
|
1551
|
|
- // Number of esteppers may change
|
1552
|
|
- uint8_t esteppers;
|
1553
|
|
- EEPROM_READ_ALWAYS(esteppers);
|
|
1589
|
+ // Number of e_factors may change
|
|
1590
|
+ uint8_t e_factors;
|
|
1591
|
+ EEPROM_READ_ALWAYS(e_factors);
|
1554
|
1592
|
|
1555
|
1593
|
//
|
1556
|
1594
|
// Planner Motion
|
|
@@ -1558,16 +1596,16 @@ void MarlinSettings::postprocess() {
|
1558
|
1596
|
{
|
1559
|
1597
|
// Get only the number of E stepper parameters previously stored
|
1560
|
1598
|
// Any steppers added later are set to their defaults
|
1561
|
|
- uint32_t tmp1[LINEAR_AXES + esteppers];
|
1562
|
|
- float tmp2[LINEAR_AXES + esteppers];
|
1563
|
|
- feedRate_t tmp3[LINEAR_AXES + esteppers];
|
|
1599
|
+ uint32_t tmp1[LINEAR_AXES + e_factors];
|
|
1600
|
+ float tmp2[LINEAR_AXES + e_factors];
|
|
1601
|
+ feedRate_t tmp3[LINEAR_AXES + e_factors];
|
1564
|
1602
|
EEPROM_READ((uint8_t *)tmp1, sizeof(tmp1)); // max_acceleration_mm_per_s2
|
1565
|
1603
|
EEPROM_READ(planner.settings.min_segment_time_us);
|
1566
|
1604
|
EEPROM_READ((uint8_t *)tmp2, sizeof(tmp2)); // axis_steps_per_mm
|
1567
|
1605
|
EEPROM_READ((uint8_t *)tmp3, sizeof(tmp3)); // max_feedrate_mm_s
|
1568
|
1606
|
|
1569
|
1607
|
if (!validating) LOOP_DISTINCT_AXES(i) {
|
1570
|
|
- const bool in = (i < esteppers + LINEAR_AXES);
|
|
1608
|
+ const bool in = (i < e_factors + LINEAR_AXES);
|
1571
|
1609
|
planner.settings.max_acceleration_mm_per_s2[i] = in ? tmp1[i] : pgm_read_dword(&_DMA[ALIM(i, _DMA)]);
|
1572
|
1610
|
planner.settings.axis_steps_per_mm[i] = in ? tmp2[i] : pgm_read_float(&_DASU[ALIM(i, _DASU)]);
|
1573
|
1611
|
planner.settings.max_feedrate_mm_s[i] = in ? tmp3[i] : pgm_read_float(&_DMF[ALIM(i, _DMF)]);
|
|
@@ -2496,7 +2534,7 @@ void MarlinSettings::postprocess() {
|
2496
|
2534
|
return success;
|
2497
|
2535
|
}
|
2498
|
2536
|
reset();
|
2499
|
|
- #if ENABLED(EEPROM_AUTO_INIT)
|
|
2537
|
+ #if EITHER(EEPROM_AUTO_INIT, EEPROM_INIT_NOW)
|
2500
|
2538
|
(void)save();
|
2501
|
2539
|
SERIAL_ECHO_MSG("EEPROM Initialized");
|
2502
|
2540
|
#endif
|