pyocd / pyocd/pyOCD

It takes ~3 seconds for gdb to connect to pyocd (likely windows only)

Open
#1,622 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.5k
Forks
560
Avg merge
1h 41m
Merged PRs (30d)
3

Description

Hi. When I run

pyocd gdbserver --port 50000 --telnet-port 50001 --target rp2040
then
arm-none-eabi-gdb.exe .\build\templateRP2040.elf
target remote localhost:50000

It can take up to 3 seconds to connect. When I use 127.0.0.1 instead of localhost it is instant.

I looked at wireshark and it seems like my computer is trying to connect to the ipv6 localhost ::1 before giving up and trying ipv4.

image

I tried editing the hosts file but apparently doesn't work for localhost anymore, I tried editing the local adapter to not use ipv6 and no dice. I'm on windows 10 (10.0.19045.0 Microsoft Windows NT 10.0.19045.0)

When I edit this line in sockets.py it works.

image
however this breaks 127.0.0.1, so it's debatable whether this would be a good change.

I am using cortex debug vscode extension and thus I can't easily edit cortex debug so it specifies 127.0.0.1 and not localhost.

TLDR: AFAICT the default behavior in windows causes it to take 3 seconds to connect for a debug session.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the delay with the pyocd gdbserver and GDB commands on Windows, then inspect sockets.py where changing the address behavior affects localhost and 127.0.0.1 differently. Compare IPv6 and IPv4 connection attempts; done means localhost connects without the delay while 127.0.0.1 continues to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, networking, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.