From b0a4ea79b84e92326b7da4349126a5cf2d9821a0 Mon Sep 17 00:00:00 2001
From: yangwenxiong <46896566+yangwenxiong@users.noreply.github.com>
Date: Tue, 11 Jun 2019 10:10:51 +0800
Subject: [PATCH] BigTreeTech SKR Mini v1.1 (#14041)
---
Marlin/src/core/boards.h | 1 +
Marlin/src/pins/pins.h | 2 +
Marlin/src/pins/pins_BIGTREE_SKR_MINI_V1_1.h | 134 ++++++++++++++++++
.../PlatformIO/ldscripts/STM32F1_SKR_MINI.ld | 14 ++
.../PlatformIO/scripts/STM32F1_SKR_MINI.py | 8 ++
platformio.ini | 26 ++++
6 files changed, 185 insertions(+)
create mode 100644 Marlin/src/pins/pins_BIGTREE_SKR_MINI_V1_1.h
create mode 100644 buildroot/share/PlatformIO/ldscripts/STM32F1_SKR_MINI.ld
create mode 100644 buildroot/share/PlatformIO/scripts/STM32F1_SKR_MINI.py
diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h
index d30ec9f086..86ca7f0be1 100644
--- a/Marlin/src/core/boards.h
+++ b/Marlin/src/core/boards.h
@@ -245,6 +245,7 @@
#define BOARD_GTM32_PRO_VB 1805 // STM32f103VET6 controller
#define BOARD_MORPHEUS 1806 // STM32F103C8/STM32F103CB Libmaple based stm32f1 controller
#define BOARD_MKS_ROBIN 1808 // MKS Robin / STM32F103ZET6
+#define BOARD_BIGTREE_SKR_MINI_V1_1 1814 // STM32F103RC
//
// STM32 ARM Cortex-M4F
diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h
index eed0fdcb81..f7352e0a07 100644
--- a/Marlin/src/pins/pins.h
+++ b/Marlin/src/pins/pins.h
@@ -414,6 +414,8 @@
#include "pins_STM32F1R.h" // STM32F1 env:STM32F1
#elif MB(STM3R_MINI)
#include "pins_STM3R_MINI.h" // STM32F1 env:STM32F1
+#elif MB(BIGTREE_SKR_MINI_V1_1)
+ #include "pins_BIGTREE_SKR_MINI_V1_1.h" // STM32F1 env:BIGTREE_SKR_MINI
#elif MB(MALYAN_M200)
#include "pins_MALYAN_M200.h" // STM32F1 env:malyanm200
#elif MB(CHITU3D)
diff --git a/Marlin/src/pins/pins_BIGTREE_SKR_MINI_V1_1.h b/Marlin/src/pins/pins_BIGTREE_SKR_MINI_V1_1.h
new file mode 100644
index 0000000000..3f3f78446d
--- /dev/null
+++ b/Marlin/src/pins/pins_BIGTREE_SKR_MINI_V1_1.h
@@ -0,0 +1,134 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (C) 2016 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 .
+ *
+ */
+
+#ifndef TARGET_STM32F1
+ #error "Oops! Select an STM32F1 board in 'Tools > Board.'"
+#endif
+
+#ifndef BOARD_NAME
+ #define BOARD_NAME "BIGTREE SKR mini V1.1"
+#endif
+
+// Ignore temp readings during develpment.
+//#define BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
+
+//
+// Limit Switches
+//
+#define X_MIN_PIN PC2
+#define X_MAX_PIN PA2
+#define Y_MIN_PIN PC1
+#define Y_MAX_PIN PA1
+#define Z_MIN_PIN PC0
+#define Z_MAX_PIN PC3
+
+//
+// Steppers
+//
+
+/**
+ * TODO: Currently using same Enable pin for all steppers.
+ */
+
+#define X_STEP_PIN PC6
+#define X_DIR_PIN PC7
+#define X_ENABLE_PIN PB15
+
+#define Y_STEP_PIN PB13
+#define Y_DIR_PIN PB14
+#define Y_ENABLE_PIN PB12
+
+#define Z_STEP_PIN PB10
+#define Z_DIR_PIN PB11
+#define Z_ENABLE_PIN PB2
+
+#define E0_STEP_PIN PC5
+#define E0_DIR_PIN PB0
+#define E0_ENABLE_PIN PC4
+
+#if ENABLED(TMC_USE_SW_SPI)
+ #define TMC_SW_SCK PB3
+ #define TMC_SW_MISO PB4
+ #define TMC_SW_MOSI PB5
+#endif
+
+//
+// Heaters / Fans
+//
+#define HEATER_0_PIN PA8
+#define FAN_PIN PC8
+#define HEATER_BED_PIN PC9
+
+//
+// Temperature Sensors
+//
+#define TEMP_BED_PIN PB1 // Analog Input
+#define TEMP_0_PIN PA0 // Analog Input
+
+//
+// LCD Pins
+//
+
+/**
+ * _____ _____
+ * NC | · · | GND 5V | · · | GND
+ * RESET | · · | 1.31(SD_DETECT) (LCD_D7) 1.23 | · · | 1.22 (LCD_D6)
+ * (MOSI)0.18 | · · | 3.25(BTN_EN2) (LCD_D5) 1.21 | · · | 1.20 (LCD_D4)
+ * (SD_SS)0.16 | · · | 3.26(BTN_EN1) (LCD_RS) 1.19 | · · | 1.18 (LCD_EN)
+ * (SCK)0.15 | · · | 0.17(MISO) (BTN_ENC) 0.28 | · · | 1.30 (BEEPER)
+ *  ̄ ̄  ̄ ̄
+ * EXP2 EXP1
+ */
+
+#if ENABLED(ULTRA_LCD)
+
+ #define BEEPER_PIN PC10
+ #define BTN_ENC PC11
+ #define LCD_PINS_RS PC12
+
+ #define BTN_EN1 PD2
+ #define BTN_EN2 PB8
+
+ #define LCD_PINS_ENABLE PB6
+ #define LCD_PINS_D4 PC13
+
+ #if ENABLED(ULTIPANEL)
+ #define LCD_PINS_D5 PB7
+ #define LCD_PINS_D6 PC15
+ #define LCD_PINS_D7 PC14
+ #endif
+
+#endif // ULTRA_LCD
+
+//
+// SD Card
+//
+
+// Marlin uses the SD drive attached to the LCD
+//#define STM32_SD_LCD
+
+#ifdef STM32_SD_LCD
+ #define SD_DETECT_PIN PB9
+ #define ENABLE_SPI3
+#else
+ #define SD_DETECT_PIN PA3
+#endif
diff --git a/buildroot/share/PlatformIO/ldscripts/STM32F1_SKR_MINI.ld b/buildroot/share/PlatformIO/ldscripts/STM32F1_SKR_MINI.ld
new file mode 100644
index 0000000000..1ed03caa0a
--- /dev/null
+++ b/buildroot/share/PlatformIO/ldscripts/STM32F1_SKR_MINI.ld
@@ -0,0 +1,14 @@
+MEMORY
+{
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 48K - 40
+ rom (rx) : ORIGIN = 0x08007000, LENGTH = 256K - 28K
+}
+
+/* Provide memory region aliases for common.inc */
+REGION_ALIAS("REGION_TEXT", rom);
+REGION_ALIAS("REGION_DATA", ram);
+REGION_ALIAS("REGION_BSS", ram);
+REGION_ALIAS("REGION_RODATA", rom);
+
+/* Let common.inc handle the real work. */
+INCLUDE common.inc
diff --git a/buildroot/share/PlatformIO/scripts/STM32F1_SKR_MINI.py b/buildroot/share/PlatformIO/scripts/STM32F1_SKR_MINI.py
new file mode 100644
index 0000000000..0ef67ee602
--- /dev/null
+++ b/buildroot/share/PlatformIO/scripts/STM32F1_SKR_MINI.py
@@ -0,0 +1,8 @@
+Import("env")
+
+# Relocate firmware from 0x08000000 to 0x08007000
+for define in env['CPPDEFINES']:
+ if define[0] == "VECT_TAB_ADDR":
+ env['CPPDEFINES'].remove(define)
+env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000"))
+env.Replace(LDSCRIPT_PATH="buildroot/share/PlatformIO/ldscripts/STM32F1_SKR_MINI.ld")
diff --git a/platformio.ini b/platformio.ini
index 96f33b3eba..6953a9caec 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -272,6 +272,32 @@ lib_ldf_mode = 1
src_filter = ${common.default_src_filter} +
monitor_speed = 250000
+#
+# BIGTREE_SKR_MINI
+#
+[env:BIGTREE_SKR_MINI]
+platform = ststm32
+framework = arduino
+board = genericSTM32F103RC
+extra_scripts = buildroot/share/PlatformIO/scripts/STM32F1_SKR_MINI.py
+build_flags = !python Marlin/src/HAL/HAL_STM32F1/STM32F1_flag_script.py
+ ${common.build_flags}
+ -g
+lib_deps = ${common.lib_deps}
+lib_ignore = U8glib-HAL
+ c1921b4
+ libf3c
+ lib066
+ Adafruit NeoPixel_ID28
+ Adafruit NeoPixel
+ libf3e
+ TMC26XStepper
+lib_ldf_mode = 1
+src_filter = ${common.default_src_filter} +
+monitor_speed = 115200
+upload_protocol = stlink
+debug_tool = stlink
+
#
# STM32F4
#