I am flashing firmware to an STM32 with a Segger jlink. There is a small annoyance though: the jlink halts the MCU after upload instead of running the newly uploaded code, so I have to push the reset button every time.
I found that PlatformIO creates a jlink command script in \platforms\ststm32\builder\main.py with the following lines:
commands = [
"h",
"loadbin %s, %s" % (source, board.get(
"upload.offset_address", "0x08000000")),
"r",
"q"
]
The “r” resets the MCU, but also halts it. I tried a few of the available Segger commands (e. g. “g” for “go” which should run the code), but while they worked when I called jlink.exe myself on the commandline they didn’t make the MCU run when used in the script file. What did work was replacing the “r” with “r1” followed by “r0” which makes the jlink toggle the reset pin, so the commands look like this now:
commands = [
"h",
"loadbin %s, %s" % (source, board.get(
"upload.offset_address", "0x08000000")),
"r1",
"r0",
"q"
]
My problem now is that I had to change a file of one of PlatformIO’s packages for that, which means every packages update will reset them. Unfortunately the reset can’t be triggered by simply adding parameters to upload_flags for example.
What would be the best way to solve this? Toggling the reset pin is not a necessity (no other chips on the board that need resets), I just want to code to run automatically after an upload with the jlink.