Skip to content

Commit

Permalink
Synchronize PlatformIO build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
valeros authored and fpistm committed Nov 26, 2021
1 parent 7ae74e4 commit feba432
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 34 deletions.
8 changes: 6 additions & 2 deletions tools/platformio/boards_remap.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,9 @@
"thunder_pack": "THUNDERPACK_L072",
"thunder_pack_f411": "THUNDERPACK_F411",
"vccgnd_f103zet6": "VCCGND_F103ZET6_MINI",
"waveshare_open103z": "GENERIC_F103ZEHX"
}
"waveshare_open103z": "GENERIC_F103ZEHX",
"bw_swan_r5": "SWAN_R5",
"disco_b_g431b_esc1": "B_G431B_ESC1",
"disco_b_u585i_iot02a": "B_U585I_IOT02A",
"nucleo_wl55jc": "NUCLEO_WL55JC1"
}
63 changes: 31 additions & 32 deletions tools/platformio/platformio-build.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
import json
from os.path import isfile, isdir, join

from SCons.Script import DefaultEnvironment
from platformio.util import get_systype

from SCons.Script import COMMAND_LINE_TARGETS, DefaultEnvironment

env = DefaultEnvironment()
platform = env.PioPlatform()
Expand All @@ -40,14 +42,21 @@
mcu = board_config.get("build.mcu", "")
mcu_type = mcu[:-2]
variant = board_config.get(
"build.variant", board_config.get("build.arduino.variant", "generic"))
"build.variant", board_config.get("build.arduino.variant", "generic")
)
series = mcu_type[:7].upper() + "xx"
variants_dir = (
join("$PROJECT_DIR", board_config.get("build.variants_dir"))
if board_config.get("build.variants_dir", "")
else join(FRAMEWORK_DIR, "variants")
)
variant_dir = join(variants_dir, variant)
inc_variant_dir = variant_dir
if "windows" not in get_systype().lower() and not (
set(["_idedata", "idedata"]) & set(COMMAND_LINE_TARGETS) and " " not in variant_dir
):
inc_variant_dir = variant_dir.replace("(", r"\(").replace(")", r"\)")

upload_protocol = env.subst("$UPLOAD_PROTOCOL")


Expand Down Expand Up @@ -140,13 +149,18 @@ def configure_application_offset(mcu, upload_protocol):
env.Append(CPPDEFINES=["BL_LEGACY_LEAF"])

if offset != 0:
env.Append(CPPDEFINES=[("VECT_TAB_OFFSET", "%s" % hex(offset))],)
env.Append(
CPPDEFINES=[("VECT_TAB_OFFSET", "%s" % hex(offset))],
)

# LD_FLASH_OFFSET is mandatory even if there is no offset
env.Append(LINKFLAGS=["-Wl,--defsym=LD_FLASH_OFFSET=%s" % hex(offset)])


if any(mcu in board_config.get("build.cpu") for mcu in ("cortex-m4", "cortex-m7")) and "stm32wl" not in mcu:
if (
any(cpu in board_config.get("build.cpu") for cpu in ("cortex-m4", "cortex-m7"))
and "stm32wl" not in mcu
):
env.Append(
CCFLAGS=["-mfpu=fpv4-sp-d16", "-mfloat-abi=hard"],
LINKFLAGS=["-mfpu=fpv4-sp-d16", "-mfloat-abi=hard"],
Expand Down Expand Up @@ -235,11 +249,7 @@ def get_arduino_board_id(board_config, mcu):
% board_config.get(
"build.arduino.variant_h",
"variant_%s.h"
% (
"generic"
if board_id.lower().startswith("generic")
else board_id
),
% ("generic" if board_id.lower().startswith("generic") else board_id),
),
),
],
Expand Down Expand Up @@ -272,12 +282,7 @@ def get_arduino_board_id(board_config, mcu):
"Core",
"Src",
),
join(
FRAMEWORK_DIR,
"system",
"Middlewares",
"OpenAMP"
),
join(FRAMEWORK_DIR, "system", "Middlewares", "OpenAMP"),
join(
FRAMEWORK_DIR,
"system",
Expand All @@ -296,13 +301,7 @@ def get_arduino_board_id(board_config, mcu):
"lib",
"include",
),
join(
FRAMEWORK_DIR,
"system",
"Middlewares",
"OpenAMP",
"virtual_driver"
),
join(FRAMEWORK_DIR, "system", "Middlewares", "OpenAMP", "virtual_driver"),
join(CMSIS_DIR, "Core", "Include"),
join(
FRAMEWORK_DIR,
Expand Down Expand Up @@ -341,7 +340,8 @@ def get_arduino_board_id(board_config, mcu):
"-Wl,--unresolved-symbols=report-all",
"-Wl,--warn-common",
"-Wl,--defsym=LD_MAX_SIZE=%d" % board_config.get("upload.maximum_size"),
"-Wl,--defsym=LD_MAX_DATA_SIZE=%d" % board_config.get("upload.maximum_ram_size"),
"-Wl,--defsym=LD_MAX_DATA_SIZE=%d"
% board_config.get("upload.maximum_ram_size"),
],
LIBS=[
get_arm_math_lib(board_config.get("build.cpu")),
Expand Down Expand Up @@ -369,8 +369,8 @@ def get_arduino_board_id(board_config, mcu):
LINKFLAGS=[
(
"-Wl,--default-script",
'\"%s\"' % join(
variant_dir,
join(
inc_variant_dir,
board_config.get("build.arduino.ldscript", "ldscript.ld"),
),
)
Expand Down Expand Up @@ -405,15 +405,14 @@ def get_arduino_board_id(board_config, mcu):
libs = []

if "build.variant" in board_config:
env.Append(
CCFLAGS='"-I%s"' % variant_dir,
LINKFLAGS=['"-L%s"' % variant_dir]
)
env.Append(CPPPATH=[inc_variant_dir], LIBPATH=[inc_variant_dir])
env.BuildSources(join("$BUILD_DIR", "FrameworkArduinoVariant"), variant_dir)

libs.append(env.BuildLibrary(
join("$BUILD_DIR", "FrameworkArduino"), join(FRAMEWORK_DIR, "cores", "arduino")
))
libs.append(
env.BuildLibrary(
join("$BUILD_DIR", "FrameworkArduino"), join(FRAMEWORK_DIR, "cores", "arduino")
)
)

env.BuildSources(
join("$BUILD_DIR", "SrcWrapper"), join(FRAMEWORK_DIR, "libraries", "SrcWrapper")
Expand Down

0 comments on commit feba432

Please sign in to comment.