Here is my scenario. I have two target boards connected via two STLink interfaces. I finally got them to coexist (Thanks to manuelbl’s suggestion for serial number identification!). However, now there is a new problem when I try to get both targets running for debugging.
It appears that when one STLink is active in a debug session, then the second STLink will fail when trying to debug or upload to it. From what I can tell from the error messages it looks like GDB cannot manage more than one connection. The first STLink is using Localhost:3333 as port, and I guess the second STLink tries to do the same, so there is a collision resulting in this error message:
Info : rejected ‘gdb’ connection, no more connections allowed
Is there any way to get around this problem and have two debug sessions in two seperate instances of PlatformIO?
Ah, this is tricky. In that case you must use a combination of debug_server and debug_port commands, where you
Tell OpenOCD to use a certain port numbers for opening the GDB server (all others can be random or unused). See docs. I think something like -c "gdb_port 3334" -c "tcl_port disabled" -c "telnet_port disabled" should work? Maybe with a set at the start too…
Tell PlatformIO to use these new port numbers in the debug_port, e.g. localhost:3334
one to each project’s platformio.ini and it runs perfectly, I can simultaneously debug both projects each on it’s own STLink device. Still using the serial number method to keep them identified for now.