简体   繁体   中英

openocd couldn't bind telnet to socket on port

I'm so tired of damn Windows and damn computers, its just entropy churning out more waste of time... but now that I'm here, this is my problem:

I use openocd in MINGW64 on Windows 10; and when I run openocd with the intent to connect with gdb to it, - typically after a reboot, - I have had this problem:

$ /path/to/openocd/src/openocd.exe -s /path/to/openocd/tcl -f interface/picoprobe.cfg -f target/rp2040.cfg
Open On-Chip Debugger 0.11.0-g610f137 (2022-03-29-13:44)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'swd'
adapter speed: 5000 kHz

Info : Hardware thread awareness created
Info : Hardware thread awareness created
Info : RP2040 Flash Bank Command
Error: couldn't bind tcl to socket on port 6666: No error

Thanks to this thread:

OpenOCD couldn't bind tcl to socket

... I've learned that I have to open PowerShell as Administrator, and run:

$portProcessID = ( Get-NetTCPConnection -LocalPort 6666 ).OwningProcess
( Get-WmiObject win32_process | Where-Object {$_.ProcessID -eq $portProcessID } ).ProcessName
Stop-Process -id $portProcessID

This usually brought back openocd so I could work with it... until today.

Today, after running the above, I was greeted with the following:

$ /path/to/openocd/src/openocd.exe -s /path/to/openocd/tcl -f interface/picoprobe.cfg -f target/rp2040.cfg
Open On-Chip Debugger 0.11.0-g610f137 (2022-03-29-13:44)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'swd'
adapter speed: 5000 kHz

Info : Hardware thread awareness created
Info : Hardware thread awareness created
Info : RP2040 Flash Bank Command
Info : Listening on port 6666 for tcl connections
Error: couldn't bind telnet to socket on port 4444: No error

Well, great - and thank you for the useful "Error:... No error" message

So, one would think that the same procedure as above would work, that is, we just need to find the process... but:

PS C:\WINDOWS\system32> $portProcessID = ( Get-NetTCPConnection -LocalPort 4444 ).OwningProcess
Get-NetTCPConnection : No MSFT_NetTCPConnection objects found with property 'LocalPort' equal to '4444'.  Verify the
value of the property and retry.
At line:1 char:20
+ $portProcessID = ( Get-NetTCPConnection -LocalPort 4444 ).OwningProce ...
+                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (4444:UInt16) [Get-NetTCPConnection], CimJobException
    + FullyQualifiedErrorId : CmdletizationQuery_NotFound_LocalPort,Get-NetTCPConnection

Well, that's great, So there is no process holding port 4444 I've checked with netstat -ab in Administrator Command Prompt - no mention of port 4444

Now what? How do I get this damn thing to work again?

Well, it started working again; noting what I've done (though, I'm not really sure this is the solution):

  • Checked %systemroot%\system32\LogFiles\Firewall\pfirewall.log - no mention of any relevant blocked connections
  • In Administrative cmd.exe , tried net stop winnat then net start winnat ; did not work;
  • In Administrative cmd.exe , tried netsh winsock reset - it demands "You must restart the computer in order to complete the reset.", so I restarted

After this, I got again the "Error: couldn't bind tcl to socket on port 6666: No error"; did the Powershell commands again - and now it started working (no complaints about port 4444).

There was a larger Windows update couple of days ago, so it is possible it messed up ports - but who knows ... Eventually this stuff will get so complicated (if it isn't already), we'll all have to chant magic invocations around computers, anointing them with myrrh and incense, in hopes that something starts working. What crap ...

You can check "windows Control Panel\Programs\trun windows features on or off" that the telnet client is enabled. And if openocd still couldn't bind telnet to socket on port 4444. Then try using openocd.exe -c telnet_port 18848 to specify another port. Please ensure that the port you use is open in the firewall setting.

example: /path/to/openocd/src/openocd.exe -s /path/to/openocd/tcl -c telnet_port 18848 -f interface/picoprobe.cfg -f target/rp2040.cfg

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM