From 5fefecc5268f596ded2154ae323249c003e5d934 Mon Sep 17 00:00:00 2001
From: Jason Smith <jason.inet@gmail.com>
Date: Mon, 25 May 2020 16:24:16 -0700
Subject: [PATCH] Use 'extends' for STM32F1, fix lib versions (#18099)

---
 platformio.ini | 297 ++++++++++++++++++-------------------------------
 1 file changed, 110 insertions(+), 187 deletions(-)

diff --git a/platformio.ini b/platformio.ini
index 9d7da43fba0..350095e37fc 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -27,15 +27,35 @@ extra_scripts = pre:buildroot/share/PlatformIO/scripts/common-cxxflags.py
 build_flags = -fmax-errors=5 -g -D__MARLIN_FIRMWARE__ -fmerge-all-constants
 lib_deps =
   LiquidCrystal
-  TMCStepper@>=0.6.2,<1.0.0
+  TMCStepper@>=0.6.2
+  Adafruit MAX31865 library
   Adafruit NeoPixel
   U8glib-HAL=https://github.com/MarlinFirmware/U8glib-HAL/archive/bugfix.zip
-  Adafruit_MAX31865=https://github.com/adafruit/Adafruit_MAX31865/archive/master.zip
   LiquidTWI2=https://github.com/lincomatic/LiquidTWI2/archive/master.zip
   Arduino-L6470=https://github.com/ameyer/Arduino-L6470/archive/0.8.0.zip
   SailfishLCD=https://github.com/mikeshub/SailfishLCD/archive/master.zip
   SlowSoftI2CMaster=https://github.com/mikeshub/SlowSoftI2CMaster/archive/master.zip
 
+[common_stm32f1]
+platform      = ststm32
+build_flags   = !python Marlin/src/HAL/STM32F1/build_flags.py
+  ${common.build_flags} -std=gnu++14 -DHAVE_SW_SERIAL
+build_unflags = -std=gnu++11
+src_filter    = ${common.default_src_filter} +<src/HAL/STM32F1>
+lib_ignore    =
+  Adafruit NeoPixel
+  SPI
+lib_deps      =
+  LiquidCrystal
+  TMCStepper@>=0.6.2
+  U8glib-HAL=https://github.com/MarlinFirmware/U8glib-HAL/archive/bugfix.zip
+  Adafruit MAX31865 library@>=1.1,<1.2
+  LiquidTWI2=https://github.com/lincomatic/LiquidTWI2/archive/master.zip
+  Arduino-L6470=https://github.com/ameyer/Arduino-L6470/archive/0.8.0.zip
+  SailfishLCD=https://github.com/mikeshub/SailfishLCD/archive/master.zip
+  SlowSoftI2CMaster=https://github.com/mikeshub/SlowSoftI2CMaster/archive/master.zip
+  SoftwareSerialM=https://github.com/FYSETC/SoftwareSerialM/archive/master.zip
+
 # Globally defined properties
 # inherited by all environments
 [env]
@@ -296,34 +316,20 @@ lib_deps          = Servo
 # STM32F103RC
 #
 [env:STM32F103RC]
-platform          = ststm32
+platform          = ${common_stm32f1.platform}
+extends           = common_stm32f1
 board             = genericSTM32F103RC
 platform_packages = tool-stm32duino
-build_flags       = !python Marlin/src/HAL/STM32F1/build_flags.py
-  ${common.build_flags} -std=gnu++14
-build_unflags     = -std=gnu++11
-src_filter        = ${common.default_src_filter} +<src/HAL/STM32F1>
-lib_deps          = ${common.lib_deps}
-  SoftwareSerialM=https://github.com/FYSETC/SoftwareSerialM/archive/master.zip
-lib_ignore        = Adafruit NeoPixel, SPI
 monitor_speed     = 115200
 
 #
 # STM32F103RC_fysetc
 #
 [env:STM32F103RC_fysetc]
-platform          = ststm32
-board             = genericSTM32F103RC
-#board_build.core = maple
-platform_packages = tool-stm32duino
-build_flags       = !python Marlin/src/HAL/STM32F1/build_flags.py
-  ${common.build_flags} -std=gnu++14 -DDEBUG_LEVEL=0 -DHAVE_SW_SERIAL
-build_unflags     = -std=gnu++11
+platform          = ${common_stm32f1.platform}
+extends           = env:STM32F103RC
 extra_scripts     = buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py
-src_filter        = ${common.default_src_filter} +<src/HAL/STM32F1>
-lib_deps          = ${common.lib_deps}
-  SoftwareSerialM=https://github.com/FYSETC/SoftwareSerialM/archive/master.zip
-lib_ignore        = Adafruit NeoPixel, SPI
+build_flags       = ${common_stm32f1.build_flags} -DDEBUG_LEVEL=0
 lib_ldf_mode      = chain
 debug_tool        = stlink
 upload_protocol   = serial
@@ -338,79 +344,41 @@ upload_protocol   = serial
 #
 
 [env:STM32F103RC_btt]
-platform          = ststm32
-board             = genericSTM32F103RC
-platform_packages = tool-stm32duino
-build_flags       = !python Marlin/src/HAL/STM32F1/build_flags.py
-  ${common.build_flags} -DDEBUG_LEVEL=0 -std=gnu++14 -DHAVE_SW_SERIAL -DSS_TIMER=4
-build_unflags     = -std=gnu++11
+platform          = ${common_stm32f1.platform}
+extends           = env:STM32F103RC
 extra_scripts     = buildroot/share/PlatformIO/scripts/STM32F103RC_SKR_MINI.py
-src_filter        = ${common.default_src_filter} +<src/HAL/STM32F1>
-lib_deps          = ${common.lib_deps}
-  SoftwareSerialM=https://github.com/FYSETC/SoftwareSerialM/archive/master.zip
-lib_ignore        = Adafruit NeoPixel, SPI
+build_flags       = ${common_stm32f1.build_flags}
+  -DDEBUG_LEVEL=0 -DSS_TIMER=4
 monitor_speed     = 115200
 
 [env:STM32F103RC_btt_USB]
-platform          = ststm32
-board             = genericSTM32F103RC
-platform_packages = tool-stm32duino
-build_flags       = !python Marlin/src/HAL/STM32F1/build_flags.py
-  ${common.build_flags} -DDEBUG_LEVEL=0 -std=gnu++14 -DHAVE_SW_SERIAL -DSS_TIMER=4 -DUSE_USB_COMPOSITE
-build_unflags     = -std=gnu++11
-extra_scripts     = buildroot/share/PlatformIO/scripts/STM32F103RC_SKR_MINI.py
-src_filter        = ${common.default_src_filter} +<src/HAL/STM32F1>
-lib_deps          = ${common.lib_deps}
-  SoftwareSerialM=https://github.com/FYSETC/SoftwareSerialM/archive/master.zip
+platform          = ${common_stm32f1.platform}
+extends           = env:STM32F103RC_btt
+build_flags       = ${env:STM32F103RC_btt.build_flags} -DUSE_USB_COMPOSITE
+lib_deps          = ${env:STM32F103RC_btt.lib_deps}
   USBComposite for STM32F1@==0.91
-lib_ignore        = Adafruit NeoPixel, SPI
-monitor_speed     = 115200
 
 [env:STM32F103RC_btt_512K]
-platform          = ststm32
-board             = genericSTM32F103RC
+platform          = ${common_stm32f1.platform}
+extends           = env:STM32F103RC_btt
 board_upload.maximum_size=524288
-platform_packages = tool-stm32duino
-build_flags       = !python Marlin/src/HAL/STM32F1/build_flags.py
-  ${common.build_flags} -DDEBUG_LEVEL=0 -std=gnu++14 -DHAVE_SW_SERIAL -DSS_TIMER=4 -DSTM32_FLASH_SIZE=512
-build_unflags     = -std=gnu++11
-extra_scripts     = buildroot/share/PlatformIO/scripts/STM32F103RC_SKR_MINI.py
-src_filter        = ${common.default_src_filter} +<src/HAL/STM32F1>
-lib_deps          = ${common.lib_deps}
-  SoftwareSerialM=https://github.com/FYSETC/SoftwareSerialM/archive/master.zip
-lib_ignore        = Adafruit NeoPixel, SPI
-monitor_speed     = 115200
+build_flags       = ${env:STM32F103RC_btt.build_flags} -DSTM32_FLASH_SIZE=512
 
 [env:STM32F103RC_btt_512K_USB]
-platform          = ststm32
-board             = genericSTM32F103RC
-board_upload.maximum_size=524288
-platform_packages = tool-stm32duino
-build_flags       = !python Marlin/src/HAL/STM32F1/build_flags.py
-  ${common.build_flags} -DDEBUG_LEVEL=0 -std=gnu++14 -DHAVE_SW_SERIAL -DSS_TIMER=4 -DSTM32_FLASH_SIZE=512 -DUSE_USB_COMPOSITE
-build_unflags     = -std=gnu++11
-extra_scripts     = buildroot/share/PlatformIO/scripts/STM32F103RC_SKR_MINI.py
-src_filter        = ${common.default_src_filter} +<src/HAL/STM32F1>
-lib_deps          = ${common.lib_deps}
-  SoftwareSerialM=https://github.com/FYSETC/SoftwareSerialM/archive/master.zip
+platform          = ${common_stm32f1.platform}
+extends           = env:STM32F103RC_btt_512K
+build_flags       = ${env:STM32F103RC_btt_512K.build_flags} -DUSE_USB_COMPOSITE
+lib_deps          = ${env:STM32F103RC_btt_512K.lib_deps}
   USBComposite for STM32F1@==0.91
-lib_ignore        = Adafruit NeoPixel, SPI
-monitor_speed     = 115200
 
 #
 # STM32F103RE
 #
 [env:STM32F103RE]
-platform          = ststm32
+platform          = ${common_stm32f1.platform}
+extends           = common_stm32f1
 board             = genericSTM32F103RE
 platform_packages = tool-stm32duino
-build_flags       = !python Marlin/src/HAL/STM32F1/build_flags.py
-  ${common.build_flags} -std=gnu++14
-build_unflags     = -std=gnu++11
-src_filter        = ${common.default_src_filter} +<src/HAL/STM32F1>
-lib_deps          = ${common.lib_deps}
-  SoftwareSerialM=https://github.com/FYSETC/SoftwareSerialM/archive/master.zip
-lib_ignore        = Adafruit NeoPixel, SPI
 monitor_speed     = 115200
 
 #
@@ -418,37 +386,19 @@ monitor_speed     = 115200
 #   STM32F103RE_btt_USB ......... RET6 (USB mass storage)
 #
 [env:STM32F103RE_btt]
-platform          = ststm32
-board             = genericSTM32F103RE
-platform_packages = tool-stm32duino
-build_flags       = !python Marlin/src/HAL/STM32F1/build_flags.py
-  ${common.build_flags} -DDEBUG_LEVEL=0 -std=gnu++14 -DHAVE_SW_SERIAL -DSS_TIMER=4
-build_unflags     = -std=gnu++11
+platform          = ${common_stm32f1.platform}
+extends           = env:STM32F103RE
 extra_scripts     = buildroot/share/PlatformIO/scripts/STM32F103RE_SKR_E3_DIP.py
-src_filter        = ${common.default_src_filter} +<src/HAL/STM32F1>
-lib_deps          = ${common.lib_deps}
-  SoftwareSerialM=https://github.com/FYSETC/SoftwareSerialM/archive/master.zip
-lib_ignore        = Adafruit NeoPixel, SPI
+build_flags       = ${common_stm32f1.build_flags} -DDEBUG_LEVEL=0 -DSS_TIMER=4
 debug_tool        = stlink
 upload_protocol   = stlink
-monitor_speed     = 115200
 
 [env:STM32F103RE_btt_USB]
-platform          = ststm32
-board             = genericSTM32F103RE
-platform_packages = tool-stm32duino
-build_flags       = !python Marlin/src/HAL/STM32F1/build_flags.py
-  ${common.build_flags} -DDEBUG_LEVEL=0 -std=gnu++14 -DHAVE_SW_SERIAL -DSS_TIMER=4 -DUSE_USB_COMPOSITE
-build_unflags     = -std=gnu++11
-extra_scripts     = buildroot/share/PlatformIO/scripts/STM32F103RE_SKR_E3_DIP.py
-src_filter        = ${common.default_src_filter} +<src/HAL/STM32F1>
-lib_deps          = ${common.lib_deps}
-  SoftwareSerialM=https://github.com/FYSETC/SoftwareSerialM/archive/master.zip
+platform          = ${common_stm32f1.platform}
+extends           = env:STM32F103RE_btt
+build_flags       = ${env:STM32F103RE_btt.build_flags} -DUSE_USB_COMPOSITE
+lib_deps          = ${common_stm32f1.lib_deps}
   USBComposite for STM32F1@==0.91
-lib_ignore        = Adafruit NeoPixel, SPI
-debug_tool        = stlink
-upload_protocol   = stlink
-monitor_speed     = 115200
 
 #
 # STM32F4 with STM32GENERIC
@@ -488,156 +438,129 @@ src_filter    = ${common.default_src_filter} +<src/HAL/STM32>
 # Geeetech GTM32 (STM32F103VET6)
 #
 [env:STM32F103VE_GTM32]
-platform        = ststm32
-board           = genericSTM32F103VE
-build_flags     = !python Marlin/src/HAL/STM32F1/build_flags.py
-  ${common.build_flags} -std=gnu++14 -ffunction-sections -fdata-sections -nostdlib -MMD
+platform          = ${common_stm32f1.platform}
+extends           = common_stm32f1
+board             = genericSTM32F103VE
+build_flags       = ${common_stm32f1.build_flags}
+  -ffunction-sections -fdata-sections -nostdlib -MMD
   -DMCU_STM32F103VE -DARDUINO_GENERIC_STM32F103V -DARDUINO_ARCH_STM32F1 -DBOARD_generic_stm32f103v
-  -DDEBUG_LEVEL=DEBUG_NONE -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DVECT_TAB_ADDR=0x8000000 -DERROR_LED_PORT=GPIOE -DERROR_LED_PIN=6
-build_unflags = -std=gnu++11
-src_filter      = ${common.default_src_filter} +<src/HAL/STM32F1>
-lib_ignore      = Adafruit NeoPixel, SPI
+  -DDEBUG_LEVEL=DEBUG_NONE -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DVECT_TAB_ADDR=0x8000000
+  -DERROR_LED_PORT=GPIOE -DERROR_LED_PIN=6
 upload_protocol = serial
 
 #
 # Longer 3D board in Alfawise U20 (STM32F103VET6)
 #
 [env:STM32F103VE_longer]
-platform      = ststm32
+platform      = ${common_stm32f1.platform}
+extends       = common_stm32f1
 board         = genericSTM32F103VE
-build_flags   = !python Marlin/src/HAL/STM32F1/build_flags.py
-  ${common.build_flags} -std=gnu++14 -DMCU_STM32F103VE -DSTM32F1xx -USERIAL_USB -DU20 -DTS_V12
-build_unflags = -std=gnu++11 -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DERROR_LED_PORT=GPIOE -DERROR_LED_PIN=6
 extra_scripts = buildroot/share/PlatformIO/scripts/STM32F103VE_longer.py
-src_filter    = ${common.default_src_filter} +<src/HAL/STM32F1>
-lib_ignore    = Adafruit NeoPixel, LiquidTWI2, SPI
+build_flags   = ${common_stm32f1.build_flags}
+  -DMCU_STM32F103VE -DSTM32F1xx -USERIAL_USB -DU20 -DTS_V12
+build_unflags = ${common_stm32f1.build_unflags}
+  -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DERROR_LED_PORT=GPIOE -DERROR_LED_PIN=6
+lib_ignore    = ${common_stm32f1.lib_ignore}
+  LiquidTWI2
 
 #
 # MKS Robin Mini (STM32F103VET6)
 #
 [env:mks_robin_mini]
-platform      = ststm32
+platform      = ${common_stm32f1.platform}
+extends       = common_stm32f1
 board         = genericSTM32F103VE
-build_flags   = !python Marlin/src/HAL/STM32F1/build_flags.py
-  ${common.build_flags} -std=gnu++14 -DMCU_STM32F103VE
-build_unflags = -std=gnu++11
 extra_scripts = buildroot/share/PlatformIO/scripts/mks_robin_mini.py
-src_filter    = ${common.default_src_filter} +<src/HAL/STM32F1>
-lib_ignore    = Adafruit NeoPixel, SPI
+build_flags   = ${common_stm32f1.build_flags}
+  -DMCU_STM32F103VE
 
 #
 # MKS Robin Nano (STM32F103VET6)
 #
 [env:mks_robin_nano]
-platform      = ststm32
+platform      = ${common_stm32f1.platform}
+extends       = common_stm32f1
 board         = genericSTM32F103VE
 platform_packages = tool-stm32duino
-build_flags   = !python Marlin/src/HAL/STM32F1/build_flags.py
-  ${common.build_flags} -std=gnu++14 -DMCU_STM32F103VE -DHAVE_SW_SERIAL -DSS_TIMER=4
-build_unflags = -std=gnu++11
 extra_scripts = buildroot/share/PlatformIO/scripts/mks_robin_nano.py
-src_filter    = ${common.default_src_filter} +<src/HAL/STM32F1>
-lib_deps      = ${common.lib_deps}
-  SoftwareSerialM=https://github.com/FYSETC/SoftwareSerialM/archive/master.zip
-lib_ignore    = Adafruit NeoPixel, SPI
+build_flags   = ${common_stm32f1.build_flags}
+  -DMCU_STM32F103VE -DSS_TIMER=4
+
 
 #
 # MKS Robin (STM32F103ZET6)
 #
 [env:mks_robin]
-platform      = ststm32
+platform      = ${common_stm32f1.platform}
+extends       = common_stm32f1
 board         = genericSTM32F103ZE
-build_flags   = !python Marlin/src/HAL/STM32F1/build_flags.py
-  ${common.build_flags} -std=gnu++14 -DHAVE_SW_SERIAL -DSS_TIMER=4 -DSTM32_XL_DENSITY
-build_unflags = -std=gnu++11
 extra_scripts = buildroot/share/PlatformIO/scripts/mks_robin.py
-src_filter    = ${common.default_src_filter} +<src/HAL/STM32F1>
-lib_deps      = ${common.lib_deps}
-  SoftwareSerialM=https://github.com/FYSETC/SoftwareSerialM/archive/master.zip
-lib_ignore    = Adafruit NeoPixel, SPI
+build_flags   = ${common_stm32f1.build_flags}
+  -DSS_TIMER=4 -DSTM32_XL_DENSITY
 
 #
 # MKS Robin Pro (STM32F103ZET6)
 #
 [env:mks_robin_pro]
-platform      = ststm32
-board         = genericSTM32F103ZE
+platform      = ${common_stm32f1.platform}
+extends       = env:mks_robin
 extra_scripts = buildroot/share/PlatformIO/scripts/mks_robin_pro.py
-build_flags   = !python Marlin/src/HAL/STM32F1/build_flags.py
-  ${common.build_flags} -std=gnu++14 -DHAVE_SW_SERIAL -DSS_TIMER=4 -DSTM32_XL_DENSITY
-build_unflags = -std=gnu++11
-src_filter    = ${common.default_src_filter} +<src/HAL/STM32F1>
-lib_deps      = ${common.lib_deps}
-  SoftwareSerialM=https://github.com/FYSETC/SoftwareSerialM/archive/master.zip
-lib_ignore    = Adafruit NeoPixel, SPI
 
 #
 # MKS Robin E3D (STM32F103RCT6) and
 # MKS Robin E3 with TMC2209
 #
 [env:mks_robin_e3]
-platform          = ststm32
-board             = genericSTM32F103RC
+platform      = ${common_stm32f1.platform}
+extends       = common_stm32f1
+board         = genericSTM32F103RC
 platform_packages = tool-stm32duino
-build_flags       = !python Marlin/src/HAL/STM32F1/build_flags.py
-  ${common.build_flags} -DDEBUG_LEVEL=0 -std=gnu++14 -DHAVE_SW_SERIAL -DSS_TIMER=4
-build_unflags     = -std=gnu++11
-extra_scripts     = buildroot/share/PlatformIO/scripts/mks_robin_e3.py
-src_filter        = ${common.default_src_filter} +<src/HAL/STM32F1>
-lib_deps          = ${common.lib_deps}
-  SoftwareSerialM=https://github.com/FYSETC/SoftwareSerialM/archive/master.zip
-lib_ignore        = Adafruit NeoPixel, SPI
+extra_scripts = buildroot/share/PlatformIO/scripts/mks_robin_e3.py
+build_flags   = ${common_stm32f1.build_flags}
+  -DDEBUG_LEVEL=0 -DSS_TIMER=4
 
 #
 # MKS Robin Lite/Lite2 (STM32F103RCT6)
 #
 [env:mks_robin_lite]
-platform      = ststm32
+platform      = ${common_stm32f1.platform}
+extends       = common_stm32f1
 board         = genericSTM32F103RC
-build_flags   = !python Marlin/src/HAL/STM32F1/build_flags.py
-  ${common.build_flags} -std=gnu++14
-build_unflags = -std=gnu++11
 extra_scripts = buildroot/share/PlatformIO/scripts/mks_robin_lite.py
-src_filter    = ${common.default_src_filter} +<src/HAL/STM32F1>
-lib_ignore    = Adafruit NeoPixel, SPI
+
 
 #
 # MKS ROBIN LITE3 (STM32F103RCT6)
 #
 [env:mks_robin_lite3]
-platform      = ststm32
+platform      = ${common_stm32f1.platform}
+extends       = common_stm32f1
 board         = genericSTM32F103RC
 extra_scripts = buildroot/share/PlatformIO/scripts/mks_robin_lite3.py
-build_flags   = !python Marlin/src/HAL/STM32F1/build_flags.py
-  ${common.build_flags} -std=gnu++14
-build_unflags = -std=gnu++11
-src_filter    = ${common.default_src_filter} +<src/HAL/STM32F1>
-lib_deps      = ${common.lib_deps}
-lib_ignore    = Adafruit NeoPixel, SPI
 
 #
 # JGAurora A5S A1 (STM32F103ZET6)
 #
 [env:jgaurora_a5s_a1]
-platform      = ststm32
+platform      = ${common_stm32f1.platform}
+extends       = common_stm32f1
 board         = genericSTM32F103ZE
-build_flags   = !python Marlin/src/HAL/STM32F1/build_flags.py
-  ${common.build_flags} -DSTM32F1xx -std=gnu++14 -DSTM32_XL_DENSITY
-build_unflags = -std=gnu++11
 extra_scripts = buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py
-src_filter    = ${common.default_src_filter} +<src/HAL/STM32F1>
-lib_ignore    = Adafruit NeoPixel, SPI
+build_flags   = ${common_stm32f1.build_flags}
+  -DSTM32F1xx -DSTM32_XL_DENSITY
 
 #
 # Malyan M200 (STM32F103CB)
 #
 [env:STM32F103CB_malyan]
-platform    = ststm32
-board       = malyanM200
-build_flags = !python Marlin/src/HAL/STM32F1/build_flags.py -DMCU_STM32F103CB -D __STM32F1__=1 -std=c++1y -DSERIAL_USB -ffunction-sections -fdata-sections -Wl,--gc-sections
-  -DDEBUG_LEVEL=0 -D__MARLIN_FIRMWARE__
-src_filter  = ${common.default_src_filter} +<src/HAL/STM32F1>
-lib_ignore  = LiquidCrystal, LiquidTWI2, Adafruit NeoPixel, TMCStepper, U8glib-HAL, SPI
+platform      = ${common_stm32f1.platform}
+extends       = common_stm32f1
+board         = malyanM200
+build_flags   = ${common_stm32f1.build_flags}
+  -DMCU_STM32F103CB -D__STM32F1__=1 -std=c++1y -DSERIAL_USB -ffunction-sections -fdata-sections
+  -Wl,--gc-sections -DDEBUG_LEVEL=0 -D__MARLIN_FIRMWARE__
+lib_ignore    = ${common_stm32f1.lib_ignore}
+  LiquidCrystal, LiquidTWI2, TMCStepper, U8glib-HAL, SoftwareSerialM
 
 #
 # Malyan M200 v2 (STM32F070RB)
@@ -669,14 +592,14 @@ lib_ignore  = LiquidCrystal, LiquidTWI2, Adafruit NeoPixel, TMCStepper, U8glib-H
 # Chitu boards like Tronxy X5s (STM32F103ZET6)
 #
 [env:chitu_f103]
-platform      = ststm32
+platform      = ${common_stm32f1.platform}
+extends       = common_stm32f1
 board         = genericSTM32F103ZE
-build_flags   = !python Marlin/src/HAL/STM32F1/build_flags.py
-  ${common.build_flags} -DSTM32F1xx -std=gnu++14 -DSTM32_XL_DENSITY
-build_unflags = -std=gnu++11 -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG= -DERROR_LED_PORT=GPIOE -DERROR_LED_PIN=6
 extra_scripts = buildroot/share/PlatformIO/scripts/chitu_crypt.py
-src_filter    = ${common.default_src_filter} +<src/HAL/STM32F1>
-lib_ignore    = Adafruit NeoPixel
+build_flags   = ${common_stm32f1.build_flags}
+  -DSTM32F1xx -DSTM32_XL_DENSITY
+build_unflags = ${common_stm32f1.build_unflags}
+  -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG= -DERROR_LED_PORT=GPIOE -DERROR_LED_PIN=6
 
 #
 # STM32F401VE