From 213d4b890ea4997db63b0946cde766581d7f96e5 Mon Sep 17 00:00:00 2001 From: Italo Soares Date: Mon, 18 May 2020 02:50:35 -0300 Subject: [PATCH 01/16] Hotend Idle Timeout (#16362) --- Marlin/Configuration_adv.h | 14 ++++- Marlin/src/MarlinCore.cpp | 6 ++ Marlin/src/feature/hotend_idle.cpp | 89 +++++++++++++++++++++++++++ Marlin/src/feature/hotend_idle.h | 37 +++++++++++ Marlin/src/inc/Conditionals_LCD.h | 1 + Marlin/src/lcd/language/language_en.h | 1 + Marlin/src/module/temperature.h | 8 +++ buildroot/share/tests/esp32-tests | 3 +- 8 files changed, 157 insertions(+), 2 deletions(-) create mode 100644 Marlin/src/feature/hotend_idle.cpp create mode 100644 Marlin/src/feature/hotend_idle.h diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 20c110ff7b2e..9d1118838aff 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -330,6 +330,18 @@ #define EXTRUDER_RUNOUT_EXTRUDE 5 // (mm) #endif +/** + * Hotend Idle Timeout + * Prevent filament in the nozzle from charring and causing a critical jam. + */ +//#define HOTEND_IDLE_TIMEOUT +#if ENABLED(HOTEND_IDLE_TIMEOUT) + #define HOTEND_IDLE_DURATION_SEC 5 // (minutes) Time without extruder movement to trigger protection + #define HOTEND_IDLE_MIN_TRIGGER 180 // (°C) Minimum temperature to enable hotend protection + #define HOTEND_IDLE_NOZZLE_TARGET 0 // (°C) Safe temperature for the nozzle after timeout + #define HOTEND_IDLE_BED_TARGET 0 // (°C) Safe temperature for the bed after timeout +#endif + // @section temperature // Calibration for AD595 / AD8495 sensor to adjust temperature measurements. @@ -3308,7 +3320,7 @@ */ //#define MMU_EXTRUDER_SENSOR - #if ENABLED(MMU_EXTRUDER_SENSOR) + #if ENABLED(MMU_EXTRUDER_SENSOR) #define MMU_LOADING_ATTEMPTS_NR 5 //max. number of attempts to load filament if first load fail #endif diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 2434df0ad493..3b076768406a 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -159,6 +159,10 @@ #include "feature/runout.h" #endif +#if ENABLED(HOTEND_IDLE_TIMEOUT) + #include "feature/hotend_idle.h" +#endif + #if ENABLED(TEMP_STAT_LEDS) #include "feature/leds/tempstat.h" #endif @@ -527,6 +531,8 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) { TERN_(AUTO_POWER_CONTROL, powerManager.check()); + TERN_(HOTEND_IDLE_TIMEOUT, hotend_idle.check()); + #if ENABLED(EXTRUDER_RUNOUT_PREVENT) if (thermalManager.degHotend(active_extruder) > EXTRUDER_RUNOUT_MINTEMP && ELAPSED(ms, gcode.previous_move_ms + SEC_TO_MS(EXTRUDER_RUNOUT_SECONDS)) diff --git a/Marlin/src/feature/hotend_idle.cpp b/Marlin/src/feature/hotend_idle.cpp new file mode 100644 index 000000000000..6b5d1b276d5f --- /dev/null +++ b/Marlin/src/feature/hotend_idle.cpp @@ -0,0 +1,89 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * Hotend Idle Timeout + * Prevent filament in the nozzle from charring and causing a critical jam. + */ + +#include "../inc/MarlinConfig.h" + +#if ENABLED(HOTEND_IDLE_TIMEOUT) + +#include "hotend_idle.h" +#include "../gcode/gcode.h" + +#include "../module/temperature.h" +#include "../module/motion.h" +#include "../lcd/ultralcd.h" + +extern HotendIdleProtection hotend_idle; + +millis_t HotendIdleProtection::next_protect_ms = 0; + +void HotendIdleProtection::check_hotends(const millis_t &ms) { + bool do_prot = false; + HOTEND_LOOP() { + if (thermalManager.degHotendNear(e, HOTEND_IDLE_MIN_TRIGGER)) { + do_prot = true; break; + } + } + if (bool(next_protect_ms) != do_prot) + next_protect_ms = do_prot ? ms + hp_interval : 0; +} + +void HotendIdleProtection::check_e_motion(const millis_t &ms) { + static float old_e_position = 0; + if (old_e_position != current_position.e) { + old_e_position = current_position.e; // Track filament motion + if (next_protect_ms) // If some heater is on then... + next_protect_ms = ms + hp_interval; // ...delay the timeout till later + } +} + +void HotendIdleProtection::check() { + const millis_t ms = millis(); // Shared millis + + check_hotends(ms); // Any hotends need protection? + check_e_motion(ms); // Motion will protect them + + // Hot and not moving for too long... + if (next_protect_ms && ELAPSED(ms, next_protect_ms)) + timed_out(); +} + +// Lower (but don't raise) hotend / bed temperatures +void HotendIdleProtection::timed_out() { + next_protect_ms = 0; + SERIAL_ECHOLNPGM("Hotend Idle Timeout"); + LCD_MESSAGEPGM(MSG_HOTEND_IDLE_TIMEOUT); + HOTEND_LOOP() { + if ((HOTEND_IDLE_NOZZLE_TARGET) < thermalManager.degTargetHotend(e)) + thermalManager.setTargetHotend(HOTEND_IDLE_NOZZLE_TARGET, e); + } + #if HAS_HEATED_BED + if ((HOTEND_IDLE_BED_TARGET) < thermalManager.degTargetBed()) + thermalManager.setTargetBed(HOTEND_IDLE_BED_TARGET); + #endif +} + +#endif // HOTEND_IDLE_TIMEOUT diff --git a/Marlin/src/feature/hotend_idle.h b/Marlin/src/feature/hotend_idle.h new file mode 100644 index 000000000000..298439da299d --- /dev/null +++ b/Marlin/src/feature/hotend_idle.h @@ -0,0 +1,37 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#include "../core/millis_t.h" + +class HotendIdleProtection { +public: + static void check(); +private: + static constexpr millis_t hp_interval = SEC_TO_MS(HOTEND_IDLE_DURATION_SEC); + static millis_t next_protect_ms; + static void check_hotends(const millis_t &ms); + static void check_e_motion(const millis_t &ms); + static void timed_out(); +}; + +extern HotendIdleProtection hotend_idle; diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 47a94d00745e..11cf5826375e 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -414,6 +414,7 @@ #undef MIXING_EXTRUDER #undef MK2_MULTIPLEXER #undef PRUSA_MMU2 + #undef HOTEND_IDLE_TIMEOUT #endif #if ENABLED(SWITCHING_EXTRUDER) // One stepper for every two EXTRUDERS diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 3ee5bea6e410..b8013bf16c0f 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -488,6 +488,7 @@ namespace Language_en { PROGMEM Language_Str MSG_INFO_PROTOCOL = _UxGT("Protocol"); PROGMEM Language_Str MSG_INFO_RUNAWAY_OFF = _UxGT("Runaway Watch: OFF"); PROGMEM Language_Str MSG_INFO_RUNAWAY_ON = _UxGT("Runaway Watch: ON"); + PROGMEM Language_Str MSG_HOTEND_IDLE_TIMEOUT = _UxGT("Hotend Idle Timeout"); PROGMEM Language_Str MSG_CASE_LIGHT = _UxGT("Case Light"); PROGMEM Language_Str MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Light Brightness"); diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 155644e7f8f0..b2c5497b00af 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -612,6 +612,10 @@ class Temperature { return degTargetHotend(e) > TEMP_HYSTERESIS && ABS(degHotend(e) - degTargetHotend(e)) > TEMP_HYSTERESIS; } + FORCE_INLINE static bool degHotendNear(const uint8_t e, const float &temp) { + return ABS(degHotend(e) - temp) < (TEMP_HYSTERESIS); + } + #endif // HOTENDS #if HAS_HEATED_BED @@ -650,6 +654,10 @@ class Temperature { static void wait_for_bed_heating(); + FORCE_INLINE static bool degBedNear(const float &temp) { + return ABS(degBed() - temp) < (TEMP_BED_HYSTERESIS); + } + #endif // HAS_HEATED_BED #if HAS_TEMP_PROBE diff --git a/buildroot/share/tests/esp32-tests b/buildroot/share/tests/esp32-tests index 37a67fcae619..ccc01a1c1c8a 100755 --- a/buildroot/share/tests/esp32-tests +++ b/buildroot/share/tests/esp32-tests @@ -31,7 +31,8 @@ opt_set X_HARDWARE_SERIAL Serial1 opt_set Y_HARDWARE_SERIAL Serial1 opt_set Z_HARDWARE_SERIAL Serial1 opt_set E0_HARDWARE_SERIAL Serial1 -exec_test $1 $2 "ESP32 with TMC Hardware Serial" +opt_enable HOTEND_IDLE_TIMEOUT +exec_test $1 $2 "ESP32, TMC HW Serial, Hotend Idle" # cleanup restore_configs From 94063e3a873d3e3644d1c363cd4d6eec82de649f Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Mon, 18 May 2020 11:51:32 -0700 Subject: [PATCH 02/16] Fix PID + Thermal Protection combos (#18023) --- Marlin/Configuration.h | 14 +++++++++----- Marlin/src/module/temperature.cpp | 14 +++++++------- buildroot/share/tests/mks_robin_pro-tests | 6 ++++-- buildroot/share/tests/rumba32_f446ve-tests | 6 +++++- 4 files changed, 25 insertions(+), 15 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 777f9a534bf3..25f359c13cd2 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -479,16 +479,12 @@ #define BANG_MAX 255 // Limits current to nozzle while in bang-bang mode; 255=full current #define PID_MAX BANG_MAX // Limits current to nozzle while PID is active (see PID_FUNCTIONAL_RANGE below); 255=full current #define PID_K1 0.95 // Smoothing factor within any PID loop + #if ENABLED(PIDTEMP) //#define PID_EDIT_MENU // Add PID editing to the "Advanced Settings" menu. (~700 bytes of PROGMEM) //#define PID_AUTOTUNE_MENU // Add PID auto-tuning to the "Advanced Settings" menu. (~250 bytes of PROGMEM) - //#define PID_DEBUG // Sends debug data to the serial port. Use 'M303 D' to toggle activation. - //#define PID_OPENLOOP 1 // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX - //#define SLOW_PWM_HEATERS // PWM with very low frequency (roughly 0.125Hz=8s) and minimum state time of approximately 1s useful for heaters driven by a relay //#define PID_PARAMS_PER_HOTEND // Uses separate PID parameters for each extruder (useful for mismatched extruders) // Set/get with gcode: M301 E[extruder number, 0-2] - #define PID_FUNCTIONAL_RANGE 10 // If the temperature difference between the target temperature and the actual temperature - // is more than PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max. // If you are using a pre-configured hotend then you can use one of the value sets by uncommenting it @@ -557,6 +553,14 @@ // FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles. #endif // PIDTEMPBED +#if EITHER(PIDTEMP, PIDTEMPBED) + //#define PID_DEBUG // Sends debug data to the serial port. Use 'M303 D' to toggle activation. + //#define PID_OPENLOOP // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX + //#define SLOW_PWM_HEATERS // PWM with very low frequency (roughly 0.125Hz=8s) and minimum state time of approximately 1s useful for heaters driven by a relay + #define PID_FUNCTIONAL_RANGE 10 // If the temperature difference between the target temperature and the actual temperature + // is more than PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max. +#endif + // @section extruder /** diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 7518e0ef2c2c..f9482aedb27d 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -381,15 +381,15 @@ volatile bool Temperature::raw_temps_ready = false; #define ONHEATINGSTART() printerEventLEDs.onHotendHeatingStart() #define ONHEATING(S,C,T) printerEventLEDs.onHotendHeating(S,C,T) #endif + #define WATCH_PID BOTH(WATCH_BED, PIDTEMPBED) || BOTH(WATCH_HOTENDS, PIDTEMP) - #if WATCH_BED || WATCH_HOTENDS - #define HAS_TP_BED BOTH(THERMAL_PROTECTION_BED, PIDTEMPBED) - #if HAS_TP_BED && BOTH(THERMAL_PROTECTION_HOTENDS, PIDTEMP) + #if WATCH_PID + #if ALL(THERMAL_PROTECTION_HOTENDS, PIDTEMP, THERMAL_PROTECTION_BED, PIDTEMPBED) #define GTV(B,H) (isbed ? (B) : (H)) - #elif HAS_TP_BED - #define GTV(B,H) (B) - #else + #elif BOTH(THERMAL_PROTECTION_HOTENDS, PIDTEMP) #define GTV(B,H) (H) + #else + #define GTV(B,H) (B) #endif const uint16_t watch_temp_period = GTV(WATCH_BED_TEMP_PERIOD, WATCH_TEMP_PERIOD); const uint8_t watch_temp_increase = GTV(WATCH_BED_TEMP_INCREASE, WATCH_TEMP_INCREASE); @@ -528,7 +528,7 @@ volatile bool Temperature::raw_temps_ready = false; next_temp_ms = ms + 2000UL; // Make sure heating is actually working - #if WATCH_BED || WATCH_HOTENDS + #if WATCH_PID if (BOTH(WATCH_BED, WATCH_HOTENDS) || isbed == DISABLED(WATCH_HOTENDS)) { if (!heated) { // If not yet reached target... if (current_temp > next_watch_temp) { // Over the watch temp? diff --git a/buildroot/share/tests/mks_robin_pro-tests b/buildroot/share/tests/mks_robin_pro-tests index 4b437e0e0320..cfd36832fdef 100644 --- a/buildroot/share/tests/mks_robin_pro-tests +++ b/buildroot/share/tests/mks_robin_pro-tests @@ -10,7 +10,9 @@ use_example_configs Mks/Robin_Pro opt_set SDCARD_CONNECTION LCD opt_set X_DRIVER_TYPE TMC2209 opt_set Y_DRIVER_TYPE TMC2130 -exec_test $1 $2 "MKS Robin Pro with TMC Drivers " +opt_set TEMP_SENSOR_BED 1 +opt_disable THERMAL_PROTECTION_HOTENDS +exec_test $1 $2 "MKS Robin Pro with TMC Drivers, hotend thermal protection disabled" # cleanup -restore_configs +#restore_configs diff --git a/buildroot/share/tests/rumba32_f446ve-tests b/buildroot/share/tests/rumba32_f446ve-tests index a0286b54a91b..868bbe53380f 100644 --- a/buildroot/share/tests/rumba32_f446ve-tests +++ b/buildroot/share/tests/rumba32_f446ve-tests @@ -10,8 +10,12 @@ set -e restore_configs opt_set MOTHERBOARD BOARD_RUMBA32_AUS3D opt_set SERIAL_PORT -1 +opt_disable PIDTEMP +opt_enable PIDTEMPBED +opt_set TEMP_SENSOR_BED 1 +opt_disable THERMAL_PROTECTION_BED opt_set X_DRIVER_TYPE TMC2130 -exec_test $1 $2 "rumba32_f446ve Default Config with TMC2130" +exec_test $1 $2 "rumba32_f446ve with TMC2130, PID Bed, and bed thermal protection disabled" # cleanup restore_configs From 63c43de9b425ae042add4d14041053a3c5d2f157 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Tue, 19 May 2020 00:04:18 +0000 Subject: [PATCH 03/16] [cron] Bump distribution date (2020-05-19) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index abe4df3286aa..349e20043d66 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2020-05-18" + #define STRING_DISTRIBUTION_DATE "2020-05-19" #endif /** From bce952770992bb9e1dbb7f943d67d9839e32b1a0 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 18 May 2020 22:52:13 -0500 Subject: [PATCH 04/16] Whitespace --- Marlin/Configuration.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 25f359c13cd2..cb5ae0661710 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -559,7 +559,7 @@ //#define SLOW_PWM_HEATERS // PWM with very low frequency (roughly 0.125Hz=8s) and minimum state time of approximately 1s useful for heaters driven by a relay #define PID_FUNCTIONAL_RANGE 10 // If the temperature difference between the target temperature and the actual temperature // is more than PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max. -#endif +#endif // @section extruder From 7696dea1c6eeddb1f1dd99e8acb480c2aab8f28d Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Tue, 19 May 2020 00:29:19 -0700 Subject: [PATCH 05/16] Fix LPC + EXPERIMENTAL_I2CBUS build error (#18040) --- Marlin/src/HAL/LPC1768/HAL.h | 2 +- buildroot/share/tests/LPC1769-tests | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Marlin/src/HAL/LPC1768/HAL.h b/Marlin/src/HAL/LPC1768/HAL.h index 2d385fd16c65..7d2b289f3505 100644 --- a/Marlin/src/HAL/LPC1768/HAL.h +++ b/Marlin/src/HAL/LPC1768/HAL.h @@ -49,7 +49,7 @@ extern "C" volatile uint32_t _millis; #include // i2c uses 8-bit shifted address -#define I2C_ADDRESS(A) ((A) << 1) +#define I2C_ADDRESS(A) uint8_t((A) << 1) // // Default graphical display delays diff --git a/buildroot/share/tests/LPC1769-tests b/buildroot/share/tests/LPC1769-tests index 53a7b2818908..9c7a1ba10e83 100755 --- a/buildroot/share/tests/LPC1769-tests +++ b/buildroot/share/tests/LPC1769-tests @@ -49,7 +49,8 @@ opt_set Y_DRIVER_TYPE TMC2130 opt_set Z_DRIVER_TYPE TMC2130 opt_enable AUTO_BED_LEVELING_BILINEAR EEPROM_SETTINGS EEPROM_CHITCHAT \ TMC_USE_SW_SPI MONITOR_DRIVER_STATUS STEALTHCHOP_XY STEALTHCHOP_Z HYBRID_THRESHOLD \ - SENSORLESS_PROBING Z_SAFE_HOMING X_STALL_SENSITIVITY Y_STALL_SENSITIVITY Z_STALL_SENSITIVITY TMC_DEBUG + SENSORLESS_PROBING Z_SAFE_HOMING X_STALL_SENSITIVITY Y_STALL_SENSITIVITY Z_STALL_SENSITIVITY TMC_DEBUG \ + EXPERIMENTAL_I2CBUS opt_disable PSU_CONTROL exec_test $1 $2 "Cohesion3D Remix DELTA + ABL Bilinear + EEPROM + SENSORLESS_PROBING" From 1e32df4c7533c507c8271c570ac8e90f47b8f644 Mon Sep 17 00:00:00 2001 From: thisiskeithb <13375512+thisiskeithb@users.noreply.github.com> Date: Tue, 19 May 2020 00:34:15 -0700 Subject: [PATCH 06/16] Fix Hotend Idle Timeout comment (#18032) Co-authored-by: Scott Lahteine --- Marlin/Configuration_adv.h | 2 +- Marlin/src/feature/hotend_idle.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 9d1118838aff..76cf40e36221 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -336,7 +336,7 @@ */ //#define HOTEND_IDLE_TIMEOUT #if ENABLED(HOTEND_IDLE_TIMEOUT) - #define HOTEND_IDLE_DURATION_SEC 5 // (minutes) Time without extruder movement to trigger protection + #define HOTEND_IDLE_TIMEOUT_SEC (5*60) // (seconds) Time without extruder movement to trigger protection #define HOTEND_IDLE_MIN_TRIGGER 180 // (°C) Minimum temperature to enable hotend protection #define HOTEND_IDLE_NOZZLE_TARGET 0 // (°C) Safe temperature for the nozzle after timeout #define HOTEND_IDLE_BED_TARGET 0 // (°C) Safe temperature for the bed after timeout diff --git a/Marlin/src/feature/hotend_idle.h b/Marlin/src/feature/hotend_idle.h index 298439da299d..73de51c2dd0f 100644 --- a/Marlin/src/feature/hotend_idle.h +++ b/Marlin/src/feature/hotend_idle.h @@ -27,7 +27,7 @@ class HotendIdleProtection { public: static void check(); private: - static constexpr millis_t hp_interval = SEC_TO_MS(HOTEND_IDLE_DURATION_SEC); + static constexpr millis_t hp_interval = SEC_TO_MS(HOTEND_IDLE_TIMEOUT_SEC); static millis_t next_protect_ms; static void check_hotends(const millis_t &ms); static void check_e_motion(const millis_t &ms); From 7be748b9b767c5095dc90b9527bb4329da2e909a Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Wed, 20 May 2020 00:04:09 +0000 Subject: [PATCH 07/16] [cron] Bump distribution date (2020-05-20) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 349e20043d66..c7665bf52f26 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2020-05-19" + #define STRING_DISTRIBUTION_DATE "2020-05-20" #endif /** From 0b0ba7dcf612a5ae0f59d3e3697e2baff8ce4464 Mon Sep 17 00:00:00 2001 From: Giuliano Zaro <3684609+GMagician@users.noreply.github.com> Date: Wed, 20 May 2020 22:28:02 +0200 Subject: [PATCH 08/16] Fix LCD throttle issue (#18055) Fixes #18044 --- Marlin/src/lcd/ultralcd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/lcd/ultralcd.cpp b/Marlin/src/lcd/ultralcd.cpp index 76aa773cd361..12c005a91869 100644 --- a/Marlin/src/lcd/ultralcd.cpp +++ b/Marlin/src/lcd/ultralcd.cpp @@ -881,7 +881,7 @@ void MarlinUI::update() { // Instead of tracking changes just redraw the Status Screen once per second. if (on_status_screen() && !lcd_status_update_delay--) { lcd_status_update_delay = TERN(HAS_GRAPHICAL_LCD, 12, 9); - max_display_update_time--; + if (max_display_update_time) max_display_update_time--; // Be sure never go to a very big number refresh(LCDVIEW_REDRAW_NOW); } From 7b2a056656938b19409eab44a3e7874667cdcf3b Mon Sep 17 00:00:00 2001 From: Giuliano Zaro <3684609+GMagician@users.noreply.github.com> Date: Wed, 20 May 2020 22:31:08 +0200 Subject: [PATCH 09/16] Update SAMD-RAMPS runout pin (#18048) --- Marlin/src/pins/samd/pins_RAMPS_144.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/pins/samd/pins_RAMPS_144.h b/Marlin/src/pins/samd/pins_RAMPS_144.h index c9cc8c3c6738..54363713e7b2 100644 --- a/Marlin/src/pins/samd/pins_RAMPS_144.h +++ b/Marlin/src/pins/samd/pins_RAMPS_144.h @@ -130,7 +130,7 @@ #endif #ifndef FIL_RUNOUT_PIN - #define FIL_RUNOUT_PIN 71 + #define FIL_RUNOUT_PIN 70 #endif #ifndef PS_ON_PIN From 60bed3434bb7aa51b02978e93dae5985ff24fe3a Mon Sep 17 00:00:00 2001 From: Mobilinkd LLC Date: Wed, 20 May 2020 15:38:29 -0500 Subject: [PATCH 10/16] Ignore spurious MAX31855K / 6675 thermocouple errors (#18039) --- Marlin/Configuration_adv.h | 13 +++++++ Marlin/src/module/temperature.cpp | 60 +++++++++++++++++++------------ 2 files changed, 50 insertions(+), 23 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 76cf40e36221..db89a1d5e976 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -39,6 +39,19 @@ //=============================Thermal Settings ============================ //=========================================================================== +/** + * Thermocouple sensors are quite sensitive to noise. Any noise induced in + * the sensor wires, such as by stepper motor wires run in parallel to them, + * may result in the thermocouple sensor reporting spurious errors. This + * value is the number of errors which can occur in a row before the error + * is reported. This allows us to ignore intermittent error conditions while + * still detecting an actual failure, which should result in a continuous + * stream of errors from the sensor. + * + * Set this value to 0 to fail on the first error to occur. + */ +#define THERMOCOUPLE_MAX_ERRORS 15 + // // Custom Thermistor 1000 parameters // diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index f9482aedb27d..0b073bc16c95 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -2060,6 +2060,10 @@ void Temperature::disable_all_heaters() { #if HAS_MAX6675 + #ifndef THERMOCOUPLE_MAX_ERRORS + #define THERMOCOUPLE_MAX_ERRORS 15 + #endif + int Temperature::read_max6675( #if COUNT_6675 > 1 const uint8_t hindex @@ -2071,6 +2075,8 @@ void Temperature::disable_all_heaters() { // Needed to return the correct temp when this is called too soon static uint16_t max6675_temp_previous[COUNT_6675] = { 0 }; #endif + + static uint8_t max6675_errors[COUNT_6675] = { 0 }; #define MAX6675_HEAT_INTERVAL 250UL @@ -2144,33 +2150,41 @@ void Temperature::disable_all_heaters() { WRITE_MAX6675(HIGH); // disable TT_MAX6675 if (max6675_temp & MAX6675_ERROR_MASK) { - SERIAL_ERROR_START(); - SERIAL_ECHOPGM("Temp measurement error! "); - #if MAX6675_ERROR_MASK == 7 - SERIAL_ECHOPGM("MAX31855 "); - if (max6675_temp & 1) - SERIAL_ECHOLNPGM("Open Circuit"); - else if (max6675_temp & 2) - SERIAL_ECHOLNPGM("Short to GND"); - else if (max6675_temp & 4) - SERIAL_ECHOLNPGM("Short to VCC"); - #else - SERIAL_ECHOLNPGM("MAX6675"); - #endif - - // Thermocouple open - max6675_temp = 4 * ( - #if COUNT_6675 > 1 - hindex ? HEATER_1_MAX6675_TMAX : HEATER_0_MAX6675_TMAX - #elif ENABLED(HEATER_1_USES_MAX6675) - HEATER_1_MAX6675_TMAX + max6675_errors[hindex] += 1; + if (max6675_errors[hindex] > THERMOCOUPLE_MAX_ERRORS) { + SERIAL_ERROR_START(); + SERIAL_ECHOPGM("Temp measurement error! "); + #if MAX6675_ERROR_MASK == 7 + SERIAL_ECHOPGM("MAX31855 "); + if (max6675_temp & 1) + SERIAL_ECHOLNPGM("Open Circuit"); + else if (max6675_temp & 2) + SERIAL_ECHOLNPGM("Short to GND"); + else if (max6675_temp & 4) + SERIAL_ECHOLNPGM("Short to VCC"); #else - HEATER_0_MAX6675_TMAX + SERIAL_ECHOLNPGM("MAX6675"); #endif - ); + + // Thermocouple open + max6675_temp = 4 * ( + #if COUNT_6675 > 1 + hindex ? HEATER_1_MAX6675_TMAX : HEATER_0_MAX6675_TMAX + #elif ENABLED(HEATER_1_USES_MAX6675) + HEATER_1_MAX6675_TMAX + #else + HEATER_0_MAX6675_TMAX + #endif + ); + } + else { + max6675_temp >>= MAX6675_DISCARD_BITS; + } } - else + else { max6675_temp >>= MAX6675_DISCARD_BITS; + max6675_errors[hindex] = 0; + } #if ENABLED(MAX6675_IS_MAX31855) if (max6675_temp & 0x00002000) max6675_temp |= 0xFFFFC000; // Support negative temperature From 9bf768a3fbefdc270efa237a10a9031c975878d3 Mon Sep 17 00:00:00 2001 From: Giuliano Zaro <3684609+GMagician@users.noreply.github.com> Date: Wed, 20 May 2020 22:39:08 +0200 Subject: [PATCH 11/16] Update Italian language (#18049) --- Marlin/src/lcd/language/language_it.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Marlin/src/lcd/language/language_it.h b/Marlin/src/lcd/language/language_it.h index f7dce0709dfd..aa853e56f482 100644 --- a/Marlin/src/lcd/language/language_it.h +++ b/Marlin/src/lcd/language/language_it.h @@ -342,6 +342,7 @@ namespace Language_it { PROGMEM Language_Str MSG_BUTTON_STOP = _UxGT("Stop"); PROGMEM Language_Str MSG_BUTTON_PRINT = _UxGT("Stampa"); PROGMEM Language_Str MSG_BUTTON_RESET = _UxGT("Resetta"); + PROGMEM Language_Str MSG_BUTTON_IGNORE = _UxGT("Ignora"); PROGMEM Language_Str MSG_BUTTON_CANCEL = _UxGT("Annulla"); PROGMEM Language_Str MSG_BUTTON_DONE = _UxGT("Fatto"); PROGMEM Language_Str MSG_BUTTON_BACK = _UxGT("Indietro"); @@ -485,8 +486,12 @@ namespace Language_it { PROGMEM Language_Str MSG_INFO_PROTOCOL = _UxGT("Protocollo"); PROGMEM Language_Str MSG_INFO_RUNAWAY_OFF = _UxGT("Controllo fuga: OFF"); PROGMEM Language_Str MSG_INFO_RUNAWAY_ON = _UxGT("Controllo fuga: ON"); + PROGMEM Language_Str MSG_HOTEND_IDLE_TIMEOUT = _UxGT("Timeout inatt.ugello"); + PROGMEM Language_Str MSG_CASE_LIGHT = _UxGT("Luci Case"); PROGMEM Language_Str MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Luminosità Luci"); + PROGMEM Language_Str MSG_KILL_EXPECTED_PRINTER = _UxGT("STAMPANTE ERRATA"); + #if LCD_WIDTH >= 20 PROGMEM Language_Str MSG_INFO_PRINT_COUNT = _UxGT("Contat. stampa"); PROGMEM Language_Str MSG_INFO_COMPLETED_PRINTS = _UxGT("Completati"); @@ -570,7 +575,8 @@ namespace Language_it { PROGMEM Language_Str MSG_SNAKE = _UxGT("Sn4k3"); PROGMEM Language_Str MSG_MAZE = _UxGT("Maze"); - PROGMEM Language_Str MSG_KILL_EXPECTED_PRINTER = _UxGT("Stampante errata"); + PROGMEM Language_Str MSG_BAD_PAGE = _UxGT("Indice pag. errato"); + PROGMEM Language_Str MSG_BAD_PAGE_SPEED = _UxGT("Vel. pag. errata"); // // Le schermate di Cambio Filamento possono visualizzare fino a 3 linee su un display a 4 righe From 4e512405633911f8809f774c175c270d288a8586 Mon Sep 17 00:00:00 2001 From: thisiskeithb <13375512+thisiskeithb@users.noreply.github.com> Date: Wed, 20 May 2020 13:42:45 -0700 Subject: [PATCH 12/16] BTT GTR has I2C EEPROM (#18029) --- Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h index ce3a282b5e9a..47fcb97be542 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h @@ -31,18 +31,10 @@ #define BOARD_INFO_NAME "BIGTREE GTR 1.0" -// Use one of these or SDCard-based Emulation will be used -#if NO_EEPROM_SELECTED - //#define I2C_EEPROM - //#define SRAM_EEPROM_EMULATION // Use BackSRAM-based EEPROM emulation - //#define FLASH_EEPROM_EMULATION // Use Flash-based EEPROM emulation -#endif - -#if ENABLED(FLASH_EEPROM_EMULATION) - // Decrease delays and flash wear by spreading writes across the - // 128 kB sector allocated for EEPROM emulation. - #define FLASH_EEPROM_LEVELING -#endif +// Onboard I2C EEPROM +#define I2C_EEPROM +#undef E2END +#define E2END 0x1FFF // EEPROM end address 24C64 (64Kb = 8KB) #define TP // Enable to define servo and probe pins From 8cfcabe14602b459923c02e43a730fec4ac70e42 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Thu, 21 May 2020 00:04:28 +0000 Subject: [PATCH 13/16] [cron] Bump distribution date (2020-05-21) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index c7665bf52f26..bee3a5ced871 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2020-05-20" + #define STRING_DISTRIBUTION_DATE "2020-05-21" #endif /** From f7346b6ee12b2153f84fd34faf6b954a5d76ab91 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Fri, 22 May 2020 00:04:21 +0000 Subject: [PATCH 14/16] [cron] Bump distribution date (2020-05-22) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index bee3a5ced871..e0f8987373f1 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2020-05-21" + #define STRING_DISTRIBUTION_DATE "2020-05-22" #endif /** From 31eb487da5778f653c771331bcef6b57e3511404 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 22 May 2020 02:02:03 -0500 Subject: [PATCH 15/16] whitespace --- Marlin/Configuration_adv.h | 2 +- Marlin/src/feature/direct_stepping.cpp | 2 +- Marlin/src/module/temperature.cpp | 2 +- Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h | 3 +-- Marlin/src/pins/ramps/pins_TRIGORILLA_14.h | 4 ++-- Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_V1_1.h | 4 ++-- 6 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index db89a1d5e976..22755f8122c2 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -47,7 +47,7 @@ * is reported. This allows us to ignore intermittent error conditions while * still detecting an actual failure, which should result in a continuous * stream of errors from the sensor. - * + * * Set this value to 0 to fail on the first error to occur. */ #define THERMOCOUPLE_MAX_ERRORS 15 diff --git a/Marlin/src/feature/direct_stepping.cpp b/Marlin/src/feature/direct_stepping.cpp index 7bed075b8762..76dfac7de55f 100644 --- a/Marlin/src/feature/direct_stepping.cpp +++ b/Marlin/src/feature/direct_stepping.cpp @@ -61,7 +61,7 @@ namespace DirectStepping { template uint8_t SerialPageManager::pages[Cfg::NUM_PAGES][Cfg::PAGE_SIZE]; - + template uint8_t SerialPageManager::checksum; diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 0b073bc16c95..6121a5a0acd4 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -2075,7 +2075,7 @@ void Temperature::disable_all_heaters() { // Needed to return the correct temp when this is called too soon static uint16_t max6675_temp_previous[COUNT_6675] = { 0 }; #endif - + static uint8_t max6675_errors[COUNT_6675] = { 0 }; #define MAX6675_HEAT_INTERVAL 250UL diff --git a/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h b/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h index dd4cb4ea0852..601edc83d002 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h +++ b/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h @@ -47,7 +47,6 @@ #define PS_ON_PIN 40 // Used by CR2020 Industrial series #endif - #if ENABLED(CASE_LIGHT_ENABLE) && !defined(CASE_LIGHT_PIN) #define CASE_LIGHT_PIN 65 #endif @@ -65,5 +64,5 @@ #define SUICIDE_PIN 12 // Used by CR2020 Industrial series #ifndef SUICIDE_PIN_INVERTING - #define SUICIDE_PIN_INVERTING true + #define SUICIDE_PIN_INVERTING true #endif diff --git a/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h b/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h index cfb9acb054ce..a512aa8353fe 100644 --- a/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h +++ b/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h @@ -59,7 +59,7 @@ #define RAMPS_D10_PIN TG_HEATER_0_PIN // HEATER_0_PIN is always RAMPS_D10_PIN in pins_RAMPS.h -#if HAS_MULTI_HOTEND // EEF and EEB +#if HAS_MULTI_HOTEND // EEF and EEB #define RAMPS_D9_PIN TG_HEATER_1_PIN #if !TEMP_SENSOR_BED // EEF @@ -79,7 +79,7 @@ #define RAMPS_D8_PIN TG_FAN0_PIN #endif -#if HAS_MULTI_HOTEND || TEMP_SENSOR_BED // EEF, EEB, EFB +#if HAS_MULTI_HOTEND || TEMP_SENSOR_BED // EEF, EEB, EFB #define FAN1_PIN TG_FAN1_PIN #endif #define FAN2_PIN TG_FAN2_PIN diff --git a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_V1_1.h b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_V1_1.h index 3df81a7842e5..ba1ea0879603 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_V1_1.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_V1_1.h @@ -352,8 +352,8 @@ *  ̄ ̄ * W1 */ -#define ESP_WIFI_MODULE_COM 6 // Must also set either SERIAL_PORT or SERIAL_PORT_2 to this -#define ESP_WIFI_MODULE_BAUDRATE BAUDRATE // Must use same BAUDRATE as SERIAL_PORT & SERIAL_PORT_2 +#define ESP_WIFI_MODULE_COM 6 // Must also set either SERIAL_PORT or SERIAL_PORT_2 to this +#define ESP_WIFI_MODULE_BAUDRATE BAUDRATE // Must use same BAUDRATE as SERIAL_PORT & SERIAL_PORT_2 #define ESP_WIFI_MODULE_RESET_PIN PG0 #define ESP_WIFI_MODULE_ENABLE_PIN PG1 #define ESP_WIFI_MODULE_GPIO0_PIN PF14 From 461647fcee5f9d519e0e54f809dbfb38bf573e59 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 22 May 2020 02:15:40 -0500 Subject: [PATCH 16/16] Use MARLIN_EEPROM_SIZE with E2END as fallback (#18059) --- Marlin/src/HAL/AVR/eeprom.cpp | 5 +- Marlin/src/HAL/DUE/eeprom_flash.cpp | 9 ++- Marlin/src/HAL/DUE/eeprom_wired.cpp | 5 +- Marlin/src/HAL/ESP32/eeprom.cpp | 17 ++--- Marlin/src/HAL/LINUX/eeprom.cpp | 15 +++-- Marlin/src/HAL/LPC1768/eeprom_flash.cpp | 25 +++---- Marlin/src/HAL/LPC1768/eeprom_sdcard.cpp | 5 +- Marlin/src/HAL/LPC1768/eeprom_wired.cpp | 12 ++-- Marlin/src/HAL/SAMD51/eeprom_wired.cpp | 12 ++-- Marlin/src/HAL/STM32/eeprom_flash.cpp | 39 +++++------ Marlin/src/HAL/STM32/eeprom_sdcard.cpp | 65 ++++++++----------- Marlin/src/HAL/STM32/eeprom_sram.cpp | 6 +- Marlin/src/HAL/STM32/eeprom_wired.cpp | 12 ++-- Marlin/src/HAL/STM32F1/eeprom_flash.cpp | 18 ++--- Marlin/src/HAL/STM32F1/eeprom_sdcard.cpp | 22 +++---- Marlin/src/HAL/STM32F1/eeprom_wired.cpp | 8 ++- Marlin/src/HAL/STM32_F4_F7/eeprom_flash.cpp | 8 ++- Marlin/src/HAL/STM32_F4_F7/eeprom_wired.cpp | 12 ++-- Marlin/src/HAL/TEENSY31_32/eeprom.cpp | 8 ++- Marlin/src/HAL/TEENSY35_36/eeprom.cpp | 6 +- Marlin/src/module/configuration_store.cpp | 2 +- Marlin/src/pins/linux/pins_RAMPS_LINUX.h | 4 +- Marlin/src/pins/sam/pins_RADDS.h | 2 +- Marlin/src/pins/sam/pins_RAMPS_FD_V2.h | 2 +- Marlin/src/pins/sam/pins_RAMPS_SMART.h | 2 +- Marlin/src/pins/sam/pins_RURAMPS4D_11.h | 2 +- Marlin/src/pins/sam/pins_RURAMPS4D_13.h | 2 +- Marlin/src/pins/samd/pins_RAMPS_144.h | 2 +- Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h | 6 +- .../src/pins/stm32f1/pins_BTT_SKR_MINI_E3.h | 3 +- .../src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h | 2 +- Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h | 3 +- Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h | 3 +- Marlin/src/pins/stm32f1/pins_GTM32_MINI.h | 2 +- Marlin/src/pins/stm32f1/pins_GTM32_MINI_A30.h | 2 +- Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h | 2 +- Marlin/src/pins/stm32f1/pins_GTM32_REV_B.h | 2 +- .../src/pins/stm32f1/pins_JGAURORA_A5S_A1.h | 6 +- Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h | 7 +- Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h | 2 +- Marlin/src/pins/stm32f4/pins_ARMED.h | 4 +- .../src/pins/stm32f4/pins_BLACK_STM32F407VE.h | 2 +- Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h | 3 +- Marlin/src/pins/stm32f4/pins_FLYF407ZG.h | 3 +- Marlin/src/pins/stm32f4/pins_FYSETC_S6.h | 3 +- .../src/pins/stm32f4/pins_GENERIC_STM32F4.h | 4 +- Marlin/src/pins/stm32f4/pins_RUMBA32_common.h | 5 +- Marlin/src/pins/stm32f4/pins_VAKE403D.h | 3 +- Marlin/src/pins/stm32f7/pins_THE_BORG.h | 4 +- 49 files changed, 201 insertions(+), 197 deletions(-) diff --git a/Marlin/src/HAL/AVR/eeprom.cpp b/Marlin/src/HAL/AVR/eeprom.cpp index 0519e5732e9d..7f4384215506 100644 --- a/Marlin/src/HAL/AVR/eeprom.cpp +++ b/Marlin/src/HAL/AVR/eeprom.cpp @@ -32,7 +32,10 @@ #include "../shared/eeprom_api.h" -size_t PersistentStore::capacity() { return E2END + 1; } +#ifndef MARLIN_EEPROM_SIZE + #define MARLIN_EEPROM_SIZE size_t(E2END + 1) +#endif +size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; } bool PersistentStore::access_start() { return true; } bool PersistentStore::access_finish() { return true; } diff --git a/Marlin/src/HAL/DUE/eeprom_flash.cpp b/Marlin/src/HAL/DUE/eeprom_flash.cpp index c07d05adfc93..cb27e23c58ba 100644 --- a/Marlin/src/HAL/DUE/eeprom_flash.cpp +++ b/Marlin/src/HAL/DUE/eeprom_flash.cpp @@ -26,10 +26,6 @@ #if ENABLED(FLASH_EEPROM_EMULATION) -#ifndef E2END - #define E2END 0xFFF // Default to Flash emulated EEPROM size (eeprom_emul.cpp) -#endif - /* EEPROM emulation over flash with reduced wear * * We will use 2 contiguous groups of pages as main and alternate. @@ -973,7 +969,10 @@ static void ee_Init() { #include "../shared/eeprom_api.h" -size_t PersistentStore::capacity() { return E2END + 1; } +#ifndef MARLIN_EEPROM_SIZE + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB +#endif +size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; } bool PersistentStore::access_start() { ee_Init(); return true; } bool PersistentStore::access_finish() { ee_Flush(); return true; } diff --git a/Marlin/src/HAL/DUE/eeprom_wired.cpp b/Marlin/src/HAL/DUE/eeprom_wired.cpp index a9b2cc92d2be..e26d19f36608 100644 --- a/Marlin/src/HAL/DUE/eeprom_wired.cpp +++ b/Marlin/src/HAL/DUE/eeprom_wired.cpp @@ -34,7 +34,10 @@ #include "../shared/eeprom_if.h" #include "../shared/eeprom_api.h" -size_t PersistentStore::capacity() { return E2END + 1; } +#ifndef MARLIN_EEPROM_SIZE + #error "MARLIN_EEPROM_SIZE is required for I2C / SPI EEPROM." +#endif +size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; } bool PersistentStore::access_start() { return true; } bool PersistentStore::access_finish() { return true; } diff --git a/Marlin/src/HAL/ESP32/eeprom.cpp b/Marlin/src/HAL/ESP32/eeprom.cpp index 35cebb592f7d..27974fe55e10 100644 --- a/Marlin/src/HAL/ESP32/eeprom.cpp +++ b/Marlin/src/HAL/ESP32/eeprom.cpp @@ -28,16 +28,13 @@ #include "../shared/eeprom_api.h" #include -#define EEPROM_SIZE 4096 +#ifndef MARLIN_EEPROM_SIZE + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB +#endif +size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; } -bool PersistentStore::access_start() { - return EEPROM.begin(EEPROM_SIZE); -} - -bool PersistentStore::access_finish() { - EEPROM.end(); - return true; -} +bool PersistentStore::access_start() { return EEPROM.begin(MARLIN_EEPROM_SIZE); } +bool PersistentStore::access_finish() { EEPROM.end(); return true; } bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { for (size_t i = 0; i < size; i++) { @@ -56,7 +53,5 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t return false; } -size_t PersistentStore::capacity() { return EEPROM_SIZE; } - #endif // EEPROM_SETTINGS #endif // ARDUINO_ARCH_ESP32 diff --git a/Marlin/src/HAL/LINUX/eeprom.cpp b/Marlin/src/HAL/LINUX/eeprom.cpp index 7a9a1db381f8..50f33eae21dd 100644 --- a/Marlin/src/HAL/LINUX/eeprom.cpp +++ b/Marlin/src/HAL/LINUX/eeprom.cpp @@ -28,10 +28,15 @@ #include "../shared/eeprom_api.h" #include -#define LINUX_EEPROM_SIZE (E2END + 1) -uint8_t buffer[LINUX_EEPROM_SIZE]; +#ifndef MARLIN_EEPROM_SIZE + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB of Emulated EEPROM +#endif + +uint8_t buffer[MARLIN_EEPROM_SIZE]; char filename[] = "eeprom.dat"; +size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; } + bool PersistentStore::access_start() { const char eeprom_erase_value = 0xFF; FILE * eeprom_file = fopen(filename, "rb"); @@ -40,8 +45,8 @@ bool PersistentStore::access_start() { fseek(eeprom_file, 0L, SEEK_END); std::size_t file_size = ftell(eeprom_file); - if (file_size < LINUX_EEPROM_SIZE) { - memset(buffer + file_size, eeprom_erase_value, LINUX_EEPROM_SIZE - file_size); + if (file_size < MARLIN_EEPROM_SIZE) { + memset(buffer + file_size, eeprom_erase_value, MARLIN_EEPROM_SIZE - file_size); } else { fseek(eeprom_file, 0L, SEEK_SET); @@ -95,7 +100,5 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, const size_t size, uin return bytes_read != size; // return true for any error } -size_t PersistentStore::capacity() { return 4096; } // 4KiB of Emulated EEPROM - #endif // EEPROM_SETTINGS #endif // __PLAT_LINUX__ diff --git a/Marlin/src/HAL/LPC1768/eeprom_flash.cpp b/Marlin/src/HAL/LPC1768/eeprom_flash.cpp index 3bcda68adb32..759b01b36560 100644 --- a/Marlin/src/HAL/LPC1768/eeprom_flash.cpp +++ b/Marlin/src/HAL/LPC1768/eeprom_flash.cpp @@ -46,19 +46,22 @@ extern "C" { #include } -#define SECTOR_START(sector) ((sector < 16) ? (sector * 0x1000) : ((sector - 14) * 0x8000)) +#ifndef MARLIN_EEPROM_SIZE + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB +#endif + +#define SECTOR_START(sector) ((sector < 16) ? (sector << 12) : ((sector - 14) << 15)) #define EEPROM_SECTOR 29 -#define EEPROM_SIZE (4096) -#define SECTOR_SIZE (32768) -#define EEPROM_SLOTS (SECTOR_SIZE/EEPROM_SIZE) -#define EEPROM_ERASE (0xFF) -#define SLOT_ADDRESS(sector, slot) (((uint8_t *)SECTOR_START(sector)) + slot * EEPROM_SIZE) +#define SECTOR_SIZE 32768 +#define EEPROM_SLOTS ((SECTOR_SIZE)/(MARLIN_EEPROM_SIZE)) +#define EEPROM_ERASE 0xFF +#define SLOT_ADDRESS(sector, slot) (((uint8_t *)SECTOR_START(sector)) + slot * (MARLIN_EEPROM_SIZE)) -static uint8_t ram_eeprom[EEPROM_SIZE] __attribute__((aligned(4))) = {0}; +static uint8_t ram_eeprom[MARLIN_EEPROM_SIZE] __attribute__((aligned(4))) = {0}; static bool eeprom_dirty = false; static int current_slot = 0; -size_t PersistentStore::capacity() { return EEPROM_SIZE; } +size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; } bool PersistentStore::access_start() { uint32_t first_nblank_loc, first_nblank_val; @@ -71,15 +74,15 @@ bool PersistentStore::access_start() { if (status == CMD_SUCCESS) { // sector is blank so nothing stored yet - for (int i = 0; i < EEPROM_SIZE; i++) ram_eeprom[i] = EEPROM_ERASE; + for (int i = 0; i < MARLIN_EEPROM_SIZE; i++) ram_eeprom[i] = EEPROM_ERASE; current_slot = EEPROM_SLOTS; } else { // current slot is the first non blank one - current_slot = first_nblank_loc / EEPROM_SIZE; + current_slot = first_nblank_loc / (MARLIN_EEPROM_SIZE); uint8_t *eeprom_data = SLOT_ADDRESS(EEPROM_SECTOR, current_slot); // load current settings - for (int i = 0; i < EEPROM_SIZE; i++) ram_eeprom[i] = eeprom_data[i]; + for (int i = 0; i < MARLIN_EEPROM_SIZE; i++) ram_eeprom[i] = eeprom_data[i]; } eeprom_dirty = false; diff --git a/Marlin/src/HAL/LPC1768/eeprom_sdcard.cpp b/Marlin/src/HAL/LPC1768/eeprom_sdcard.cpp index aac41ab307a4..92a9d6f0c0b3 100644 --- a/Marlin/src/HAL/LPC1768/eeprom_sdcard.cpp +++ b/Marlin/src/HAL/LPC1768/eeprom_sdcard.cpp @@ -38,7 +38,10 @@ FATFS fat_fs; FIL eeprom_file; bool eeprom_file_open = false; -size_t PersistentStore::capacity() { return 4096; } // 4KiB of Emulated EEPROM +#ifndef MARLIN_EEPROM_SIZE + #define MARLIN_EEPROM_SIZE size_t(0x1000) // 4KiB of Emulated EEPROM +#endif +size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; } bool PersistentStore::access_start() { const char eeprom_erase_value = 0xFF; diff --git a/Marlin/src/HAL/LPC1768/eeprom_wired.cpp b/Marlin/src/HAL/LPC1768/eeprom_wired.cpp index 255ff6faadcf..6daedc50e089 100644 --- a/Marlin/src/HAL/LPC1768/eeprom_wired.cpp +++ b/Marlin/src/HAL/LPC1768/eeprom_wired.cpp @@ -33,18 +33,14 @@ #include "../shared/eeprom_if.h" #include "../shared/eeprom_api.h" -#ifndef EEPROM_SIZE - #define EEPROM_SIZE 0x8000 // 32kB‬ +#ifndef MARLIN_EEPROM_SIZE + #define MARLIN_EEPROM_SIZE 0x8000 // 32KB‬ #endif +size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; } -size_t PersistentStore::capacity() { return EEPROM_SIZE; } +bool PersistentStore::access_start() { eeprom_init(); return true; } bool PersistentStore::access_finish() { return true; } -bool PersistentStore::access_start() { - eeprom_init(); - return true; -} - bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { while (size--) { uint8_t v = *value; diff --git a/Marlin/src/HAL/SAMD51/eeprom_wired.cpp b/Marlin/src/HAL/SAMD51/eeprom_wired.cpp index e5c14e9cbff7..22210dc49eb9 100644 --- a/Marlin/src/HAL/SAMD51/eeprom_wired.cpp +++ b/Marlin/src/HAL/SAMD51/eeprom_wired.cpp @@ -32,13 +32,13 @@ #include "../shared/eeprom_if.h" #include "../shared/eeprom_api.h" -size_t PersistentStore::capacity() { return E2END + 1; } -bool PersistentStore::access_finish() { return true; } +#ifndef MARLIN_EEPROM_SIZE + #error "MARLIN_EEPROM_SIZE is required for I2C / SPI EEPROM." +#endif +size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; } -bool PersistentStore::access_start() { - eeprom_init(); - return true; -} +bool PersistentStore::access_start() { eeprom_init(); return true; } +bool PersistentStore::access_finish() { return true; } bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { while (size--) { diff --git a/Marlin/src/HAL/STM32/eeprom_flash.cpp b/Marlin/src/HAL/STM32/eeprom_flash.cpp index 309c5eea9f86..57713593c8fa 100644 --- a/Marlin/src/HAL/STM32/eeprom_flash.cpp +++ b/Marlin/src/HAL/STM32/eeprom_flash.cpp @@ -32,7 +32,7 @@ #include "Servo.h" #define PAUSE_SERVO_OUTPUT() libServo::pause_all_servos() #define RESUME_SERVO_OUTPUT() libServo::resume_all_servos() -#else +#else #define PAUSE_SERVO_OUTPUT() #define RESUME_SERVO_OUTPUT() #endif @@ -59,8 +59,8 @@ #define DEBUG_OUT ENABLED(EEPROM_CHITCHAT) #include "src/core/debug_out.h" - #ifndef EEPROM_SIZE - #define EEPROM_SIZE 0x1000 // 4kB + #ifndef MARLIN_EEPROM_SIZE + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB #endif #ifndef FLASH_SECTOR @@ -70,11 +70,11 @@ #define FLASH_UNIT_SIZE 0x20000 // 128kB #endif - #define FLASH_ADDRESS_START (FLASH_END - ((FLASH_SECTOR_TOTAL - FLASH_SECTOR) * FLASH_UNIT_SIZE) + 1) + #define FLASH_ADDRESS_START (FLASH_END - ((FLASH_SECTOR_TOTAL - (FLASH_SECTOR)) * (FLASH_UNIT_SIZE)) + 1) #define FLASH_ADDRESS_END (FLASH_ADDRESS_START + FLASH_UNIT_SIZE - 1) - #define EEPROM_SLOTS (FLASH_UNIT_SIZE/EEPROM_SIZE) - #define SLOT_ADDRESS(slot) (FLASH_ADDRESS_START + (slot * EEPROM_SIZE)) + #define EEPROM_SLOTS ((FLASH_UNIT_SIZE) / (MARLIN_EEPROM_SIZE)) + #define SLOT_ADDRESS(slot) (FLASH_ADDRESS_START + (slot * (MARLIN_EEPROM_SIZE))) #define UNLOCK_FLASH() if (!flash_unlocked) { \ HAL_FLASH_Unlock(); \ @@ -87,12 +87,12 @@ #define EMPTY_UINT32 ((uint32_t)-1) #define EMPTY_UINT8 ((uint8_t)-1) - static uint8_t ram_eeprom[EEPROM_SIZE] __attribute__((aligned(4))) = {0}; + static uint8_t ram_eeprom[MARLIN_EEPROM_SIZE] __attribute__((aligned(4))) = {0}; static int current_slot = -1; - static_assert(0 == EEPROM_SIZE % 4, "EEPROM_SIZE must be a multiple of 4"); // Ensure copying as uint32_t is safe - static_assert(0 == FLASH_UNIT_SIZE % EEPROM_SIZE, "EEPROM_SIZE must divide evenly into your FLASH_UNIT_SIZE"); - static_assert(FLASH_UNIT_SIZE >= EEPROM_SIZE, "FLASH_UNIT_SIZE must be greater than or equal to your EEPROM_SIZE"); + static_assert(0 == MARLIN_EEPROM_SIZE % 4, "MARLIN_EEPROM_SIZE must be a multiple of 4"); // Ensure copying as uint32_t is safe + static_assert(0 == FLASH_UNIT_SIZE % MARLIN_EEPROM_SIZE, "MARLIN_EEPROM_SIZE must divide evenly into your FLASH_UNIT_SIZE"); + static_assert(FLASH_UNIT_SIZE >= MARLIN_EEPROM_SIZE, "FLASH_UNIT_SIZE must be greater than or equal to your MARLIN_EEPROM_SIZE"); static_assert(IS_FLASH_SECTOR(FLASH_SECTOR), "FLASH_SECTOR is invalid"); static_assert(IS_POWER_OF_2(FLASH_UNIT_SIZE), "FLASH_UNIT_SIZE should be a power of 2, please check your chip's spec sheet"); @@ -100,6 +100,11 @@ static bool eeprom_data_written = false; +#ifndef MARLIN_EEPROM_SIZE + #define MARLIN_EEPROM_SIZE size_t(E2END + 1) +#endif +size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; } + bool PersistentStore::access_start() { #if ENABLED(FLASH_EEPROM_LEVELING) @@ -113,20 +118,20 @@ bool PersistentStore::access_start() { while (address <= FLASH_ADDRESS_END) { uint32_t address_value = (*(__IO uint32_t*)address); if (address_value != EMPTY_UINT32) { - current_slot = (address - FLASH_ADDRESS_START) / EEPROM_SIZE; + current_slot = (address - (FLASH_ADDRESS_START)) / (MARLIN_EEPROM_SIZE); break; } address += sizeof(uint32_t); } if (current_slot == -1) { // We didn't find anything, so we'll just intialize to empty - for (int i = 0; i < EEPROM_SIZE; i++) ram_eeprom[i] = EMPTY_UINT8; + for (int i = 0; i < MARLIN_EEPROM_SIZE; i++) ram_eeprom[i] = EMPTY_UINT8; current_slot = EEPROM_SLOTS; } else { // load current settings uint8_t *eeprom_data = (uint8_t *)SLOT_ADDRESS(current_slot); - for (int i = 0; i < EEPROM_SIZE; i++) ram_eeprom[i] = eeprom_data[i]; + for (int i = 0; i < MARLIN_EEPROM_SIZE; i++) ram_eeprom[i] = eeprom_data[i]; DEBUG_ECHOLNPAIR("EEPROM loaded from slot ", current_slot, "."); } eeprom_data_written = false; @@ -146,7 +151,7 @@ bool PersistentStore::access_finish() { // MCU may come up with flash error bits which prevent some flash operations. // Clear flags prior to flash operations to prevent errors. __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR); - #endif + #endif #if ENABLED(FLASH_EEPROM_LEVELING) @@ -185,7 +190,7 @@ bool PersistentStore::access_finish() { uint32_t offset = 0; uint32_t address = SLOT_ADDRESS(current_slot); - uint32_t address_end = address + EEPROM_SIZE; + uint32_t address_end = address + MARLIN_EEPROM_SIZE; uint32_t data = 0; bool success = true; @@ -267,9 +272,5 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t return false; } -size_t PersistentStore::capacity() { - return TERN(FLASH_EEPROM_LEVELING, EEPROM_SIZE, E2END + 1); -} - #endif // FLASH_EEPROM_EMULATION #endif // ARDUINO_ARCH_STM32 && !STM32GENERIC diff --git a/Marlin/src/HAL/STM32/eeprom_sdcard.cpp b/Marlin/src/HAL/STM32/eeprom_sdcard.cpp index 2b89c21b8997..2fcf5ec3d98b 100644 --- a/Marlin/src/HAL/STM32/eeprom_sdcard.cpp +++ b/Marlin/src/HAL/STM32/eeprom_sdcard.cpp @@ -31,53 +31,44 @@ #if ENABLED(SDCARD_EEPROM_EMULATION) #include "../shared/eeprom_api.h" +#include "../../sd/cardreader.h" -#ifndef E2END - #define E2END 0xFFF // 4KB +#define EEPROM_FILENAME "eeprom.dat" + +#ifndef MARLIN_EEPROM_SIZE + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB #endif -#define HAL_EEPROM_SIZE int(E2END + 1) +size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; } #define _ALIGN(x) __attribute__ ((aligned(x))) -static char _ALIGN(4) HAL_eeprom_data[HAL_EEPROM_SIZE]; - -#if ENABLED(SDSUPPORT) +static char _ALIGN(4) HAL_eeprom_data[MARLIN_EEPROM_SIZE]; - #include "../../sd/cardreader.h" +bool PersistentStore::access_start() { + if (!card.isMounted()) return false; - #define EEPROM_FILENAME "eeprom.dat" + SdFile file, root = card.getroot(); + if (!file.open(&root, EEPROM_FILENAME, O_RDONLY)) + return true; - bool PersistentStore::access_start() { - if (!card.isMounted()) return false; + int bytes_read = file.read(HAL_eeprom_data, MARLIN_EEPROM_SIZE); + if (bytes_read < 0) return false; + for (; bytes_read < MARLIN_EEPROM_SIZE; bytes_read++) + HAL_eeprom_data[bytes_read] = 0xFF; + file.close(); + return true; +} - SdFile file, root = card.getroot(); - if (!file.open(&root, EEPROM_FILENAME, O_RDONLY)) - return true; +bool PersistentStore::access_finish() { + if (!card.isMounted()) return false; - int bytes_read = file.read(HAL_eeprom_data, HAL_EEPROM_SIZE); - if (bytes_read < 0) return false; - for (; bytes_read < HAL_EEPROM_SIZE; bytes_read++) - HAL_eeprom_data[bytes_read] = 0xFF; + SdFile file, root = card.getroot(); + int bytes_written = 0; + if (file.open(&root, EEPROM_FILENAME, O_CREAT | O_WRITE | O_TRUNC)) { + bytes_written = file.write(HAL_eeprom_data, MARLIN_EEPROM_SIZE); file.close(); - return true; } - - bool PersistentStore::access_finish() { - if (!card.isMounted()) return false; - - SdFile file, root = card.getroot(); - int bytes_written = 0; - if (file.open(&root, EEPROM_FILENAME, O_CREAT | O_WRITE | O_TRUNC)) { - bytes_written = file.write(HAL_eeprom_data, HAL_EEPROM_SIZE); - file.close(); - } - return (bytes_written == HAL_EEPROM_SIZE); - } - -#else // !SDSUPPORT - - #error "Please define an EEPROM, a SDCARD or disable EEPROM_SETTINGS." - -#endif // !SDSUPPORT + return (bytes_written == MARLIN_EEPROM_SIZE); +} bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { for (size_t i = 0; i < size; i++) @@ -97,7 +88,5 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, const size_t size, uin return false; } -size_t PersistentStore::capacity() { return HAL_EEPROM_SIZE; } - #endif // SDCARD_EEPROM_EMULATION #endif // STM32 && !STM32GENERIC diff --git a/Marlin/src/HAL/STM32/eeprom_sram.cpp b/Marlin/src/HAL/STM32/eeprom_sram.cpp index 0993dee33df4..640631428783 100644 --- a/Marlin/src/HAL/STM32/eeprom_sram.cpp +++ b/Marlin/src/HAL/STM32/eeprom_sram.cpp @@ -29,7 +29,11 @@ #include "../shared/eeprom_if.h" #include "../shared/eeprom_api.h" -size_t PersistentStore::capacity() { return 4096; } // 4K of SRAM +#ifndef MARLIN_EEPROM_SIZE + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB +#endif +size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; } + bool PersistentStore::access_start() { return true; } bool PersistentStore::access_finish() { return true; } diff --git a/Marlin/src/HAL/STM32/eeprom_wired.cpp b/Marlin/src/HAL/STM32/eeprom_wired.cpp index 084b9e6eabaa..7fe1116d614d 100644 --- a/Marlin/src/HAL/STM32/eeprom_wired.cpp +++ b/Marlin/src/HAL/STM32/eeprom_wired.cpp @@ -34,13 +34,13 @@ #include "../shared/eeprom_if.h" #include "../shared/eeprom_api.h" -size_t PersistentStore::capacity() { return E2END + 1; } -bool PersistentStore::access_finish() { return true; } +#ifndef MARLIN_EEPROM_SIZE + #define MARLIN_EEPROM_SIZE size_t(E2END + 1) +#endif +size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; } -bool PersistentStore::access_start() { - eeprom_init(); - return true; -} +bool PersistentStore::access_start() { eeprom_init(); return true; } +bool PersistentStore::access_finish() { return true; } bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { while (size--) { diff --git a/Marlin/src/HAL/STM32F1/eeprom_flash.cpp b/Marlin/src/HAL/STM32F1/eeprom_flash.cpp index 9c81730465c8..57a2bc5bedb0 100644 --- a/Marlin/src/HAL/STM32F1/eeprom_flash.cpp +++ b/Marlin/src/HAL/STM32F1/eeprom_flash.cpp @@ -39,18 +39,20 @@ #include // Store settings in the last two pages -#define EEPROM_SIZE (EEPROM_PAGE_SIZE * 2) -#define ACCESS_FINISHED(TF) do{ FLASH_Lock(); eeprom_dirty = false; return TF; }while(0) +#ifndef MARLIN_EEPROM_SIZE + #define MARLIN_EEPROM_SIZE ((EEPROM_PAGE_SIZE) * 2) +#endif +size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; } -static uint8_t ram_eeprom[EEPROM_SIZE] __attribute__((aligned(4))) = {0}; +static uint8_t ram_eeprom[MARLIN_EEPROM_SIZE] __attribute__((aligned(4))) = {0}; static bool eeprom_dirty = false; bool PersistentStore::access_start() { const uint32_t* source = reinterpret_cast(EEPROM_PAGE0_BASE); uint32_t* destination = reinterpret_cast(ram_eeprom); - static_assert(0 == EEPROM_SIZE % 4, "EEPROM_SIZE is corrupted. (Must be a multiple of 4.)"); // Ensure copying as uint32_t is safe - constexpr size_t eeprom_size_u32 = EEPROM_SIZE / 4; + static_assert(0 == (MARLIN_EEPROM_SIZE) % 4, "MARLIN_EEPROM_SIZE is corrupted. (Must be a multiple of 4.)"); // Ensure copying as uint32_t is safe + constexpr size_t eeprom_size_u32 = (MARLIN_EEPROM_SIZE) / 4; for (size_t i = 0; i < eeprom_size_u32; ++i, ++destination, ++source) *destination = *source; @@ -72,13 +74,15 @@ bool PersistentStore::access_finish() { // page changes...either way, something to look at later. FLASH_Unlock(); + #define ACCESS_FINISHED(TF) { FLASH_Lock(); eeprom_dirty = false; return TF; } + status = FLASH_ErasePage(EEPROM_PAGE0_BASE); if (status != FLASH_COMPLETE) ACCESS_FINISHED(true); status = FLASH_ErasePage(EEPROM_PAGE1_BASE); if (status != FLASH_COMPLETE) ACCESS_FINISHED(true); const uint16_t *source = reinterpret_cast(ram_eeprom); - for (size_t i = 0; i < EEPROM_SIZE; i += 2, ++source) { + for (size_t i = 0; i < MARLIN_EEPROM_SIZE; i += 2, ++source) { if (FLASH_ProgramHalfWord(EEPROM_PAGE0_BASE + i, *source) != FLASH_COMPLETE) ACCESS_FINISHED(false); } @@ -105,7 +109,5 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, const size_t size, uin return false; // return true for any error } -size_t PersistentStore::capacity() { return EEPROM_SIZE; } - #endif // FLASH_EEPROM_EMULATION #endif // __STM32F1__ diff --git a/Marlin/src/HAL/STM32F1/eeprom_sdcard.cpp b/Marlin/src/HAL/STM32F1/eeprom_sdcard.cpp index bfa9b78dc911..0ca6900fa656 100644 --- a/Marlin/src/HAL/STM32F1/eeprom_sdcard.cpp +++ b/Marlin/src/HAL/STM32F1/eeprom_sdcard.cpp @@ -34,15 +34,15 @@ #include "../shared/eeprom_api.h" #include "../../sd/cardreader.h" -#ifndef E2END - #define E2END 0xFFF // 4KB +#define EEPROM_FILENAME "eeprom.dat" + +#ifndef MARLIN_EEPROM_SIZE + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB #endif -#define HAL_EEPROM_SIZE (E2END + 1) +size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; } #define _ALIGN(x) __attribute__ ((aligned(x))) // SDIO uint32_t* compat. -static char _ALIGN(4) HAL_eeprom_data[HAL_EEPROM_SIZE]; - -#define EEPROM_FILENAME "eeprom.dat" +static char _ALIGN(4) HAL_eeprom_data[MARLIN_EEPROM_SIZE]; bool PersistentStore::access_start() { if (!card.isMounted()) return false; @@ -51,9 +51,9 @@ bool PersistentStore::access_start() { if (!file.open(&root, EEPROM_FILENAME, O_RDONLY)) return true; // false aborts the save - int bytes_read = file.read(HAL_eeprom_data, HAL_EEPROM_SIZE); + int bytes_read = file.read(HAL_eeprom_data, MARLIN_EEPROM_SIZE); if (bytes_read < 0) return false; - for (; bytes_read < HAL_EEPROM_SIZE; bytes_read++) + for (; bytes_read < MARLIN_EEPROM_SIZE; bytes_read++) HAL_eeprom_data[bytes_read] = 0xFF; file.close(); return true; @@ -65,10 +65,10 @@ bool PersistentStore::access_finish() { SdFile file, root = card.getroot(); int bytes_written = 0; if (file.open(&root, EEPROM_FILENAME, O_CREAT | O_WRITE | O_TRUNC)) { - bytes_written = file.write(HAL_eeprom_data, HAL_EEPROM_SIZE); + bytes_written = file.write(HAL_eeprom_data, MARLIN_EEPROM_SIZE); file.close(); } - return (bytes_written == HAL_EEPROM_SIZE); + return (bytes_written == MARLIN_EEPROM_SIZE); } bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { @@ -89,7 +89,5 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, const size_t size, uin return false; } -size_t PersistentStore::capacity() { return HAL_EEPROM_SIZE; } - #endif // SDCARD_EEPROM_EMULATION #endif // __STM32F1__ diff --git a/Marlin/src/HAL/STM32F1/eeprom_wired.cpp b/Marlin/src/HAL/STM32F1/eeprom_wired.cpp index 8d584c67b03a..54540531746b 100644 --- a/Marlin/src/HAL/STM32F1/eeprom_wired.cpp +++ b/Marlin/src/HAL/STM32F1/eeprom_wired.cpp @@ -31,7 +31,12 @@ #include "../shared/eeprom_if.h" #include "../shared/eeprom_api.h" -size_t PersistentStore::capacity() { return E2END + 1; } +#ifndef MARLIN_EEPROM_SIZE + #error "MARLIN_EEPROM_SIZE is required for I2C / SPI EEPROM." +#endif +size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; } + +bool PersistentStore::access_finish() { return true; } bool PersistentStore::access_start() { #if ENABLED(SPI_EEPROM) @@ -45,7 +50,6 @@ bool PersistentStore::access_start() { #endif return true; } -bool PersistentStore::access_finish() { return true; } bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { while (size--) { diff --git a/Marlin/src/HAL/STM32_F4_F7/eeprom_flash.cpp b/Marlin/src/HAL/STM32_F4_F7/eeprom_flash.cpp index 85503a56e594..48c0b770324b 100644 --- a/Marlin/src/HAL/STM32_F4_F7/eeprom_flash.cpp +++ b/Marlin/src/HAL/STM32_F4_F7/eeprom_flash.cpp @@ -52,10 +52,14 @@ uint8_t ee_read_byte(uint8_t *pos) { return uint8_t(data); } -size_t PersistentStore::capacity() { return E2END + 1; } +#ifndef MARLIN_EEPROM_SIZE + #error "MARLIN_EEPROM_SIZE is required for Flash-based EEPROM." +#endif +size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; } + bool PersistentStore::access_finish() { return true; } -bool PersistentStore::access_start() { +bool PersistentStore::access_start() { static bool ee_initialized = false; if (!ee_initialized) { HAL_FLASH_Unlock(); diff --git a/Marlin/src/HAL/STM32_F4_F7/eeprom_wired.cpp b/Marlin/src/HAL/STM32_F4_F7/eeprom_wired.cpp index 08c3c30528e8..b362503a6b1d 100644 --- a/Marlin/src/HAL/STM32_F4_F7/eeprom_wired.cpp +++ b/Marlin/src/HAL/STM32_F4_F7/eeprom_wired.cpp @@ -34,13 +34,13 @@ #include "../shared/eeprom_if.h" #include "../shared/eeprom_api.h" -size_t PersistentStore::capacity() { return E2END + 1; } -bool PersistentStore::access_finish() { return true; } +#ifndef MARLIN_EEPROM_SIZE + #error "MARLIN_EEPROM_SIZE is required for I2C / SPI EEPROM." +#endif +size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; } -bool PersistentStore::access_start() { - eeprom_init(); - return true; -} +bool PersistentStore::access_start() { eeprom_init(); return true; } +bool PersistentStore::access_finish() { return true; } bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { while (size--) { diff --git a/Marlin/src/HAL/TEENSY31_32/eeprom.cpp b/Marlin/src/HAL/TEENSY31_32/eeprom.cpp index 5e3c8bfcfc14..d4ccfe82bbb6 100644 --- a/Marlin/src/HAL/TEENSY31_32/eeprom.cpp +++ b/Marlin/src/HAL/TEENSY31_32/eeprom.cpp @@ -28,8 +28,14 @@ */ #include "../shared/eeprom_api.h" +#include -bool PersistentStore::access_start() { return true; } +#ifndef MARLIN_EEPROM_SIZE + #define MARLIN_EEPROM_SIZE size_t(E2END + 1) +#endif +size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; } + +bool PersistentStore::access_start() { return true; } bool PersistentStore::access_finish() { return true; } bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { diff --git a/Marlin/src/HAL/TEENSY35_36/eeprom.cpp b/Marlin/src/HAL/TEENSY35_36/eeprom.cpp index 992674551172..d7cc8654baea 100644 --- a/Marlin/src/HAL/TEENSY35_36/eeprom.cpp +++ b/Marlin/src/HAL/TEENSY35_36/eeprom.cpp @@ -34,7 +34,11 @@ #include "../shared/eeprom_api.h" #include -size_t PersistentStore::capacity() { return E2END + 1; } +#ifndef MARLIN_EEPROM_SIZE + #define MARLIN_EEPROM_SIZE size_t(E2END + 1) +#endif +size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; } + bool PersistentStore::access_start() { return true; } bool PersistentStore::access_finish() { return true; } diff --git a/Marlin/src/module/configuration_store.cpp b/Marlin/src/module/configuration_store.cpp index 2ebff1f03560..d86016db6d20 100644 --- a/Marlin/src/module/configuration_store.cpp +++ b/Marlin/src/module/configuration_store.cpp @@ -389,7 +389,7 @@ typedef struct SettingsDataStruct { } SettingsData; -//static_assert(sizeof(SettingsData) <= E2END + 1, "EEPROM too small to contain SettingsData!"); +//static_assert(sizeof(SettingsData) <= MARLIN_EEPROM_SIZE, "EEPROM too small to contain SettingsData!"); MarlinSettings settings; diff --git a/Marlin/src/pins/linux/pins_RAMPS_LINUX.h b/Marlin/src/pins/linux/pins_RAMPS_LINUX.h index 27d9bc11ccc9..11699375cf89 100644 --- a/Marlin/src/pins/linux/pins_RAMPS_LINUX.h +++ b/Marlin/src/pins/linux/pins_RAMPS_LINUX.h @@ -49,7 +49,9 @@ #define BOARD_INFO_NAME "RAMPS 1.4" #endif -#define E2END 0xFFF // 4KB +#ifndef MARLIN_EEPROM_SIZE + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB +#endif #define IS_RAMPS_EFB diff --git a/Marlin/src/pins/sam/pins_RADDS.h b/Marlin/src/pins/sam/pins_RADDS.h index 3bc52e9387df..0e67a77578cc 100644 --- a/Marlin/src/pins/sam/pins_RADDS.h +++ b/Marlin/src/pins/sam/pins_RADDS.h @@ -206,7 +206,7 @@ #endif #define I2C_EEPROM -#define E2END 0x1FFF // 8KB +#define MARLIN_EEPROM_SIZE 0x2000 // 8KB // // M3/M4/M5 - Spindle/Laser Control diff --git a/Marlin/src/pins/sam/pins_RAMPS_FD_V2.h b/Marlin/src/pins/sam/pins_RAMPS_FD_V2.h index 6e7d05506930..9dbae7773c84 100644 --- a/Marlin/src/pins/sam/pins_RAMPS_FD_V2.h +++ b/Marlin/src/pins/sam/pins_RAMPS_FD_V2.h @@ -41,7 +41,7 @@ #undef INVERTED_FAN_PINS #define I2C_EEPROM -#define E2END 0xFFFF // 64K in a 24C512 +#define MARLIN_EEPROM_SIZE 0x10000 // 64K in a 24C512 #ifndef PS_ON_PIN #define PS_ON_PIN 12 diff --git a/Marlin/src/pins/sam/pins_RAMPS_SMART.h b/Marlin/src/pins/sam/pins_RAMPS_SMART.h index d82c69b254bd..bcd3f288ee5c 100644 --- a/Marlin/src/pins/sam/pins_RAMPS_SMART.h +++ b/Marlin/src/pins/sam/pins_RAMPS_SMART.h @@ -70,7 +70,7 @@ // I2C EEPROM with 4K of space #define I2C_EEPROM -#define E2END 0xFFF +#define MARLIN_EEPROM_SIZE 0x1000 #define RESET_PIN 42 // Resets the board if the jumper is attached diff --git a/Marlin/src/pins/sam/pins_RURAMPS4D_11.h b/Marlin/src/pins/sam/pins_RURAMPS4D_11.h index 7b844b5be0b5..71596087de83 100644 --- a/Marlin/src/pins/sam/pins_RURAMPS4D_11.h +++ b/Marlin/src/pins/sam/pins_RURAMPS4D_11.h @@ -186,7 +186,7 @@ // // EEPROM // -#define E2END 0x7FFF // 32Kb (24lc256) +#define MARLIN_EEPROM_SIZE 0x8000 // 32Kb (24lc256) #define I2C_EEPROM // EEPROM on I2C-0 //#define EEPROM_SD // EEPROM on SDCARD //#define SPI_EEPROM // EEPROM on SPI-0 diff --git a/Marlin/src/pins/sam/pins_RURAMPS4D_13.h b/Marlin/src/pins/sam/pins_RURAMPS4D_13.h index 0d06b149362e..434223a2a45d 100644 --- a/Marlin/src/pins/sam/pins_RURAMPS4D_13.h +++ b/Marlin/src/pins/sam/pins_RURAMPS4D_13.h @@ -172,7 +172,7 @@ // // EEPROM // -#define E2END 0x7FFF // 32Kb (24lc256) +#define MARLIN_EEPROM_SIZE 0x8000 // 32Kb (24lc256) #define I2C_EEPROM // EEPROM on I2C-0 //#define EEPROM_SD // EEPROM on SDCARD //#define SPI_EEPROM // EEPROM on SPI-0 diff --git a/Marlin/src/pins/samd/pins_RAMPS_144.h b/Marlin/src/pins/samd/pins_RAMPS_144.h index 54363713e7b2..566a72655942 100644 --- a/Marlin/src/pins/samd/pins_RAMPS_144.h +++ b/Marlin/src/pins/samd/pins_RAMPS_144.h @@ -46,7 +46,7 @@ // //#define QSPI_EEPROM // Use AGCM4 onboard QSPI EEPROM (Uses 4K of RAM) #define I2C_EEPROM // EEPROM on I2C-0 -#define E2END 0x7FFF // 32K (24lc256) +#define MARLIN_EEPROM_SIZE 0x8000 // 32K (24lc256) // // Limit Switches diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h index 7dbd62accf5b..01dd6a7e9fe6 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h @@ -37,8 +37,7 @@ #define FLASH_EEPROM_EMULATION #define EEPROM_PAGE_SIZE (0x800U) // 2KB #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) - #undef E2END - #define E2END (EEPROM_PAGE_SIZE - 1) // 2KB + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2KB #endif // @@ -172,7 +171,6 @@ * EXP1 */ - #if HAS_SPI_LCD #if ENABLED(CR10_STOCKDISPLAY) @@ -276,7 +274,7 @@ // #ifndef SDCARD_CONNECTION - #define SDCARD_CONNECTION ONBOARD + #define SDCARD_CONNECTION ONBOARD #endif #if SD_CONNECTION_IS(ONBOARD) diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3.h index 30963b98798f..4a435d674027 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3.h @@ -35,8 +35,7 @@ #define FLASH_EEPROM_EMULATION #define EEPROM_PAGE_SIZE (0x800U) // 2KB #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) - #undef E2END - #define E2END (EEPROM_PAGE_SIZE - 1) // 2KB + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2KB #endif // diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h index 6d42b8395795..cd0ff58a29b6 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h @@ -37,7 +37,7 @@ #define FLASH_EEPROM_EMULATION #define EEPROM_PAGE_SIZE (0x800U) // 2KB #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) - #define E2END (EEPROM_PAGE_SIZE - 1) + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2KB #endif // diff --git a/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h b/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h index b40306e22d8f..187aec763634 100644 --- a/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h +++ b/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h @@ -42,8 +42,7 @@ #define FLASH_EEPROM_EMULATION #define EEPROM_PAGE_SIZE (0x800U) // 2KB #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) - #undef E2END - #define E2END (EEPROM_PAGE_SIZE - 1) // 2KB + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2KB #endif // diff --git a/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h b/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h index 52444008bee3..e45059eab767 100644 --- a/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h +++ b/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h @@ -40,8 +40,7 @@ #define FLASH_EEPROM_EMULATION #define EEPROM_PAGE_SIZE (0x800U) // 2KB #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) - #undef E2END - #define E2END (EEPROM_PAGE_SIZE - 1) // 2KB + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2KB #endif // diff --git a/Marlin/src/pins/stm32f1/pins_GTM32_MINI.h b/Marlin/src/pins/stm32f1/pins_GTM32_MINI.h index 908a1003416e..e7e71977c068 100644 --- a/Marlin/src/pins/stm32f1/pins_GTM32_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_GTM32_MINI.h @@ -54,7 +54,7 @@ // Enable EEPROM Emulation for this board as it doesn't have EEPROM #if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) #define FLASH_EEPROM_EMULATION - #define E2END 0xFFF // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB #endif // diff --git a/Marlin/src/pins/stm32f1/pins_GTM32_MINI_A30.h b/Marlin/src/pins/stm32f1/pins_GTM32_MINI_A30.h index ca1c2894cb8f..947bbe55cbcb 100644 --- a/Marlin/src/pins/stm32f1/pins_GTM32_MINI_A30.h +++ b/Marlin/src/pins/stm32f1/pins_GTM32_MINI_A30.h @@ -54,7 +54,7 @@ // Enable EEPROM Emulation for this board as it doesn't have EEPROM #if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) #define FLASH_EEPROM_EMULATION - #define E2END 0xFFF // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB #endif // diff --git a/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h b/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h index 908a1003416e..e7e71977c068 100644 --- a/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h +++ b/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h @@ -54,7 +54,7 @@ // Enable EEPROM Emulation for this board as it doesn't have EEPROM #if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) #define FLASH_EEPROM_EMULATION - #define E2END 0xFFF // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB #endif // diff --git a/Marlin/src/pins/stm32f1/pins_GTM32_REV_B.h b/Marlin/src/pins/stm32f1/pins_GTM32_REV_B.h index 5dbffd2897e5..ad140ce92751 100644 --- a/Marlin/src/pins/stm32f1/pins_GTM32_REV_B.h +++ b/Marlin/src/pins/stm32f1/pins_GTM32_REV_B.h @@ -54,7 +54,7 @@ // Enable EEPROM Emulation for this board as it doesn't have EEPROM #if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) #define FLASH_EEPROM_EMULATION - #define E2END 0xFFF // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB #endif // diff --git a/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h b/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h index 340e4053029d..9ec0f267343f 100644 --- a/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h +++ b/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h @@ -43,11 +43,11 @@ // Enable EEPROM Emulation for this board, so that we don't overwrite factory data //#define I2C_EEPROM // AT24C64 -//#define E2END 0x7FFFUL // 64KB +//#define MARLIN_EEPROM_SIZE 0x8000UL // 64KB //#define FLASH_EEPROM_EMULATION -//#define E2END 0xFFFUL // 4KB -//#define E2END (EEPROM_START_ADDRESS + (EEPROM_PAGE_SIZE) * 2UL - 1UL) +//#define MARLIN_EEPROM_SIZE 0x1000UL // 4KB +//#define MARLIN_EEPROM_SIZE (EEPROM_START_ADDRESS + (EEPROM_PAGE_SIZE) * 2UL) //#define EEPROM_CHITCHAT //#define DEBUG_EEPROM_READWRITE diff --git a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h index 8f5619aa690a..aea7cedce718 100644 --- a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h +++ b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h @@ -152,7 +152,6 @@ #define FLASH_EEPROM_EMULATION #endif -#undef E2END #if ENABLED(SPI_EEPROM) // SPI1 EEPROM Winbond W25Q64 (8MB/64Mbits) #define SPI_CHAN_EEPROM1 1 @@ -161,12 +160,12 @@ #define EEPROM_MISO BOARD_SPI1_MISO_PIN // PA6 pin 31 #define EEPROM_MOSI BOARD_SPI1_MOSI_PIN // PA7 pin 32 #define EEPROM_PAGE_SIZE 0x1000U // 4KB (from datasheet) - #define E2END (16UL * (EEPROM_PAGE_SIZE) - 1UL) // Limit to 64KB for now... + #define MARLIN_EEPROM_SIZE 16UL * (EEPROM_PAGE_SIZE) // Limit to 64KB for now... #elif ENABLED(FLASH_EEPROM_EMULATION) // SoC Flash (framework-arduinoststm32-maple/STM32F1/libraries/EEPROM/EEPROM.h) #define EEPROM_PAGE_SIZE (0x800U) // 2KB #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) - #define E2END (EEPROM_PAGE_SIZE - 1) + #define MARLIN_EEPROM_SIZE (EEPROM_PAGE_SIZE) #else - #define E2END (0x7FFU) // On SD, Limit to 2KB, require this amount of RAM + #define MARLIN_EEPROM_SIZE 0x800U // On SD, Limit to 2KB, require this amount of RAM #endif diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h index 6f3897814d83..c352acc17c9b 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h @@ -43,7 +43,7 @@ // 2K in a AT24C16N #define EEPROM_PAGE_SIZE (0x800U) // 2KB #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) - #define E2END (EEPROM_PAGE_SIZE - 1) + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2KB #endif // diff --git a/Marlin/src/pins/stm32f4/pins_ARMED.h b/Marlin/src/pins/stm32f4/pins_ARMED.h index ddbe09c355fd..d98c79363954 100644 --- a/Marlin/src/pins/stm32f4/pins_ARMED.h +++ b/Marlin/src/pins/stm32f4/pins_ARMED.h @@ -39,9 +39,7 @@ #define DEFAULT_MACHINE_NAME BOARD_INFO_NAME #define I2C_EEPROM - -#undef E2END // Defined in Arduino Core STM32 to be used with EEPROM emulation. This board uses a real EEPROM. -#define E2END 0xFFF // 4KB +#define MARLIN_EEPROM_SIZE 0x1000 // 4KB // // Limit Switches diff --git a/Marlin/src/pins/stm32f4/pins_BLACK_STM32F407VE.h b/Marlin/src/pins/stm32f4/pins_BLACK_STM32F407VE.h index 1a6bd80ae600..91903b5883db 100644 --- a/Marlin/src/pins/stm32f4/pins_BLACK_STM32F407VE.h +++ b/Marlin/src/pins/stm32f4/pins_BLACK_STM32F407VE.h @@ -40,8 +40,8 @@ #define DEFAULT_MACHINE_NAME "STM32F407VET6" //#define I2C_EEPROM -//#define E2END 0x1FFF // 8KB #define SRAM_EEPROM_EMULATION +#define MARLIN_EEPROM_SIZE 0x2000 // 8KB // // Servos diff --git a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h index 47fcb97be542..43c4d4279f86 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h @@ -33,8 +33,7 @@ // Onboard I2C EEPROM #define I2C_EEPROM -#undef E2END -#define E2END 0x1FFF // EEPROM end address 24C64 (64Kb = 8KB) +#define MARLIN_EEPROM_SIZE 0x2000 // 8KB (24C64 ... 64Kb = 8KB) #define TP // Enable to define servo and probe pins diff --git a/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h b/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h index 3681fde8d185..2c8f0a95bc7b 100644 --- a/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h +++ b/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h @@ -31,8 +31,7 @@ #define BOARD_WEBSITE_URL "github.com/FLYmaker/FLYF407ZG" #define DEFAULT_MACHINE_NAME BOARD_INFO_NAME -#undef E2END -#define E2END 0xFFF // 4KB +#define MARLIN_EEPROM_SIZE 0x1000 // 4KB // // Servos diff --git a/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h b/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h index 18a91d3ea02c..989521322922 100644 --- a/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h +++ b/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h @@ -51,8 +51,7 @@ // 128 kB sector allocated for EEPROM emulation. #define FLASH_EEPROM_LEVELING #elif ENABLED(I2C_EEPROM) - #undef E2END // Defined in Arduino Core STM32 to be used with EEPROM emulation. This board uses a real EEPROM. - #define E2END 0xFFF // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB #endif // diff --git a/Marlin/src/pins/stm32f4/pins_GENERIC_STM32F4.h b/Marlin/src/pins/stm32f4/pins_GENERIC_STM32F4.h index 5df7ffe4668b..0d9356ce52cb 100644 --- a/Marlin/src/pins/stm32f4/pins_GENERIC_STM32F4.h +++ b/Marlin/src/pins/stm32f4/pins_GENERIC_STM32F4.h @@ -36,8 +36,8 @@ //#define I2C_EEPROM -#ifndef E2END - #define E2END 0xFFF // 4KB +#ifndef MARLIN_EEPROM_SIZE + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB #endif // Ignore temp readings during development. diff --git a/Marlin/src/pins/stm32f4/pins_RUMBA32_common.h b/Marlin/src/pins/stm32f4/pins_RUMBA32_common.h index 19853a78fea2..d13733222812 100644 --- a/Marlin/src/pins/stm32f4/pins_RUMBA32_common.h +++ b/Marlin/src/pins/stm32f4/pins_RUMBA32_common.h @@ -35,10 +35,7 @@ #define DEFAULT_MACHINE_NAME BOARD_INFO_NAME //#define I2C_EEPROM -#ifdef E2END - #undef E2END -#endif -#define E2END 0xFFF // 4KB +#define MARLIN_EEPROM_SIZE 0x1000 // 4KB // // Limit Switches diff --git a/Marlin/src/pins/stm32f4/pins_VAKE403D.h b/Marlin/src/pins/stm32f4/pins_VAKE403D.h index 08f8adebc4f1..ccfc76146c26 100644 --- a/Marlin/src/pins/stm32f4/pins_VAKE403D.h +++ b/Marlin/src/pins/stm32f4/pins_VAKE403D.h @@ -31,8 +31,7 @@ #define BOARD_INFO_NAME "STM32F4 VAkE" //#define I2C_EEPROM - -#define E2END 0xFFF // EEPROM end address (4kB) +#define MARLIN_EEPROM_SIZE 0x1000 // 4KB // // Servos diff --git a/Marlin/src/pins/stm32f7/pins_THE_BORG.h b/Marlin/src/pins/stm32f7/pins_THE_BORG.h index c937c5397255..ffb6638213ba 100644 --- a/Marlin/src/pins/stm32f7/pins_THE_BORG.h +++ b/Marlin/src/pins/stm32f7/pins_THE_BORG.h @@ -30,8 +30,8 @@ #define BOARD_INFO_NAME "The-Borge" #define DEFAULT_MACHINE_NAME BOARD_INFO_NAME -#ifndef E2END - #define E2END 0xFFF // EEPROM end address +#ifndef MARLIN_EEPROM_SIZE + #define MARLIN_EEPROM_SIZE 0x1000 #endif // Ignore temp readings during development.