Well if I do
[env:stm32f4]
board = black_f407ve
platform = ststm32
framework = arduino
upload_flags =
-f
interface/stlink.cfg
-c
transport select hla_swd
-f
target/stm32f4x.cfg
-c
init; reset halt; stm32f4x unlock 0; reset run
it does
openocd -f interface/stlink.cfg -c “transport select hla_swd” -f target/stm32f4x.cfg -c “init; reset halt; stm32f4x unlock 0; reset run” -d2 -s C:\Users\Max.platformio\packages\tool-openocd/scripts -f interface/stlink.cfg -c “transport select hla_swd” -f target/stm32f4x.cfg -c “program {.pio\build\stm32f4\firmware.elf} verify reset; shutdown;”
which might work, even with those double config files. If not, see this section of advanced scripting for modifying the upload command. Or again specify the whole upload_command.
Indeed Custom Targets can also be used.
If I add to the .ini file
extra_scripts = add_unlock_task.py
with add_unlock_task.py
Import("env")
env.AddCustomTarget(
"unlock",
None,
'"$PROJECT_PACKAGES_DIR/tool-openocd/bin/openocd" -f interface/stlink.cfg -f target/stm32f4x.cfg -c "init; reset halt; stm32f4x unlock 0; reset run; exit"'
)
doing a
>pio run -t unlock -v
"C:\Users\Max\.platformio\packages/tool-openocd/bin/openocd" -f interface/stlink.cfg -f target/stm32f4x.cfg -c "init; reset halt; stm32f4x unlock 0; reset run; exit"
xPack OpenOCD, x86_64 Open On-Chip Debugger 0.11.0-00155-ge392e485e (2021-03-15-16:44)
Licensed under GNU GPL v2
...
shows that it tries to do the right thing. The task also shows up in the VSCode project task list.
There’s a lot of ways to achieve this.