@@ -136,13 +136,19 @@ def configure_application_offset(mcu, upload_protocol):
136
136
offset = 0x2000
137
137
env .Append (CPPDEFINES = ["BL_LEGACY_LEAF" ])
138
138
139
- if offset != 0 :
140
- env .Append (
141
- CPPDEFINES = [("VECT_TAB_OFFSET" , "%s" % hex (offset ))],
142
- )
139
+ env .Append (
140
+ CPPDEFINES = [
141
+ ("VECT_TAB_OFFSET" , board_config .get ("build.flash_offset" , hex (offset )))
142
+ ],
143
+ )
143
144
144
145
# LD_FLASH_OFFSET is mandatory even if there is no offset
145
- env .Append (LINKFLAGS = ["-Wl,--defsym=LD_FLASH_OFFSET=%s" % hex (offset )])
146
+ env .Append (
147
+ LINKFLAGS = [
148
+ "-Wl,--defsym=LD_FLASH_OFFSET=%s"
149
+ % board_config .get ("build.flash_offset" , hex (offset ))
150
+ ]
151
+ )
146
152
147
153
148
154
def load_boards_remap ():
@@ -190,42 +196,50 @@ def get_arduino_board_id(board_config, mcu):
190
196
191
197
return board_id .upper ()
192
198
199
+
193
200
board_id = get_arduino_board_id (board_config , mcu )
194
201
machine_flags = [
195
202
"-mcpu=%s" % board_config .get ("build.cpu" ),
196
203
"-mthumb" ,
197
204
]
198
205
199
206
if (
200
- any (cpu in board_config .get ("build.cpu" ) for cpu in ("cortex-m33" , "cortex-m4" , "cortex-m7" ))
207
+ any (
208
+ cpu in board_config .get ("build.cpu" )
209
+ for cpu in ("cortex-m33" , "cortex-m4" , "cortex-m7" )
210
+ )
201
211
and "stm32wl" not in mcu
202
212
):
203
213
machine_flags .extend (["-mfpu=fpv4-sp-d16" , "-mfloat-abi=hard" ])
204
214
205
215
env .Append (
206
216
ASFLAGS = machine_flags ,
207
217
ASPPFLAGS = [
208
- "-x" , "assembler-with-cpp" ,
218
+ "-x" ,
219
+ "assembler-with-cpp" ,
209
220
],
210
- CFLAGS = ["-std=gnu11 " ],
221
+ CFLAGS = ["-std=gnu17 " ],
211
222
CXXFLAGS = [
212
- "-std=gnu++14 " ,
223
+ "-std=gnu++17 " ,
213
224
"-fno-threadsafe-statics" ,
214
225
"-fno-rtti" ,
215
226
"-fno-exceptions" ,
216
227
"-fno-use-cxa-atexit" ,
217
228
],
218
- CCFLAGS = machine_flags + [
229
+ CCFLAGS = machine_flags
230
+ + [
219
231
"-Os" , # optimize for size
220
232
"-ffunction-sections" , # place each function in its own section
221
233
"-fdata-sections" ,
222
234
"-nostdlib" ,
223
- "--param" , "max-inline-insns-single=500" ,
235
+ "--param" ,
236
+ "max-inline-insns-single=500" ,
224
237
],
225
238
CPPDEFINES = [
226
239
series ,
227
240
("ARDUINO" , 10808 ),
228
241
"ARDUINO_ARCH_STM32" ,
242
+ "NDEBUG" ,
229
243
"ARDUINO_%s" % board_id ,
230
244
("BOARD_NAME" , '\\ "%s\\ "' % board_id ),
231
245
"HAL_UART_MODULE_ENABLED" ,
@@ -316,7 +330,8 @@ def get_arduino_board_id(board_config, mcu):
316
330
join (CMSIS_DIR , "DSP" , "PrivateInclude" ),
317
331
join (FRAMEWORK_DIR , "cores" , "arduino" ),
318
332
],
319
- LINKFLAGS = machine_flags + [
333
+ LINKFLAGS = machine_flags
334
+ + [
320
335
"-Os" ,
321
336
"--specs=nano.specs" ,
322
337
"-Wl,--gc-sections,--relax" ,
@@ -327,6 +342,7 @@ def get_arduino_board_id(board_config, mcu):
327
342
"-Wl,--defsym=LD_MAX_SIZE=%d" % board_config .get ("upload.maximum_size" ),
328
343
"-Wl,--defsym=LD_MAX_DATA_SIZE=%d"
329
344
% board_config .get ("upload.maximum_ram_size" ),
345
+ '-Wl,-Map="%s"' % join ("${BUILD_DIR}" , "${PROGNAME}.map" ),
330
346
],
331
347
LIBS = [
332
348
"c" ,
0 commit comments