Browse Source

STM32 PIO: Override default LD Script using LINKFLAGS build scope (#15853)

Ivan Kravets 5 years ago
parent
commit
4ff708cb3a

+ 8
- 1
buildroot/share/PlatformIO/scripts/STM32F103RC_SKR_MINI.py View File

1
+import os
1
 Import("env")
2
 Import("env")
2
 
3
 
3
 # Relocate firmware from 0x08000000 to 0x08007000
4
 # Relocate firmware from 0x08000000 to 0x08007000
5
     if define[0] == "VECT_TAB_ADDR":
6
     if define[0] == "VECT_TAB_ADDR":
6
         env['CPPDEFINES'].remove(define)
7
         env['CPPDEFINES'].remove(define)
7
 env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000"))
8
 env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000"))
8
-env.Replace(LDSCRIPT_PATH="buildroot/share/PlatformIO/ldscripts/STM32F103RC_SKR_MINI.ld")
9
+
10
+custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/STM32F103RC_SKR_MINI.ld")
11
+for i, flag in enumerate(env["LINKFLAGS"]):
12
+    if "-Wl,-T" in flag:
13
+        env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script
14
+    elif flag == "-T":
15
+        env["LINKFLAGS"][i + 1] = custom_ld_script

+ 0
- 1
buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py View File

5
 # Relocate firmware from 0x08000000 to 0x08002000
5
 # Relocate firmware from 0x08000000 to 0x08002000
6
 #env['CPPDEFINES'].remove(("VECT_TAB_ADDR", 134217728))
6
 #env['CPPDEFINES'].remove(("VECT_TAB_ADDR", 134217728))
7
 #env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08010000"))
7
 #env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08010000"))
8
-#env.Replace(LDSCRIPT_PATH="buildroot/share/PlatformIO/ldscripts/fysetc_aio_ii.ld")
9
 
8
 
10
 # Custom HEX from ELF
9
 # Custom HEX from ELF
11
 env.AddPostAction(
10
 env.AddPostAction(

+ 9
- 1
buildroot/share/PlatformIO/scripts/STM32F103VE_longer.py View File

1
+import os
1
 Import("env")
2
 Import("env")
2
 
3
 
3
 # Relocate firmware from 0x08000000 to 0x08010000
4
 # Relocate firmware from 0x08000000 to 0x08010000
5
     if define[0] == "VECT_TAB_ADDR":
6
     if define[0] == "VECT_TAB_ADDR":
6
         env['CPPDEFINES'].remove(define)
7
         env['CPPDEFINES'].remove(define)
7
 env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08010000"))
8
 env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08010000"))
8
-env.Replace(LDSCRIPT_PATH="buildroot/share/PlatformIO/ldscripts/STM32F103VE_longer.ld")
9
+
10
+custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/STM32F103VE_longer.ld")
11
+for i, flag in enumerate(env["LINKFLAGS"]):
12
+    if "-Wl,-T" in flag:
13
+        env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script
14
+    elif flag == "-T":
15
+        env["LINKFLAGS"][i + 1] = custom_ld_script
16
+
9
 
17
 
10
 # Rename ${PROGNAME}.bin and save it as 'project.bin' (No encryption on the Longer3D)
18
 # Rename ${PROGNAME}.bin and save it as 'project.bin' (No encryption on the Longer3D)
11
 def encrypt(source, target, env):
19
 def encrypt(source, target, env):

+ 10
- 2
buildroot/share/PlatformIO/scripts/chitu_crypt.py View File

1
-Import("env")
1
+import os
2
 import struct
2
 import struct
3
+Import("env")
3
 
4
 
4
 # Relocate firmware from 0x08000000 to 0x08008800
5
 # Relocate firmware from 0x08000000 to 0x08008800
5
 for define in env['CPPDEFINES']:
6
 for define in env['CPPDEFINES']:
6
     if define[0] == "VECT_TAB_ADDR":
7
     if define[0] == "VECT_TAB_ADDR":
7
         env['CPPDEFINES'].remove(define)
8
         env['CPPDEFINES'].remove(define)
8
 env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x8008800"))
9
 env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x8008800"))
9
-env.Replace(LDSCRIPT_PATH="buildroot/share/PlatformIO/ldscripts/chitu_f103.ld")
10
+
11
+custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/chitu_f103.ld")
12
+for i, flag in enumerate(env["LINKFLAGS"]):
13
+    if "-Wl,-T" in flag:
14
+        env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script
15
+    elif flag == "-T":
16
+        env["LINKFLAGS"][i + 1] = custom_ld_script
17
+
10
 
18
 
11
 def calculate_crc(contents, seed):
19
 def calculate_crc(contents, seed):
12
     accumulating_xor_value = seed;
20
     accumulating_xor_value = seed;

+ 8
- 1
buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py View File

1
+import os
1
 Import("env")
2
 Import("env")
2
 
3
 
3
 # Relocate firmware from 0x08000000 to 0x0800A000
4
 # Relocate firmware from 0x08000000 to 0x0800A000
5
 #alternatively, for STSTM <=5.1.0 use line below
6
 #alternatively, for STSTM <=5.1.0 use line below
6
 #env['CPPDEFINES'].remove(("VECT_TAB_ADDR", 134217728))
7
 #env['CPPDEFINES'].remove(("VECT_TAB_ADDR", 134217728))
7
 env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x0800A000"))
8
 env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x0800A000"))
8
-env.Replace(LDSCRIPT_PATH="buildroot/share/PlatformIO/ldscripts/jgaurora_a5s_a1.ld")
9
+
10
+custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/jgaurora_a5s_a1.ld")
11
+for i, flag in enumerate(env["LINKFLAGS"]):
12
+    if "-Wl,-T" in flag:
13
+        env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script
14
+    elif flag == "-T":
15
+        env["LINKFLAGS"][i + 1] = custom_ld_script
9
 
16
 
10
 #append ${PROGNAME}.bin firmware after bootloader and save it as 'jgaurora_firmware.bin'
17
 #append ${PROGNAME}.bin firmware after bootloader and save it as 'jgaurora_firmware.bin'
11
 def addboot(source,target,env):
18
 def addboot(source,target,env):

+ 8
- 1
buildroot/share/PlatformIO/scripts/mks_robin.py View File

1
+import os
1
 Import("env")
2
 Import("env")
2
 
3
 
3
 # Relocate firmware from 0x08000000 to 0x08007000
4
 # Relocate firmware from 0x08000000 to 0x08007000
5
     if define[0] == "VECT_TAB_ADDR":
6
     if define[0] == "VECT_TAB_ADDR":
6
         env['CPPDEFINES'].remove(define)
7
         env['CPPDEFINES'].remove(define)
7
 env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000"))
8
 env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000"))
8
-env.Replace(LDSCRIPT_PATH="buildroot/share/PlatformIO/ldscripts/mks_robin.ld")
9
+
10
+custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin.ld")
11
+for i, flag in enumerate(env["LINKFLAGS"]):
12
+    if "-Wl,-T" in flag:
13
+        env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script
14
+    elif flag == "-T":
15
+        env["LINKFLAGS"][i + 1] = custom_ld_script
9
 
16
 
10
 # Encrypt ${PROGNAME}.bin and save it as 'Robin.bin'
17
 # Encrypt ${PROGNAME}.bin and save it as 'Robin.bin'
11
 def encrypt(source, target, env):
18
 def encrypt(source, target, env):

+ 9
- 1
buildroot/share/PlatformIO/scripts/mks_robin_lite.py View File

1
+import os
1
 Import("env")
2
 Import("env")
2
 
3
 
3
 # Relocate firmware from 0x08000000 to 0x08005000
4
 # Relocate firmware from 0x08000000 to 0x08005000
5
     if define[0] == "VECT_TAB_ADDR":
6
     if define[0] == "VECT_TAB_ADDR":
6
         env['CPPDEFINES'].remove(define)
7
         env['CPPDEFINES'].remove(define)
7
 env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08005000"))
8
 env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08005000"))
8
-env.Replace(LDSCRIPT_PATH="buildroot/share/PlatformIO/ldscripts/mks_robin_lite.ld")
9
+
10
+custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin_lite.ld")
11
+for i, flag in enumerate(env["LINKFLAGS"]):
12
+    if "-Wl,-T" in flag:
13
+        env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script
14
+    elif flag == "-T":
15
+        env["LINKFLAGS"][i + 1] = custom_ld_script
16
+
9
 
17
 
10
 # Encrypt ${PROGNAME}.bin and save it as 'mksLite.bin'
18
 # Encrypt ${PROGNAME}.bin and save it as 'mksLite.bin'
11
 def encrypt(source, target, env):
19
 def encrypt(source, target, env):

+ 10
- 1
buildroot/share/PlatformIO/scripts/mks_robin_mini.py View File

1
+import os
2
+
1
 Import("env")
3
 Import("env")
2
 
4
 
3
 # Relocate firmware from 0x08000000 to 0x08007000
5
 # Relocate firmware from 0x08000000 to 0x08007000
5
     if define[0] == "VECT_TAB_ADDR":
7
     if define[0] == "VECT_TAB_ADDR":
6
         env['CPPDEFINES'].remove(define)
8
         env['CPPDEFINES'].remove(define)
7
 env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000"))
9
 env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000"))
8
-env.Replace(LDSCRIPT_PATH="buildroot/share/PlatformIO/ldscripts/mks_robin_mini.ld")
10
+
11
+custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin_mini.ld")
12
+for i, flag in enumerate(env["LINKFLAGS"]):
13
+    if "-Wl,-T" in flag:
14
+        env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script
15
+    elif flag == "-T":
16
+        env["LINKFLAGS"][i + 1] = custom_ld_script
17
+
9
 
18
 
10
 # Encrypt ${PROGNAME}.bin and save it as 'Robin_mini.bin'
19
 # Encrypt ${PROGNAME}.bin and save it as 'Robin_mini.bin'
11
 def encrypt(source, target, env):
20
 def encrypt(source, target, env):

+ 9
- 1
buildroot/share/PlatformIO/scripts/mks_robin_nano.py View File

1
+import os
1
 Import("env")
2
 Import("env")
2
 
3
 
3
 # Relocate firmware from 0x08000000 to 0x08007000
4
 # Relocate firmware from 0x08000000 to 0x08007000
5
     if define[0] == "VECT_TAB_ADDR":
6
     if define[0] == "VECT_TAB_ADDR":
6
         env['CPPDEFINES'].remove(define)
7
         env['CPPDEFINES'].remove(define)
7
 env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000"))
8
 env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000"))
8
-env.Replace(LDSCRIPT_PATH="buildroot/share/PlatformIO/ldscripts/mks_robin_nano.ld")
9
+
10
+custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin_nano.ld")
11
+for i, flag in enumerate(env["LINKFLAGS"]):
12
+    if "-Wl,-T" in flag:
13
+        env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script
14
+    elif flag == "-T":
15
+        env["LINKFLAGS"][i + 1] = custom_ld_script
16
+
9
 
17
 
10
 # Encrypt ${PROGNAME}.bin and save it as 'Robin_nano.bin'
18
 # Encrypt ${PROGNAME}.bin and save it as 'Robin_nano.bin'
11
 def encrypt(source, target, env):
19
 def encrypt(source, target, env):

Loading…
Cancel
Save