Remote debugging works for stm32 , remote download fails

Platformio on Lubuntu , config project

upload_protocol = custom
upload_port =  limero.local:3333
debug_tool = custom
debug_port =  limero.local:3333
debug_build_flags = -O0 -ggdb3 -g3

I can do remote debugging to a raspberry pi running openocd with this config

lieven@limero:~/workspace/hoverboard $ more ocd-server.sh 
sudo openocd -f openocd.cfg
lieven@limero:~/workspace/hoverboard $ more openocd.cfg 
bindto 0.0.0.0
source [find interface/stlink.cfg]
set CHIPNAME stm32f1x
source [find target/stm32f1x.cfg]
init
targets
reset halt
# program testProgram.hex verify reset
# shutdown

When I use remote debug ( F5 ) it uploads code and I can debug, when doing the download , it doesn’t connect to the openocd and doesn’t transfer the image.
Project : GitHub - vortex314/hoverboard

PlatformIO has built in remote uploading capabilities if you use PIO Remote.

The OpenOCD upload will always try and invoke OpenOCD locally (source), setting a remote upload_port where a GDB server opened by OpenOCD is listening doesn’t change that. You would have to write a custom upload protocol command that invokes GDB with the right commands to flash the firmware on the device.

That was quick ! Didn’t expect an answer anytime soon.
I’ll have a look at PIO remote.
Thanks !

vortex314

I have a very similar system here:

Computer (PIO) ------ETH------> RPI (with OCD) -----SWD------> ATSAMD21G17

I really do not like to make things more complicated (for me) using the pio remote on the rpi.

Therefore I tried to use the pio’s gdb to upload the firmware. This command works for me using the powershell (copied the firmware.elf before):

.\arm-none-eabi-gdb.exe -iex "target extended-remote 192.168.178.37:3333" firmware.elf --batch -ex "load" -ex "monitor reset"

Now I have some trouble to get this command in a platform.ini shape :slight_smile:

tried many things similar to this, but the gdb parameters are not passed…:

upload_protocol = custom
upload_flags =-iex target extended-remote 192.168.178.37:3333 firmware.elf --batch -ex load -ex monitor reset
upload_command = “${platformio.packages_dir}/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gdb.exe $upload_flags”

I guess it is related to the >> " <<.

Could someone help me with that?