Skip to content

Need to restart vscode (devcontainer) after attach for debuggers to work properly #1362

Description

@danielschenk

In my company we develop for different microcontrollers, using a VSCode dev container on Docker+WSL. We use J-links and TI XDS110 devices for this.

Every time I (re)attach one of these debuggers, while VSCode (and thus the container) is running, lsusb can immediately see the device. Sometimes, the virtual COM port (which is part of the device) even immediately works. But what never works until I restart VSCode (and thus the container) is debugging. The J-link GDB server, and also the J-link commander, just show an error, even though they seem to recognize/enumerate the device. Here's how it looks in J-link commander (JLinkExe from J-link software package 8.72a for Linux):

J-Link>ShowEmuList USB
J-Link[0]: Connection: USB, Serial number: 853000808, ProductName: J-Link Compact PLUS
J-Link>c
J-Link connection not established yet but required for command.
Connecting to J-Link via USB...FAILED: Cannot connect to J-Link.
J-Link>

Not sure if this is a known/expected issue or not. It seems as if not all endpoints are working immediately, and the container needs to be restarted for that. I also noticed that when attaching a 2nd J-link, often the virtual COM port part also does not work.

I made a log of the server, with annotations to show what I did at which point in time.

# --- VSCODE IS ALREADY RUNNING AT THIS POINT, WITH WSL DEVCONTAINER ---
usbipd server Logging:LogLevel:Default=Trace
dbug: Microsoft.Extensions.Hosting.Internal.Host[1]
      Hosting starting
dbug: Usbipd.PcapNg[1000]
      usbipd:PcapNg:Path = ''
dbug: Usbipd.Server[1000]
      usbipd:Port = 3240
dbug: Usbipd.Server[1000]
      5.3.0-54+Branch.master.Sha.aa3db8b82c4cb5071fd31bc54211606c70886912
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: C:\Users\320288329
dbug: Microsoft.Extensions.Hosting.Internal.Host[2]
      Hosting started
dbug: Usbipd.Server[1000]
      new connection from 172.17.78.244
dbug: Usbipd.Server[1000]
      connection close: Unable to read beyond the end of the stream.
dbug: Usbipd.Server[1000]
      connection closed
dbug: Usbipd.Server[1000]
      new connection from 172.17.78.244
dbug: Usbipd.ConnectedClient[1000]
      Received opcode: OP_REQ_IMPORT
dbug: Usbipd.ConnectedClient[1000]
      Claiming took 202 ms
info: Usbipd.ConnectedClient[1]
      Client 172.17.78.244 claimed device at 5-2 (USB\VID_1366&PID_0105\000772846897).
dbug: 5-2.0[1000]
      Endpoint created
dbug: 5-2.0[1000]
      USBSUP_XFER_STALL -> EPIPE -> -32
dbug: 5-2.0[1000]
      USBSUP_XFER_STALL -> EPIPE -> -32
dbug: 5-2.0[1000]
      USBSUP_XFER_STALL -> EPIPE -> -32
dbug: 5-2.0[1000]
      Endpoint created
dbug: 5-2.0[1000]
      Trapped SET_CONFIGURATION: 1
# --- OPENING JLINK VIRTUAL COMPORT, WORKS ---
dbug: 5-2.3[1000]
      Endpoint created
dbug: 5-2.1[1000]
      Endpoint created
# --- TRYING JLINK, DOES NOT WORK ---
# --- EXITING VSCODE ---
trce: 5-2.3[1001]
      Unlinking: PendingSubmits=1, PendingUnlinks=1
trce: 5-2.3[1001]
      Aborting endpoint
dbug: 5-2.3[1000]
      USBSUP_XFER_STALL -> EPIPE -> -32
trce: 5-2.1[1001]
      Unlinking: PendingSubmits=16, PendingUnlinks=1
trce: 5-2.1[1001]
      Unlinking: PendingSubmits=16, PendingUnlinks=2
trce: 5-2.1[1001]
      Unlinking: PendingSubmits=16, PendingUnlinks=3
trce: 5-2.1[1001]
      Unlinking: PendingSubmits=16, PendingUnlinks=4
trce: 5-2.1[1001]
      Unlinking: PendingSubmits=16, PendingUnlinks=5
trce: 5-2.1[1001]
      Unlinking: PendingSubmits=16, PendingUnlinks=6
trce: 5-2.1[1001]
      Unlinking: PendingSubmits=16, PendingUnlinks=7
trce: 5-2.1[1001]
      Unlinking: PendingSubmits=16, PendingUnlinks=8
trce: 5-2.1[1001]
      Unlinking: PendingSubmits=16, PendingUnlinks=9
trce: 5-2.1[1001]
      Unlinking: PendingSubmits=16, PendingUnlinks=10
trce: 5-2.1[1001]
      Unlinking: PendingSubmits=16, PendingUnlinks=11
trce: 5-2.1[1001]
      Unlinking: PendingSubmits=16, PendingUnlinks=12
trce: 5-2.1[1001]
      Unlinking: PendingSubmits=16, PendingUnlinks=13
trce: 5-2.1[1001]
      Unlinking: PendingSubmits=16, PendingUnlinks=14
trce: 5-2.1[1001]
      Unlinking: PendingSubmits=16, PendingUnlinks=15
trce: 5-2.1[1001]
      Unlinking: PendingSubmits=16, PendingUnlinks=16
trce: 5-2.1[1001]
      Aborting endpoint
dbug: 5-2.1[1000]
      USBSUP_XFER_STALL -> EPIPE -> -32
dbug: 5-2.1[1000]
      USBSUP_XFER_STALL -> EPIPE -> -32
dbug: 5-2.1[1000]
      USBSUP_XFER_STALL -> EPIPE -> -32
dbug: 5-2.1[1000]
      USBSUP_XFER_STALL -> EPIPE -> -32
dbug: 5-2.1[1000]
      USBSUP_XFER_STALL -> EPIPE -> -32
dbug: 5-2.1[1000]
      USBSUP_XFER_STALL -> EPIPE -> -32
dbug: 5-2.1[1000]
      USBSUP_XFER_STALL -> EPIPE -> -32
dbug: 5-2.1[1000]
      USBSUP_XFER_STALL -> EPIPE -> -32
dbug: 5-2.1[1000]
      USBSUP_XFER_STALL -> EPIPE -> -32
dbug: 5-2.1[1000]
      USBSUP_XFER_STALL -> EPIPE -> -32
dbug: 5-2.1[1000]
      USBSUP_XFER_STALL -> EPIPE -> -32
dbug: 5-2.1[1000]
      USBSUP_XFER_STALL -> EPIPE -> -32
dbug: 5-2.1[1000]
      USBSUP_XFER_STALL -> EPIPE -> -32
dbug: 5-2.1[1000]
      USBSUP_XFER_STALL -> EPIPE -> -32
dbug: 5-2.1[1000]
      USBSUP_XFER_STALL -> EPIPE -> -32
dbug: 5-2.1[1000]
      USBSUP_XFER_STALL -> EPIPE -> -32
# --- STARTING VSCODE ---
# --- TRYING JLINK, WORKS NOW ---
dbug: 5-2.5[1000]
      Endpoint created
dbug: 5-2.4[1000]
      Endpoint created
# --- CTRL+C ON SERVER ---
info: Microsoft.Hosting.Lifetime[0]
      Application is shutting down...
dbug: Microsoft.Extensions.Hosting.Internal.Host[3]
      Hosting stopping
dbug: Usbipd.ConnectedClient[1000]
      Unbind or unplug while attached
dbug: Microsoft.Extensions.Hosting.Internal.Host[4]
      Hosting stopped
dbug: 5-2.1[1000]
      USBSUP_XFER_STALL -> EPIPE -> -32
dbug: 5-2.1[1000]
      USBSUP_XFER_STALL -> EPIPE -> -32
dbug: 5-2.1[1000]
      USBSUP_XFER_STALL -> EPIPE -> -32
dbug: 5-2.1[1000]
      USBSUP_XFER_STALL -> EPIPE -> -32
dbug: 5-2.1[1000]
      USBSUP_XFER_STALL -> EPIPE -> -32
dbug: 5-2.1[1000]
      USBSUP_XFER_STALL -> EPIPE -> -32
dbug: 5-2.1[1000]
      USBSUP_XFER_STALL -> EPIPE -> -32
dbug: 5-2.1[1000]
      USBSUP_XFER_STALL -> EPIPE -> -32
dbug: 5-2.1[1000]
      USBSUP_XFER_STALL -> EPIPE -> -32
dbug: 5-2.1[1000]
      USBSUP_XFER_STALL -> EPIPE -> -32
dbug: 5-2.1[1000]
      USBSUP_XFER_STALL -> EPIPE -> -32

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions