Bläddra i källkod

MKS Robin E3 / E3D support (#17569)

Co-authored-by: Scott Lahteine <github@thinkyhead.com>
mks-viva 4 år sedan
förälder
incheckning
bc856fd8ec
Inget konto är kopplat till bidragsgivarens mejladress

+ 2
- 0
Marlin/src/core/boards.h Visa fil

@@ -298,6 +298,8 @@
298 298
 #define BOARD_GTM32_MINI              4021  // STM32F103VET6 controller
299 299
 #define BOARD_GTM32_MINI_A30          4022  // STM32F103VET6 controller
300 300
 #define BOARD_GTM32_REV_B             4023  // STM32F103VET6 controller
301
+#define BOARD_MKS_ROBIN_E3D           4024  // MKS Robin E3D(STM32F103RCT6)
302
+#define BOARD_MKS_ROBIN_E3            4025  // MKS Robin E3(STM32F103RCT6)
301 303
 
302 304
 //
303 305
 // ARM Cortex-M4F

+ 4
- 0
Marlin/src/pins/pins.h Visa fil

@@ -516,6 +516,10 @@
516 516
   #include "stm32f1/pins_MKS_ROBIN_LITE3.h"     // STM32F1                                env:mks_robin_lite3
517 517
 #elif MB(MKS_ROBIN_PRO)
518 518
   #include "stm32f1/pins_MKS_ROBIN_PRO.h"       // STM32F1                                env:mks_robin_pro
519
+#elif MB(MKS_ROBIN_E3D)
520
+  #include "stm32f1/pins_MKS_ROBIN_E3D.h"       // STM32F1                                env:mks_robin_e3
521
+#elif MB(MKS_ROBIN_E3)
522
+  #include "stm32f1/pins_MKS_ROBIN_E3.h"        // STM32F1                                env:mks_robin_e3
519 523
 
520 524
 //
521 525
 // ARM Cortex-M4F

+ 178
- 0
Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3.h Visa fil

@@ -0,0 +1,178 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2019 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
+#pragma once
23
+
24
+/**
25
+ * MKS Robin E3D (STM32F103RCT6) board pin assignments
26
+ */
27
+
28
+#ifndef __STM32F1__
29
+  #error "Oops! Select an STM32F1 board in 'Tools > Board.'"
30
+#elif HOTENDS > 1 || E_STEPPERS > 1
31
+  #error "MKS Robin E3D supports up to 1 hotends / E-steppers. Comment out this line to continue."
32
+#endif
33
+
34
+#ifndef BOARD_INFO_NAME
35
+  #define BOARD_INFO_NAME "MKS Robin E3D"
36
+#endif
37
+#define BOARD_WEBSITE_URL "github.com/makerbase-mks"
38
+
39
+//#define DISABLE_DEBUG
40
+#define DISABLE_JTAG
41
+#define ENABLE_SPI2
42
+
43
+//
44
+// Servos
45
+//
46
+#define SERVO0_PIN                          PA3
47
+
48
+//
49
+// Limit Switches
50
+//
51
+#define X_STOP_PIN                          PA12
52
+#define Y_STOP_PIN                          PA11
53
+#define Z_MIN_PIN                           PC6
54
+#define Z_MAX_PIN                           PB1
55
+
56
+//
57
+// Steppers
58
+//
59
+#define X_STEP_PIN                          PC0
60
+#define X_DIR_PIN                           PB2
61
+#define X_ENABLE_PIN                        PC13
62
+
63
+#define Y_STEP_PIN                          PC2
64
+#define Y_DIR_PIN                           PB9
65
+#define Y_ENABLE_PIN                        PB12
66
+
67
+#define Z_STEP_PIN                          PB7
68
+#define Z_DIR_PIN                           PB6
69
+#define Z_ENABLE_PIN                        PB8
70
+
71
+#define E0_STEP_PIN                         PB4
72
+#define E0_DIR_PIN                          PB3
73
+#define E0_ENABLE_PIN                       PB5
74
+
75
+#if HAS_TMC220x
76
+  /**
77
+   * TMC2208/TMC2209 stepper drivers
78
+   *
79
+   * Hardware serial communication ports.
80
+   * If undefined software serial is used according to the pins below
81
+   */
82
+  //#define X_HARDWARE_SERIAL  Serial1
83
+  //#define Y_HARDWARE_SERIAL  Serial1
84
+  //#define Z_HARDWARE_SERIAL  Serial1
85
+  //#define E0_HARDWARE_SERIAL Serial1
86
+
87
+  //
88
+  // Software serial
89
+  //
90
+  #define X_SERIAL_TX_PIN                   PC7
91
+  #define X_SERIAL_RX_PIN                   PC7
92
+
93
+  #define Y_SERIAL_TX_PIN                   PD2
94
+  #define Y_SERIAL_RX_PIN                   PD2
95
+
96
+  #define Z_SERIAL_TX_PIN                   PC12
97
+  #define Z_SERIAL_RX_PIN                   PC12
98
+
99
+  #define E0_SERIAL_TX_PIN                  PC11
100
+  #define E0_SERIAL_RX_PIN                  PC11
101
+
102
+  // Reduce baud rate to improve software serial reliability
103
+  #define TMC_BAUD_RATE 19200
104
+#endif
105
+
106
+//
107
+// Heaters 0,1 / Fans / Bed
108
+//
109
+#define HEATER_0_PIN                        PC9
110
+#define FAN_PIN                             PA8
111
+#define HEATER_BED_PIN                      PC8
112
+
113
+//
114
+// Temperature Sensors
115
+//
116
+#define TEMP_BED_PIN                        PA1   //TB
117
+#define TEMP_0_PIN                          PA0   //TH1
118
+
119
+#define FIL_RUNOUT_PIN                      PB10  // MT_DET
120
+
121
+//
122
+// LCD Pins
123
+//
124
+#if HAS_SPI_LCD
125
+
126
+  #define BEEPER_PIN                        PC1
127
+  #define BTN_ENC                           PC3
128
+  #define LCD_PINS_ENABLE                   PA4
129
+  #define LCD_PINS_RS                       PA5
130
+  #define BTN_EN1                           PB11
131
+  #define BTN_EN2                           PB0
132
+
133
+  // MKS MINI12864 and MKS LCD12864B; If using MKS LCD12864A (Need to remove RPK2 resistor)
134
+  #if ENABLED(MKS_MINI_12864)
135
+
136
+    #define LCD_BACKLIGHT_PIN               -1
137
+    #define LCD_RESET_PIN                   -1
138
+    #define DOGLCD_A0                       PC4
139
+    #define DOGLCD_CS                       PA7
140
+    #define DOGLCD_SCK                      PB13
141
+    #define DOGLCD_MOSI                     PB15
142
+
143
+    // Required for MKS_MINI_12864 with this board
144
+    #define MKS_LCD12864B
145
+    #undef SHOW_BOOTSCREEN
146
+
147
+  #else                                           // !MKS_MINI_12864
148
+
149
+    #define LCD_PINS_D4                     PA6
150
+    #if ENABLED(ULTIPANEL)
151
+      #define LCD_PINS_D5                   PA7
152
+      #define LCD_PINS_D6                   PC4
153
+      #define LCD_PINS_D7                   PC5
154
+    #endif
155
+
156
+  #endif // !MKS_MINI_12864
157
+
158
+#endif // HAS_SPI_LCD
159
+
160
+//
161
+// SD Card
162
+//
163
+#define ENABLE_SPI2
164
+#define SD_DETECT_PIN                       PC10
165
+#define SCK_PIN                             PB13
166
+#define MISO_PIN                            PB14
167
+#define MOSI_PIN                            PB15
168
+#define SS_PIN                              PA15
169
+
170
+#ifndef ST7920_DELAY_1
171
+  #define ST7920_DELAY_1           DELAY_NS(125)
172
+#endif
173
+#ifndef ST7920_DELAY_2
174
+  #define ST7920_DELAY_2           DELAY_NS(125)
175
+#endif
176
+#ifndef ST7920_DELAY_3
177
+  #define ST7920_DELAY_3           DELAY_NS(125)
178
+#endif

+ 205
- 0
Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3D.h Visa fil

@@ -0,0 +1,205 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2019 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
+#pragma once
23
+
24
+/**
25
+ * MKS Robin E3D (STM32F103RCT6) board pin assignments
26
+ */
27
+
28
+#ifndef __STM32F1__
29
+  #error "Oops! Select an STM32F1 board in 'Tools > Board.'"
30
+#elif HOTENDS > 1 || E_STEPPERS > 1
31
+  #error "MKS Robin E3D supports up to 1 hotends / E-steppers. Comment out this line to continue."
32
+#endif
33
+
34
+#ifndef BOARD_INFO_NAME
35
+  #define BOARD_INFO_NAME "MKS Robin E3D"
36
+#endif
37
+#define BOARD_WEBSITE_URL "github.com/makerbase-mks"
38
+
39
+//#define DISABLE_DEBUG
40
+#define DISABLE_JTAG
41
+#define ENABLE_SPI2
42
+
43
+//
44
+// Servos
45
+//
46
+#define SERVO0_PIN                          PA3
47
+
48
+//
49
+// Limit Switches
50
+//
51
+#define X_STOP_PIN                          PA12
52
+#define Y_STOP_PIN                          PA11
53
+#define Z_MIN_PIN                           PC6
54
+#define Z_MAX_PIN                           PB1
55
+
56
+//
57
+// Steppers
58
+//
59
+#define X_STEP_PIN                          PC0
60
+#define X_DIR_PIN                           PB2
61
+#define X_ENABLE_PIN                        PC13
62
+#ifndef X_CS_PIN
63
+  #define X_CS_PIN                          PC7
64
+#endif
65
+
66
+#define Y_STEP_PIN                          PC2
67
+#define Y_DIR_PIN                           PB9
68
+#define Y_ENABLE_PIN                        PB12
69
+#ifndef Y_CS_PIN
70
+  #define Y_CS_PIN                          PD2
71
+#endif
72
+
73
+#define Z_STEP_PIN                          PB7
74
+#define Z_DIR_PIN                           PB6
75
+#define Z_ENABLE_PIN                        PB8
76
+#ifndef Z_CS_PIN
77
+  #define Z_CS_PIN                          PC12
78
+#endif
79
+
80
+#define E0_STEP_PIN                         PB4
81
+#define E0_DIR_PIN                          PB3
82
+#define E0_ENABLE_PIN                       PB5
83
+#ifndef E0_CS_PIN
84
+  #define E0_CS_PIN                         PC11
85
+#endif
86
+
87
+//
88
+// Software SPI pins for TMC2130 stepper drivers
89
+//
90
+#if ENABLED(TMC_USE_SW_SPI)
91
+  #ifndef TMC_SW_MOSI
92
+    #define TMC_SW_MOSI                     PB15
93
+  #endif
94
+  #ifndef TMC_SW_MISO
95
+    #define TMC_SW_MISO                     PB14
96
+  #endif
97
+  #ifndef TMC_SW_SCK
98
+    #define TMC_SW_SCK                      PB13
99
+  #endif
100
+#endif
101
+
102
+#if HAS_TMC220x
103
+  /**
104
+   * TMC2208/TMC2209 stepper drivers
105
+   *
106
+   * Hardware serial communication ports.
107
+   * If undefined software serial is used according to the pins below
108
+   */
109
+  //#define X_HARDWARE_SERIAL  Serial1
110
+  //#define Y_HARDWARE_SERIAL  Serial1
111
+  //#define Z_HARDWARE_SERIAL  Serial1
112
+  //#define E0_HARDWARE_SERIAL Serial1
113
+
114
+  //
115
+  // Software serial
116
+  //
117
+  #define X_SERIAL_TX_PIN                   PC7
118
+  #define X_SERIAL_RX_PIN                   PC7
119
+
120
+  #define Y_SERIAL_TX_PIN                   PD2
121
+  #define Y_SERIAL_RX_PIN                   PD2
122
+
123
+  #define Z_SERIAL_TX_PIN                   PC12
124
+  #define Z_SERIAL_RX_PIN                   PC12
125
+
126
+  #define E0_SERIAL_TX_PIN                  PC11
127
+  #define E0_SERIAL_RX_PIN                  PC11
128
+
129
+  // Reduce baud rate to improve software serial reliability
130
+  #define TMC_BAUD_RATE 19200
131
+#endif
132
+
133
+//
134
+// Heaters 0,1 / Fans / Bed
135
+//
136
+#define HEATER_0_PIN                        PC9
137
+#define FAN_PIN                             PA8
138
+#define HEATER_BED_PIN                      PC8
139
+
140
+//
141
+// Temperature Sensors
142
+//
143
+#define TEMP_BED_PIN                        PA1   //TB
144
+#define TEMP_0_PIN                          PA0   //TH1
145
+
146
+#define FIL_RUNOUT_PIN                      PB10  // MT_DET
147
+
148
+//
149
+// LCD Pins
150
+//
151
+#if HAS_SPI_LCD
152
+
153
+  #define BEEPER_PIN                        PC1
154
+  #define BTN_ENC                           PC3
155
+  #define LCD_PINS_ENABLE                   PA4
156
+  #define LCD_PINS_RS                       PA5
157
+  #define BTN_EN1                           PB11
158
+  #define BTN_EN2                           PB0
159
+
160
+  // MKS MINI12864 and MKS LCD12864B; If using MKS LCD12864A (Need to remove RPK2 resistor)
161
+  #if ENABLED(MKS_MINI_12864)
162
+
163
+    #define LCD_BACKLIGHT_PIN               -1
164
+    #define LCD_RESET_PIN                   -1
165
+    #define DOGLCD_A0                       PC4
166
+    #define DOGLCD_CS                       PA7
167
+    #define DOGLCD_SCK                      PB13
168
+    #define DOGLCD_MOSI                     PB15
169
+
170
+    // Required for MKS_MINI_12864 with this board
171
+    #define MKS_LCD12864B
172
+    #undef SHOW_BOOTSCREEN
173
+
174
+  #else                                           // !MKS_MINI_12864
175
+
176
+    #define LCD_PINS_D4                     PA6
177
+    #if ENABLED(ULTIPANEL)
178
+      #define LCD_PINS_D5                   PA7
179
+      #define LCD_PINS_D6                   PC4
180
+      #define LCD_PINS_D7                   PC5
181
+    #endif
182
+
183
+  #endif // !MKS_MINI_12864
184
+
185
+#endif // HAS_SPI_LCD
186
+
187
+//
188
+// SD Card
189
+//
190
+#define ENABLE_SPI2
191
+#define SD_DETECT_PIN                       PC10
192
+#define SCK_PIN                             PB13
193
+#define MISO_PIN                            PB14
194
+#define MOSI_PIN                            PB15
195
+#define SS_PIN                              PA15
196
+
197
+#ifndef ST7920_DELAY_1
198
+  #define ST7920_DELAY_1           DELAY_NS(125)
199
+#endif
200
+#ifndef ST7920_DELAY_2
201
+  #define ST7920_DELAY_2           DELAY_NS(125)
202
+#endif
203
+#ifndef ST7920_DELAY_3
204
+  #define ST7920_DELAY_3           DELAY_NS(125)
205
+#endif

+ 14
- 0
buildroot/share/PlatformIO/ldscripts/mks_robin_e3.ld Visa fil

@@ -0,0 +1,14 @@
1
+MEMORY
2
+{
3
+  ram (rwx) : ORIGIN = 0x20000000, LENGTH = 48K - 40
4
+  rom (rx)  : ORIGIN = 0x08005000, LENGTH = 256K - 20K
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

+ 40
- 0
buildroot/share/PlatformIO/scripts/mks_robin_e3.py Visa fil

@@ -0,0 +1,40 @@
1
+import os
2
+Import("env")
3
+
4
+# Relocate firmware from 0x08000000 to 0x08005000
5
+for define in env['CPPDEFINES']:
6
+    if define[0] == "VECT_TAB_ADDR":
7
+        env['CPPDEFINES'].remove(define)
8
+env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08005000"))
9
+
10
+custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin_e3.ld")
11
+for i, flag in enumerate(env["LINKFLAGS"]):
12
+    if "-Wl,-T" in flag:
13
+        env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script
14
+    elif flag == "-T":
15
+        env["LINKFLAGS"][i + 1] = custom_ld_script
16
+
17
+
18
+# Encrypt ${PROGNAME}.bin and save it as 'mksLite.bin'
19
+def encrypt(source, target, env):
20
+    import sys
21
+
22
+    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]
23
+
24
+    firmware = open(target[0].path, "rb")
25
+    robin = open(target[0].dir.path +'/Robin_e3.bin', "wb")
26
+    length = os.path.getsize(target[0].path)
27
+    position = 0
28
+    try:
29
+        while position < length:
30
+            byte = firmware.read(1)
31
+            if position >= 320 and position < 31040:
32
+                byte = chr(ord(byte) ^ key[position & 31])
33
+                if sys.version_info[0] > 2:
34
+                    byte = bytes(byte, 'latin1')
35
+            robin.write(byte)
36
+            position += 1
37
+    finally:
38
+        firmware.close()
39
+        robin.close()
40
+env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt);

+ 17
- 0
platformio.ini Visa fil

@@ -544,6 +544,23 @@ lib_deps      = ${common.lib_deps}
544 544
 lib_ignore    = Adafruit NeoPixel, SPI, TMCStepper
545 545
 
546 546
 #
547
+# MKS Robin E3D (STM32F103RCT6) and
548
+# MKS Robin E3 with TMC2209
549
+#
550
+[env:mks_robin_e3]
551
+platform          = ststm32
552
+board             = genericSTM32F103RC
553
+platform_packages = tool-stm32duino
554
+build_flags       = !python Marlin/src/HAL/STM32F1/build_flags.py
555
+  ${common.build_flags} -DDEBUG_LEVEL=0 -std=gnu++14 -DHAVE_SW_SERIAL -DSS_TIMER=4
556
+build_unflags     = -std=gnu++11
557
+extra_scripts     = buildroot/share/PlatformIO/scripts/mks_robin_e3.py
558
+src_filter        = ${common.default_src_filter} +<src/HAL/STM32F1>
559
+lib_deps          = ${common.lib_deps}
560
+  SoftwareSerialM=https://github.com/FYSETC/SoftwareSerialM/archive/master.zip
561
+lib_ignore        = Adafruit NeoPixel, SPI
562
+
563
+#
547 564
 # MKS Robin Lite/Lite2 (STM32F103RCT6)
548 565
 #
549 566
 [env:mks_robin_lite]

Laddar…
Avbryt
Spara