Comment, clean up some PlatformIO scripts

This commit is contained in:
Scott Lahteine 2021-03-22 23:58:03 -05:00
parent 30e7e2c276
commit 832059967c
4 changed files with 23 additions and 10 deletions

View File

@ -40,9 +40,9 @@ _Min_Stack_Size = 0x400;; /* required amount of stack */
/* Specify the memory areas */ /* Specify the memory areas */
MEMORY MEMORY
{ {
FLASH (rx) : ORIGIN = 0x8000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET FLASH (rx) : ORIGIN = 0x08000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE
CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K
} }
/* Define output sections */ /* Define output sections */

View File

@ -1,5 +1,6 @@
# Generate the firmware as OpenBLT needs #
# Convert the ELF to an SREC file suitable for some bootloaders
#
import os,sys import os,sys
from os.path import join from os.path import join
@ -10,5 +11,5 @@ env.AddPostAction(
env.VerboseAction(" ".join([ env.VerboseAction(" ".join([
"$OBJCOPY", "-O", "srec", "$OBJCOPY", "-O", "srec",
"\"$BUILD_DIR/${PROGNAME}.elf\"", "\"$BUILD_DIR/${PROGNAME}.srec\"" "\"$BUILD_DIR/${PROGNAME}.elf\"", "\"$BUILD_DIR/${PROGNAME}.srec\""
]), "Building " + join("$BUILD_DIR","${PROGNAME}.srec")) ]), "Building " + join("$BUILD_DIR", "${PROGNAME}.srec"))
) )

View File

@ -7,18 +7,28 @@ Import("env")
from SCons.Script import DefaultEnvironment from SCons.Script import DefaultEnvironment
board = DefaultEnvironment().BoardConfig() board = DefaultEnvironment().BoardConfig()
#
# Copy the firmware.bin file to build.firmware, no encryption
#
def noencrypt(source, target, env): def noencrypt(source, target, env):
firmware = os.path.join(target[0].dir.path, board.get("build.firmware")) firmware = os.path.join(target[0].dir.path, board.get("build.firmware"))
shutil.copy(target[0].path, 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(): if 'offset' in board.get("build").keys():
LD_FLASH_OFFSET = board.get("build.offset") LD_FLASH_OFFSET = board.get("build.offset")
# Remove an existing VECT_TAB_OFFSET from CPPDEFINES
for define in env['CPPDEFINES']: for define in env['CPPDEFINES']:
if define[0] == "VECT_TAB_OFFSET": if define[0] == "VECT_TAB_OFFSET":
env['CPPDEFINES'].remove(define) env['CPPDEFINES'].remove(define)
# Replace VECT_TAB_OFFSET with our LD_FLASH_OFFSET
env['CPPDEFINES'].append(("VECT_TAB_OFFSET", 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") maximum_ram_size = board.get("upload.maximum_ram_size")
for i, flag in enumerate(env["LINKFLAGS"]): 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: if "-Wl,--defsym=LD_MAX_DATA_SIZE" in flag:
env["LINKFLAGS"][i] = "-Wl,--defsym=LD_MAX_DATA_SIZE=" + str(maximum_ram_size - 40) 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() 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: if 'firmware' in board_keys and not 'encrypt' in board_keys:
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", noencrypt) env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", noencrypt)

View File

@ -58,9 +58,9 @@ _Min_Stack_Size = 0x400; /* required amount of stack */
/* Specify the memory areas */ /* Specify the memory areas */
MEMORY MEMORY
{ {
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE
CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K
FLASH (rx) : ORIGIN = 0x8000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET FLASH (rx) : ORIGIN = 0x08000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET
} }
/* Define output sections */ /* Define output sections */