瀏覽代碼

In addition to the firmware version number, store the "PRUSA3D"
magic at the beginning of the EEPROM,
so at the upgrade the firmware would know, if the previous firmware
was a Prusa3D firmware.

bubnikv 8 年之前
父節點
當前提交
3c21438392
共有 2 個文件被更改,包括 21 次插入1 次删除
  1. 12 1
      Firmware/Configuration.h
  2. 9 0
      Firmware/util.cpp

+ 12 - 1
Firmware/Configuration.h

@@ -7,7 +7,8 @@
 // Firmware version
 #define FW_version "3.0.5"
 
-
+#define FW_PRUSA3D_MAGIC "PRUSA3DFW"
+#define FW_PRUSA3D_MAGIC_LEN 10
 
 // The total size of the EEPROM is
 // 4096 for the Atmega2560
@@ -30,6 +31,16 @@
 // The offsets are saved as 16bit signed int, scaled to tenths of microns.
 #define EEPROM_BED_CALIBRATION_Z_JITTER   (EEPROM_BED_CALIBRATION_VEC_Y-2*8)
 
+
+// Currently running firmware, each digit stored as uint16_t.
+// The flavor differentiates a dev, alpha, beta, release candidate or a release version.
+#define EEPROM_FIRMWARE_VERSION_FLAVOR    (FW_PRUSA3D_MAGIC_LEN+6)
+#define EEPROM_FIRMWARE_VERSION_REVISION  (FW_PRUSA3D_MAGIC_LEN+4)
+#define EEPROM_FIRMWARE_VERSION_MINOR     (FW_PRUSA3D_MAGIC_LEN+2)
+#define EEPROM_FIRMWARE_VERSION_MAJOR     FW_PRUSA3D_MAGIC_LEN
+// Magic string, indicating that the current or the previous firmware running was the Prusa3D firmware.
+#define EEPROM_FIRMWARE_PRUSA_MAGIC
+
 // This configuration file contains the basic settings.
 // Advanced settings can be found in Configuration_adv.h
 // BASIC SETTINGS: select your board type, temperature sensor type, axis scaling, and endstop configuration

+ 9 - 0
Firmware/util.cpp

@@ -12,6 +12,13 @@ const char* FW_VERSION_STR_P()
     return FW_VERSION_STR;
 }
 
+const char FW_PRUSA3D_MAGIC_STR[] PROGMEM = FW_PRUSA3D_MAGIC;
+
+const char* FW_PRUSA3D_MAGIC_STR_P()
+{
+    return FW_PRUSA3D_MAGIC_STR;
+}
+
 const char STR_REVISION_DEV  [] PROGMEM = "dev";
 const char STR_REVISION_ALPHA[] PROGMEM = "alpha";
 const char STR_REVISION_BETA [] PROGMEM = "beta";
@@ -268,6 +275,8 @@ bool show_upgrade_dialog_if_version_newer(const char *version_string)
 
 void update_current_firmware_version_to_eeprom()
 {
+    for (int8_t i = 0; i < FW_PRUSA3D_MAGIC_LEN; ++ i)
+        eeprom_update_byte((uint8_t*)(EEPROM_FIRMWARE_PRUSA_MAGIC+i), pgm_read_byte(FW_PRUSA3D_MAGIC_STR+i));
     uint16_t ver_current[4];
     if (parse_version_P(FW_VERSION_STR, ver_current)) {
         eeprom_update_word((uint16_t*)EEPROM_FIRMWARE_VERSION_MAJOR,    ver_current[0]);