Skip to content

Commit

Permalink
✨ Robin Nano v1 CDC (USB mod) (MarlinFirmware#24619)
Browse files Browse the repository at this point in the history
  • Loading branch information
EvilGremlin authored Aug 22, 2022
1 parent 20c7284 commit 2a1c2e2
Show file tree
Hide file tree
Showing 13 changed files with 127 additions and 43 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/test-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
#- mks_robin_maple
- mks_robin_lite_maple
- mks_robin_pro_maple
#- mks_robin_nano35_maple
#- mks_robin_nano_v1v2_maple
#- STM32F103RE_creality_maple
- STM32F103VE_ZM3E4V2_USB_maple

Expand All @@ -93,7 +93,9 @@ jobs:
- rumba32
- LERDGEX
- LERDGEK
- mks_robin_nano35
- mks_robin_nano_v1v2
- mks_robin_nano_v1_2_usbmod
- mks_robin_nano_v1_3_f4_usbmod
- NUCLEO_F767ZI
- REMRAM_V1
- BTT_SKR_SE_BX
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/pins/pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 10 additions & 3 deletions Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion buildroot/share/PlatformIO/scripts/offset_and_rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,13 @@ def encrypt(source, target, env):
#
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)
19 changes: 19 additions & 0 deletions buildroot/tests/mks_robin_nano_v1_3_f4_usbmod
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions buildroot/tests/mks_robin_nano_v1v2_usbmod
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions ini/renamed.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 2 additions & 4 deletions ini/stm32f1-maple.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
24 changes: 18 additions & 6 deletions ini/stm32f1.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
58 changes: 35 additions & 23 deletions ini/stm32f4.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2a1c2e2

Please sign in to comment.