Skip to content

Commit 6b6a254

Browse files
authored
Update PlatformIO scripts (stm32duino#1164)
* Sync PlatformIO build script * Update PlatformIO CI script
1 parent 962470a commit 6b6a254

File tree

2 files changed

+53
-4
lines changed

2 files changed

+53
-4
lines changed

.github/actions/pio-build/entrypoint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ platformio platform install "https://github.com/platformio/platform-ststm32.git"
88
exit 1
99
}
1010
# Prepare framework for CI
11-
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()" || {
11+
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()" || {
1212
exit 1
1313
}
1414
ln --symbolic "$GITHUB_WORKSPACE" "$HOME/.platformio/packages/framework-arduinoststm32" || {

tools/platformio-build.py

+52-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
board = env.BoardConfig()
3333

3434
FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoststm32")
35-
CMSIS_DIR = join(platform.get_package_dir("framework-arduinoststm32"), "CMSIS", "CMSIS")
35+
CMSIS_DIR = join(platform.get_package_dir("framework-cmsis"), "CMSIS")
3636
assert isdir(FRAMEWORK_DIR)
3737
assert isdir(CMSIS_DIR)
3838

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

89+
if any(
90+
d in cpp_defines
91+
for d in (
92+
"PIO_FRAMEWORK_ARDUINO_ENABLE_CDC",
93+
"PIO_FRAMEWORK_ARDUINO_ENABLE_CDC_WITHOUT_SERIAL",
94+
"PIO_FRAMEWORK_ARDUINO_ENABLE_HID",
95+
)
96+
):
97+
env.Append(
98+
CPPDEFINES=[
99+
"USBCON",
100+
("USB_VID", board.get("build.hwids", [[0, 0]])[0][0]),
101+
("USB_PID", board.get("build.hwids", [[0, 0]])[0][1]),
102+
]
103+
)
104+
89105
if any(f in env["CPPDEFINES"] for f in ("USBD_USE_CDC", "USBD_USE_HID_COMPOSITE")):
90106
env.Append(CPPDEFINES=["HAL_PCD_MODULE_ENABLED"])
91107

@@ -168,6 +184,7 @@ def configure_application_offset(mcu, upload_protocol):
168184
join(FRAMEWORK_DIR, "cores", "arduino", "stm32"),
169185
join(FRAMEWORK_DIR, "cores", "arduino", "stm32", "LL"),
170186
join(FRAMEWORK_DIR, "cores", "arduino", "stm32", "usb"),
187+
join(FRAMEWORK_DIR, "cores", "arduino", "stm32", "OpenAMP"),
171188
join(FRAMEWORK_DIR, "cores", "arduino", "stm32", "usb", "hid"),
172189
join(FRAMEWORK_DIR, "cores", "arduino", "stm32", "usb", "cdc"),
173190
join(FRAMEWORK_DIR, "system", "Drivers", series + "_HAL_Driver", "Inc"),
@@ -191,6 +208,37 @@ def configure_application_offset(mcu, upload_protocol):
191208
"Core",
192209
"Src",
193210
),
211+
join(
212+
FRAMEWORK_DIR,
213+
"system",
214+
"Middlewares",
215+
"OpenAMP"
216+
),
217+
join(
218+
FRAMEWORK_DIR,
219+
"system",
220+
"Middlewares",
221+
"OpenAMP",
222+
"open-amp",
223+
"lib",
224+
"include",
225+
),
226+
join(
227+
FRAMEWORK_DIR,
228+
"system",
229+
"Middlewares",
230+
"OpenAMP",
231+
"libmetal",
232+
"lib",
233+
"include",
234+
),
235+
join(
236+
FRAMEWORK_DIR,
237+
"system",
238+
"Middlewares",
239+
"OpenAMP",
240+
"virtual_driver"
241+
),
194242
join(CMSIS_DIR, "Core", "Include"),
195243
join(
196244
FRAMEWORK_DIR,
@@ -202,7 +250,6 @@ def configure_application_offset(mcu, upload_protocol):
202250
series,
203251
"Include",
204252
),
205-
join(CMSIS_DIR, "DSP", "Include"),
206253
join(
207254
FRAMEWORK_DIR,
208255
"system",
@@ -215,6 +262,7 @@ def configure_application_offset(mcu, upload_protocol):
215262
"Templates",
216263
"gcc",
217264
),
265+
join(CMSIS_DIR, "DSP", "Include"),
218266
join(FRAMEWORK_DIR, "cores", "arduino"),
219267
variant_dir,
220268
],
@@ -250,9 +298,10 @@ def configure_application_offset(mcu, upload_protocol):
250298
#
251299

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

257306
#
258307
# Process configuration flags

0 commit comments

Comments
 (0)