Skip to content

Update PlatformIO scripts #1164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/pio-build/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ platformio platform install "https://github.com/platformio/platform-ststm32.git"
exit 1
}
# Prepare framework for CI
python3 -c "import json; import os; fp=open(os.path.expanduser('~/.platformio/platforms/ststm32/platform.json'), 'r+'); data=json.load(fp); data['packages']['framework-arduinoststm32']['version'] = '*'; fp.seek(0); fp.truncate(); json.dump(data, fp); fp.close()" || {
python3 -c "import json; import os; fp=open(os.path.expanduser('~/.platformio/platforms/ststm32/platform.json'), 'r+'); data=json.load(fp); data['packages']['framework-arduinoststm32']['version'] = '*'; del data['packages']['framework-arduinoststm32']['owner']; fp.seek(0); fp.truncate(); json.dump(data, fp); fp.close()" || {
exit 1
}
ln --symbolic "$GITHUB_WORKSPACE" "$HOME/.platformio/packages/framework-arduinoststm32" || {
Expand Down
55 changes: 52 additions & 3 deletions tools/platformio-build.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
board = env.BoardConfig()

FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoststm32")
CMSIS_DIR = join(platform.get_package_dir("framework-arduinoststm32"), "CMSIS", "CMSIS")
CMSIS_DIR = join(platform.get_package_dir("framework-cmsis"), "CMSIS")
assert isdir(FRAMEWORK_DIR)
assert isdir(CMSIS_DIR)

Expand Down Expand Up @@ -86,6 +86,22 @@ def process_usb_configuration(cpp_defines):
elif "PIO_FRAMEWORK_ARDUINO_ENABLE_HID" in cpp_defines:
env.Append(CPPDEFINES=["USBD_USE_HID_COMPOSITE"])

if any(
d in cpp_defines
for d in (
"PIO_FRAMEWORK_ARDUINO_ENABLE_CDC",
"PIO_FRAMEWORK_ARDUINO_ENABLE_CDC_WITHOUT_SERIAL",
"PIO_FRAMEWORK_ARDUINO_ENABLE_HID",
)
):
env.Append(
CPPDEFINES=[
"USBCON",
("USB_VID", board.get("build.hwids", [[0, 0]])[0][0]),
("USB_PID", board.get("build.hwids", [[0, 0]])[0][1]),
]
)

if any(f in env["CPPDEFINES"] for f in ("USBD_USE_CDC", "USBD_USE_HID_COMPOSITE")):
env.Append(CPPDEFINES=["HAL_PCD_MODULE_ENABLED"])

Expand Down Expand Up @@ -168,6 +184,7 @@ def configure_application_offset(mcu, upload_protocol):
join(FRAMEWORK_DIR, "cores", "arduino", "stm32"),
join(FRAMEWORK_DIR, "cores", "arduino", "stm32", "LL"),
join(FRAMEWORK_DIR, "cores", "arduino", "stm32", "usb"),
join(FRAMEWORK_DIR, "cores", "arduino", "stm32", "OpenAMP"),
join(FRAMEWORK_DIR, "cores", "arduino", "stm32", "usb", "hid"),
join(FRAMEWORK_DIR, "cores", "arduino", "stm32", "usb", "cdc"),
join(FRAMEWORK_DIR, "system", "Drivers", series + "_HAL_Driver", "Inc"),
Expand All @@ -191,6 +208,37 @@ def configure_application_offset(mcu, upload_protocol):
"Core",
"Src",
),
join(
FRAMEWORK_DIR,
"system",
"Middlewares",
"OpenAMP"
),
join(
FRAMEWORK_DIR,
"system",
"Middlewares",
"OpenAMP",
"open-amp",
"lib",
"include",
),
join(
FRAMEWORK_DIR,
"system",
"Middlewares",
"OpenAMP",
"libmetal",
"lib",
"include",
),
join(
FRAMEWORK_DIR,
"system",
"Middlewares",
"OpenAMP",
"virtual_driver"
),
join(CMSIS_DIR, "Core", "Include"),
join(
FRAMEWORK_DIR,
Expand All @@ -202,7 +250,6 @@ def configure_application_offset(mcu, upload_protocol):
series,
"Include",
),
join(CMSIS_DIR, "DSP", "Include"),
join(
FRAMEWORK_DIR,
"system",
Expand All @@ -215,6 +262,7 @@ def configure_application_offset(mcu, upload_protocol):
"Templates",
"gcc",
),
join(CMSIS_DIR, "DSP", "Include"),
join(FRAMEWORK_DIR, "cores", "arduino"),
variant_dir,
],
Expand Down Expand Up @@ -250,9 +298,10 @@ def configure_application_offset(mcu, upload_protocol):
#

if not board.get("build.ldscript", ""):
env.Replace(LDSCRIPT_PATH=join(FRAMEWORK_DIR, "system", "ldscript.ld"))
if not isfile(join(env.subst(variant_dir), "ldscript.ld")):
print("Warning! Cannot find linker script for the current target!\n")
env.Replace(LDSCRIPT_PATH=join(variant_dir, "ldscript.ld"))
env.Append(LINKFLAGS=[("-Wl,--default-script", join(variant_dir, "ldscript.ld"))])

#
# Process configuration flags
Expand Down