From d99d0c8a10b2d0ee540e115b15eef24a71028863 Mon Sep 17 00:00:00 2001
From: Bruno Henrique de Paula <bruno.henriquy@gmail.com>
Date: Fri, 4 Feb 2022 18:57:43 -0300
Subject: [PATCH] =?UTF-8?q?=F0=9F=93=8C=20Distinct=20BOARD=5FCREALITY=5FV4?=
 =?UTF-8?q?22=20(#23674)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 Marlin/src/pins/pins.h                        |  4 ++-
 Marlin/src/pins/stm32f1/pins_CREALITY_V24S1.h |  2 +-
 .../pins/stm32f1/pins_CREALITY_V24S1_301.h    |  2 +-
 Marlin/src/pins/stm32f1/pins_CREALITY_V4.h    |  2 +-
 Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h |  2 +-
 Marlin/src/pins/stm32f1/pins_CREALITY_V422.h  | 31 +++++++++++++++++++
 Marlin/src/pins/stm32f1/pins_CREALITY_V423.h  |  2 +-
 Marlin/src/pins/stm32f1/pins_CREALITY_V427.h  |  2 +-
 Marlin/src/pins/stm32f1/pins_CREALITY_V431.h  |  2 +-
 Marlin/src/pins/stm32f1/pins_CREALITY_V452.h  |  2 +-
 Marlin/src/pins/stm32f1/pins_CREALITY_V453.h  |  2 +-
 buildroot/share/scripts/upload.py             | 10 +++---
 12 files changed, 49 insertions(+), 14 deletions(-)
 create mode 100644 Marlin/src/pins/stm32f1/pins_CREALITY_V422.h

diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h
index 8c69bccc2e4..54a7c3c610a 100644
--- a/Marlin/src/pins/pins.h
+++ b/Marlin/src/pins/pins.h
@@ -559,10 +559,12 @@
   #include "stm32f1/pins_CHITU3D_V6.h"          // STM32F1                                env:chitu_f103 env:chitu_f103_maple
 #elif MB(CHITU3D_V9)
   #include "stm32f1/pins_CHITU3D_V9.h"          // STM32F1                                env:chitu_f103 env:chitu_f103_maple
-#elif MB(CREALITY_V4, CREALITY_V422)
+#elif MB(CREALITY_V4)
   #include "stm32f1/pins_CREALITY_V4.h"         // STM32F1                                env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple
 #elif MB(CREALITY_V4210)
   #include "stm32f1/pins_CREALITY_V4210.h"      // STM32F1                                env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple
+#elif MB(CREALITY_V422)
+  #include "stm32f1/pins_CREALITY_V422.h"       // STM32F1                                env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple
 #elif MB(CREALITY_V423)
   #include "stm32f1/pins_CREALITY_V423.h"       // STM32F1                                env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer
 #elif MB(CREALITY_V427)
diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V24S1.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V24S1.h
index ffd7baa00c4..9d7e0f695b7 100644
--- a/Marlin/src/pins/stm32f1/pins_CREALITY_V24S1.h
+++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V24S1.h
@@ -22,7 +22,7 @@
 #pragma once
 
 /**
- * Creality v2.4.S1 (STM32F103RE) v101 as found in the Ender 7 board pin assignments
+ * Creality v2.4.S1 (STM32F103RE / STM32F103RC) v101 as found in the Ender 7 board pin assignments
  */
 
 #define BOARD_INFO_NAME      "Creality v2.4.S1 V101"
diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V24S1_301.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V24S1_301.h
index 336754bc1a3..8616a8fb340 100644
--- a/Marlin/src/pins/stm32f1/pins_CREALITY_V24S1_301.h
+++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V24S1_301.h
@@ -22,7 +22,7 @@
 #pragma once
 
 /**
- * Creality V24S1_301 (STM32F103RCT) board pin assignments as found on Ender 3 S1
+ * Creality V24S1_301 (STM32F103RE / STM32F103RC) board pin assignments as found on Ender 3 S1
  */
 
 #include "env_validate.h"
diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h
index 6122206d6a8..d6d49662412 100644
--- a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h
+++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h
@@ -22,7 +22,7 @@
 #pragma once
 
 /**
- * Creality 4.2.x (STM32F103RET6) board pin assignments
+ * Creality 4.2.x (STM32F103RE / STM32F103RC) board pin assignments
  */
 
 #include "env_validate.h"
diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h
index 0cc3393ebc5..7bf34441bcf 100644
--- a/Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h
+++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h
@@ -22,7 +22,7 @@
 #pragma once
 
 /**
- * CREALITY 4.2.10 (STM32F103) board pin assignments
+ * CREALITY 4.2.10 (STM32F103RE / STM32F103RC) board pin assignments
  */
 
 #include "env_validate.h"
diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V422.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V422.h
new file mode 100644
index 00000000000..5499adb0766
--- /dev/null
+++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V422.h
@@ -0,0 +1,31 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2022 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 <https://www.gnu.org/licenses/>.
+ *
+ */
+#pragma once
+
+/**
+ * CREALITY v4.2.2 (STM32F103RE / STM32F103RC) board pin assignments
+ */
+
+#define BOARD_INFO_NAME      "Creality v4.2.2"
+#define DEFAULT_MACHINE_NAME "Creality3D"
+
+#include "pins_CREALITY_V4.h"
diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V423.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V423.h
index 186051c1fcb..c174b0e56ed 100644
--- a/Marlin/src/pins/stm32f1/pins_CREALITY_V423.h
+++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V423.h
@@ -22,7 +22,7 @@
 #pragma once
 
 /**
- * CREALITY v4.2.3 (STM32F103) board pin assignments
+ * CREALITY v4.2.3 (STM32F103RE / STM32F103RC) board pin assignments
  */
 
 #define BOARD_INFO_NAME      "Creality v4.2.3"
diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V427.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V427.h
index c327abee779..077f4c73a65 100644
--- a/Marlin/src/pins/stm32f1/pins_CREALITY_V427.h
+++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V427.h
@@ -22,7 +22,7 @@
 #pragma once
 
 /**
- * CREALITY v4.2.7 (STM32F103) board pin assignments
+ * CREALITY v4.2.7 (STM32F103RE / STM32F103RC) board pin assignments
  */
 
 #define BOARD_INFO_NAME      "Creality v4.2.7"
diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V431.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V431.h
index 2f1f2ffb411..9226b537d91 100644
--- a/Marlin/src/pins/stm32f1/pins_CREALITY_V431.h
+++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V431.h
@@ -22,7 +22,7 @@
 #pragma once
 
 /**
- * CREALITY v4.3.1 (STM32F103) board pin assignments
+ * CREALITY v4.3.1 (STM32F103RE / STM32F103RC) board pin assignments
  */
 
 #define BOARD_INFO_NAME      "Creality v4.3.1"
diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V452.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V452.h
index 9b6862d99bd..ced64e2a893 100644
--- a/Marlin/src/pins/stm32f1/pins_CREALITY_V452.h
+++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V452.h
@@ -22,7 +22,7 @@
 #pragma once
 
 /**
- * Creality v4.5.2 (STM32F103RET6) board pin assignments
+ * Creality v4.5.2 (STM32F103RE / STM32F103RC) board pin assignments
  */
 
 #if HAS_MULTI_HOTEND || E_STEPPERS > 1
diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V453.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V453.h
index fd3ea93c32d..e7296d1ed07 100644
--- a/Marlin/src/pins/stm32f1/pins_CREALITY_V453.h
+++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V453.h
@@ -22,7 +22,7 @@
 #pragma once
 
 /**
- * Creality v4.5.3 (STM32F103RET6) board pin assignments
+ * Creality v4.5.3 (STM32F103RE / STM32F103RC) board pin assignments
  */
 
 #if HAS_MULTI_HOTEND || E_STEPPERS > 1
diff --git a/buildroot/share/scripts/upload.py b/buildroot/share/scripts/upload.py
index ceb0db4f10a..f6b25396ada 100644
--- a/buildroot/share/scripts/upload.py
+++ b/buildroot/share/scripts/upload.py
@@ -153,11 +153,13 @@ def Upload(source, target, env):
 
     # Set local upload params based on board type to change script behavior
     # "upload_delete_old_bins": delete all *.bin files in the root of SD Card
-    upload_delete_old_bins = marlin_motherboard in ['BOARD_CREALITY_V4',   'BOARD_CREALITY_V4210', 'BOARD_CREALITY_V423', 'BOARD_CREALITY_V427',
-                                                    'BOARD_CREALITY_V431', 'BOARD_CREALITY_V452',  'BOARD_CREALITY_V453', 'BOARD_CREALITY_V24S1']
+    upload_delete_old_bins = marlin_motherboard in ['BOARD_CREALITY_V4',   'BOARD_CREALITY_V4210', 'BOARD_CREALITY_V422', 'BOARD_CREALITY_V423',
+                                                    'BOARD_CREALITY_V427', 'BOARD_CREALITY_V431', 'BOARD_CREALITY_V452',  'BOARD_CREALITY_V453',
+                                                    'BOARD_CREALITY_V24S1']
     # "upload_random_name": generate a random 8.3 firmware filename to upload
-    upload_random_filename = marlin_motherboard in ['BOARD_CREALITY_V4',   'BOARD_CREALITY_V4210', 'BOARD_CREALITY_V423', 'BOARD_CREALITY_V427',
-                                                    'BOARD_CREALITY_V431', 'BOARD_CREALITY_V452',  'BOARD_CREALITY_V453', 'BOARD_CREALITY_V24S1'] and not marlin_long_filename_host_support
+    upload_random_filename = marlin_motherboard in ['BOARD_CREALITY_V4',   'BOARD_CREALITY_V4210', 'BOARD_CREALITY_V422', 'BOARD_CREALITY_V423',
+                                                    'BOARD_CREALITY_V427', 'BOARD_CREALITY_V431', 'BOARD_CREALITY_V452',  'BOARD_CREALITY_V453',
+                                                    'BOARD_CREALITY_V24S1'] and not marlin_long_filename_host_support
 
     try: