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

🔨 Simplify generic variants, update DFU tool #27502

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
],
"ldscript": "ldscript.ld",
"mcu": "stm32f401ret6",
"variant": "MARLIN_CREALITY_STM32F401RE"
"variant": "MARLIN_F401RE_CREALITY"
},
"debug": {
"jlink_device": "STM32F401RE",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
],
"ldscript": "ldscript.ld",
"mcu": "stm32f401ret6",
"variant": "MARLIN_STM32F401RE_FREERUNS"
"variant": "MARLIN_F401RE_FREERUNS"
},
"debug": {
"jlink_device": "STM32F401RE",
Expand Down
40 changes: 26 additions & 14 deletions buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,40 @@
#
import pioutil
if pioutil.is_pio_build():
import shutil, marlin
from pathlib import Path
env = pioutil.env
platform = env.PioPlatform()
board = env.BoardConfig()

FRAMEWORK_DIR = Path(platform.get_package_dir("framework-arduinoststm32-maple"))
assert FRAMEWORK_DIR.is_dir()

source_root = Path("buildroot/share/PlatformIO/variants")
source_root_str = "buildroot/share/PlatformIO/variants"
source_root = Path(source_root_str)
assert source_root.is_dir()

env = pioutil.env
board = env.BoardConfig()
variant = board.get("build.variant")
variant_dir = FRAMEWORK_DIR / "STM32F1/variants" / variant

source_dir = source_root / variant
assert source_dir.is_dir()

if variant_dir.is_dir():
shutil.rmtree(variant_dir)
if True:
thinkyhead marked this conversation as resolved.
Show resolved Hide resolved

platform = env.PioPlatform()
FRAMEWORK_DIR = Path(platform.get_package_dir("framework-arduinoststm32-maple"))
assert FRAMEWORK_DIR.is_dir()

variant_dir = FRAMEWORK_DIR / "STM32F1/variants" / variant

if variant_dir.is_dir():
import shutil
shutil.rmtree(variant_dir)

if not variant_dir.is_dir():
variant_dir.mkdir()

import marlin
marlin.copytree(source_dir, variant_dir)

if not variant_dir.is_dir():
variant_dir.mkdir()
else:

marlin.copytree(source_dir, variant_dir)
# The following almost works, but __start__ (from wirish/start.S) is not seen by common.inc
board.update("build.variants_dir", source_root_str);
src = str(source_dir)
env.Append(BUILD_FLAGS=[f"-I{src}", f"-L{src}/ld"]) # Add include path for variant
23 changes: 7 additions & 16 deletions buildroot/share/PlatformIO/scripts/generic_create_variant.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,17 @@
FRAMEWORK_DIR = Path(platform.get_package_dir(platform_name))
assert FRAMEWORK_DIR.is_dir()

#
# Point variants_dir to our variant folder when board_build.variant
# is provided and the variant name begins with "marlin_".
#
board = env.BoardConfig()

#mcu_type = board.get("build.mcu")[:-2]
variant = board.get("build.variant")
#mcu_type = board.get("build.mcu")[:-2]
#series = mcu_type[:7].upper() + "xx"

# Only prepare a new variant if the PlatformIO configuration provides it (board_build.variant).
# This check is important to avoid deleting official board config variants.
# Make sure the local variant sub-folder exists
if marlin_variant_pattern.match(str(variant).lower()):
# Prepare a new empty folder at the destination
variant_dir = FRAMEWORK_DIR / "variants" / variant
if variant_dir.is_dir():
shutil.rmtree(variant_dir)
if not variant_dir.is_dir():
variant_dir.mkdir()

# Source dir is a local variant sub-folder
source_dir = Path("buildroot/share/PlatformIO/variants", variant)
assert source_dir.is_dir()

print("Copying variant " + str(variant) + " to framework directory...")

marlin.copytree(source_dir, variant_dir)
board.update("build.variants_dir", "buildroot/share/PlatformIO/variants");
1 change: 1 addition & 0 deletions ini/stm32f1-maple.ini
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ monitor_speed = 115200
[env:STM32F103RC_meeb_maple]
extends = env:STM32F103RC_maple
board = marlin_maple_MEEB_3DP
platform_packages = platformio/tool-dfuutil@~1.11.0
build_flags = ${env:STM32F103RC_maple.build_flags}
-DDEBUG_LEVEL=0
-DSS_TIMER=4
Expand Down
6 changes: 3 additions & 3 deletions ini/stm32f1.ini
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ board = genericSTM32F103RC
extends = STM32F103Rx_creality
board = genericSTM32F103VE
board_build.variant = MARLIN_F103Vx
build_flags = ${stm32_variant.build_flags}
build_flags = ${STM32F103Rx_creality.build_flags}
-DSS_TIMER=4 -DTIMER_SERVO=TIM5
-DENABLE_HWSERIAL3 -DTRANSFER_CLOCK_DIV=8
#
Expand Down Expand Up @@ -253,7 +253,7 @@ board = malyanm200_f103cb
build_flags = ${common_stm32.build_flags}
-DHAL_PCD_MODULE_ENABLED -DDISABLE_GENERIC_SERIALUSB
-DHAL_UART_MODULE_ENABLED
build_src_filter = ${common.default_src_filter} +<src/HAL/STM32> -<src/HAL/STM32/tft>
build_src_filter = ${common_stm32.build_src_filter} +<src/HAL/STM32> -<src/HAL/STM32/tft>

#
# FLYmaker FLY Mini (STM32F103RCT6)
Expand Down Expand Up @@ -462,7 +462,7 @@ board_upload.offset_address = 0x08005000
board_build.offset = 0x5000
board_upload.maximum_size = 237568
extra_scripts = ${stm32_variant.extra_scripts}
build_flags = ${common_stm32.build_flags}
build_flags = ${stm32_variant.build_flags}
-DSS_TIMER=4 -DTIMER_SERVO=TIM5 -DUSE_USB_FS -DUSBD_IRQ_PRIO=5 -DUSBD_IRQ_SUBPRIO=6 -DUSBD_USE_CDC_MSC
build_unflags = ${stm32_variant.build_unflags} -DUSBD_USE_CDC

Expand Down
13 changes: 10 additions & 3 deletions ini/stm32f4.ini
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ build_flags = ${common_stm32.build_flags}
#
[env:FYSETC_CHEETAH_V20]
extends = stm32_variant
platform_packages = platformio/tool-dfuutil@~1.11.0
board = marlin_FYSETC_CHEETAH_V20
board_build.offset = 0x8000
build_flags = ${stm32_variant.build_flags} -DSTM32F401xC
Expand All @@ -43,6 +44,7 @@ upload_command = dfu-util -a 0 -s 0x08008000:leave -D "$SOURCE"
#
[env:FYSETC_CHEETAH_V30]
extends = stm32_variant
platform_packages = platformio/tool-dfuutil@~1.11.0
board = marlin_FYSETC_CHEETAH_V30
build_flags = ${stm32_variant.build_flags} -DHAL_PCD_MODULE_ENABLED
debug_tool = stlink
Expand All @@ -54,6 +56,7 @@ upload_command = dfu-util -a 0 -s 0x08000000:leave -D "$SOURCE"
#
[env:FLYF407ZG]
extends = stm32_variant
platform_packages = platformio/tool-dfuutil@~1.11.0
board = marlin_STM32F407ZGT6
board_build.variant = MARLIN_FLY_F407ZG
board_build.offset = 0x8000
Expand All @@ -64,6 +67,7 @@ upload_protocol = dfu
#
[env:FYSETC_S6]
extends = stm32_variant
platform_packages = platformio/tool-dfuutil@~1.11.0
board = marlin_fysetc_s6
board_build.offset = 0x10000
board_upload.offset_address = 0x08010000
Expand All @@ -87,6 +91,7 @@ upload_command = dfu-util -a 0 -s 0x08008000:leave -D "$SOURCE"
#
[env:FYSETC_SPIDER_KING407]
extends = stm32_variant
platform_packages = platformio/tool-dfuutil@~1.11.0
board = marlin_STM32F407ZGT6
board_build.variant = MARLIN_FYSETC_SPIDER_KING407
board_build.offset = 0x8000
Expand Down Expand Up @@ -418,6 +423,7 @@ build_flags = ${stm_flash_drive.build_flags} ${lerdge_common.build_flags}
#
[env:rumba32]
extends = stm32_variant
platform_packages = platformio/tool-dfuutil@~1.11.0
board = rumba32_f446ve
board_build.variant = MARLIN_F446VE
board_build.offset = 0x0000
Expand Down Expand Up @@ -685,7 +691,7 @@ extra_scripts = ${common_stm32.extra_scripts}
[STM32F401RC_creality_base]
extends = stm32_variant
board = genericSTM32F401RC
board_build.variant = MARLIN_CREALITY_STM32F401RC
board_build.variant = MARLIN_F401RC_CREALITY
build_flags = ${stm32_variant.build_flags} -DMCU_STM32F401RC -DSTM32F4
-DSS_TIMER=4 -DTIMER_SERVO=TIM5
-DENABLE_HWSERIAL3 -DTRANSFER_CLOCK_DIV=8
Expand Down Expand Up @@ -720,7 +726,7 @@ upload_protocol = stlink
#
[env:STM32F401RE_creality]
extends = stm32_variant
board = marlin_CREALITY_STM32F401RE
board = marlin_STM32F401RE_creality
board_build.offset = 0x10000
board_upload.offset_address = 0x08010000
board_build.rename = firmware-{date}-{time}.bin
Expand Down Expand Up @@ -806,6 +812,7 @@ board_build.rename = mks_skipr.bin

[env:mks_skipr_v1_nobootloader]
extends = env:mks_skipr_v1
platform_packages = platformio/tool-dfuutil@~1.11.0
board_build.rename = firmware.bin
board_build.offset = 0x0000
board_upload.offset_address = 0x08000000
Expand Down Expand Up @@ -862,6 +869,7 @@ upload_protocol = stlink
#
[env:BLACKBEEZMINI_V1]
platform = ststm32
platform_packages = platformio/tool-dfuutil@~1.11.0
extends = common_stm32
board = blackpill_f401cc
board_build.offset = 0x0000
Expand Down Expand Up @@ -894,7 +902,6 @@ upload_protocol = stlink
# XTLW3D Climber-8th-F4 (STM32F407VGT6 ARM Cortex-M4)
#
[env:XTLW_CLIMBER_8TH]
platform = ${common_stm32.platform}
extends = stm32_variant
platform_packages = ${stm_flash_drive.platform_packages}
board = marlin_STM32F407VGT6_CCM
Expand Down