Skip to content

Commit ce95f56

Browse files
ldurswthinkyhead
authored andcommitted
🔨 MKS Robin E3 for HAL/STM32 (MarlinFirmware#21927)
1 parent aff45fd commit ce95f56

File tree

5 files changed

+60
-8
lines changed

5 files changed

+60
-8
lines changed

Marlin/src/pins/pins.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@
503503
#elif MB(MKS_ROBIN_PRO)
504504
#include "stm32f1/pins_MKS_ROBIN_PRO.h" // STM32F1 env:mks_robin_pro
505505
#elif MB(MKS_ROBIN_E3)
506-
#include "stm32f1/pins_MKS_ROBIN_E3.h" // STM32F1 env:mks_robin_e3
506+
#include "stm32f1/pins_MKS_ROBIN_E3.h" // STM32F1 env:mks_robin_e3 env:mks_robin_e3_maple
507507
#elif MB(MKS_ROBIN_E3_V1_1)
508508
#include "stm32f1/pins_MKS_ROBIN_E3_V1_1.h" // STM32F1 env:mks_robin_e3
509509
#elif MB(MKS_ROBIN_E3D)

Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,17 @@
176176
//
177177
// SD Card
178178
//
179-
#define SPI_DEVICE 2
179+
#define SPI_DEVICE 2
180+
#define ONBOARD_SPI_DEVICE 2
181+
#define SDSS SD_SS_PIN
182+
#define SDCARD_CONNECTION ONBOARD
180183
#define SD_DETECT_PIN PC10
184+
#define ONBOARD_SD_CS_PIN SD_SS_PIN
185+
#define NO_SD_HOST_DRIVE
186+
187+
// TODO: This is the only way to set SPI for SD on STM32 (for now)
188+
#define ENABLE_SPI2
189+
#define CUSTOM_SPI_PINS
181190
#define SD_SCK_PIN PB13
182191
#define SD_MISO_PIN PB14
183192
#define SD_MOSI_PIN PB15
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#
2+
# stm32_serialbuffer.py
3+
#
4+
Import("env")
5+
6+
# Marlin has `RX_BUFFER_SIZE` and `TX_BUFFER_SIZE` to configure the
7+
# buffer size for receiving and transmitting data respectively.
8+
# Stm32duino uses another set of defines for the same purpose,
9+
# so we get the values from the Marlin configuration and set
10+
# them in `SERIAL_RX_BUFFER_SIZE` and `SERIAL_TX_BUFFER_SIZE`.
11+
# It is not possible to change the values at runtime, they must
12+
# be set with build flags.
13+
#
14+
# The script will set the value as the default one (64 bytes)
15+
# or the user-configured one, whichever is higher.
16+
mf = env["MARLIN_FEATURES"]
17+
rxBuf = str(max(64, int(mf["RX_BUFFER_SIZE"]) if "RX_BUFFER_SIZE" in mf else 0))
18+
txBuf = str(max(64, int(mf["TX_BUFFER_SIZE"]) if "TX_BUFFER_SIZE" in mf else 0))
19+
20+
build_flags = env.get('BUILD_FLAGS')
21+
build_flags.append("-DSERIAL_RX_BUFFER_SIZE=" + rxBuf)
22+
build_flags.append("-DSERIAL_TX_BUFFER_SIZE=" + txBuf)
23+
env.Replace(BUILD_FLAGS=build_flags)

ini/stm32f1-maple.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ extra_scripts = ${common_stm32f1.extra_scripts}
268268
# MKS Robin E3D (STM32F103RCT6) and
269269
# MKS Robin E3 with TMC2209
270270
#
271-
[env:mks_robin_e3]
271+
[env:mks_robin_e3_maple]
272272
platform = ${common_stm32f1.platform}
273273
extends = common_stm32f1
274274
board = genericSTM32F103RC

ini/stm32f1.ini

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ build_flags = ${common.build_flags}
3131
-DADC_RESOLUTION=12
3232
build_unflags = -std=gnu++11
3333
src_filter = ${common.default_src_filter} +<src/HAL/STM32> +<src/HAL/shared/backtrace>
34+
extra_scripts = ${common.extra_scripts}
35+
pre:buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py
3436

3537
#
3638
# BigTree SKR Mini V1.1 / SKR mini E3 / SKR E3 DIP (STM32F103RCT6 ARM Cortex-M3)
@@ -53,7 +55,7 @@ monitor_speed = 115200
5355
board_build.core = stm32
5456
board_build.variant = MARLIN_F103Rx
5557
board_build.ldscript = ldscript.ld
56-
extra_scripts = ${common.extra_scripts}
58+
extra_scripts = ${common_stm32.extra_scripts}
5759
pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
5860
buildroot/share/PlatformIO/scripts/stm32_bootloader.py
5961

@@ -136,12 +138,30 @@ build_flags = ${common_stm32.build_flags}
136138
-DENABLE_HWSERIAL3 -DTIMER_SERIAL=TIM5
137139
build_unflags = ${common_stm32.build_unflags}
138140
-DUSBCON -DUSBD_USE_CDC
139-
extra_scripts = ${common.extra_scripts}
141+
extra_scripts = ${common_stm32.extra_scripts}
140142
pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
141143
buildroot/share/PlatformIO/scripts/stm32_bootloader.py
142144
buildroot/share/PlatformIO/scripts/mks_encrypt.py
143145
lib_deps =
144146

147+
#
148+
# MKS Robin E3/E3D (STM32F103RCT6) with TMC2209
149+
#
150+
[env:mks_robin_e3]
151+
platform = ${common_stm32.platform}
152+
extends = common_STM32F103RC
153+
build_flags = ${common_stm32.build_flags}
154+
-DDEBUG_LEVEL=0 -DTIMER_SERVO=TIM5
155+
build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC
156+
monitor_speed = 115200
157+
board_build.offset = 0x5000
158+
board_build.encrypt = Yes
159+
board_build.firmware = Robin_e3.bin
160+
board_upload.offset_address = 0x08005000
161+
debug_tool = stlink
162+
extra_scripts = ${env:STM32F103RC.extra_scripts}
163+
buildroot/share/PlatformIO/scripts/mks_encrypt.py
164+
145165
#
146166
# Creality (STM32F103RET6)
147167
#
@@ -181,7 +201,7 @@ board_build.firmware = Robin_mini.bin
181201
board_build.encrypt = Yes
182202
board_upload.offset_address = 0x08007000
183203
build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC
184-
extra_scripts = ${common.extra_scripts}
204+
extra_scripts = ${common_stm32.extra_scripts}
185205
pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
186206
buildroot/share/PlatformIO/scripts/stm32_bootloader.py
187207
buildroot/share/PlatformIO/scripts/mks_encrypt.py
@@ -204,7 +224,7 @@ board_upload.offset_address = 0x08007000
204224
build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC
205225
debug_tool = jlink
206226
upload_protocol = jlink
207-
extra_scripts = ${common.extra_scripts}
227+
extra_scripts = ${common_stm32.extra_scripts}
208228
pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
209229
buildroot/share/PlatformIO/scripts/stm32_bootloader.py
210230
buildroot/share/PlatformIO/scripts/mks_encrypt.py
@@ -222,6 +242,6 @@ board_build.ldscript = ldscript.ld
222242
board_build.offset = 0x10000
223243
build_flags = ${common_stm32.build_flags} -DENABLE_HWSERIAL3 -DTIMER_SERIAL=TIM5
224244
build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC
225-
extra_scripts = ${common.extra_scripts}
245+
extra_scripts = ${common_stm32.extra_scripts}
226246
pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
227247
buildroot/share/PlatformIO/scripts/stm32_bootloader.py

0 commit comments

Comments
 (0)