From b90de621971656df4c0030cd04a3b4c782e4511d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 29 Jun 2021 16:25:37 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20Clean=20up=20build=20scripts=20(?= =?UTF-8?q?#22264)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add 10K to marlin_blackSTM32F407VET6 (typo?) * Document custom build scripts. * Add a Robin common build script. * Extraneous .ldscript specifiers --- .../PlatformIO/boards/marlin_blackSTM32F407VET6.json | 2 +- buildroot/share/PlatformIO/scripts/custom_board.py | 3 +++ buildroot/share/PlatformIO/scripts/marlin.py | 8 -------- buildroot/share/PlatformIO/scripts/mks_robin.py | 4 ++-- buildroot/share/PlatformIO/scripts/mks_robin_e3.py | 4 ++-- buildroot/share/PlatformIO/scripts/mks_robin_e3p.py | 4 ++-- buildroot/share/PlatformIO/scripts/mks_robin_lite.py | 4 ++-- .../share/PlatformIO/scripts/mks_robin_lite3.py | 4 ++-- buildroot/share/PlatformIO/scripts/mks_robin_mini.py | 4 ++-- buildroot/share/PlatformIO/scripts/mks_robin_nano.py | 4 ++-- .../share/PlatformIO/scripts/mks_robin_nano35.py | 4 ++-- buildroot/share/PlatformIO/scripts/mks_robin_pro.py | 4 ++-- buildroot/share/PlatformIO/scripts/robin.py | 12 ++++++++++++ .../share/PlatformIO/scripts/stm32_bootloader.py | 7 +++++++ ini/stm32f1.ini | 7 ------- ini/stm32f4.ini | 5 ----- 16 files changed, 41 insertions(+), 39 deletions(-) create mode 100644 buildroot/share/PlatformIO/scripts/robin.py diff --git a/buildroot/share/PlatformIO/boards/marlin_blackSTM32F407VET6.json b/buildroot/share/PlatformIO/boards/marlin_blackSTM32F407VET6.json index 1765634086026..a3f130c6b174c 100644 --- a/buildroot/share/PlatformIO/boards/marlin_blackSTM32F407VET6.json +++ b/buildroot/share/PlatformIO/boards/marlin_blackSTM32F407VET6.json @@ -48,7 +48,7 @@ "upload": { "disable_flushing": false, "maximum_ram_size": 131072, - "maximum_size": 514288, + "maximum_size": 524288, "protocol": "stlink", "protocols": [ "stlink", diff --git a/buildroot/share/PlatformIO/scripts/custom_board.py b/buildroot/share/PlatformIO/scripts/custom_board.py index 5d3ca3c65214d..e462738190dd5 100644 --- a/buildroot/share/PlatformIO/scripts/custom_board.py +++ b/buildroot/share/PlatformIO/scripts/custom_board.py @@ -1,6 +1,9 @@ # # buildroot/share/PlatformIO/scripts/custom_board.py # +# - For build.address replace VECT_TAB_ADDR to relocate the firmware +# - For build.ldscript use one of the linker scripts in buildroot/share/PlatformIO/ldscripts +# import marlin board = marlin.env.BoardConfig() diff --git a/buildroot/share/PlatformIO/scripts/marlin.py b/buildroot/share/PlatformIO/scripts/marlin.py index 23c1b957426ca..3949037904bbd 100644 --- a/buildroot/share/PlatformIO/scripts/marlin.py +++ b/buildroot/share/PlatformIO/scripts/marlin.py @@ -67,11 +67,3 @@ def encrypt_mks(source, target, env, new_name): def add_post_action(action): env.AddPostAction(join("$BUILD_DIR", "${PROGNAME}.bin"), action); - -# Apply customizations for a MKS Robin -def prepare_robin(address, ldname, fwname): - def encrypt(source, target, env): - encrypt_mks(source, target, env, fwname) - relocate_firmware(address) - custom_ld_script(ldname) - add_post_action(encrypt); diff --git a/buildroot/share/PlatformIO/scripts/mks_robin.py b/buildroot/share/PlatformIO/scripts/mks_robin.py index 8c5e4ae276654..2dea7c615f798 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin.py @@ -1,5 +1,5 @@ # # buildroot/share/PlatformIO/scripts/mks_robin.py # -import marlin -marlin.prepare_robin("0x08007000", "mks_robin.ld", "Robin.bin") +import robin +robin.prepare("0x08007000", "mks_robin.ld", "Robin.bin") diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_e3.py b/buildroot/share/PlatformIO/scripts/mks_robin_e3.py index 7f6f538d6a21d..6ddeccbf80f46 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin_e3.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin_e3.py @@ -1,5 +1,5 @@ # # buildroot/share/PlatformIO/scripts/mks_robin_e3.py # -import marlin -marlin.prepare_robin("0x08005000", "mks_robin_e3.ld", "Robin_e3.bin") +import robin +robin.prepare("0x08005000", "mks_robin_e3.ld", "Robin_e3.bin") diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_e3p.py b/buildroot/share/PlatformIO/scripts/mks_robin_e3p.py index 1f3cacf873365..5eeb93c09663b 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin_e3p.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin_e3p.py @@ -1,5 +1,5 @@ # # buildroot/share/PlatformIO/scripts/mks_robin_e3p.py # -import marlin -marlin.prepare_robin("0x08007000", "mks_robin_e3p.ld", "Robin_e3p.bin") +import robin +robin.prepare("0x08007000", "mks_robin_e3p.ld", "Robin_e3p.bin") diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_lite.py b/buildroot/share/PlatformIO/scripts/mks_robin_lite.py index b8c039ada88d6..c2018336fd1f9 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin_lite.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin_lite.py @@ -1,5 +1,5 @@ # # buildroot/share/PlatformIO/scripts/mks_robin_lite.py # -import marlin -marlin.prepare_robin("0x08005000", "mks_robin_lite.ld", "mksLite.bin") +import robin +robin.prepare("0x08005000", "mks_robin_lite.ld", "mksLite.bin") diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_lite3.py b/buildroot/share/PlatformIO/scripts/mks_robin_lite3.py index bea8b80ace6c3..42c8fb18b691a 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin_lite3.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin_lite3.py @@ -1,5 +1,5 @@ # # buildroot/share/PlatformIO/scripts/mks_robin_lite3.py # -import marlin -marlin.prepare_robin("0x08005000", "mks_robin_lite.ld", "mksLite3.bin") +import robin +robin.prepare("0x08005000", "mks_robin_lite.ld", "mksLite3.bin") diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_mini.py b/buildroot/share/PlatformIO/scripts/mks_robin_mini.py index 3ff9ccf4a67a1..b0d83886533ac 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin_mini.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin_mini.py @@ -1,5 +1,5 @@ # # buildroot/share/PlatformIO/scripts/mks_robin_mini.py # -import marlin -marlin.prepare_robin("0x08007000", "mks_robin_mini.ld", "Robin_mini.bin") +import robin +robin.prepare("0x08007000", "mks_robin_mini.ld", "Robin_mini.bin") diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_nano.py b/buildroot/share/PlatformIO/scripts/mks_robin_nano.py index 319b4d498202b..35e99830c4dfb 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin_nano.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin_nano.py @@ -1,5 +1,5 @@ # # buildroot/share/PlatformIO/scripts/mks_robin_nano.py # -import marlin -marlin.prepare_robin("0x08007000", "mks_robin_nano.ld", "Robin_nano.bin") +import robin +robin.prepare("0x08007000", "mks_robin_nano.ld", "Robin_nano.bin") diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_nano35.py b/buildroot/share/PlatformIO/scripts/mks_robin_nano35.py index 310c3d6606677..4a5726ad5b98a 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin_nano35.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin_nano35.py @@ -1,5 +1,5 @@ # # buildroot/share/PlatformIO/scripts/mks_robin_nano35.py # -import marlin -marlin.prepare_robin("0x08007000", "mks_robin_nano.ld", "Robin_nano35.bin") +import robin +robin.prepare("0x08007000", "mks_robin_nano.ld", "Robin_nano35.bin") diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_pro.py b/buildroot/share/PlatformIO/scripts/mks_robin_pro.py index c624663a330c2..60e2482bb0308 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin_pro.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin_pro.py @@ -1,5 +1,5 @@ # # buildroot/share/PlatformIO/scripts/mks_robin_pro.py # -import marlin -marlin.prepare_robin("0x08007000", "mks_robin_pro.ld", "Robin_pro.bin") +import robin +robin.prepare("0x08007000", "mks_robin_pro.ld", "Robin_pro.bin") diff --git a/buildroot/share/PlatformIO/scripts/robin.py b/buildroot/share/PlatformIO/scripts/robin.py new file mode 100644 index 0000000000000..50d0d92d2ff73 --- /dev/null +++ b/buildroot/share/PlatformIO/scripts/robin.py @@ -0,0 +1,12 @@ +# +# buildroot/share/PlatformIO/scripts/robin.py +# +import marlin + +# Apply customizations for a MKS Robin +def prepare(address, ldname, fwname): + def encrypt(source, target, env): + marlin.encrypt_mks(source, target, env, fwname) + marlin.relocate_firmware(address) + marlin.custom_ld_script(ldname) + marlin.add_post_action(encrypt); diff --git a/buildroot/share/PlatformIO/scripts/stm32_bootloader.py b/buildroot/share/PlatformIO/scripts/stm32_bootloader.py index eb28b901d2675..f3b1b273a28fc 100644 --- a/buildroot/share/PlatformIO/scripts/stm32_bootloader.py +++ b/buildroot/share/PlatformIO/scripts/stm32_bootloader.py @@ -1,6 +1,13 @@ # # stm32_bootloader.py # +# - 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") diff --git a/ini/stm32f1.ini b/ini/stm32f1.ini index 3f09a45c7ba91..0b394d173058c 100644 --- a/ini/stm32f1.ini +++ b/ini/stm32f1.ini @@ -41,7 +41,6 @@ board = genericSTM32F103RC monitor_speed = 115200 board_build.core = stm32 board_build.variant = MARLIN_F103Rx -board_build.ldscript = ldscript.ld extra_scripts = ${common_stm32.extra_scripts} pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py buildroot/share/PlatformIO/scripts/stm32_bootloader.py @@ -108,7 +107,6 @@ 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 = Robin.bin build_flags = ${common_stm32.build_flags} @@ -150,7 +148,6 @@ 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} @@ -175,7 +172,6 @@ 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} extra_scripts = ${common.extra_scripts} @@ -207,7 +203,6 @@ 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 = Robin_mini.bin board_upload.offset_address = 0x08007000 @@ -227,7 +222,6 @@ 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 = Robin_nano35.bin board_upload.offset_address = 0x08007000 @@ -248,7 +242,6 @@ 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 diff --git a/ini/stm32f4.ini b/ini/stm32f4.ini index ee88135ecaa5c..e7695dcc7a27e 100644 --- a/ini/stm32f4.ini +++ b/ini/stm32f4.ini @@ -112,7 +112,6 @@ 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.encrypt = firmware.srec # Just openblt.py (not stm32_bootloader.py) generates the file board_build.offset = 0x10000 @@ -222,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} @@ -344,7 +342,6 @@ upload_protocol = dfu monitor_speed = 500000 board_build.core = stm32 board_build.variant = MARLIN_F446VE -board_build.ldscript = ldscript.ld board_build.offset = 0x0000 extra_scripts = ${common.extra_scripts} pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py @@ -361,7 +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.offset = 0x0000 board_upload.offset_address = 0x08000000 build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC @@ -387,7 +383,6 @@ 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.rename = Robin_nano_v3.bin board_build.offset = 0xC000 board_upload.offset_address = 0x0800C000