|
@@ -7,18 +7,28 @@ Import("env")
|
7
|
7
|
from SCons.Script import DefaultEnvironment
|
8
|
8
|
board = DefaultEnvironment().BoardConfig()
|
9
|
9
|
|
|
10
|
+#
|
|
11
|
+# Copy the firmware.bin file to build.firmware, no encryption
|
|
12
|
+#
|
10
|
13
|
def noencrypt(source, target, env):
|
11
|
14
|
firmware = os.path.join(target[0].dir.path, board.get("build.firmware"))
|
12
|
15
|
shutil.copy(target[0].path, firmware)
|
13
|
16
|
|
|
17
|
+#
|
|
18
|
+# For build.offset define LD_FLASH_OFFSET, used by ldscript.ld
|
|
19
|
+#
|
14
|
20
|
if 'offset' in board.get("build").keys():
|
15
|
21
|
LD_FLASH_OFFSET = board.get("build.offset")
|
16
|
22
|
|
|
23
|
+ # Remove an existing VECT_TAB_OFFSET from CPPDEFINES
|
17
|
24
|
for define in env['CPPDEFINES']:
|
18
|
25
|
if define[0] == "VECT_TAB_OFFSET":
|
19
|
26
|
env['CPPDEFINES'].remove(define)
|
|
27
|
+
|
|
28
|
+ # Replace VECT_TAB_OFFSET with our LD_FLASH_OFFSET
|
20
|
29
|
env['CPPDEFINES'].append(("VECT_TAB_OFFSET", LD_FLASH_OFFSET))
|
21
|
30
|
|
|
31
|
+ # Get upload.maximum_ram_size (defined by /buildroot/share/PlatformIO/boards/VARIOUS.json)
|
22
|
32
|
maximum_ram_size = board.get("upload.maximum_ram_size")
|
23
|
33
|
|
24
|
34
|
for i, flag in enumerate(env["LINKFLAGS"]):
|
|
@@ -27,7 +37,9 @@ if 'offset' in board.get("build").keys():
|
27
|
37
|
if "-Wl,--defsym=LD_MAX_DATA_SIZE" in flag:
|
28
|
38
|
env["LINKFLAGS"][i] = "-Wl,--defsym=LD_MAX_DATA_SIZE=" + str(maximum_ram_size - 40)
|
29
|
39
|
|
|
40
|
+#
|
|
41
|
+# Only copy the file if there's no encrypt
|
|
42
|
+#
|
30
|
43
|
board_keys = board.get("build").keys()
|
31
|
|
-# Only copy file if there's no encryptation
|
32
|
44
|
if 'firmware' in board_keys and not 'encrypt' in board_keys:
|
33
|
45
|
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", noencrypt)
|