ソースを参照

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

Ivan Kravets 5年前
コミット
4ff708cb3a

+ 8
- 1
buildroot/share/PlatformIO/scripts/STM32F103RC_SKR_MINI.py ファイルの表示

@@ -1,3 +1,4 @@
1
+import os
1 2
 Import("env")
2 3
 
3 4
 # Relocate firmware from 0x08000000 to 0x08007000
@@ -5,4 +6,10 @@ for define in env['CPPDEFINES']:
5 6
     if define[0] == "VECT_TAB_ADDR":
6 7
         env['CPPDEFINES'].remove(define)
7 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 ファイルの表示

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

+ 9
- 1
buildroot/share/PlatformIO/scripts/STM32F103VE_longer.py ファイルの表示

@@ -1,3 +1,4 @@
1
+import os
1 2
 Import("env")
2 3
 
3 4
 # Relocate firmware from 0x08000000 to 0x08010000
@@ -5,7 +6,14 @@ for define in env['CPPDEFINES']:
5 6
     if define[0] == "VECT_TAB_ADDR":
6 7
         env['CPPDEFINES'].remove(define)
7 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 18
 # Rename ${PROGNAME}.bin and save it as 'project.bin' (No encryption on the Longer3D)
11 19
 def encrypt(source, target, env):

+ 10
- 2
buildroot/share/PlatformIO/scripts/chitu_crypt.py ファイルの表示

@@ -1,12 +1,20 @@
1
-Import("env")
1
+import os
2 2
 import struct
3
+Import("env")
3 4
 
4 5
 # Relocate firmware from 0x08000000 to 0x08008800
5 6
 for define in env['CPPDEFINES']:
6 7
     if define[0] == "VECT_TAB_ADDR":
7 8
         env['CPPDEFINES'].remove(define)
8 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 19
 def calculate_crc(contents, seed):
12 20
     accumulating_xor_value = seed;

+ 8
- 1
buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py ファイルの表示

@@ -1,3 +1,4 @@
1
+import os
1 2
 Import("env")
2 3
 
3 4
 # Relocate firmware from 0x08000000 to 0x0800A000
@@ -5,7 +6,13 @@ env['CPPDEFINES'].remove(("VECT_TAB_ADDR", "0x8000000"))
5 6
 #alternatively, for STSTM <=5.1.0 use line below
6 7
 #env['CPPDEFINES'].remove(("VECT_TAB_ADDR", 134217728))
7 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 17
 #append ${PROGNAME}.bin firmware after bootloader and save it as 'jgaurora_firmware.bin'
11 18
 def addboot(source,target,env):

+ 8
- 1
buildroot/share/PlatformIO/scripts/mks_robin.py ファイルの表示

@@ -1,3 +1,4 @@
1
+import os
1 2
 Import("env")
2 3
 
3 4
 # Relocate firmware from 0x08000000 to 0x08007000
@@ -5,7 +6,13 @@ for define in env['CPPDEFINES']:
5 6
     if define[0] == "VECT_TAB_ADDR":
6 7
         env['CPPDEFINES'].remove(define)
7 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 17
 # Encrypt ${PROGNAME}.bin and save it as 'Robin.bin'
11 18
 def encrypt(source, target, env):

+ 9
- 1
buildroot/share/PlatformIO/scripts/mks_robin_lite.py ファイルの表示

@@ -1,3 +1,4 @@
1
+import os
1 2
 Import("env")
2 3
 
3 4
 # Relocate firmware from 0x08000000 to 0x08005000
@@ -5,7 +6,14 @@ for define in env['CPPDEFINES']:
5 6
     if define[0] == "VECT_TAB_ADDR":
6 7
         env['CPPDEFINES'].remove(define)
7 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 18
 # Encrypt ${PROGNAME}.bin and save it as 'mksLite.bin'
11 19
 def encrypt(source, target, env):

+ 10
- 1
buildroot/share/PlatformIO/scripts/mks_robin_mini.py ファイルの表示

@@ -1,3 +1,5 @@
1
+import os
2
+
1 3
 Import("env")
2 4
 
3 5
 # Relocate firmware from 0x08000000 to 0x08007000
@@ -5,7 +7,14 @@ for define in env['CPPDEFINES']:
5 7
     if define[0] == "VECT_TAB_ADDR":
6 8
         env['CPPDEFINES'].remove(define)
7 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 19
 # Encrypt ${PROGNAME}.bin and save it as 'Robin_mini.bin'
11 20
 def encrypt(source, target, env):

+ 9
- 1
buildroot/share/PlatformIO/scripts/mks_robin_nano.py ファイルの表示

@@ -1,3 +1,4 @@
1
+import os
1 2
 Import("env")
2 3
 
3 4
 # Relocate firmware from 0x08000000 to 0x08007000
@@ -5,7 +6,14 @@ for define in env['CPPDEFINES']:
5 6
     if define[0] == "VECT_TAB_ADDR":
6 7
         env['CPPDEFINES'].remove(define)
7 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 18
 # Encrypt ${PROGNAME}.bin and save it as 'Robin_nano.bin'
11 19
 def encrypt(source, target, env):

読み込み中…
キャンセル
保存