From a31e65e30b0d71da113db8540a8c49aa3f07034c Mon Sep 17 00:00:00 2001 From: EvilGremlin <22657714+EvilGremlin@users.noreply.github.com> Date: Mon, 22 Aug 2022 18:31:02 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Robin=20Nano=20v1=20CDC=20(USB=20mo?= =?UTF-8?q?d)=20(#24619)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/pins/pins.h | 6 +- .../src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h | 4 +- .../pins/stm32f1/pins_MKS_ROBIN_NANO_common.h | 13 ++++- .../PlatformIO/scripts/offset_and_rename.py | 7 ++- buildroot/tests/mks_robin_nano_v1_2_usbmod | 19 ++++++ buildroot/tests/mks_robin_nano_v1_3_f4_usbmod | 19 ++++++ .../{mks_robin_nano35 => mks_robin_nano_v1v2} | 0 ...nano35_maple => mks_robin_nano_v1v2_maple} | 0 ini/renamed.ini | 8 +++ ini/stm32f1-maple.ini | 6 +- ini/stm32f1.ini | 24 ++++++-- ini/stm32f4.ini | 58 +++++++++++-------- 12 files changed, 123 insertions(+), 41 deletions(-) create mode 100755 buildroot/tests/mks_robin_nano_v1_2_usbmod create mode 100755 buildroot/tests/mks_robin_nano_v1_3_f4_usbmod rename buildroot/tests/{mks_robin_nano35 => mks_robin_nano_v1v2} (100%) rename buildroot/tests/{mks_robin_nano35_maple => mks_robin_nano_v1v2_maple} (100%) diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 37e222d004..1bd58487e7 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -512,9 +512,9 @@ #elif MB(MKS_ROBIN_MINI) #include "stm32f1/pins_MKS_ROBIN_MINI.h" // STM32F1 env:mks_robin_mini env:mks_robin_mini_maple #elif MB(MKS_ROBIN_NANO) - #include "stm32f1/pins_MKS_ROBIN_NANO.h" // STM32F1 env:mks_robin_nano35 env:mks_robin_nano35_maple + #include "stm32f1/pins_MKS_ROBIN_NANO.h" // STM32F1 env:mks_robin_nano_v1v2 env:mks_robin_nano_v1v2_maple env:mks_robin_nano_v1_2_usbmod #elif MB(MKS_ROBIN_NANO_V2) - #include "stm32f1/pins_MKS_ROBIN_NANO_V2.h" // STM32F1 env:mks_robin_nano35 env:mks_robin_nano35_maple + #include "stm32f1/pins_MKS_ROBIN_NANO_V2.h" // STM32F1 env:mks_robin_nano_v1v2 env:mks_robin_nano3_v1v2_maple #elif MB(MKS_ROBIN_LITE) #include "stm32f1/pins_MKS_ROBIN_LITE.h" // STM32F1 env:mks_robin_lite env:mks_robin_lite_maple #elif MB(MKS_ROBIN_LITE3) @@ -694,7 +694,7 @@ #elif MB(OPULO_LUMEN_REV3) #include "stm32f4/pins_OPULO_LUMEN_REV3.h" // STM32F4 env:Opulo_Lumen_REV3 #elif MB(MKS_ROBIN_NANO_V1_3_F4) - #include "stm32f4/pins_MKS_ROBIN_NANO_V1_3_F4.h" // STM32F4 env:mks_robin_nano_v1_3_f4 + #include "stm32f4/pins_MKS_ROBIN_NANO_V1_3_F4.h" // STM32F4 env:mks_robin_nano_v1_3_f4 env:mks_robin_nano_v1_3_f4_usbmod #elif MB(MKS_EAGLE) #include "stm32f4/pins_MKS_EAGLE.h" // STM32F4 env:mks_eagle #elif MB(ARTILLERY_RUBY) diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h index 9ce5d270b5..9c6373bef9 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h @@ -35,7 +35,9 @@ #define BOARD_INFO_NAME "MKS Robin nano V2.0" -#define BOARD_NO_NATIVE_USB +#ifndef USB_MOD + #define BOARD_NO_NATIVE_USB +#endif #define USES_DIAG_PINS // Avoid conflict with TIMER_SERVO when using the STM32 HAL diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_common.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_common.h index 0eb7bbdffe..6f1a790580 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_common.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_common.h @@ -29,7 +29,9 @@ #error "MKS Robin nano boards support up to 2 hotends / E steppers." #endif -#define BOARD_NO_NATIVE_USB +#ifndef USB_MOD + #define BOARD_NO_NATIVE_USB +#endif // Avoid conflict with TIMER_SERVO when using the STM32 HAL #define TEMP_TIMER 5 @@ -58,9 +60,14 @@ // Limit Switches // #define X_STOP_PIN PA15 -#define Y_STOP_PIN PA12 -#define Z_MIN_PIN PA11 #define Z_MAX_PIN PC4 +#ifndef USB_MOD + #define Y_STOP_PIN PA12 + #define Z_MIN_PIN PA11 +#else + #define Y_STOP_PIN PB10 + #define Z_MIN_PIN PB11 +#endif // // Steppers diff --git a/buildroot/share/PlatformIO/scripts/offset_and_rename.py b/buildroot/share/PlatformIO/scripts/offset_and_rename.py index 98b345d698..6a095210ec 100644 --- a/buildroot/share/PlatformIO/scripts/offset_and_rename.py +++ b/buildroot/share/PlatformIO/scripts/offset_and_rename.py @@ -53,8 +53,13 @@ if pioutil.is_pio_build(): # if 'rename' in board_keys: + # If FIRMWARE_BIN is defined by config, override all + mf = env["MARLIN_FEATURES"] + if "FIRMWARE_BIN" in mf: new_name = mf["FIRMWARE_BIN"] + else: new_name = board.get("build.rename") + def rename_target(source, target, env): from pathlib import Path - Path(target[0].path).replace(Path(target[0].dir.path, board.get("build.rename"))) + Path(target[0].path).replace(Path(target[0].dir.path, new_name)) marlin.add_post_action(rename_target) diff --git a/buildroot/tests/mks_robin_nano_v1_2_usbmod b/buildroot/tests/mks_robin_nano_v1_2_usbmod new file mode 100755 index 0000000000..a3ec1d4075 --- /dev/null +++ b/buildroot/tests/mks_robin_nano_v1_2_usbmod @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# +# Build tests for MKS Robin nano +# (STM32F1 genericSTM32F103VE) +# + +# exit on first failure +set -e + +# +# MKS/ZNP Robin nano v1.2 Emulated DOGM FSMC and native USB mod +# +use_example_configs Mks/Robin +opt_add USB_MOD +opt_set MOTHERBOARD BOARD_MKS_ROBIN_NANO SERIAL_PORT -1 +exec_test $1 $2 "MKS/ZNP Robin nano v1.2 Emulated DOGM FSMC and native USB mod" "$3" + +# cleanup +restore_configs diff --git a/buildroot/tests/mks_robin_nano_v1_3_f4_usbmod b/buildroot/tests/mks_robin_nano_v1_3_f4_usbmod new file mode 100755 index 0000000000..5213eb84f7 --- /dev/null +++ b/buildroot/tests/mks_robin_nano_v1_3_f4_usbmod @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# +# Build tests for MKS Robin nano +# (STM32F4 genericSTM32F407VE) +# + +# exit on first failure +set -e + +# +# MKS/ZNP Robin nano v1.3 Emulated DOGM FSMC and native USB mod +# +use_example_configs Mks/Robin +opt_add USB_MOD +opt_set MOTHERBOARD BOARD_MKS_ROBIN_NANO_V1_3_F4 SERIAL_PORT -1 +exec_test $1 $2 "MKS/ZNP Robin nano v1.3 Emulated DOGM FSMC and native USB mod" "$3" + +# cleanup +restore_configs diff --git a/buildroot/tests/mks_robin_nano35 b/buildroot/tests/mks_robin_nano_v1v2 similarity index 100% rename from buildroot/tests/mks_robin_nano35 rename to buildroot/tests/mks_robin_nano_v1v2 diff --git a/buildroot/tests/mks_robin_nano35_maple b/buildroot/tests/mks_robin_nano_v1v2_maple similarity index 100% rename from buildroot/tests/mks_robin_nano35_maple rename to buildroot/tests/mks_robin_nano_v1v2_maple diff --git a/ini/renamed.ini b/ini/renamed.ini index 75f5dc3acc..5785bfac67 100644 --- a/ini/renamed.ini +++ b/ini/renamed.ini @@ -56,3 +56,11 @@ extends = renamed [env:STM32F103VE_GTM32] # Renamed to STM32F103VE_GTM32_maple extends = renamed + +[env:mks_robin_nano_35] +# Renamed to mks_robin_nano_v1v2 +extends = renamed + +[env:mks_robin_nano_35_maple] +# Renamed to mks_robin_nano_v1v2_maple +extends = renamed diff --git a/ini/stm32f1-maple.ini b/ini/stm32f1-maple.ini index 84055bebab..fcf320293c 100644 --- a/ini/stm32f1-maple.ini +++ b/ini/stm32f1-maple.ini @@ -203,17 +203,15 @@ board_build.ldscript = mks_robin_mini.ld build_flags = ${STM32F1_maple.build_flags} -DMCU_STM32F103VE # -# MKS Robin Nano (STM32F103VET6) +# MKS Robin Nano v1.x and v2 (STM32F103VET6) # -[env:mks_robin_nano35_maple] +[env:mks_robin_nano_v1v2_maple] extends = STM32F1_maple board = genericSTM32F103VE board_build.address = 0x08007000 board_build.rename = Robin_nano35.bin board_build.ldscript = mks_robin_nano.ld build_flags = ${STM32F1_maple.build_flags} -DMCU_STM32F103VE -DSS_TIMER=4 -debug_tool = jlink -upload_protocol = jlink # # MKS Robin (STM32F103ZET6) diff --git a/ini/stm32f1.ini b/ini/stm32f1.ini index 1e29ea6de5..f06eef4594 100644 --- a/ini/stm32f1.ini +++ b/ini/stm32f1.ini @@ -216,23 +216,35 @@ build_flags = ${stm32_variant.build_flags} build_unflags = ${stm32_variant.build_unflags} -DUSBCON -DUSBD_USE_CDC -# -# MKS Robin Nano V1.2 and V2 -# -[env:mks_robin_nano35] +[mks_robin_nano_v1v2_common] extends = stm32_variant board = genericSTM32F103VE board_build.variant = MARLIN_F103Vx board_build.encrypt_mks = Robin_nano35.bin board_build.offset = 0x7000 board_upload.offset_address = 0x08007000 +debug_tool = stlink +upload_protocol = stlink + +# +# MKS Robin Nano V1.2 and V2 +# +[env:mks_robin_nano_v1v2] +extends = mks_robin_nano_v1v2_common build_flags = ${stm32_variant.build_flags} -DMCU_STM32F103VE -DSS_TIMER=4 -DENABLE_HWSERIAL3 -DTIMER_TONE=TIM3 -DTIMER_SERVO=TIM2 build_unflags = ${stm32_variant.build_unflags} -DUSBCON -DUSBD_USE_CDC -debug_tool = jlink -upload_protocol = jlink + +# +# MKS/ZNP Robin Nano v1.2 with native USB modification +# +[env:mks_robin_nano_v1_2_usbmod] +extends = mks_robin_nano_v1v2_common +build_flags = ${common_stm32.build_flags} + -DMCU_STM32F103VE -DSS_TIMER=4 + -DTIMER_TONE=TIM3 -DTIMER_SERVO=TIM2 # # Mingda MPX_ARM_MINI diff --git a/ini/stm32f4.ini b/ini/stm32f4.ini index 5e0d4a13ec..0857dec398 100644 --- a/ini/stm32f4.ini +++ b/ini/stm32f4.ini @@ -570,42 +570,54 @@ board_upload.offset_address = 0x0800C000 extra_scripts = ${stm32_variant.extra_scripts} buildroot/share/PlatformIO/scripts/openblt.py -# -# BOARD_MKS_ROBIN_NANO_V1_3_F4 -# - MKS Robin Nano V1.3 (STM32F407VET6) 5 Pololu Plug -# - MKS Robin Nano-S V1.3 (STM32F407VET6) 4 TMC2225 + 1 Pololu Plug -# -[env:mks_robin_nano_v1_3_f4] +[mks_robin_nano_v1_3_f4_common] extends = stm32_variant board = marlin_STM32F407VGT6_CCM board_build.variant = MARLIN_F4x7Vx board_build.offset = 0x8000 board_upload.offset_address = 0x08008000 board_build.rename = Robin_nano35.bin -build_flags = ${stm32_variant.build_flags} - -DMCU_STM32F407VE -DSS_TIMER=4 -DENABLE_HWSERIAL3 - -DSTM32_FLASH_SIZE=512 - -DTIMER_TONE=TIM3 -DTIMER_SERVO=TIM2 - -DHAL_SD_MODULE_ENABLED - -DHAL_SRAM_MODULE_ENABLED -build_unflags = ${stm32_variant.build_unflags} - -DUSBCON -DUSBD_USE_CDC debug_tool = jlink upload_protocol = jlink +# +# BOARD_MKS_ROBIN_NANO_V1_3_F4 +# - MKS Robin Nano V1.3 (STM32F407VET6, 5 Pololu Plug) +# - MKS Robin Nano-S V1.3 (STM32F407VET6, 4 TMC2225, 1 Pololu Plug) +# - ZNP Robin Nano V1.3 (STM32F407VET6, 2 TMC2208, 2 A4988, 1x Polulu plug) +# +[env:mks_robin_nano_v1_3_f4] +extends = mks_robin_nano_v1_3_f4_common +build_flags = ${stm32_variant.build_flags} + -DMCU_STM32F407VE -DENABLE_HWSERIAL3 -DSTM32_FLASH_SIZE=512 + -DTIMER_SERVO=TIM2 -DTIMER_TONE=TIM3 -DSS_TIMER=4 + -DHAL_SD_MODULE_ENABLED -DHAL_SRAM_MODULE_ENABLED +build_unflags = ${stm32_variant.build_unflags} + -DUSBCON -DUSBD_USE_CDC + +# +# MKS/ZNP Robin Nano V1.3 with native USB mod +# +[env:mks_robin_nano_v1_3_f4_usbmod] +extends = mks_robin_nano_v1_3_f4_common +build_flags = ${stm32_variant.build_flags} + -DMCU_STM32F407VE -DSTM32_FLASH_SIZE=512 + -DTIMER_SERVO=TIM2 -DTIMER_TONE=TIM3 -DSS_TIMER=4 + -DHAL_SD_MODULE_ENABLED -DHAL_SRAM_MODULE_ENABLED + # # Artillery Ruby # [env:Artillery_Ruby] -extends = common_stm32 -board = marlin_Artillery_Ruby -build_flags = ${common_stm32.build_flags} - -DSTM32F401xC -DTARGET_STM32F4 -DDISABLE_GENERIC_SERIALUSB -DARDUINO_ARCH_STM32 - -DUSBD_USE_CDC_COMPOSITE -DUSE_USB_FS - -DUSB_PRODUCT=\"Artillery_3D_Printer\" - -DFLASH_DATA_SECTOR=1U -DFLASH_BASE_ADDRESS=0x08004000 -extra_scripts = ${common_stm32.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py +extends = common_stm32 +board = marlin_Artillery_Ruby +build_flags = ${common_stm32.build_flags} + -DSTM32F401xC -DTARGET_STM32F4 -DDISABLE_GENERIC_SERIALUSB -DARDUINO_ARCH_STM32 + -DUSBD_USE_CDC_COMPOSITE -DUSE_USB_FS + -DUSB_PRODUCT=\"Artillery_3D_Printer\" + -DFLASH_DATA_SECTOR=1U -DFLASH_BASE_ADDRESS=0x08004000 +extra_scripts = ${common_stm32.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py # # Ender-3 S1 STM32F401RC_creality