From b4af335b7ab1bedd011335ea06bfb1d1c2928c03 Mon Sep 17 00:00:00 2001
From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com>
Date: Fri, 19 Aug 2022 11:11:15 -0700
Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Remove=20STM32F4=20Print=20Count?=
 =?UTF-8?q?er=20Sanity=20Check=20(#24605)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 Marlin/Configuration.h                       | 2 +-
 Marlin/src/HAL/STM32/inc/Conditionals_post.h | 5 +++++
 Marlin/src/HAL/STM32/inc/SanityCheck.h       | 5 -----
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h
index 683b61298b8..b30ba9b8d3f 100644
--- a/Marlin/Configuration.h
+++ b/Marlin/Configuration.h
@@ -2362,7 +2362,7 @@
  */
 //#define PRINTCOUNTER
 #if ENABLED(PRINTCOUNTER)
-  #define PRINTCOUNTER_SAVE_INTERVAL 60 // (minutes) EEPROM save interval during print
+  #define PRINTCOUNTER_SAVE_INTERVAL 60 // (minutes) EEPROM save interval during print. A value of 0 will save stats at end of print.
 #endif
 
 // @section security
diff --git a/Marlin/src/HAL/STM32/inc/Conditionals_post.h b/Marlin/src/HAL/STM32/inc/Conditionals_post.h
index 18826e11d24..5ac47661829 100644
--- a/Marlin/src/HAL/STM32/inc/Conditionals_post.h
+++ b/Marlin/src/HAL/STM32/inc/Conditionals_post.h
@@ -27,3 +27,8 @@
 #elif EITHER(I2C_EEPROM, SPI_EEPROM)
   #define USE_SHARED_EEPROM 1
 #endif
+
+// Some STM32F4 boards may lose steps when saving to EEPROM during print (PR #17946)
+#if defined(STM32F4xx) && PRINTCOUNTER_SAVE_INTERVAL > 0
+  #define PRINTCOUNTER_SYNC 1
+#endif
diff --git a/Marlin/src/HAL/STM32/inc/SanityCheck.h b/Marlin/src/HAL/STM32/inc/SanityCheck.h
index 0f1a2acaa41..a440695a06f 100644
--- a/Marlin/src/HAL/STM32/inc/SanityCheck.h
+++ b/Marlin/src/HAL/STM32/inc/SanityCheck.h
@@ -37,11 +37,6 @@
   #error "SDCARD_EEPROM_EMULATION requires SDSUPPORT. Enable SDSUPPORT or choose another EEPROM emulation."
 #endif
 
-#if defined(STM32F4xx) && BOTH(PRINTCOUNTER, FLASH_EEPROM_EMULATION)
-  #warning "FLASH_EEPROM_EMULATION may cause long delays when writing and should not be used while printing."
-  #error "Disable PRINTCOUNTER or choose another EEPROM emulation."
-#endif
-
 #if !defined(STM32F4xx) && ENABLED(FLASH_EEPROM_LEVELING)
   #error "FLASH_EEPROM_LEVELING is currently only supported on STM32F4 hardware."
 #endif