Skip to content

Commit 74a1ec7

Browse files
valerosfpistm
authored andcommitted
Update platformio-build.py
Signed-off-by: Valerii Koval <valeros@users.noreply.github.com>
1 parent 20acaa7 commit 74a1ec7

File tree

1 file changed

+28
-12
lines changed

1 file changed

+28
-12
lines changed

tools/platformio/platformio-build.py

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,19 @@ def configure_application_offset(mcu, upload_protocol):
136136
offset = 0x2000
137137
env.Append(CPPDEFINES=["BL_LEGACY_LEAF"])
138138

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+
)
143144

144145
# 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+
)
146152

147153

148154
def load_boards_remap():
@@ -190,42 +196,50 @@ def get_arduino_board_id(board_config, mcu):
190196

191197
return board_id.upper()
192198

199+
193200
board_id = get_arduino_board_id(board_config, mcu)
194201
machine_flags = [
195202
"-mcpu=%s" % board_config.get("build.cpu"),
196203
"-mthumb",
197204
]
198205

199206
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+
)
201211
and "stm32wl" not in mcu
202212
):
203213
machine_flags.extend(["-mfpu=fpv4-sp-d16", "-mfloat-abi=hard"])
204214

205215
env.Append(
206216
ASFLAGS=machine_flags,
207217
ASPPFLAGS=[
208-
"-x", "assembler-with-cpp",
218+
"-x",
219+
"assembler-with-cpp",
209220
],
210-
CFLAGS=["-std=gnu11"],
221+
CFLAGS=["-std=gnu17"],
211222
CXXFLAGS=[
212-
"-std=gnu++14",
223+
"-std=gnu++17",
213224
"-fno-threadsafe-statics",
214225
"-fno-rtti",
215226
"-fno-exceptions",
216227
"-fno-use-cxa-atexit",
217228
],
218-
CCFLAGS=machine_flags + [
229+
CCFLAGS=machine_flags
230+
+ [
219231
"-Os", # optimize for size
220232
"-ffunction-sections", # place each function in its own section
221233
"-fdata-sections",
222234
"-nostdlib",
223-
"--param", "max-inline-insns-single=500",
235+
"--param",
236+
"max-inline-insns-single=500",
224237
],
225238
CPPDEFINES=[
226239
series,
227240
("ARDUINO", 10808),
228241
"ARDUINO_ARCH_STM32",
242+
"NDEBUG",
229243
"ARDUINO_%s" % board_id,
230244
("BOARD_NAME", '\\"%s\\"' % board_id),
231245
"HAL_UART_MODULE_ENABLED",
@@ -316,7 +330,8 @@ def get_arduino_board_id(board_config, mcu):
316330
join(CMSIS_DIR, "DSP", "PrivateInclude"),
317331
join(FRAMEWORK_DIR, "cores", "arduino"),
318332
],
319-
LINKFLAGS=machine_flags + [
333+
LINKFLAGS=machine_flags
334+
+ [
320335
"-Os",
321336
"--specs=nano.specs",
322337
"-Wl,--gc-sections,--relax",
@@ -327,6 +342,7 @@ def get_arduino_board_id(board_config, mcu):
327342
"-Wl,--defsym=LD_MAX_SIZE=%d" % board_config.get("upload.maximum_size"),
328343
"-Wl,--defsym=LD_MAX_DATA_SIZE=%d"
329344
% board_config.get("upload.maximum_ram_size"),
345+
'-Wl,-Map="%s"' % join("${BUILD_DIR}", "${PROGNAME}.map"),
330346
],
331347
LIBS=[
332348
"c",

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy