PlatformIO Community

Debug Restart/Stop error

In the debug menu there are Restart and Stop commands. When I click on Restart I am getting this error:

firmware.elf: The process cannot access the file because it is being used by another process
======================================================================================================== [FAILED] Took 0.97 seconds ========================================================================================================The terminal process “C:\Users\<user>\.platformio\penv\Scripts\pio.exe ‘debug’” terminated with exit code: 1.

Also, when I click on Stop I am getting this error:

pio_reset_run_target
Warning! Undefined pio_reset_run_target command
Cannot execute this command while the target is running.
Use the “interrupt” command to stop the target
and then try again.
Cannot execute this command while the target is running.
Use the “interrupt” command to stop the target
and then try again.
Cannot execute this command while the target is running.
Use the “interrupt” command to stop the target
and then try again.

Does anyone know what these buttons do and what GDB commands they send to the board? Also are these configurable? I would love to just change them to my own GDB commands if possible.

Hm I think it’s because of the stop commands failing that restart fails like this too.

See docs. The debug_init_cmds are set to some default values depending on which program opens the GDB-server. Depending on that, those GDB script functions are defined.

For JLink it’s apparently

and thuse one would have to set that value for debug_init_cmds in the platformio.ini too so that these functions are defined.

Thanks, those seem to work as is which is weird if they are the default… I wish they were documented a bit more, is reset_halt_target = stop and reset_run_target = restart?

Also, do you happen to know if debugging is supposed to upload the code beforehand? Just wondering as mine does not and I was curious if it was because of my custom upload protocol.

As soon as you do debug_tool = custom those won’t be autofilled anymore – only if you were using vanilla debug_tool = jlink.

Yes, a firmware that is recompiled in debug mode (-Og -ggdb3…) will be uploaded after connecting to the GDB server with the $LOAD_CMDS in the initialization commands. This is also really important because if you don’t upload a firmware compiled in debug mode, the debugger will have limited / no symbol information and optimization makes the firmware jump around in code (exception: build_type = debug is set and even the uploaded firmware is compiled in debug mode). However, if you fully control debug_init_cmds yourself and those don’t contain $LOAD_CMDS, you’ve effectively disabled / bypassed that behavior.

$LOAD_CMDS will also be empty if the option debug_load_mode is set to manual and modified in some cases.

Same goes for $INIT_BREAK, in which PIO will fill the break or tbreak commands that are created as a result the default or modified debug_init_break value.