Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add STM32 HAL to MKS Robin E3 #21927

Merged
merged 8 commits into from
Jun 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"]
ldursw marked this conversation as resolved.
Show resolved Hide resolved
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