diff --git a/buildroot/share/PlatformIO/scripts/stm32_bootloader.py b/buildroot/share/PlatformIO/scripts/stm32_bootloader.py index b2b5daadb604..f3b1b273a28f 100644 --- a/buildroot/share/PlatformIO/scripts/stm32_bootloader.py +++ b/buildroot/share/PlatformIO/scripts/stm32_bootloader.py @@ -1,23 +1,25 @@ # # stm32_bootloader.py # -import os,sys,shutil,marlin +# - If 'build.offset' is provided, either by JSON or by the environment... +# - Set linker flag LD_FLASH_OFFSET and relocate the VTAB based on 'build.offset'. +# - Set linker flag LD_MAX_DATA_SIZE based on 'build.maximum_ram_size'. +# - Define STM32_FLASH_SIZE from 'upload.maximum_size' for use by Flash-based EEPROM emulation. +# +# - For 'board_build.rename' add a post-action to rename the firmware file. +# +import os,sys,marlin Import("env") from SCons.Script import DefaultEnvironment board = DefaultEnvironment().BoardConfig() -# -# Copy the firmware.bin file to build.firmware, no encryption -# -def noencrypt(source, target, env): - firmware = os.path.join(target[0].dir.path, board.get("build.firmware")) - shutil.copy(target[0].path, firmware) +board_keys = board.get("build").keys() # # For build.offset define LD_FLASH_OFFSET, used by ldscript.ld # -if 'offset' in board.get("build").keys(): +if 'offset' in board_keys: LD_FLASH_OFFSET = board.get("build.offset") marlin.relocate_vtab(LD_FLASH_OFFSET) @@ -35,9 +37,13 @@ def noencrypt(source, target, env): env["LINKFLAGS"][i] = "-Wl,--defsym=LD_MAX_DATA_SIZE=" + str(maximum_ram_size - 40) # -# Only copy the file if there's no encrypt +# For build.rename simply rename the firmware file. # -board_keys = board.get("build").keys() -if 'firmware' in board_keys and ('encrypt' not in board_keys or board.get("build.encrypt") == 'No'): - import marlin - marlin.add_post_action(noencrypt) +if 'rename' in board_keys: + + def rename_target(source, target, env): + firmware = os.path.join(target[0].dir.path, board.get("build.rename")) + import shutil + shutil.copy(target[0].path, firmware) + + marlin.add_post_action(rename_target) diff --git a/ini/stm32f1.ini b/ini/stm32f1.ini index c6aa464979f5..0b394d173058 100644 --- a/ini/stm32f1.ini +++ b/ini/stm32f1.ini @@ -31,20 +31,9 @@ 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) -# -# STM32F103RC_btt ............. RCT6 with 256K -# STM32F103RC_btt_USB ......... RCT6 with 256K (USB mass storage) -# STM32F103RC_btt_512K ........ RCT6 with 512K -# STM32F103RC_btt_512K_USB .... RCT6 with 512K (USB mass storage) -# -# WARNING! If you have an SKR Mini v1.1 or an SKR Mini E3 1.0 / 1.2 / 2.0 / DIP -# and experience a printer freeze, re-flash Marlin using the regular (non-512K) -# build option. 256K chips may be re-branded 512K chips, but this means the -# upper 256K is sketchy, and failure is very likely. -# [common_STM32F103RC] platform = ${common_stm32.platform} extends = common_stm32 @@ -52,45 +41,62 @@ board = genericSTM32F103RC 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 +# +# STM32F103RE +# +[env:STM32F103RE] +platform = ${common_stm32.platform} +extends = common_stm32 +board = genericSTM32F103RE +monitor_speed = 115200 + +# +# STM32F103VE +# +[env:STM32F103VE] +platform = ${common_stm32.platform} +extends = common_stm32 +board = genericSTM32F103VE +monitor_speed = 115200 + +# +# STM32F103ZE +# +[env:STM32F103ZE] +platform = ${common_stm32.platform} +extends = common_stm32 +board = genericSTM32F103ZE +monitor_speed = 115200 + +# +# BigTree SKR Mini V1.1 / SKR Mini E3 & MZ (STM32F103RCT6 ARM Cortex-M3) +# +# STM32F103RC_btt ............. RCT6 with 256K +# STM32F103RC_btt_USB ......... RCT6 with 256K (USB mass storage) +# [env:STM32F103RC_btt] platform = ${common_stm32.platform} extends = common_STM32F103RC build_flags = ${common_stm32.build_flags} -DDEBUG_LEVEL=0 -DTIMER_SERVO=TIM5 board_build.offset = 0x7000 -board_build.encrypt = No -board_build.firmware = firmware.bin board_upload.offset_address = 0x08007000 [env:STM32F103RC_btt_USB] extends = env:STM32F103RC_btt platform = ${common_stm32.platform} -platform_packages = framework-arduinoststm32@https://github.com/rhapsodyv/Arduino_Core_STM32/archive/usb-host-msc-cdc-msc-2.zip +platform_packages = framework-arduinoststm32@https://github.com/rhapsodyv/Arduino_Core_STM32/archive/usb-host-msc-cdc-msc-3.zip build_unflags = ${common_stm32.build_unflags} -DUSBD_USE_CDC build_flags = ${env:STM32F103RC_btt.build_flags} ${env:stm32_flash_drive.build_flags} -DUSBCON - -DUSE_USBHOST_HS + -DUSE_USB_FS -DUSBD_IRQ_PRIO=5 -DUSBD_IRQ_SUBPRIO=6 - -DUSE_USB_HS_IN_FS -DUSBD_USE_CDC_MSC -[env:STM32F103RC_btt_512K] -platform = ${common_stm32.platform} -extends = env:STM32F103RC_btt -board_upload.maximum_size = 524288 -build_flags = ${env:STM32F103RC_btt.build_flags} -DLD_MAX_DATA_SIZE=524288 -DSTM32_FLASH_SIZE=512 - -[env:STM32F103RC_btt_512K_USB] -platform = ${common_stm32.platform} -extends = env:STM32F103RC_btt_USB -board_upload.maximum_size = 524288 -build_flags = ${env:STM32F103RC_btt_USB.build_flags} -DLD_MAX_DATA_SIZE=524288 -DSTM32_FLASH_SIZE=512 - # # MKS Robin (STM32F103ZET6) # Uses HAL STM32 to support Marlin UI for TFT screen with optional touch panel @@ -101,33 +107,47 @@ extends = common_stm32 board = genericSTM32F103ZE board_build.core = stm32 board_build.variant = MARLIN_F103Zx -board_build.ldscript = ldscript.ld board_build.offset = 0x7000 -board_build.encrypt = Yes -board_build.firmware = Robin.bin +board_build.encrypt = Robin.bin 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 = Robin_e3.bin +board_upload.offset_address = 0x08005000 +debug_tool = stlink +extra_scripts = ${common_STM32F103RC.extra_scripts} + buildroot/share/PlatformIO/scripts/mks_encrypt.py + # # Creality (STM32F103RET6) # [env:STM32F103RET6_creality] platform = ${common_stm32.platform} extends = common_stm32 -build_flags = ${common_stm32.build_flags} -DMCU_STM32F103RE -DHAL_SD_MODULE_ENABLED -DSS_TIMER=4 -DENABLE_HWSERIAL3 -DTRANSFER_CLOCK_DIV=8 +build_flags = ${common_stm32.build_flags} -DMCU_STM32F103RE -DHAL_SD_MODULE_ENABLED -DSS_TIMER=4 -DTIMER_SERVO=TIM5 -DENABLE_HWSERIAL3 -DTRANSFER_CLOCK_DIV=8 board = genericSTM32F103RE monitor_speed = 115200 board_build.core = stm32 board_build.variant = MARLIN_F103Rx board_build.offset = 0x7000 -board_build.ldscript = ldscript.ld board_upload.offset_address = 0x08007000 build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC extra_scripts = ${common.extra_scripts} @@ -137,6 +157,41 @@ extra_scripts = ${common.extra_scripts} debug_tool = jlink upload_protocol = jlink +# +# BigTree SKR Mini E3 V2.0 & DIP / SKR CR6 (STM32F103RET6 ARM Cortex-M3) +# +# STM32F103RE_btt ............. RET6 +# STM32F103RE_btt_USB ......... RET6 (USB mass storage) +# +[env:STM32F103RE_btt] +platform = ${common_stm32.platform} +extends = common_stm32 +build_flags = ${common_stm32.build_flags} -DMCU_STM32F103RE -DHAL_SD_MODULE_ENABLED -DSS_TIMER=4 -DTIMER_SERVO=TIM5 -DENABLE_HWSERIAL3 -DTRANSFER_CLOCK_DIV=8 +board = genericSTM32F103RE +monitor_speed = 115200 +board_build.core = stm32 +board_build.variant = MARLIN_F103Rx +board_build.offset = 0x7000 +board_upload.offset_address = 0x08007000 +build_unflags = ${common_stm32.build_unflags} +extra_scripts = ${common.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py + buildroot/share/PlatformIO/scripts/stm32_bootloader.py +debug_tool = jlink +upload_protocol = jlink + +[env:STM32F103RE_btt_USB] +extends = env:STM32F103RE_btt +platform = ${common_stm32.platform} +platform_packages = framework-arduinoststm32@https://github.com/rhapsodyv/Arduino_Core_STM32/archive/usb-host-msc-cdc-msc-3.zip +build_unflags = ${common_stm32.build_unflags} -DUSBD_USE_CDC +build_flags = ${env:STM32F103RE_btt.build_flags} ${env:stm32_flash_drive.build_flags} + -DUSBCON + -DUSE_USB_FS + -DUSBD_IRQ_PRIO=5 + -DUSBD_IRQ_SUBPRIO=6 + -DUSBD_USE_CDC_MSC + # # FLSUN QQS Pro (STM32F103VET6) # board Hispeedv1 @@ -148,13 +203,11 @@ build_flags = ${common_stm32.build_flags} -DMCU_STM32F103VE -DSS_TIMER= board = genericSTM32F103VE board_build.core = stm32 board_build.variant = MARLIN_F103Vx -board_build.ldscript = ldscript.ld board_build.offset = 0x7000 -board_build.firmware = Robin_mini.bin -board_build.encrypt = Yes +board_build.encrypt = Robin_mini.bin 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 @@ -169,15 +222,13 @@ build_flags = ${common_stm32.build_flags} -DMCU_STM32F103VE -DSS_TIMER= board = genericSTM32F103VE board_build.core = stm32 board_build.variant = MARLIN_F103Vx -board_build.ldscript = ldscript.ld board_build.offset = 0x7000 -board_build.encrypt = Yes -board_build.firmware = Robin_nano35.bin +board_build.encrypt = Robin_nano35.bin 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 @@ -191,10 +242,20 @@ extends = common_stm32 board = genericSTM32F103ZE board_build.core = stm32 board_build.variant = MARLIN_F103Zx -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 + +# +# Malyan M200 (STM32F103CB) +# +[env:STM32F103CB_malyan] +platform = ${common_stm32.platform} +extends = common_stm32 +board = malyanm200_f103cb +build_flags = ${common_stm32.build_flags} + -DHAL_PCD_MODULE_ENABLED -DDISABLE_GENERIC_SERIALUSB -DHAL_UART_MODULE_ENABLED +src_filter = ${common.default_src_filter} + diff --git a/ini/stm32f4.ini b/ini/stm32f4.ini index 3c11f0df216e..e7695dcc7a27 100644 --- a/ini/stm32f4.ini +++ b/ini/stm32f4.ini @@ -68,20 +68,6 @@ build_flags = ${common_stm32.build_flags} extra_scripts = ${common.extra_scripts} pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py -# -# FLY MINI (STM32F103RCT6) -# -[env:FLY_MINI] -platform = ${common_stm32f1.platform} -extends = common_stm32f1 -board = genericSTM32F103RC -board_build.address = 0x08005000 -board_build.ldscript = fly_mini.ld -extra_scripts = ${common_stm32f1.extra_scripts} - buildroot/share/PlatformIO/scripts/custom_board.py -build_flags = ${common_stm32f1.build_flags} - -DDEBUG_LEVEL=0 -DSS_TIMER=4 - # # FYSETC S6 (STM32F446RET6 ARM Cortex-M4) # @@ -126,10 +112,8 @@ build_flags = ${common_stm32.build_flags} -DHAL_SD_MODULE_ENABLED -DHAL board = marlin_STM32F407VGT6_CCM board_build.core = stm32 board_build.variant = MARLIN_F4x7Vx -board_build.ldscript = ldscript.ld -board_build.firmware = firmware.srec +board_build.encrypt = firmware.srec # Just openblt.py (not stm32_bootloader.py) generates the file -board_build.encrypt = Yes board_build.offset = 0x10000 board_upload.offset_address = 0x08010000 build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC -DUSBD_VID=0x0483 @@ -160,7 +144,7 @@ debug_init_break = # USB Flash Drive mix-ins for STM32 # [stm_flash_drive] -platform_packages = framework-arduinoststm32@https://github.com/rhapsodyv/Arduino_Core_STM32/archive/usb-host-msc-cdc-msc-2.zip +platform_packages = framework-arduinoststm32@https://github.com/rhapsodyv/Arduino_Core_STM32/archive/usb-host-msc-cdc-msc-3.zip build_flags = ${common_stm32.build_flags} -DHAL_PCD_MODULE_ENABLED -DHAL_HCD_MODULE_ENABLED -DUSBHOST -DUSBH_IRQ_PRIO=3 -DUSBH_IRQ_SUBPRIO=4 @@ -237,7 +221,6 @@ extends = common_stm32 board = marlin_STM32F407VGT6_CCM board_build.core = stm32 board_build.variant = MARLIN_F4x7Vx -board_build.ldscript = ldscript.ld board_build.offset = 0x8000 board_upload.offset_address = 0x08008000 extra_scripts = ${common.extra_scripts} @@ -248,22 +231,22 @@ build_flags = ${stm_flash_drive.build_flags} -DHSE_VALUE=8000000U -DHAL_SD_MODULE_ENABLED # -# BigTreeTech Octopus V1.0 (STM32F446ZET6 ARM Cortex-M4) +# BigTreeTech Octopus V1.0/1.1 (STM32F446ZET6 ARM Cortex-M4) # -[env:BIGTREE_OCTOPUS_V1_0] +[env:BIGTREE_OCTOPUS_V1] platform = ${common_stm32.platform} extends = common_stm32 -board = marlin_BigTree_octopus_v1 +board = marlin_BigTree_Octopus_v1 extra_scripts = ${common.extra_scripts} pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py build_flags = ${common_stm32.build_flags} -DSTM32F446_5VX -DVECT_TAB_OFFSET=0x8000 -DUSE_USB_HS_IN_FS # -# BigTreeTech Octopus V1.0 (STM32F446ZET6 ARM Cortex-M4) with USB Flash Drive Support +# BigTreeTech Octopus V1.0/1.1 (STM32F446ZET6 ARM Cortex-M4) with USB Flash Drive Support # -[env:BIGTREE_OCTOPUS_V1_0_USB] -extends = env:BIGTREE_OCTOPUS_V1_0 +[env:BIGTREE_OCTOPUS_V1_USB] +extends = env:BIGTREE_OCTOPUS_V1 platform_packages = ${stm_flash_drive.platform_packages} #build_unflags = -DUSBCON -DUSBD_USE_CDC build_flags = ${stm_flash_drive.build_flags} @@ -279,7 +262,7 @@ extends = common_stm32 board = marlin_STM32F407ZGT6 board_build.variant = MARLIN_LERDGE board_build.offset = 0x10000 -board_build.encrypt = Yes +board_build.encrypt = firmware.bin extra_scripts = ${common.extra_scripts} pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py buildroot/share/PlatformIO/scripts/stm32_bootloader.py @@ -294,9 +277,9 @@ build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC -DUS # Lerdge X # [env:LERDGEX] -platform = ${lerdge_common.platform} -extends = lerdge_common -board_build.firmware = Lerdge_X_firmware_force.bin +platform = ${lerdge_common.platform} +extends = lerdge_common +board_build.encrypt = Lerdge_X_firmware_force.bin # # Lerdge X with USB Flash Drive Support @@ -305,15 +288,15 @@ board_build.firmware = Lerdge_X_firmware_force.bin platform = ${env:LERDGEX.platform} extends = env:LERDGEX platform_packages = ${stm_flash_drive.platform_packages} -build_flags = ${stm_flash_drive.build_flags} +build_flags = ${stm_flash_drive.build_flags} ${lerdge_common.build_flags} # # Lerdge S # [env:LERDGES] -platform = ${lerdge_common.platform} -extends = lerdge_common -board_build.firmware = Lerdge_firmware_force.bin +platform = ${lerdge_common.platform} +extends = lerdge_common +board_build.encrypt = Lerdge_firmware_force.bin # # Lerdge S with USB Flash Drive Support @@ -322,16 +305,16 @@ board_build.firmware = Lerdge_firmware_force.bin platform = ${env:LERDGES.platform} extends = env:LERDGES platform_packages = ${stm_flash_drive.platform_packages} -build_flags = ${stm_flash_drive.build_flags} +build_flags = ${stm_flash_drive.build_flags} ${lerdge_common.build_flags} # # Lerdge K # [env:LERDGEK] -platform = ${lerdge_common.platform} -extends = lerdge_common -board_build.firmware = Lerdge_K_firmware_force.bin -build_flags = ${lerdge_common.build_flags} -DLERDGEK +platform = ${lerdge_common.platform} +extends = lerdge_common +board_build.encrypt = Lerdge_K_firmware_force.bin +build_flags = ${lerdge_common.build_flags} -DLERDGEK # # Lerdge K with USB Flash Drive Support @@ -340,7 +323,7 @@ build_flags = ${lerdge_common.build_flags} -DLERDGEK platform = ${env:LERDGEK.platform} extends = env:LERDGEK platform_packages = ${stm_flash_drive.platform_packages} -build_flags = ${stm_flash_drive.build_flags} +build_flags = ${stm_flash_drive.build_flags} ${lerdge_common.build_flags} # # RUMBA32 @@ -359,10 +342,7 @@ upload_protocol = dfu monitor_speed = 500000 board_build.core = stm32 board_build.variant = MARLIN_F446VE -board_build.ldscript = ldscript.ld board_build.offset = 0x0000 -board_build.encrypt = No -board_build.firmware = firmware.bin extra_scripts = ${common.extra_scripts} pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py buildroot/share/PlatformIO/scripts/stm32_bootloader.py @@ -378,8 +358,6 @@ build_flags = ${stm_flash_drive.build_flags} board = genericSTM32F407VET6 board_build.core = stm32 board_build.variant = MARLIN_F4x7Vx -board_build.ldscript = ldscript.ld -board_build.firmware = firmware.bin board_build.offset = 0x0000 board_upload.offset_address = 0x08000000 build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC @@ -405,8 +383,7 @@ build_flags = ${common_stm32.build_flags} ${stm32f4_I2C1.build_flags} - board = marlin_STM32F407VGT6_CCM board_build.core = stm32 board_build.variant = MARLIN_F4x7Vx -board_build.ldscript = ldscript.ld -board_build.firmware = Robin_nano_v3.bin +board_build.rename = Robin_nano_v3.bin board_build.offset = 0xC000 board_upload.offset_address = 0x0800C000 build_unflags = ${common_stm32.build_unflags} @@ -438,7 +415,7 @@ build_flags = ${stm_flash_drive.build_flags} ${stm32f4_I2C1.build_flags} [env:mks_robin_nano_v3_usb_flash_drive_msc] platform = ${common_stm32.platform} extends = env:mks_robin_nano_v3 -platform_packages = framework-arduinoststm32@https://github.com/rhapsodyv/Arduino_Core_STM32/archive/usb-host-msc-cdc-msc-2.zip +platform_packages = framework-arduinoststm32@https://github.com/rhapsodyv/Arduino_Core_STM32/archive/usb-host-msc-cdc-msc-3.zip build_unflags = ${common_stm32.build_unflags} -DUSBD_USE_CDC build_flags = ${stm_flash_drive.build_flags} ${stm32f4_I2C1.build_flags} -DUSBCON