From 5d80f7006a32bbf4b56dcb2c88388782a8e26ffa Mon Sep 17 00:00:00 2001
From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com>
Date: Thu, 10 Jun 2021 14:09:29 -0700
Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20Envs=20for=20BTT=20SKR=20Mini=20?=
 =?UTF-8?q?with=20RET6=20(512K)=20(#22050)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 Marlin/src/core/boards.h |  2 +-
 Marlin/src/pins/pins.h   | 12 ++++++------
 ini/stm32f1-maple.ini    | 26 ++------------------------
 ini/stm32f1.ini          | 33 +++++++--------------------------
 4 files changed, 16 insertions(+), 57 deletions(-)

diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h
index 651df5aedf..9dc951e229 100644
--- a/Marlin/src/core/boards.h
+++ b/Marlin/src/core/boards.h
@@ -321,7 +321,7 @@
 #define BOARD_BTT_SKR_MINI_V1_1       4023  // BigTreeTech SKR Mini v1.1 (STM32F103RC)
 #define BOARD_BTT_SKR_MINI_E3_V1_0    4024  // BigTreeTech SKR Mini E3 (STM32F103RC)
 #define BOARD_BTT_SKR_MINI_E3_V1_2    4025  // BigTreeTech SKR Mini E3 V1.2 (STM32F103RC)
-#define BOARD_BTT_SKR_MINI_E3_V2_0    4026  // BigTreeTech SKR Mini E3 V2.0 (STM32F103RC)
+#define BOARD_BTT_SKR_MINI_E3_V2_0    4026  // BigTreeTech SKR Mini E3 V2.0 (STM32F103RC / STM32F103RE)
 #define BOARD_BTT_SKR_MINI_MZ_V1_0    4027  // BigTreeTech SKR Mini MZ V1.0 (STM32F103RC)
 #define BOARD_BTT_SKR_E3_DIP          4028  // BigTreeTech SKR E3 DIP V1.0 (STM32F103RC / STM32F103RE)
 #define BOARD_BTT_SKR_CR6             4029  // BigTreeTech SKR CR6 v1.0 (STM32F103RE)
diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h
index 3b0f7d42ea..88dd170a9e 100644
--- a/Marlin/src/pins/pins.h
+++ b/Marlin/src/pins/pins.h
@@ -508,17 +508,17 @@
 #elif MB(MKS_ROBIN_E3P)
   #include "stm32f1/pins_MKS_ROBIN_E3P.h"       // STM32F1                                env:mks_robin_e3p
 #elif MB(BTT_SKR_MINI_V1_1)
-  #include "stm32f1/pins_BTT_SKR_MINI_V1_1.h"   // STM32F1                                env:STM32F103RC_btt env:STM32F103RC_btt_512K env:STM32F103RC_btt_maple env:STM32F103RC_btt_512K_maple env:STM32F103RC_btt_USB_maple env:STM32F103RC_btt_512K_USB_maple
+  #include "stm32f1/pins_BTT_SKR_MINI_V1_1.h"   // STM32F1                                env:STM32F103RC_btt env:STM32F103RC_btt_USB env:STM32F103RC_btt_maple env:STM32F103RC_btt_USB_maple
 #elif MB(BTT_SKR_MINI_E3_V1_0)
-  #include "stm32f1/pins_BTT_SKR_MINI_E3_V1_0.h"  // STM32F1                              env:STM32F103RC_btt env:STM32F103RC_btt_512K env:STM32F103RC_btt_maple env:STM32F103RC_btt_512K_maple env:STM32F103RC_btt_USB_maple env:STM32F103RC_btt_512K_USB_maple
+  #include "stm32f1/pins_BTT_SKR_MINI_E3_V1_0.h"  // STM32F1                              env:STM32F103RC_btt env:STM32F103RC_btt_USB env:STM32F103RC_btt_maple env:STM32F103RC_btt_USB_maple
 #elif MB(BTT_SKR_MINI_E3_V1_2)
-  #include "stm32f1/pins_BTT_SKR_MINI_E3_V1_2.h"  // STM32F1                              env:STM32F103RC_btt env:STM32F103RC_btt_512K env:STM32F103RC_btt_maple env:STM32F103RC_btt_512K_maple env:STM32F103RC_btt_USB_maple env:STM32F103RC_btt_512K_USB_maple
+  #include "stm32f1/pins_BTT_SKR_MINI_E3_V1_2.h"  // STM32F1                              env:STM32F103RC_btt env:STM32F103RC_btt_USB env:STM32F103RC_btt_maple env:STM32F103RC_btt_USB_maple
 #elif MB(BTT_SKR_MINI_E3_V2_0)
-  #include "stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h"  // STM32F1                              env:STM32F103RC_btt env:STM32F103RC_btt_512K env:STM32F103RC_btt_maple env:STM32F103RC_btt_512K_maple env:STM32F103RC_btt_USB_maple env:STM32F103RC_btt_512K_USB_maple
+  #include "stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h"  // STM32F1                              env:STM32F103RC_btt env:STM32F103RC_btt_USB env:STM32F103RE_btt env:STM32F103RE_btt_USB env:STM32F103RC_btt_maple env:STM32F103RC_btt_USB_maple env:STM32F103RE_btt_maple env:STM32F103RE_btt_USB_maple
 #elif MB(BTT_SKR_MINI_MZ_V1_0)
-  #include "stm32f1/pins_BTT_SKR_MINI_MZ_V1_0.h"  // STM32F1                              env:STM32F103RC_btt env:STM32F103RC_btt_512K env:STM32F103RC_btt_maple env:STM32F103RC_btt_512K_maple env:STM32F103RC_btt_USB_maple env:STM32F103RC_btt_512K_USB_maple
+  #include "stm32f1/pins_BTT_SKR_MINI_MZ_V1_0.h"  // STM32F1                              env:STM32F103RC_btt env:STM32F103RC_btt_USB env:STM32F103RC_btt_maple env:STM32F103RC_btt_USB_maple
 #elif MB(BTT_SKR_E3_DIP)
-  #include "stm32f1/pins_BTT_SKR_E3_DIP.h"      // STM32F1                                env:STM32F103RE_btt env:STM32F103RE_btt_USB env:STM32F103RE_btt_maple env:STM32F103RE_btt_USB_maple env:STM32F103RC_btt env:STM32F103RC_btt_512K
+  #include "stm32f1/pins_BTT_SKR_E3_DIP.h"      // STM32F1                                env:STM32F103RC_btt env:STM32F103RC_btt_USB env:STM32F103RE_btt env:STM32F103RE_btt_USB env:STM32F103RC_btt_maple env:STM32F103RC_btt_USB_maple env:STM32F103RE_btt_maple env:STM32F103RE_btt_USB_maple
 #elif MB(BTT_SKR_CR6)
   #include "stm32f1/pins_BTT_SKR_CR6.h"         // STM32F1                                env:STM32F103RE_btt env:STM32F103RE_btt_USB env:STM32F103RE_btt_maple env:STM32F103RE_btt_USB_maple
 #elif MB(JGAURORA_A5S_A1)
diff --git a/ini/stm32f1-maple.ini b/ini/stm32f1-maple.ini
index 349016145c..25ebfb64b6 100644
--- a/ini/stm32f1-maple.ini
+++ b/ini/stm32f1-maple.ini
@@ -85,19 +85,11 @@ debug_tool        = stlink
 upload_protocol   = serial
 
 #
-# BigTree SKR Mini V1.1 / SKR mini E3 / SKR E3 DIP (STM32F103RCT6 ARM Cortex-M3)
+# BigTree SKR Mini V1.1 / SKR Mini E3 & MZ (STM32F103RCT6 ARM Cortex-M3)
 #
 #   STM32F103RC_btt_maple ............. RCT6 with 256K
 #   STM32F103RC_btt_USB_maple ......... RCT6 with 256K (USB mass storage)
-#   STM32F103RC_btt_512K_maple ........ RCT6 with 512K
-#   STM32F103RC_btt_512K_USB_maple .... RCT6 with 512K (USB mass storage)
 #
-# WARNING! If you have an SKR Mini v1.1 or an SKR Mini E3 1.0 / 1.2 / 2.0 / DIP
-# and experience a printer freeze, re-flash Marlin using the regular (non-512K)
-# build option. 256K chips may be re-branded 512K chips, but this means the
-# upper 256K is sketchy, and failure is very likely.
-#
-
 [env:STM32F103RC_btt_maple]
 platform             = ${common_stm32f1.platform}
 extends              = common_STM32F103RC_maple
@@ -116,20 +108,6 @@ build_flags       = ${env:STM32F103RC_btt_maple.build_flags} -DUSE_USB_COMPOSITE
 lib_deps          = ${env:STM32F103RC_btt_maple.lib_deps}
   USBComposite for STM32F1@0.91
 
-[env:STM32F103RC_btt_512K_maple]
-platform                  = ${common_stm32f1.platform}
-extends                   = env:STM32F103RC_btt_maple
-board_build.ldscript      = STM32F103RE_SKR_MINI_512K.ld
-board_upload.maximum_size = 524288
-build_flags               = ${env:STM32F103RC_btt_maple.build_flags} -DSTM32_FLASH_SIZE=512
-
-[env:STM32F103RC_btt_512K_USB_maple]
-platform          = ${common_stm32f1.platform}
-extends           = env:STM32F103RC_btt_512K_maple
-build_flags       = ${env:STM32F103RC_btt_512K_maple.build_flags} -DUSE_USB_COMPOSITE
-lib_deps          = ${env:STM32F103RC_btt_512K_maple.lib_deps}
-  USBComposite for STM32F1@0.91
-
 #
 # Generic STM32F103RE environment
 #
@@ -155,7 +133,7 @@ debug_tool           = jlink
 upload_protocol      = jlink
 
 #
-# BigTree SKR Mini E3 DIP / SKR CR6 (STM32F103RET6 ARM Cortex-M3)
+# BigTree SKR Mini E3 V2.0 & DIP / SKR CR6 (STM32F103RET6 ARM Cortex-M3)
 #
 #   STM32F103RE_btt_maple ............. RET6
 #   STM32F103RE_btt_USB_maple ......... RET6 (USB mass storage)
diff --git a/ini/stm32f1.ini b/ini/stm32f1.ini
index 150ddba01e..9954411c14 100644
--- a/ini/stm32f1.ini
+++ b/ini/stm32f1.ini
@@ -34,19 +34,6 @@ src_filter    = ${common.default_src_filter} +<src/HAL/STM32> +<src/HAL/shared/b
 extra_scripts = ${common.extra_scripts}
   pre:buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py
 
-#
-# BigTree SKR Mini V1.1 / SKR mini E3 / SKR E3 DIP (STM32F103RCT6 ARM Cortex-M3)
-#
-#   STM32F103RC_btt ............. RCT6 with 256K
-#   STM32F103RC_btt_USB ......... RCT6 with 256K (USB mass storage)
-#   STM32F103RC_btt_512K ........ RCT6 with 512K
-#   STM32F103RC_btt_512K_USB .... RCT6 with 512K (USB mass storage)
-#
-# WARNING! If you have an SKR Mini v1.1 or an SKR Mini E3 1.0 / 1.2 / 2.0 / DIP
-# and experience a printer freeze, re-flash Marlin using the regular (non-512K)
-# build option. 256K chips may be re-branded 512K chips, but this means the
-# upper 256K is sketchy, and failure is very likely.
-#
 [common_STM32F103RC]
 platform             = ${common_stm32.platform}
 extends              = common_stm32
@@ -86,6 +73,12 @@ extends           = common_stm32
 board             = genericSTM32F103ZE
 monitor_speed     = 115200
 
+#
+# BigTree SKR Mini V1.1 / SKR Mini E3 & MZ (STM32F103RCT6 ARM Cortex-M3)
+#
+#   STM32F103RC_btt ............. RCT6 with 256K
+#   STM32F103RC_btt_USB ......... RCT6 with 256K (USB mass storage)
+#
 [env:STM32F103RC_btt]
 platform             = ${common_stm32.platform}
 extends              = common_STM32F103RC
@@ -108,18 +101,6 @@ build_flags       = ${env:STM32F103RC_btt.build_flags} ${env:stm32_flash_drive.b
   -DUSE_USB_HS_IN_FS
   -DUSBD_USE_CDC_MSC
 
-[env:STM32F103RC_btt_512K]
-platform          = ${common_stm32.platform}
-extends           = env:STM32F103RC_btt
-board_upload.maximum_size = 524288
-build_flags       = ${env:STM32F103RC_btt.build_flags} -DLD_MAX_DATA_SIZE=524288 -DSTM32_FLASH_SIZE=512
-
-[env:STM32F103RC_btt_512K_USB]
-platform          = ${common_stm32.platform}
-extends           = env:STM32F103RC_btt_USB
-board_upload.maximum_size = 524288
-build_flags       = ${env:STM32F103RC_btt_USB.build_flags} -DLD_MAX_DATA_SIZE=524288 -DSTM32_FLASH_SIZE=512
-
 #
 # MKS Robin (STM32F103ZET6)
 # Uses HAL STM32 to support Marlin UI for TFT screen with optional touch panel
@@ -185,7 +166,7 @@ debug_tool           = jlink
 upload_protocol      = jlink
 
 #
-# BigTree SKR Mini E3 DIP / SKR CR6 (STM32F103RET6 ARM Cortex-M3)
+# BigTree SKR Mini E3 V2.0 & DIP / SKR CR6 (STM32F103RET6 ARM Cortex-M3)
 #
 #   STM32F103RE_btt ............. RET6
 #   STM32F103RE_btt_USB ......... RET6 (USB mass storage)