Skip to content

[BUG] M502/M500 when TMC drivers do not have VMOT results in incorrect values being stored in EEPROM #19313

@ManuelMcLure

Description

@ManuelMcLure

Bug Description

If a motherboard is powered by USB but the main power supply is not powered on, executing M500 will save the wrong values into EEPROM.

My Configurations

Config.zip

Steps to Reproduce

  • Use my configuration on an LPC-1768-based board.
  • Power board with main power.
  • Execute M502.
  • Execute M503 and see that there is no M569 S1 T0 E line in the output. This is the correct behavior.
  • Execute M500.
  • Power down the board, power it up again, execute M503 and see that there still is no M569 S1 T0 E line.
  • Power down the board, power it up just via USB, execute M502 followed by M500.
  • Power down the board, power it up via the main supply. Execute M503 - there will be a M569 S1 T0 E line.

Expected behavior: [What you expect to happen]

M502 followed by M500 will initialize EEPROM to the values in Configuration.h regardless of whether the TMC drivers have full power.

Actual behavior: [What actually happens]

Executing M502 followed by M500 when board is only powered by USB results in different values in EEPROM than if full power is applied.

Additional Information

It looks like MarlinSettings::save() attempts to fetch the values from the drivers instead of using the cached values that are used by M80 and M122 I to re-initialize the drivers. I noticed this specifically with StealthChop/Spreadcycle but code review shows that other TMC driver configuration values suffer from the same issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions