From 05f37edad595c1cb092d8ae14894a65fcb5e592c Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Thu, 29 Dec 2022 15:26:15 +0100 Subject: [PATCH] Read version data from progmem in eeprom_fw_version_older_than --- Firmware/Marlin_main.cpp | 3 ++- Firmware/util.cpp | 8 ++++---- Firmware/util.h | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index bc6c68fb..77f6c212 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -1548,7 +1548,8 @@ void setup() // calibrated printer upgraded from FW<3.12 calibration_status |= (CALIBRATION_STATUS_SELFTEST | CALIBRATION_STATUS_XYZ | CALIBRATION_STATUS_Z | CALIBRATION_STATUS_LIVE_ADJUST); - if (eeprom_fw_version_older_than({3, 2, 0, 4})) { + static const uint16_t v3_2_0_4[] PROGMEM = {3, 2, 0, 4}; + if (eeprom_fw_version_older_than_p(v3_2_0_4)) { // printer upgraded from FW<3.2.0.4 and requires re-running selftest lcd_show_fullscreen_message_and_wait_P(_i("Selftest will be run to calibrate accurate sensorless rehoming."));////MSG_FORCE_SELFTEST c=20 r=8 calibration_status &= ~CALIBRATION_STATUS_SELFTEST; diff --git a/Firmware/util.cpp b/Firmware/util.cpp index f3e0b518..f36b8dae 100644 --- a/Firmware/util.cpp +++ b/Firmware/util.cpp @@ -181,19 +181,19 @@ inline int8_t is_provided_version_newer(const char *version_string) return 0; } -bool eeprom_fw_version_older_than(const uint16_t (&ver_req)[4]) +bool eeprom_fw_version_older_than_p(const uint16_t (&ver_req)[4]) { uint16_t ver_eeprom[4]; - ver_eeprom[0] = eeprom_read_word((uint16_t*)EEPROM_FIRMWARE_VERSION_MAJOR); ver_eeprom[1] = eeprom_read_word((uint16_t*)EEPROM_FIRMWARE_VERSION_MINOR); ver_eeprom[2] = eeprom_read_word((uint16_t*)EEPROM_FIRMWARE_VERSION_REVISION); ver_eeprom[3] = eeprom_read_word((uint16_t*)EEPROM_FIRMWARE_VERSION_FLAVOR); for (uint8_t i = 0; i < 4; ++i) { - if (ver_req[i] > ver_eeprom[i]) + uint16_t v = pgm_read_word(&ver_req[i]); + if (v > ver_eeprom[i]) return true; - else if (ver_req[i] < ver_eeprom[i]) + else if (v < ver_eeprom[i]) break; } diff --git a/Firmware/util.h b/Firmware/util.h index 9290fdb2..9a3ce9bb 100644 --- a/Firmware/util.h +++ b/Firmware/util.h @@ -17,7 +17,7 @@ enum FirmwareRevisionFlavorType : uint16_t { }; bool show_upgrade_dialog_if_version_newer(const char *version_string); -bool eeprom_fw_version_older_than(const uint16_t (&req_ver)[4]); +bool eeprom_fw_version_older_than_p(const uint16_t (&req_ver)[4]); void update_current_firmware_version_to_eeprom();