diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 49d91e493a2a..fa6c5208f9d4 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -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) diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h index da7bdc79e50d..6369fcd31beb 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h @@ -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 diff --git a/buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py b/buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py new file mode 100644 index 000000000000..2be5a202efed --- /dev/null +++ b/buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py @@ -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) diff --git a/ini/stm32f1-maple.ini b/ini/stm32f1-maple.ini index 7a43e2d0cb13..c42d6d261e7a 100644 --- a/ini/stm32f1-maple.ini +++ b/ini/stm32f1-maple.ini @@ -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 diff --git a/ini/stm32f1.ini b/ini/stm32f1.ini index 7bf8ea36172a..0c7cc61e9f24 100644 --- a/ini/stm32f1.ini +++ b/ini/stm32f1.ini @@ -31,6 +31,8 @@ build_flags = ${common.build_flags} -DADC_RESOLUTION=12 build_unflags = -std=gnu++11 src_filter = ${common.default_src_filter} + + +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) @@ -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 @@ -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) # @@ -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 @@ -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 @@ -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