diff --git a/Marlin/src/HAL/HAL_STM32/HAL.cpp b/Marlin/src/HAL/HAL_STM32/HAL.cpp
index 1bddf77f4..8a5e76eb3 100644
--- a/Marlin/src/HAL/HAL_STM32/HAL.cpp
+++ b/Marlin/src/HAL/HAL_STM32/HAL.cpp
@@ -21,7 +21,8 @@
*
*/
-#ifdef ARDUINO_ARCH_STM32
+#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
+
// --------------------------------------------------------------------------
// Includes
diff --git a/Marlin/src/HAL/HAL_STM32/HAL_Servo_STM32.cpp b/Marlin/src/HAL/HAL_STM32/HAL_Servo_STM32.cpp
index 2b08ab314..bc6f154e8 100644
--- a/Marlin/src/HAL/HAL_STM32/HAL_Servo_STM32.cpp
+++ b/Marlin/src/HAL/HAL_STM32/HAL_Servo_STM32.cpp
@@ -20,7 +20,8 @@
* along with this program. If not, see .
*
*/
-#ifdef ARDUINO_ARCH_STM32
+#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
+
#include "../../inc/MarlinConfig.h"
diff --git a/Marlin/src/HAL/HAL_STM32/HAL_spi_STM32.cpp b/Marlin/src/HAL/HAL_STM32/HAL_spi_STM32.cpp
index 597305fa0..a11b1585f 100644
--- a/Marlin/src/HAL/HAL_STM32/HAL_spi_STM32.cpp
+++ b/Marlin/src/HAL/HAL_STM32/HAL_spi_STM32.cpp
@@ -20,7 +20,8 @@
* along with this program. If not, see .
*
*/
-#ifdef ARDUINO_ARCH_STM32
+#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
+
// --------------------------------------------------------------------------
// Includes
diff --git a/Marlin/src/HAL/HAL_STM32/HAL_timers_STM32.cpp b/Marlin/src/HAL/HAL_STM32/HAL_timers_STM32.cpp
index 23a1e3bf1..cebec33dc 100644
--- a/Marlin/src/HAL/HAL_STM32/HAL_timers_STM32.cpp
+++ b/Marlin/src/HAL/HAL_STM32/HAL_timers_STM32.cpp
@@ -19,7 +19,8 @@
* along with this program. If not, see .
*
*/
-#ifdef ARDUINO_ARCH_STM32
+#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
+
// --------------------------------------------------------------------------
// Includes
diff --git a/Marlin/src/HAL/HAL_STM32/fastio_STM32.cpp b/Marlin/src/HAL/HAL_STM32/fastio_STM32.cpp
index e1824ed18..ae429c892 100644
--- a/Marlin/src/HAL/HAL_STM32/fastio_STM32.cpp
+++ b/Marlin/src/HAL/HAL_STM32/fastio_STM32.cpp
@@ -20,7 +20,7 @@
* along with this program. If not, see .
*
*/
-#ifdef ARDUINO_ARCH_STM32
+#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
#include "../../inc/MarlinConfig.h"
diff --git a/Marlin/src/HAL/HAL_STM32/persistent_store_impl.cpp b/Marlin/src/HAL/HAL_STM32/persistent_store_impl.cpp
index 5fc87cc24..a4c9850c7 100644
--- a/Marlin/src/HAL/HAL_STM32/persistent_store_impl.cpp
+++ b/Marlin/src/HAL/HAL_STM32/persistent_store_impl.cpp
@@ -20,7 +20,7 @@
* along with this program. If not, see .
*
*/
-#ifdef ARDUINO_ARCH_STM32
+#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
#include "../../inc/MarlinConfig.h"
diff --git a/Marlin/src/HAL/HAL_STM32/watchdog_STM32.cpp b/Marlin/src/HAL/HAL_STM32/watchdog_STM32.cpp
index 7b049f155..304e0c47f 100644
--- a/Marlin/src/HAL/HAL_STM32/watchdog_STM32.cpp
+++ b/Marlin/src/HAL/HAL_STM32/watchdog_STM32.cpp
@@ -20,7 +20,7 @@
*
*/
-#ifdef ARDUINO_ARCH_STM32
+#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
#include "../../inc/MarlinConfig.h"
diff --git a/Marlin/src/HAL/HAL_STM32F4/EEPROM_Emul/eeprom_emul.cpp b/Marlin/src/HAL/HAL_STM32F4/EEPROM_Emul/eeprom_emul.cpp
index c13d42818..8bae46777 100644
--- a/Marlin/src/HAL/HAL_STM32F4/EEPROM_Emul/eeprom_emul.cpp
+++ b/Marlin/src/HAL/HAL_STM32F4/EEPROM_Emul/eeprom_emul.cpp
@@ -47,7 +47,7 @@
/** @addtogroup EEPROM_Emulation
* @{
*/
-#if defined(STM32GENERIC) && (defined(STM32F4) || defined(STM32F4xx))
+#if defined(STM32GENERIC) && (defined(STM32F4))
/* Includes ------------------------------------------------------------------*/
#include "eeprom_emul.h"
diff --git a/Marlin/src/HAL/HAL_STM32F4/EmulatedEeprom.cpp b/Marlin/src/HAL/HAL_STM32F4/EmulatedEeprom.cpp
index 7d45ef18d..dfb005dc2 100644
--- a/Marlin/src/HAL/HAL_STM32F4/EmulatedEeprom.cpp
+++ b/Marlin/src/HAL/HAL_STM32F4/EmulatedEeprom.cpp
@@ -17,7 +17,7 @@
*
*/
-#if defined(STM32GENERIC) && (defined(STM32F4) || defined(STM32F4xx))
+#if defined(STM32GENERIC) && (defined(STM32F4))
/**
* Description: functions for I2C connected external EEPROM.
@@ -139,4 +139,4 @@ void eeprom_update_block(const void *__src, void *__dst, size_t __n) {
}
#endif // ENABLED(EEPROM_SETTINGS) && DISABLED(I2C_EEPROM) && DISABLED(SPI_EEPROM)
-#endif // STM32F4 || STM32F4xx
+#endif // STM32GENERIC && STM32F4
diff --git a/Marlin/src/HAL/HAL_STM32F4/HAL.cpp b/Marlin/src/HAL/HAL_STM32F4/HAL.cpp
index 56823ccc8..8b107f391 100644
--- a/Marlin/src/HAL/HAL_STM32F4/HAL.cpp
+++ b/Marlin/src/HAL/HAL_STM32F4/HAL.cpp
@@ -21,7 +21,7 @@
*
*/
-#if defined(STM32GENERIC) && (defined(STM32F4) || defined(STM32F4xx))
+#if defined(STM32GENERIC) && defined(STM32F4)
// --------------------------------------------------------------------------
// Includes
@@ -130,4 +130,4 @@ uint16_t HAL_adc_get_result(void) {
return HAL_adc_result;
}
-#endif // STM32F4 || STM32F4xx
+#endif // // STM32GENERIC && STM32F4
diff --git a/Marlin/src/HAL/HAL_STM32F4/HAL_Servo_STM32F4.cpp b/Marlin/src/HAL/HAL_STM32F4/HAL_Servo_STM32F4.cpp
index 9d9c722e5..8c7adeecb 100644
--- a/Marlin/src/HAL/HAL_STM32F4/HAL_Servo_STM32F4.cpp
+++ b/Marlin/src/HAL/HAL_STM32F4/HAL_Servo_STM32F4.cpp
@@ -21,7 +21,7 @@
*
*/
-#if defined(STM32GENERIC) && (defined(STM32F4) || defined(STM32F4xx))
+#if defined(STM32GENERIC) && defined(STM32F4)
#include "../../inc/MarlinConfig.h"
@@ -50,4 +50,4 @@ void libServo::move(const int value) {
}
#endif // HAS_SERVOS
-#endif // STM32F4 || STM32F4xx
+#endif // STM32GENERIC && STM32F4
diff --git a/Marlin/src/HAL/HAL_STM32F4/HAL_spi_STM32F4.cpp b/Marlin/src/HAL/HAL_STM32F4/HAL_spi_STM32F4.cpp
index 34582c30a..a7e840fb0 100644
--- a/Marlin/src/HAL/HAL_STM32F4/HAL_spi_STM32F4.cpp
+++ b/Marlin/src/HAL/HAL_STM32F4/HAL_spi_STM32F4.cpp
@@ -30,7 +30,7 @@
* Adapted to the STM32F4 HAL
*/
-#if defined(STM32GENERIC) && (defined(STM32F4) || defined(STM32F4xx))
+#if defined(STM32GENERIC) && defined(STM32F4)
// --------------------------------------------------------------------------
// Includes
@@ -173,4 +173,4 @@ void spiSendBlock(uint8_t token, const uint8_t* buf) {
#endif // SOFTWARE_SPI
-#endif // STM32F4 || STM32F4xx
+#endif // STM32GENERIC && STM32F4
diff --git a/Marlin/src/HAL/HAL_STM32F4/HAL_timers_STM32F4.cpp b/Marlin/src/HAL/HAL_STM32F4/HAL_timers_STM32F4.cpp
index 6a23090a2..acf58858a 100644
--- a/Marlin/src/HAL/HAL_STM32F4/HAL_timers_STM32F4.cpp
+++ b/Marlin/src/HAL/HAL_STM32F4/HAL_timers_STM32F4.cpp
@@ -20,7 +20,7 @@
*
*/
-#if defined(STM32GENERIC) && (defined(STM32F4) || defined(STM32F4xx))
+#if defined(STM32GENERIC) && defined(STM32F4)
// --------------------------------------------------------------------------
// Includes
@@ -156,4 +156,4 @@ bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
return false;
}
-#endif // STM32F4 || STM32F4xx
+#endif // STM32GENERIC && STM32F4
diff --git a/Marlin/src/HAL/HAL_STM32F4/persistent_store_eeprom.cpp b/Marlin/src/HAL/HAL_STM32F4/persistent_store_eeprom.cpp
index ef7038971..48b6492c1 100644
--- a/Marlin/src/HAL/HAL_STM32F4/persistent_store_eeprom.cpp
+++ b/Marlin/src/HAL/HAL_STM32F4/persistent_store_eeprom.cpp
@@ -21,7 +21,7 @@
*
*/
-#if defined(STM32GENERIC) && (defined(STM32F4) || defined(STM32F4xx))
+#if defined(STM32GENERIC) && defined(STM32F4)
#include "../shared/persistent_store_api.h"
@@ -66,4 +66,4 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t
size_t PersistentStore::capacity() { return E2END + 1; }
#endif // EEPROM_SETTINGS
-#endif // STM32F4 || STM32F4xx
+#endif // STM32GENERIC && STM32F4
diff --git a/Marlin/src/HAL/HAL_STM32F4/watchdog_STM32F4.cpp b/Marlin/src/HAL/HAL_STM32F4/watchdog_STM32F4.cpp
index dd4d4391c..41c75e411 100644
--- a/Marlin/src/HAL/HAL_STM32F4/watchdog_STM32F4.cpp
+++ b/Marlin/src/HAL/HAL_STM32F4/watchdog_STM32F4.cpp
@@ -20,7 +20,7 @@
*
*/
-#if defined(STM32GENERIC) && (defined(STM32F4) || defined(STM32F4xx))
+#if defined(STM32GENERIC) && defined(STM32F4)
#include "../../inc/MarlinConfig.h"
@@ -54,4 +54,4 @@
#endif // USE_WATCHDOG
-#endif // STM32F4 || STM32F4xx
+#endif // STM32GENERIC && STM32F4