From 832059967c4cfbd48d82282c2e700b8d4b805492 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 22 Mar 2021 23:58:03 -0500 Subject: [PATCH] Comment, clean up some PlatformIO scripts --- buildroot/share/PlatformIO/ldscripts/lerdge.ld | 6 +++--- buildroot/share/PlatformIO/scripts/openblt.py | 7 ++++--- .../share/PlatformIO/scripts/stm32_bootloader.py | 14 +++++++++++++- .../PlatformIO/variants/MARLIN_F4x7Vx/ldscript.ld | 6 +++--- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/buildroot/share/PlatformIO/ldscripts/lerdge.ld b/buildroot/share/PlatformIO/ldscripts/lerdge.ld index aa0b1dd9cb..f36ebcdea1 100644 --- a/buildroot/share/PlatformIO/ldscripts/lerdge.ld +++ b/buildroot/share/PlatformIO/ldscripts/lerdge.ld @@ -40,9 +40,9 @@ _Min_Stack_Size = 0x400;; /* required amount of stack */ /* Specify the memory areas */ MEMORY { -FLASH (rx) : ORIGIN = 0x8000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET -RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE -CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K +FLASH (rx) : ORIGIN = 0x08000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET +RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE +CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K } /* Define output sections */ diff --git a/buildroot/share/PlatformIO/scripts/openblt.py b/buildroot/share/PlatformIO/scripts/openblt.py index 2911a28e78..01cd9c9ef2 100644 --- a/buildroot/share/PlatformIO/scripts/openblt.py +++ b/buildroot/share/PlatformIO/scripts/openblt.py @@ -1,5 +1,6 @@ -# Generate the firmware as OpenBLT needs - +# +# Convert the ELF to an SREC file suitable for some bootloaders +# import os,sys from os.path import join @@ -10,5 +11,5 @@ env.AddPostAction( env.VerboseAction(" ".join([ "$OBJCOPY", "-O", "srec", "\"$BUILD_DIR/${PROGNAME}.elf\"", "\"$BUILD_DIR/${PROGNAME}.srec\"" - ]), "Building " + join("$BUILD_DIR","${PROGNAME}.srec")) + ]), "Building " + join("$BUILD_DIR", "${PROGNAME}.srec")) ) diff --git a/buildroot/share/PlatformIO/scripts/stm32_bootloader.py b/buildroot/share/PlatformIO/scripts/stm32_bootloader.py index bbec61750c..1ceff84b8f 100644 --- a/buildroot/share/PlatformIO/scripts/stm32_bootloader.py +++ b/buildroot/share/PlatformIO/scripts/stm32_bootloader.py @@ -7,18 +7,28 @@ 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) +# +# For build.offset define LD_FLASH_OFFSET, used by ldscript.ld +# if 'offset' in board.get("build").keys(): LD_FLASH_OFFSET = board.get("build.offset") + # Remove an existing VECT_TAB_OFFSET from CPPDEFINES for define in env['CPPDEFINES']: if define[0] == "VECT_TAB_OFFSET": env['CPPDEFINES'].remove(define) + + # Replace VECT_TAB_OFFSET with our LD_FLASH_OFFSET env['CPPDEFINES'].append(("VECT_TAB_OFFSET", LD_FLASH_OFFSET)) + # Get upload.maximum_ram_size (defined by /buildroot/share/PlatformIO/boards/VARIOUS.json) maximum_ram_size = board.get("upload.maximum_ram_size") for i, flag in enumerate(env["LINKFLAGS"]): @@ -27,7 +37,9 @@ if 'offset' in board.get("build").keys(): if "-Wl,--defsym=LD_MAX_DATA_SIZE" in flag: env["LINKFLAGS"][i] = "-Wl,--defsym=LD_MAX_DATA_SIZE=" + str(maximum_ram_size - 40) +# +# Only copy the file if there's no encrypt +# board_keys = board.get("build").keys() -# Only copy file if there's no encryptation if 'firmware' in board_keys and not 'encrypt' in board_keys: env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", noencrypt) diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/ldscript.ld index 19eec62fba..aa685e8111 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/ldscript.ld @@ -58,9 +58,9 @@ _Min_Stack_Size = 0x400; /* required amount of stack */ /* Specify the memory areas */ MEMORY { -RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE -CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K -FLASH (rx) : ORIGIN = 0x8000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET +RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE +CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K +FLASH (rx) : ORIGIN = 0x08000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET } /* Define output sections */