Selaa lähdekoodia

Add support for MKS Robin board (#12650)

Implement initial support for MKS Robin (STM32F103ZET6) board.
Custom build script is used to generate encrypted firmware compatible with original MSK Robin bootloader (i.e. safe firmware update from SD card and possibility to go back to original close-source firmware).
jmz52 5 vuotta sitten
vanhempi
commit
33abb86b7e

+ 20
- 2
Marlin/src/HAL/HAL_STM32F1/HAL.cpp Näytä tiedosto

@@ -43,7 +43,7 @@
43 43
 // --------------------------------------------------------------------------
44 44
 
45 45
 #define __I
46
-#define __IO
46
+#define __IO volatile
47 47
  typedef struct
48 48
  {
49 49
    __I  uint32_t CPUID;                   /*!< Offset: 0x000 (R/ )  CPUID Base Register                                   */
@@ -105,7 +105,7 @@ uint8 adc_pins[] = {
105 105
     TEMP_0_PIN,
106 106
   #endif
107 107
   #if HAS_TEMP_ADC_1
108
-    TEMP_1_PIN
108
+    TEMP_1_PIN,
109 109
   #endif
110 110
   #if HAS_TEMP_ADC_2
111 111
     TEMP_2_PIN,
@@ -175,6 +175,24 @@ static void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) {
175 175
 // Public functions
176 176
 // --------------------------------------------------------------------------
177 177
 
178
+//
179
+// Leave PA11/PA12 intact if USBSerial is not used
180
+//
181
+#if SERIAL_USB
182
+  namespace wirish { namespace priv {
183
+    #if SERIAL_PORT > 0
184
+      #if SERIAL_PORT2
185
+        #if SERIAL_PORT2 > 0
186
+          void board_setup_usb(void) {}
187
+        #endif
188
+      #else
189
+        void board_setup_usb(void) {}
190
+      #endif
191
+    #endif
192
+  } }
193
+#endif
194
+
195
+
178 196
 void HAL_init(void) {
179 197
   NVIC_SetPriorityGrouping(0x3);
180 198
 }

+ 2021
- 0
Marlin/src/config/examples/Mks/Robin/Configuration.h
File diff suppressed because it is too large
Näytä tiedosto


+ 1971
- 0
Marlin/src/config/examples/Mks/Robin/Configuration_adv.h
File diff suppressed because it is too large
Näytä tiedosto


+ 1
- 0
Marlin/src/core/boards.h Näytä tiedosto

@@ -224,6 +224,7 @@
224 224
 #define BOARD_STM3R_MINI       1803   // STM32 Libmaple based stm32f1 controller
225 225
 #define BOARD_GTM32_PRO_VB     1805   // STM32f103VET6 controller
226 226
 #define BOARD_MORPHEUS         1806   // STM32F103C8/STM32F103CB Libmaple based stm32f1 controller
227
+#define BOARD_MKS_ROBIN        1808   // MKS Robin / STM32F103ZET6
227 228
 
228 229
 //
229 230
 // STM32 ARM Cortex-M4F

+ 2
- 0
Marlin/src/pins/pins.h Näytä tiedosto

@@ -392,6 +392,8 @@
392 392
   #include "pins_GTM32_PRO_VB.h"      // STM32F1                                    env:STM32F1
393 393
 #elif MB(MORPHEUS)
394 394
   #include "pins_MORPHEUS.h"          // STM32F1                                    env:STM32F1
395
+#elif MB(MKS_ROBIN)
396
+  #include "pins_MKS_ROBIN.h"         // STM32F1                                    env:STM32F1
395 397
 
396 398
 //
397 399
 // STM32 ARM Cortex-M4F

+ 109
- 0
Marlin/src/pins/pins_MKS_ROBIN.h Näytä tiedosto

@@ -0,0 +1,109 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+/**
24
+ * MKS Robin (STM32F130ZET6) board pin assignments
25
+ */
26
+
27
+#ifndef __STM32F1__
28
+  #error "Oops! Select an STM32F1 board in 'Tools > Board.'"
29
+#endif
30
+
31
+#if HOTENDS > 2 || E_STEPPERS > 2
32
+  #error "MKS Robin supports up to 2 hotends / E-steppers. Comment out this line to continue."
33
+#endif
34
+
35
+#define BOARD_NAME "MKS Robin / STM32F103ZET6"
36
+
37
+//
38
+// Release PB4 (Y_ENABLE_PIN) from JTAG NRST role
39
+//
40
+#define DISABLE_DEBUG
41
+
42
+//
43
+// Limit Switches
44
+//
45
+#define X_MIN_PIN          PB12
46
+#define X_MAX_PIN          PB0
47
+#define Y_MIN_PIN          PC5
48
+#define Y_MAX_PIN          PC4
49
+#define Z_MIN_PIN          PA4
50
+#define Z_MAX_PIN          PF7
51
+
52
+//
53
+// Steppers
54
+//
55
+#define X_ENABLE_PIN       PB9
56
+#define X_STEP_PIN         PB8
57
+#define X_DIR_PIN          PB5
58
+
59
+#define Y_ENABLE_PIN       PB4
60
+#define Y_STEP_PIN         PG15
61
+#define Y_DIR_PIN          PG10
62
+
63
+#define Z_ENABLE_PIN       PD7
64
+#define Z_STEP_PIN         PD3
65
+#define Z_DIR_PIN          PG14
66
+
67
+#define E0_ENABLE_PIN      PG13
68
+#define E0_STEP_PIN        PG8
69
+#define E0_DIR_PIN         PA15
70
+
71
+#define E1_ENABLE_PIN      PA12
72
+#define E1_STEP_PIN        PA11
73
+#define E1_DIR_PIN         PA8
74
+
75
+//
76
+// Temperature Sensors
77
+//
78
+#define TEMP_0_PIN         PC1   // TH1
79
+#define TEMP_1_PIN         PC2   // TH2
80
+#define TEMP_BED_PIN       PC0   // TB1
81
+
82
+//
83
+// Heaters / Fans
84
+//
85
+#define HEATER_0_PIN       PC7   // HEATER1
86
+#define HEATER_1_PIN       PA6   // HEATER2
87
+#define HEATER_BED_PIN     PC6   // HOT BED
88
+
89
+#define FAN_PIN            PA7   // FAN
90
+
91
+#define SERVO0_PIN         PC3  // XS1 - 5
92
+#define SERVO1_PIN         PA1  // XS1 - 6
93
+#define SERVO2_PIN         PF9  // XS2 - 5
94
+#define SERVO3_PIN         PF8  // XS2 - 6
95
+
96
+/**
97
+ * Note: MKS Robin board is using SPI2 interface, make sure your stm32duino library is configured accordingly
98
+ */
99
+//#define MAX6675_SS_PIN     PE5  // TC1 - CS1
100
+//#define MAX6675_SS_PIN     PE6  // TC2 - CS2
101
+
102
+#define POWER_LOSS_PIN     PA2   // PW_DET
103
+#define PS_ON_PIN          PA3   // PW_OFF
104
+#define FIL_RUNOUT_PIN     PF11  // MT_DET
105
+
106
+#define BEEPER_PIN         PC13
107
+#define LED_PIN            PB2
108
+
109
+#define SDSS               -1

+ 14
- 0
buildroot/share/PlatformIO/ldscripts/mks_robin.ld Näytä tiedosto

@@ -0,0 +1,14 @@
1
+MEMORY
2
+{
3
+  ram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K - 40
4
+  rom (rx)  : ORIGIN = 0x08007000, LENGTH = 512K - 28K
5
+}
6
+
7
+/* Provide memory region aliases for common.inc */
8
+REGION_ALIAS("REGION_TEXT", rom);
9
+REGION_ALIAS("REGION_DATA", ram);
10
+REGION_ALIAS("REGION_BSS", ram);
11
+REGION_ALIAS("REGION_RODATA", rom);
12
+
13
+/* Let common.inc handle the real work. */
14
+INCLUDE common.inc

+ 28
- 0
buildroot/share/PlatformIO/scripts/mks_robin.py Näytä tiedosto

@@ -0,0 +1,28 @@
1
+Import("env")
2
+
3
+# Relocate firmware from 0x08000000 to 0x08007000
4
+env['CPPDEFINES'].remove(("VECT_TAB_ADDR", 134217728))
5
+env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000"))
6
+env.Replace(LDSCRIPT_PATH="buildroot/share/PlatformIO/ldscripts/mks_robin.ld")
7
+
8
+# Encrypt ${PROGNAME}.bin and save it as 'Robin.bin'
9
+def encrypt(source, target, env):
10
+    import os
11
+
12
+    key = [0xA3, 0xBD, 0xAD, 0x0D, 0x41, 0x11, 0xBB, 0x8D, 0xDC, 0x80, 0x2D, 0xD0, 0xD2, 0xC4, 0x9B, 0x1E, 0x26, 0xEB, 0xE3, 0x33, 0x4A, 0x15, 0xE4, 0x0A, 0xB3, 0xB1, 0x3C, 0x93, 0xBB, 0xAF, 0xF7, 0x3E]
13
+
14
+    firmware = open(target[0].path, "rb")
15
+    robin = open(target[0].dir.path +'/Robin.bin', "wb")
16
+    length = os.path.getsize(target[0].path)
17
+    position = 0
18
+    try:
19
+        while position < length:
20
+            byte = firmware.read(1)
21
+            if position >= 320 and position < 31040:
22
+                byte = chr(ord(byte) ^ key[position & 31])
23
+            robin.write(byte)
24
+            position += 1
25
+    finally:
26
+        firmware.close()
27
+        robin.close()
28
+env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt);

+ 20
- 0
platformio.ini Näytä tiedosto

@@ -294,6 +294,26 @@ src_filter    = ${common.default_src_filter} +<src/HAL/HAL_STM32F4>
294 294
 monitor_speed = 250000
295 295
 
296 296
 #
297
+# MKS Robin (STM32F103ZET6)
298
+#
299
+[env:mks_robin]
300
+platform      = ststm32
301
+framework     = arduino
302
+board         = genericSTM32F103ZE
303
+extra_scripts = buildroot/share/PlatformIO/scripts/mks_robin.py
304
+build_flags   = !python Marlin/src/HAL/HAL_STM32F1/stm32f1_flag_script.py
305
+  ${common.build_flags}
306
+src_filter    = ${common.default_src_filter} +<src/HAL/HAL_STM32F1>
307
+lib_deps      = ${common.lib_deps}
308
+lib_ignore    = c1921b4
309
+  libf3c
310
+  lib066
311
+  Adafruit NeoPixel_ID28
312
+  Adafruit NeoPixel
313
+  libf3e
314
+  TMC26XStepper
315
+
316
+#
297 317
 # Teensy 3.5 / 3.6 (ARM Cortex-M4)
298 318
 #
299 319
 [env:teensy35]

Loading…
Peruuta
Tallenna