Skip to content

Commit

Permalink
🔨 MKS Robin E3 for HAL/STM32 (MarlinFirmware#21927)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldursw authored and thinkyhead committed Jun 15, 2021
1 parent aff45fd commit ce95f56
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Marlin/src/pins/pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@
#elif MB(MKS_ROBIN_PRO)
#include "stm32f1/pins_MKS_ROBIN_PRO.h" // STM32F1 env:mks_robin_pro
#elif MB(MKS_ROBIN_E3)
#include "stm32f1/pins_MKS_ROBIN_E3.h" // STM32F1 env:mks_robin_e3
#include "stm32f1/pins_MKS_ROBIN_E3.h" // STM32F1 env:mks_robin_e3 env:mks_robin_e3_maple
#elif MB(MKS_ROBIN_E3_V1_1)
#include "stm32f1/pins_MKS_ROBIN_E3_V1_1.h" // STM32F1 env:mks_robin_e3
#elif MB(MKS_ROBIN_E3D)
Expand Down
11 changes: 10 additions & 1 deletion Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,17 @@
//
// SD Card
//
#define SPI_DEVICE 2
#define SPI_DEVICE 2
#define ONBOARD_SPI_DEVICE 2
#define SDSS SD_SS_PIN
#define SDCARD_CONNECTION ONBOARD
#define SD_DETECT_PIN PC10
#define ONBOARD_SD_CS_PIN SD_SS_PIN
#define NO_SD_HOST_DRIVE

// TODO: This is the only way to set SPI for SD on STM32 (for now)
#define ENABLE_SPI2
#define CUSTOM_SPI_PINS
#define SD_SCK_PIN PB13
#define SD_MISO_PIN PB14
#define SD_MOSI_PIN PB15
Expand Down
23 changes: 23 additions & 0 deletions buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#
# stm32_serialbuffer.py
#
Import("env")

# Marlin has `RX_BUFFER_SIZE` and `TX_BUFFER_SIZE` to configure the
# buffer size for receiving and transmitting data respectively.
# Stm32duino uses another set of defines for the same purpose,
# so we get the values from the Marlin configuration and set
# them in `SERIAL_RX_BUFFER_SIZE` and `SERIAL_TX_BUFFER_SIZE`.
# It is not possible to change the values at runtime, they must
# be set with build flags.
#
# The script will set the value as the default one (64 bytes)
# or the user-configured one, whichever is higher.
mf = env["MARLIN_FEATURES"]
rxBuf = str(max(64, int(mf["RX_BUFFER_SIZE"]) if "RX_BUFFER_SIZE" in mf else 0))
txBuf = str(max(64, int(mf["TX_BUFFER_SIZE"]) if "TX_BUFFER_SIZE" in mf else 0))

build_flags = env.get('BUILD_FLAGS')
build_flags.append("-DSERIAL_RX_BUFFER_SIZE=" + rxBuf)
build_flags.append("-DSERIAL_TX_BUFFER_SIZE=" + txBuf)
env.Replace(BUILD_FLAGS=build_flags)
2 changes: 1 addition & 1 deletion ini/stm32f1-maple.ini
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ extra_scripts = ${common_stm32f1.extra_scripts}
# MKS Robin E3D (STM32F103RCT6) and
# MKS Robin E3 with TMC2209
#
[env:mks_robin_e3]
[env:mks_robin_e3_maple]
platform = ${common_stm32f1.platform}
extends = common_stm32f1
board = genericSTM32F103RC
Expand Down
30 changes: 25 additions & 5 deletions ini/stm32f1.ini
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ build_flags = ${common.build_flags}
-DADC_RESOLUTION=12
build_unflags = -std=gnu++11
src_filter = ${common.default_src_filter} +<src/HAL/STM32> +<src/HAL/shared/backtrace>
extra_scripts = ${common.extra_scripts}
pre:buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py

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

Expand Down Expand Up @@ -136,12 +138,30 @@ build_flags = ${common_stm32.build_flags}
-DENABLE_HWSERIAL3 -DTIMER_SERIAL=TIM5
build_unflags = ${common_stm32.build_unflags}
-DUSBCON -DUSBD_USE_CDC
extra_scripts = ${common.extra_scripts}
extra_scripts = ${common_stm32.extra_scripts}
pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
buildroot/share/PlatformIO/scripts/stm32_bootloader.py
buildroot/share/PlatformIO/scripts/mks_encrypt.py
lib_deps =

#
# MKS Robin E3/E3D (STM32F103RCT6) with TMC2209
#
[env:mks_robin_e3]
platform = ${common_stm32.platform}
extends = common_STM32F103RC
build_flags = ${common_stm32.build_flags}
-DDEBUG_LEVEL=0 -DTIMER_SERVO=TIM5
build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC
monitor_speed = 115200
board_build.offset = 0x5000
board_build.encrypt = Yes
board_build.firmware = Robin_e3.bin
board_upload.offset_address = 0x08005000
debug_tool = stlink
extra_scripts = ${env:STM32F103RC.extra_scripts}
buildroot/share/PlatformIO/scripts/mks_encrypt.py

#
# Creality (STM32F103RET6)
#
Expand Down Expand Up @@ -181,7 +201,7 @@ board_build.firmware = Robin_mini.bin
board_build.encrypt = Yes
board_upload.offset_address = 0x08007000
build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC
extra_scripts = ${common.extra_scripts}
extra_scripts = ${common_stm32.extra_scripts}
pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
buildroot/share/PlatformIO/scripts/stm32_bootloader.py
buildroot/share/PlatformIO/scripts/mks_encrypt.py
Expand All @@ -204,7 +224,7 @@ board_upload.offset_address = 0x08007000
build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC
debug_tool = jlink
upload_protocol = jlink
extra_scripts = ${common.extra_scripts}
extra_scripts = ${common_stm32.extra_scripts}
pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
buildroot/share/PlatformIO/scripts/stm32_bootloader.py
buildroot/share/PlatformIO/scripts/mks_encrypt.py
Expand All @@ -222,6 +242,6 @@ board_build.ldscript = ldscript.ld
board_build.offset = 0x10000
build_flags = ${common_stm32.build_flags} -DENABLE_HWSERIAL3 -DTIMER_SERIAL=TIM5
build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC
extra_scripts = ${common.extra_scripts}
extra_scripts = ${common_stm32.extra_scripts}
pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
buildroot/share/PlatformIO/scripts/stm32_bootloader.py

0 comments on commit ce95f56

Please sign in to comment.