Hi! I'm having a somewhat confusing problem with SWV and GDB and I can't tell how pyOCD is meant to resolve this issue, so I'd welcome any guidance. The summary is that CMSIS-DAP probe responses to the regular poll for SWO data by the SWVReader thread (DAP_SWO_Data commands) are being received by the transfer thread (expecting DAP_Transfer responses), or vice versa, so either way an error is thrown, which means I can't use GDB while SWV is active.
I'm using a custom CMSIS-DAP probe, so I worry an implementation issue is causing the fault, but I don't understand how it could be mitigated. My probe implements both v1 and v2 endpoints but does not support SWO streaming on its own endpoint, so all responses are via DAP_SWO_Data command polling. The issue is the same when using either v1 or v2 backends. I don't have access to another CMSIS-DAP probe that also has SWO, and I can't see anything obvious to deal with this in the DAPlink firmware.
I'm using SWV via pyocd gdbserver -O enable_swv=true -O connect_mode=attach on a target that's constantly streaming some ITM data via SWO. There's a very low data rate, maybe 50 bytes/second. After starting pyocd I can telnet to port 4444 and view the correct ITM data, no problems there. I use connect_mode=attach as otherwise the target is halted at this stage which prevents ITM output. At this point the SWVReader thread is constantly calling swo_read(), which sends new DAP_SWO_Data commands and receives responses.
If I then try and attach a GDB session to port 3333, pyOCD sends some DAP_Transfer commands in a separate Python thread. That thread then reads the same USB endpoint as the SWVReader is using, and pretty quickly either it receives a response to the DAP_SWO_Data command, or the SWVReader thread receives a response to the DAP_Transfer command. Either way this immediately causes an error. As far as I can tell there's no locking or synchronisation in pyOCD to prevent this, and from looking at the USB logs and also inserting extra logging into pyOCD, the probe appears to correctly responding in-order.
Has anyone got SWV working at the same time as GDB using a CMSIS-DAP probe without the separate SWO endpoint? Am I missing something obvious? Thanks!
Here's a log snippet with extra logging added to pyusb_backend.py to print out transmitted and received buffers:
Hi! I'm having a somewhat confusing problem with SWV and GDB and I can't tell how pyOCD is meant to resolve this issue, so I'd welcome any guidance. The summary is that CMSIS-DAP probe responses to the regular poll for SWO data by the SWVReader thread (
DAP_SWO_Data
commands) are being received by the transfer thread (expectingDAP_Transfer
responses), or vice versa, so either way an error is thrown, which means I can't use GDB while SWV is active.I'm using a custom CMSIS-DAP probe, so I worry an implementation issue is causing the fault, but I don't understand how it could be mitigated. My probe implements both v1 and v2 endpoints but does not support SWO streaming on its own endpoint, so all responses are via
DAP_SWO_Data
command polling. The issue is the same when using either v1 or v2 backends. I don't have access to another CMSIS-DAP probe that also has SWO, and I can't see anything obvious to deal with this in the DAPlink firmware.I'm using SWV via
pyocd gdbserver -O enable_swv=true -O connect_mode=attach
on a target that's constantly streaming some ITM data via SWO. There's a very low data rate, maybe 50 bytes/second. After starting pyocd I can telnet to port 4444 and view the correct ITM data, no problems there. I useconnect_mode=attach
as otherwise the target is halted at this stage which prevents ITM output. At this point the SWVReader thread is constantly callingswo_read()
, which sends newDAP_SWO_Data
commands and receives responses.If I then try and attach a GDB session to port 3333, pyOCD sends some
DAP_Transfer
commands in a separate Python thread. That thread then reads the same USB endpoint as the SWVReader is using, and pretty quickly either it receives a response to theDAP_SWO_Data
command, or the SWVReader thread receives a response to theDAP_Transfer
command. Either way this immediately causes an error. As far as I can tell there's no locking or synchronisation in pyOCD to prevent this, and from looking at the USB logs and also inserting extra logging into pyOCD, the probe appears to correctly responding in-order.Has anyone got SWV working at the same time as GDB using a CMSIS-DAP probe without the separate SWO endpoint? Am I missing something obvious? Thanks!
Here's a log snippet with extra logging added to pyusb_backend.py to print out transmitted and received buffers: