Przeglądaj źródła

🔨 Consolidate STM32 extra_scripts (#22365)

Scott Lahteine 3 lat temu
rodzic
commit
5ca9ebfa6b

+ 1
- 1
buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py Wyświetl plik

@@ -10,7 +10,7 @@ Import("env")
10 10
 env.AddPostAction(
11 11
 	join("$BUILD_DIR", "${PROGNAME}.elf"),
12 12
 	env.VerboseAction(" ".join([
13
-		"$OBJCOPY", "-O ihex", "$TARGET", # TARGET=.pio/build/fysetc_STM32F1/firmware.elf
13
+		"$OBJCOPY", "-O ihex", "$TARGET",
14 14
 		"\"" + join("$BUILD_DIR", "${PROGNAME}.hex") + "\"", # Note: $BUILD_DIR is a full path
15 15
 	]), "Building $TARGET"))
16 16
 

+ 0
- 29
buildroot/share/PlatformIO/scripts/mks_encrypt.py Wyświetl plik

@@ -1,29 +0,0 @@
1
-#
2
-# buildroot/share/PlatformIO/scripts/mks_encrypt.py
3
-#
4
-# Apply encryption and save as 'build.firmware' for these environments:
5
-#  - env:mks_robin
6
-#  - env:mks_robin_e3
7
-#  - env:flsun_hispeedv1
8
-#  - env:mks_robin_nano35
9
-#
10
-Import("env")
11
-
12
-from SCons.Script import DefaultEnvironment
13
-board = DefaultEnvironment().BoardConfig()
14
-
15
-if 'encrypt' in board.get("build").keys():
16
-
17
-	import marlin
18
-
19
-	# Encrypt ${PROGNAME}.bin and save it with the name given in build.encrypt
20
-	def encrypt(source, target, env):
21
-		marlin.encrypt_mks(source, target, env, board.get("build.encrypt"))
22
-
23
-	marlin.add_post_action(encrypt);
24
-
25
-else:
26
-
27
-	import sys
28
-	print("You need to define output file via board_build.encrypt = 'filename' parameter", file=sys.stderr)
29
-	env.Exit(1);

buildroot/share/PlatformIO/scripts/stm32_bootloader.py → buildroot/share/PlatformIO/scripts/offset_and_rename.py Wyświetl plik

@@ -1,5 +1,5 @@
1 1
 #
2
-# stm32_bootloader.py
2
+# offset_and_rename.py
3 3
 #
4 4
 # - If 'build.offset' is provided, either by JSON or by the environment...
5 5
 # 	- Set linker flag LD_FLASH_OFFSET and relocate the VTAB based on 'build.offset'.
@@ -37,6 +37,17 @@ if 'offset' in board_keys:
37 37
 			env["LINKFLAGS"][i] = "-Wl,--defsym=LD_MAX_DATA_SIZE=" + str(maximum_ram_size - 40)
38 38
 
39 39
 #
40
+# For build.encrypt rename and encode the firmware file.
41
+#
42
+if 'encrypt' in board_keys:
43
+
44
+	# Encrypt ${PROGNAME}.bin and save it with the name given in build.encrypt
45
+	def encrypt(source, target, env):
46
+		marlin.encrypt_mks(source, target, env, board.get("build.encrypt"))
47
+
48
+	marlin.add_post_action(encrypt);
49
+
50
+#
40 51
 # For build.rename simply rename the firmware file.
41 52
 #
42 53
 if 'rename' in board_keys:

+ 1
- 2
ini/avr.ini Wyświetl plik

@@ -53,8 +53,7 @@ board    = megaatmega1280
53 53
 [mega_extended_optimized]
54 54
 extends             = common_avr8
55 55
 board_build.variant = MARLIN_MEGA_EXTENDED
56
-extra_scripts       = ${common.extra_scripts}
57
-                      pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
56
+extra_scripts       = ${env:mega2560ext.extra_scripts}
58 57
 upload_speed        = 57600
59 58
 build_flags         = ${common.build_flags} -fno-tree-scev-cprop -fno-split-wide-types -Wl,--relax -mcall-prologues
60 59
 

+ 13
- 28
ini/stm32f1.ini Wyświetl plik

@@ -34,6 +34,11 @@ src_filter    = ${common.default_src_filter} +<src/HAL/STM32> +<src/HAL/shared/b
34 34
 extra_scripts = ${common.extra_scripts}
35 35
   pre:buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py
36 36
 
37
+[stm32f1_variant]
38
+extra_scripts        = ${common_stm32.extra_scripts}
39
+  pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
40
+  buildroot/share/PlatformIO/scripts/offset_and_rename.py
41
+
37 42
 [common_STM32F103RC]
38 43
 platform             = ${common_stm32.platform}
39 44
 extends              = common_stm32
@@ -41,9 +46,7 @@ board                = genericSTM32F103RC
41 46
 monitor_speed        = 115200
42 47
 board_build.core     = stm32
43 48
 board_build.variant  = MARLIN_F103Rx
44
-extra_scripts        = ${common_stm32.extra_scripts}
45
-  pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
46
-  buildroot/share/PlatformIO/scripts/stm32_bootloader.py
49
+extra_scripts        = ${stm32f1_variant.extra_scripts}
47 50
 
48 51
 #
49 52
 # STM32F103RE
@@ -113,10 +116,7 @@ build_flags          = ${common_stm32.build_flags}
113 116
   -DENABLE_HWSERIAL3 -DTIMER_SERIAL=TIM5
114 117
 build_unflags        = ${common_stm32.build_unflags}
115 118
  -DUSBCON -DUSBD_USE_CDC
116
-extra_scripts        = ${common_stm32.extra_scripts}
117
-  pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
118
-  buildroot/share/PlatformIO/scripts/stm32_bootloader.py
119
-  buildroot/share/PlatformIO/scripts/mks_encrypt.py
119
+extra_scripts        = ${stm32f1_variant.extra_scripts}
120 120
 lib_deps             =
121 121
 
122 122
 #
@@ -134,7 +134,6 @@ board_build.encrypt         = Robin_e3.bin
134 134
 board_upload.offset_address = 0x08005000
135 135
 debug_tool                  = stlink
136 136
 extra_scripts               = ${common_STM32F103RC.extra_scripts}
137
-  buildroot/share/PlatformIO/scripts/mks_encrypt.py
138 137
 
139 138
 #
140 139
 # Creality (STM32F103RET6)
@@ -150,10 +149,8 @@ board_build.variant  = MARLIN_F103Rx
150 149
 board_build.offset   = 0x7000
151 150
 board_upload.offset_address = 0x08007000
152 151
 build_unflags        = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC
153
-extra_scripts        = ${common_stm32.extra_scripts}
154
-  pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
152
+extra_scripts        = ${stm32f1_variant.extra_scripts}
155 153
   pre:buildroot/share/PlatformIO/scripts/random-bin.py
156
-  buildroot/share/PlatformIO/scripts/stm32_bootloader.py
157 154
 debug_tool           = jlink
158 155
 upload_protocol      = jlink
159 156
 
@@ -174,9 +171,7 @@ board_build.variant  = MARLIN_F103Rx
174 171
 board_build.offset   = 0x7000
175 172
 board_upload.offset_address = 0x08007000
176 173
 build_unflags        = ${common_stm32.build_unflags}
177
-extra_scripts        = ${common_stm32.extra_scripts}
178
-  pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
179
-  buildroot/share/PlatformIO/scripts/stm32_bootloader.py
174
+extra_scripts        = ${stm32f1_variant.extra_scripts}
180 175
 debug_tool           = jlink
181 176
 upload_protocol      = jlink
182 177
 
@@ -207,10 +202,7 @@ board_build.offset   = 0x7000
207 202
 board_build.encrypt  = Robin_mini.bin
208 203
 board_upload.offset_address = 0x08007000
209 204
 build_unflags        = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC
210
-extra_scripts        = ${common_stm32.extra_scripts}
211
-  pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
212
-  buildroot/share/PlatformIO/scripts/stm32_bootloader.py
213
-  buildroot/share/PlatformIO/scripts/mks_encrypt.py
205
+extra_scripts        = ${stm32f1_variant.extra_scripts}
214 206
 
215 207
 #
216 208
 # MKS Robin Nano V1.2 and V2
@@ -228,10 +220,7 @@ board_upload.offset_address = 0x08007000
228 220
 build_unflags        = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC
229 221
 debug_tool           = jlink
230 222
 upload_protocol      = jlink
231
-extra_scripts        = ${common_stm32.extra_scripts}
232
-  pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
233
-  buildroot/share/PlatformIO/scripts/stm32_bootloader.py
234
-  buildroot/share/PlatformIO/scripts/mks_encrypt.py
223
+extra_scripts        = ${stm32f1_variant.extra_scripts}
235 224
 
236 225
 #
237 226
 # Mingda MPX_ARM_MINI
@@ -245,9 +234,7 @@ board_build.variant  = MARLIN_F103Zx
245 234
 board_build.offset   = 0x10000
246 235
 build_flags          = ${common_stm32.build_flags} -DENABLE_HWSERIAL3 -DTIMER_SERIAL=TIM5
247 236
 build_unflags        = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC
248
-extra_scripts        = ${common_stm32.extra_scripts}
249
-  pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
250
-  buildroot/share/PlatformIO/scripts/stm32_bootloader.py
237
+extra_scripts        = ${stm32f1_variant.extra_scripts}
251 238
 
252 239
 #
253 240
 # Malyan M200 (STM32F103CB)
@@ -272,6 +259,4 @@ board_build.core     = stm32
272 259
 board_build.variant  = MARLIN_F103Rx
273 260
 board_build.offset   = 0x5000
274 261
 board_upload.offset_address = 0x08005000
275
-extra_scripts        = ${common_stm32.extra_scripts}
276
-  pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
277
-  buildroot/share/PlatformIO/scripts/stm32_bootloader.py
262
+extra_scripts        = ${stm32f1_variant.extra_scripts}

+ 23
- 43
ini/stm32f4.ini Wyświetl plik

@@ -29,6 +29,11 @@ board         = armed_v1
29 29
 build_flags   = ${common_stm32.build_flags}
30 30
   -O2 -ffreestanding -fsigned-char -fno-move-loop-invariants -fno-strict-aliasing
31 31
 
32
+[stm32f4_variant]
33
+extra_scripts        = ${common.extra_scripts}
34
+  pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
35
+  buildroot/share/PlatformIO/scripts/offset_and_rename.py
36
+
32 37
 #
33 38
 # STM32F401VE
34 39
 # 'STEVAL-3DP001V1' STM32F401VE board - https://www.st.com/en/evaluation-tools/steval-3dp001v1.html
@@ -40,8 +45,7 @@ board             = marlin_STEVAL_STM32F401VE
40 45
 build_flags       = ${common_stm32.build_flags}
41 46
   -DARDUINO_STEVAL -DSTM32F401xE
42 47
   -DDISABLE_GENERIC_SERIALUSB -DUSBD_USE_CDC_COMPOSITE -DUSE_USB_FS
43
-extra_scripts     = ${common.extra_scripts}
44
-  pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
48
+extra_scripts     = ${stm32f4_variant.extra_scripts}
45 49
 
46 50
 #
47 51
 # STM32F401RC
@@ -51,8 +55,7 @@ platform          = ${common_stm32.platform}
51 55
 extends           = common_stm32
52 56
 board             = marlin_FYSETC_CHEETAH_V20
53 57
 build_flags       = ${common_stm32.build_flags} -DSTM32F401xC -DVECT_TAB_OFFSET=0xC000
54
-extra_scripts     = ${common.extra_scripts}
55
-  pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
58
+extra_scripts     = ${stm32f4_variant.extra_scripts}
56 59
 
57 60
 #
58 61
 # FLYF407ZG
@@ -65,8 +68,7 @@ board_build.variant = MARLIN_FLY_F407ZG
65 68
 upload_protocol     = dfu
66 69
 build_flags         = ${common_stm32.build_flags}
67 70
   -DVECT_TAB_OFFSET=0x8000
68
-extra_scripts       = ${common.extra_scripts}
69
-  pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
71
+extra_scripts       = ${stm32f4_variant.extra_scripts}
70 72
 
71 73
 #
72 74
 # FYSETC S6 (STM32F446RET6 ARM Cortex-M4)
@@ -77,8 +79,7 @@ extends           = common_stm32
77 79
 platform_packages = tool-stm32duino
78 80
 board             = marlin_fysetc_s6
79 81
 build_flags       = ${common_stm32.build_flags} -DVECT_TAB_OFFSET=0x10000 -DHAL_PCD_MODULE_ENABLED
80
-extra_scripts     = ${common.extra_scripts}
81
-  pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
82
+extra_scripts     = ${stm32f4_variant.extra_scripts}
82 83
 debug_tool        = stlink
83 84
 upload_protocol   = dfu
84 85
 upload_command    = dfu-util -a 0 -s 0x08010000:leave -D "$SOURCE"
@@ -93,9 +94,7 @@ board                       = marlin_fysetc_s6_8000
93 94
 board_build.offset          = 0x8000
94 95
 board_upload.offset_address = 0x08008000
95 96
 build_flags                 = ${common_stm32.build_flags} -DHAL_PCD_MODULE_ENABLED
96
-extra_scripts               = ${common.extra_scripts}
97
-  pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
98
-  buildroot/share/PlatformIO/scripts/stm32_bootloader.py
97
+extra_scripts               = ${stm32f4_variant.extra_scripts}
99 98
 upload_command              = dfu-util -a 0 -s 0x08008000:leave -D "$SOURCE"
100 99
 
101 100
 #
@@ -110,8 +109,7 @@ board             = marlin_blackSTM32F407VET6
110 109
 build_flags       = ${common_stm32.build_flags}
111 110
   -DARDUINO_BLACK_F407VE
112 111
   -DUSBD_USE_CDC_COMPOSITE -DUSE_USB_FS
113
-extra_scripts     = ${common.extra_scripts}
114
-  pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
112
+extra_scripts     = ${stm32f4_variant.extra_scripts}
115 113
 
116 114
 #
117 115
 # Anet ET4-MB_V1.x/ET4P-MB_V1.x (STM32F407VGT6 ARM Cortex-M4)
@@ -126,15 +124,12 @@ board                = marlin_STM32F407VGT6_CCM
126 124
 board_build.core     = stm32
127 125
 board_build.variant  = MARLIN_F4x7Vx
128 126
 board_build.encrypt  = firmware.srec
129
-# Just openblt.py (not stm32_bootloader.py) generates the file
130 127
 board_build.offset   = 0x10000
131 128
 board_upload.offset_address = 0x08010000
132 129
 build_unflags        = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC -DUSBD_VID=0x0483
133 130
 debug_tool           = jlink
134 131
 upload_protocol      = jlink
135
-extra_scripts        = ${common.extra_scripts}
136
-  pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
137
-  buildroot/share/PlatformIO/scripts/stm32_bootloader.py
132
+extra_scripts        = ${stm32f4_variant.extra_scripts}
138 133
   buildroot/share/PlatformIO/scripts/openblt.py
139 134
 
140 135
 #
@@ -146,8 +141,7 @@ extends           = common_stm32
146 141
 board             = marlin_BigTree_SKR_Pro
147 142
 build_flags       = ${common_stm32.build_flags}
148 143
   -DSTM32F407_5ZX -DVECT_TAB_OFFSET=0x8000
149
-extra_scripts     = ${common.extra_scripts}
150
-  pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
144
+extra_scripts     = ${stm32f4_variant.extra_scripts}
151 145
 #upload_protocol   = stlink
152 146
 #upload_command    = "$PROJECT_PACKAGES_DIR/tool-stm32duino/stlink/ST-LINK_CLI.exe" -c SWD -P "$BUILD_DIR/firmware.bin" 0x8008000 -Rst -Run
153 147
 debug_tool        = stlink
@@ -183,8 +177,7 @@ board_build.variant = MARLIN_BIGTREE_E3_RRF
183 177
 build_flags         = ${common_stm32.build_flags}
184 178
   -DSTM32F407_5VX -DVECT_TAB_OFFSET=0x8000
185 179
   -DSERIAL_RX_BUFFER_SIZE=255 -DSERIAL_TX_BUFFER_SIZE=255
186
-extra_scripts       = ${common.extra_scripts}
187
-  pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
180
+extra_scripts       = ${stm32f4_variant.extra_scripts}
188 181
 
189 182
 #
190 183
 # Bigtreetech GTR V1.0 (STM32F407IGT6 ARM Cortex-M4)
@@ -193,8 +186,7 @@ extra_scripts       = ${common.extra_scripts}
193 186
 platform          = ${common_stm32.platform}
194 187
 extends           = common_stm32
195 188
 board             = marlin_BigTree_GTR_v1
196
-extra_scripts     = ${common.extra_scripts}
197
-  pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
189
+extra_scripts     = ${stm32f4_variant.extra_scripts}
198 190
 build_flags       = ${common_stm32.build_flags}
199 191
   -DSTM32F407IX -DVECT_TAB_OFFSET=0x8000
200 192
 
@@ -221,8 +213,7 @@ build_flags       = ${common_stm32.build_flags}
221 213
   -DHAVE_HWSERIAL3
222 214
   -DPIN_SERIAL2_RX=PD_6
223 215
   -DPIN_SERIAL2_TX=PD_5
224
-extra_scripts     = ${common.extra_scripts}
225
-  pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
216
+extra_scripts     = ${stm32f4_variant.extra_scripts}
226 217
 
227 218
 #
228 219
 # BigTreeTech SKR V2.0 (STM32F407VGT6 ARM Cortex-M4) with USB Flash Drive Support
@@ -236,10 +227,8 @@ board_build.core     = stm32
236 227
 board_build.variant  = MARLIN_F4x7Vx
237 228
 board_build.offset   = 0x8000
238 229
 board_upload.offset_address = 0x08008000
239
-extra_scripts     = ${common.extra_scripts}
240
-  pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
241
-  buildroot/share/PlatformIO/scripts/stm32_bootloader.py
242
-build_flags       = ${stm_flash_drive.build_flags}
230
+extra_scripts        = ${stm32f4_variant.extra_scripts}
231
+build_flags          = ${stm_flash_drive.build_flags}
243 232
   -DUSE_USBHOST_HS -DUSE_USB_HS_IN_FS -DUSBD_IRQ_PRIO=5 -DUSBD_IRQ_SUBPRIO=6
244 233
   -DHSE_VALUE=8000000U -DHAL_SD_MODULE_ENABLED
245 234
 
@@ -260,8 +249,7 @@ build_flags       = ${env:BIGTREE_SKR_2.build_flags} -DUSBD_USE_CDC_MSC
260 249
 platform          = ${common_stm32.platform}
261 250
 extends           = common_stm32
262 251
 board             = marlin_BigTree_Octopus_v1
263
-extra_scripts     = ${common.extra_scripts}
264
-    pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
252
+extra_scripts     = ${stm32f4_variant.extra_scripts}
265 253
 build_flags       = ${common_stm32.build_flags}
266 254
   -DSTM32F446_5VX -DVECT_TAB_OFFSET=0x8000 -DUSE_USB_HS_IN_FS
267 255
 
@@ -286,9 +274,7 @@ board               = marlin_STM32F407ZGT6
286 274
 board_build.variant = MARLIN_LERDGE
287 275
 board_build.offset  = 0x10000
288 276
 board_build.encrypt = firmware.bin
289
-extra_scripts       = ${common.extra_scripts}
290
-                      pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
291
-                      buildroot/share/PlatformIO/scripts/stm32_bootloader.py
277
+extra_scripts       = ${stm32f4_variant.extra_scripts}
292 278
                       buildroot/share/PlatformIO/scripts/lerdge.py
293 279
 build_flags         = ${common_stm32.build_flags}
294 280
   -DSTM32F4 -DSTM32F4xx -DTARGET_STM32F4
@@ -366,9 +352,7 @@ monitor_speed        = 500000
366 352
 board_build.core     = stm32
367 353
 board_build.variant  = MARLIN_F446VE
368 354
 board_build.offset   = 0x0000
369
-extra_scripts        = ${common.extra_scripts}
370
-  pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
371
-  buildroot/share/PlatformIO/scripts/stm32_bootloader.py
355
+extra_scripts        = ${stm32f4_variant.extra_scripts}
372 356
 
373 357
 #
374 358
 # MKS Robin Pro V2
@@ -386,9 +370,7 @@ board_upload.offset_address = 0x08000000
386 370
 build_unflags        = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC
387 371
 debug_tool           = jlink
388 372
 upload_protocol      = jlink
389
-extra_scripts        = ${common.extra_scripts}
390
-  pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
391
-  buildroot/share/PlatformIO/scripts/stm32_bootloader.py
373
+extra_scripts        = ${stm32f4_variant.extra_scripts}
392 374
 
393 375
 #
394 376
 # This SPI is used by Robin Nano V3
@@ -412,9 +394,7 @@ board_upload.offset_address = 0x0800C000
412 394
 build_unflags        = ${common_stm32.build_unflags}
413 395
 debug_tool           = jlink
414 396
 upload_protocol      = jlink
415
-extra_scripts        = ${common.extra_scripts}
416
-  pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
417
-  buildroot/share/PlatformIO/scripts/stm32_bootloader.py
397
+extra_scripts        = ${stm32f4_variant.extra_scripts}
418 398
 
419 399
 #
420 400
 # MKS Robin Nano V3 with USB Flash Drive Support

Ładowanie…
Anuluj
Zapisz