Skip to content

Commit

Permalink
Fix EEPROM errors when EXTRUDER == 0
Browse files Browse the repository at this point in the history
Partly my fault from last time (MarlinFirmware#16464)
Problem appears to be that forcing store/retrieve of one element is inconsistent with offsetof() calculation based on size of planner_extruder_advance_K which is zero.  Instead, use save/retrieve of zero elements, which is natural for the saving (remove _MAX()) and for the retrieval a simple #ifdef covers it.
  • Loading branch information
vector76 authored Feb 19, 2020
1 parent 4c179ba commit 09030db
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions Marlin/src/module/configuration_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1246,7 +1246,7 @@ void MarlinSettings::postprocess() {
EEPROM_WRITE(planner.extruder_advance_K);
#else
dummy = 0;
for (uint8_t q = _MAX(EXTRUDERS, 1); q--;) EEPROM_WRITE(dummy);
for (uint8_t q = EXTRUDERS; q--;) EEPROM_WRITE(dummy);
#endif
}

Expand Down Expand Up @@ -2091,12 +2091,14 @@ void MarlinSettings::postprocess() {
// Linear Advance
//
{
float extruder_advance_K[_MAX(EXTRUDERS, 1)];
_FIELD_TEST(planner_extruder_advance_K);
EEPROM_READ(extruder_advance_K);
#if ENABLED(LIN_ADVANCE)
if (!validating)
COPY(planner.extruder_advance_K, extruder_advance_K);
#if EXTRUDERS
float extruder_advance_K[EXTRUDERS];
EEPROM_READ(extruder_advance_K);
#if ENABLED(LIN_ADVANCE)
if (!validating)
COPY(planner.extruder_advance_K, extruder_advance_K);
#endif
#endif
}

Expand Down

0 comments on commit 09030db

Please sign in to comment.