Saturday, February 24th 2018, 10:57pm UTC+1

You are not logged in.

  • Login
  • Register

marto

Beginner

Date of registration: Feb 14th 2018

Posts: 4

1

Wednesday, February 14th 2018, 4:43pm

Cannot use JLinkRemoteServer on linux from windows' Keil: Max. number of connections exceeded.

Hello

I'm trying to reach Jlink-base plugged into my linux box from Keil on a windows box.

The debugger fails with quite no logs. Flash is a little bit more verbose, but fails too:

Source code

1
2
3
4
5
6
7
Load "C:\\<REDACTED>\\MDK-ARM\\Release\\Objects\\<redacted>.axf" 
* JLink Info: Connecting to J-Link via TCP/IP (192.168.1.181:19020)
* JLink Info: Connected with SEGGER J-Link Remote Server V6.30c compiled 17:22:50 on Feb  9 2018
Can not connect to J-Link via TCP/IP (192.168.1.181, port 19020)

Max. Number of connections exceeded
Error: Flash Download failed  -  Target DLL has been cancelled


Output from JLinkRemoteServer:

Source code

1
2
3
4
5
6
7
8
9
10
11
16:15:18.500779 SEGGER J-Link Remote Server V6.30c
16:15:18.500875 Compiled Feb  9 2018 17:22:50
16:15:18.500896 
16:15:18.500913 'q' to quit '?' for help
16:15:18.500930 
16:15:18.500946 Connected to J-Link with S/N 5xxxxxx
16:15:18.500963 
16:15:34.486155 Waiting for client connection... Client connected.
16:15:34.548436 Additional client connection rejected.
16:15:34.548484 Reason: Max. number of connections exceeded.
16:15:34.551609 Client disconnected.


Tcpdump capture:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
16:15:34.485068 IP 192.168.1.194.50586 > 192.168.1.181.19020: Flags [S], seq 2298248450, win 64240, options [mss 1460,nop,wscale 8,nop,nop,sackOK], length 0
16:15:34.485109 IP 192.168.1.181.19020 > 192.168.1.194.50586: Flags [S.], seq 2396416812, ack 2298248451, win 29200, options [mss 1460,nop,nop,sackOK,nop,wscale 7], length 0
16:15:34.485430 IP 192.168.1.194.50586 > 192.168.1.181.19020: Flags [.], ack 1, win 2053, length 0
16:15:34.486421 IP 192.168.1.181.19020 > 192.168.1.194.50586: Flags [P.], seq 1:5, ack 1, win 229, length 4
16:15:34.486496 IP 192.168.1.181.19020 > 192.168.1.194.50586: Flags [P.], seq 5:73, ack 1, win 229, length 68
16:15:34.486704 IP 192.168.1.194.50586 > 192.168.1.181.19020: Flags [.], ack 73, win 2052, length 0
16:15:34.495522 IP 192.168.1.194.50586 > 192.168.1.181.19020: Flags [P.], seq 1:4, ack 73, win 2052, length 3
[...]
16:15:34.511677 IP 192.168.1.181.19020 > 192.168.1.194.50586: Flags [P.], seq 4957:4961, ack 48, win 229, length 4
16:15:34.512152 IP 192.168.1.194.50586 > 192.168.1.181.19020: Flags [P.], seq 48:63, ack 4961, win 2053, length 15
16:15:34.513342 IP 192.168.1.181.19020 > 192.168.1.194.50586: Flags [P.], seq 4961:5053, ack 63, win 229, length 92
16:15:34.513664 IP 192.168.1.194.50586 > 192.168.1.181.19020: Flags [P.], seq 63:78, ack 5053, win 2052, length 15
16:15:34.514861 IP 192.168.1.181.19020 > 192.168.1.194.50586: Flags [P.], seq 5053:5145, ack 78, win 229, length 92
16:15:34.519361 IP 192.168.1.194.50586 > 192.168.1.181.19020: Flags [P.], seq 78:79, ack 5145, win 2052, length 1
16:15:34.544484 IP 192.168.1.194.50586 > 192.168.1.181.19020: Flags [P.], seq 79:95, ack 5145, win 2052, length 16
16:15:34.544946 IP 192.168.1.181.19020 > 192.168.1.194.50586: Flags [.], ack 95, win 229, length 0
16:15:34.545987 IP 192.168.1.181.19020 > 192.168.1.194.50586: Flags [P.], seq 5145:5237, ack 95, win 229, length 92
16:15:34.546311 IP 192.168.1.194.50586 > 192.168.1.181.19020: Flags [F.], seq 95, ack 5237, win 2052, length 0
16:15:34.546471 IP 192.168.1.181.19020 > 192.168.1.194.50586: Flags [F.], seq 5237, ack 96, win 229, length 0
16:15:34.546804 IP 192.168.1.194.50586 > 192.168.1.181.19020: Flags [.], ack 5238, win 2052, length 0
16:15:34.547571 IP 192.168.1.194.50587 > 192.168.1.181.19020: Flags [S], seq 2760538899, win 64240, options [mss 1460,nop,wscale 8,nop,nop,sackOK], length 0
16:15:34.547590 IP 192.168.1.181.19020 > 192.168.1.194.50587: Flags [S.], seq 4257933236, ack 2760538900, win 29200, options [mss 1460,nop,nop,sackOK,nop,wscale 7], length 0
16:15:34.548007 IP 192.168.1.194.50587 > 192.168.1.181.19020: Flags [.], ack 1, win 2053, length 0
16:15:34.548314 IP 192.168.1.181.19020 > 192.168.1.194.50587: Flags [P.], seq 1:5, ack 1, win 229, length 4
16:15:34.548394 IP 192.168.1.181.19020 > 192.168.1.194.50587: Flags [P.], seq 5:77, ack 1, win 229, length 72
16:15:34.548443 IP 192.168.1.181.19020 > 192.168.1.194.50587: Flags [FP.], seq 77:117, ack 1, win 229, length 40
16:15:34.548623 IP 192.168.1.194.50587 > 192.168.1.181.19020: Flags [.], ack 77, win 2052, length 0
16:15:34.548907 IP 192.168.1.194.50587 > 192.168.1.181.19020: Flags [.], ack 118, win 2052, length 0
16:15:34.558090 IP 192.168.1.194.50587 > 192.168.1.181.19020: Flags [F.], seq 1, ack 118, win 2052, length 0
16:15:34.558103 IP 192.168.1.181.19020 > 192.168.1.194.50587: Flags [.], ack 2, win 229, length 0


The first TCP connection is correctly closed (Fin at 16:15:34.546311) before the second is established (Syn at 16:15:34.547571).

I don't know how/when the connection counter is handled, but strace shows that the first socket is closed (at 16:15:34.546458) before accepting the new connection (at 16:15:34.548074):

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
19438 16:15:34.546407 sendto(3<TCP:[127.0.0.1:37626->127.0.0.1:19030]>, "\2\0\0\0\22\0", 6, MSG_NOSIGNAL, NULL, 0) = 6
19438 16:15:34.546438 futex(0x7fa6d4382be8, FUTEX_WAKE_PRIVATE, 1) = 1
19422 16:15:34.546452 <... futex resumed> ) = 0
19438 16:15:34.546458 close(7<TCP:[192.168.1.181:19020->192.168.1.194:50586]> <unfinished ...>
19422 16:15:34.546467 futex(0x7fa6d4382be8, FUTEX_WAKE_PRIVATE, 1) = 0
19438 16:15:34.546480 <... close resumed> ) = 0
19422 16:15:34.546486 futex(0x7fa6d4384214, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 1269, {tv_sec=1518621334, tv_nsec=571481000}, 0xffffffff <unfinished ...>
19438 16:15:34.546494 close(8<UDP:[0.0.0.0:19020]>) = 0
19438 16:15:34.546516 nanosleep({tv_sec=0, tv_nsec=5000000},  <unfinished ...>
19425 16:15:34.547122 <... select resumed> ) = 0 (Timeout)
19425 16:15:34.547137 select(7, [6<TCP:[0.0.0.0:19020]>], NULL, NULL, {tv_sec=0, tv_usec=10000}) = 1 (in [6], left {tv_sec=0, tv_usec=9108})
19425 16:15:34.548074 accept(6<TCP:[0.0.0.0:19020]>, NULL, NULL) = 7<TCP:[192.168.1.181:19020->192.168.1.194:50587]>
19425 16:15:34.548269 setsockopt(7<TCP:[192.168.1.181:19020->192.168.1.194:50587]>, SOL_TCP, TCP_NODELAY, [1], 4) = 0
19425 16:15:34.548295 sendto(7<TCP:[192.168.1.181:19020->192.168.1.194:50587]>, "\376)\240D", 4, MSG_NOSIGNAL, NULL, 0) = 4
19425 16:15:34.548326 sendto(7<TCP:[192.168.1.181:19020->192.168.1.194:50587]>, "SEGGER J-Link Remote Server V6.30c compiled 17:22:50 on Feb  9 2018\0", 68, MSG_NOSIGNAL, NULL, 0) = 68
19425 16:15:34.548349 sendto(7<TCP:[192.168.1.181:19020->192.168.1.194:50587]>, "(\0\0\0", 4, MSG_NOSIGNAL, NULL, 0) = 4
19425 16:15:34.548371 sendto(7<TCP:[192.168.1.181:19020->192.168.1.194:50587]>, "\r\nMax. Number of connections exceeded\r\n\0", 40, MSG_NOSIGNAL, NULL, 0) = 40
19425 16:15:34.548408 write(1<pipe:[858864]>, "Additional client connection rejected.\r\nReason: Max. number of connections exceeded.\r\n", 86) = 86
19425 16:15:34.548432 close(7<TCP:[192.168.1.181:19020->192.168.1.194:50587]>) = 0
19425 16:15:34.548455 select(7, [6<TCP:[0.0.0.0:19020]>], NULL, NULL, {tv_sec=0, tv_usec=10000} <unfinished ...>
19439 16:15:34.550190 <... recvfrom resumed> 0x7fa6d082bed0, 64, 0, 0x7fa6d082bdf0, [16]) = -1 EAGAIN (Resource temporarily unavailable)
19439 16:15:34.550210 recvfrom(8, 0x7fa6d082bed0, 64, 0, 0x7fa6d082bdf0, [16]) = -1 EBADF (Bad file descriptor)
19439 16:15:34.550237 madvise(0x7fa6d002c000, 8368128, MADV_DONTNEED) = 0
19439 16:15:34.550268 exit(0)           = ?
19439 16:15:34.550306 +++ exited with 0 +++
19424 16:15:34.550324 <... select resumed> ) = 0 (Timeout)
19424 16:15:34.550339 select(5, [4<TCP:[127.0.0.1:19081]>], NULL, NULL, {tv_sec=0, tv_usec=10000} <unfinished ...>
19420 16:15:34.550414 <... nanosleep resumed> NULL) = 0
19420 16:15:34.550426 ioctl(0</dev/pts/13>, FIONREAD, [0]) = 0
19420 16:15:34.550452 nanosleep({tv_sec=0, tv_nsec=100000000},  <unfinished ...>
19438 16:15:34.551580 <... nanosleep resumed> NULL) = 0
19438 16:15:34.551590 write(1<pipe:[858864]>, "Client disconnected.\r\n", 22) = 22
19438 16:15:34.551615 write(1<pipe:[858864]>, "Waiting for client connection... ", 33) = 33
19438 16:15:34.551641 madvise(0x7fa6d082d000, 8368128, MADV_DONTNEED) = 0
19438 16:15:34.551661 exit(0)           = ?

The `recvfrom()` at 16:15:34.550190 fails on fd 8, closed above by pid 19438.

Client version: 6.30c.
Server version: 6.30c.
OS: debian stretch.
Tested with same result with server version 6.18a.

Probably related to abandoned http://forum.segger.com/index.php?page=Thread&threadID=4548
Both Debug and Flash create two TCP connections.

Any help appreciated.

Thanks,

Marc.

marto

Beginner

Date of registration: Feb 14th 2018

Posts: 4

2

Wednesday, February 14th 2018, 5:04pm

I succeeded to make it work once. Here's the strace:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
22984 16:55:36.653236 write(8</<redacted>/JLinkTCPIP.log>, "              JLINK_Unlock() (0002ms, 0727ms total)", 51) = 51
22984 16:55:36.653257 write(8</<redacted>/JLinkTCPIP.log>, "\r\n", 2) = 2
22984 16:55:36.653279 close(10<TCP:[192.168.1.181:19020->192.168.1.194:50674]>) = 0
22984 16:55:36.653310 close(11<UDP:[0.0.0.0:19020]>) = 0
22984 16:55:36.653333 nanosleep({tv_sec=0, tv_nsec=5000000},  <unfinished ...>
22979 16:55:36.655886 <... select resumed> ) = 0 (Timeout)
22979 16:55:36.655898 select(8, [7<TCP:[127.0.0.1:19021]>], NULL, NULL, {tv_sec=0, tv_usec=10000} <unfinished ...>
22981 16:55:36.656127 <... select resumed> ) = 0 (Timeout)
22981 16:55:36.656142 select(10, [9<TCP:[0.0.0.0:19020]>], NULL, NULL, {tv_sec=0, tv_usec=10000} <unfinished ...>
22980 16:55:36.658017 <... select resumed> ) = 0 (Timeout)
22980 16:55:36.658030 select(7, [6<TCP:[127.0.0.1:19080]>], NULL, NULL, {tv_sec=0, tv_usec=10000} <unfinished ...>
22981 16:55:36.658188 <... select resumed> ) = 1 (in [9], left {tv_sec=0, tv_usec=7977})
22985 16:55:36.658205 <... recvfrom resumed> 0x7f3b1110bed0, 64, 0, 0x7f3b1110bdf0, [16]) = -1 EAGAIN (Resource temporarily unavailable)
22981 16:55:36.658214 accept(9<TCP:[0.0.0.0:19020]>, NULL, NULL <unfinished ...>
22985 16:55:36.658226 recvfrom(11,  <unfinished ...>
22981 16:55:36.658239 <... accept resumed> ) = 10<TCP:[192.168.1.181:19020->192.168.1.194:50675]>
22985 16:55:36.658405 <... recvfrom resumed> 0x7f3b1110bed0, 64, 0, 0x7f3b1110bdf0, [16]) = -1 EBADF (Bad file descriptor)
22984 16:55:36.658415 <... nanosleep resumed> NULL) = 0
22985 16:55:36.658423 madvise(0x7f3b1090c000, 8368128, MADV_DONTNEED <unfinished ...>
22981 16:55:36.658432 setsockopt(10<TCP:[192.168.1.181:19020->192.168.1.194:50675]>, SOL_TCP, TCP_NODELAY, [1], 4 <unfinished ...>
22985 16:55:36.658447 <... madvise resumed> ) = 0
22984 16:55:36.658454 write(1<pipe:[899143]>, "Client disconnected.\r\n", 22 <unfinished ...>
22985 16:55:36.658468 exit(0 <unfinished ...>
22981 16:55:36.658475 <... setsockopt resumed> ) = 0
22985 16:55:36.658482 <... exit resumed>) = ?
22984 16:55:36.658488 <... write resumed> ) = 22
22981 16:55:36.658496 futex(0x7f3b168da760, FUTEX_WAIT_PRIVATE, 2, NULL <unfinished ...>
22985 16:55:36.658511 +++ exited with 0 +++
22984 16:55:36.658517 futex(0x7f3b168da760, FUTEX_WAKE_PRIVATE, 1) = 1
22981 16:55:36.658549 <... futex resumed> ) = 0
22984 16:55:36.658555 write(1<pipe:[899143]>, "Waiting for client connection... ", 33 <unfinished ...>
22981 16:55:36.658569 futex(0x7f3b168da760, FUTEX_WAIT_PRIVATE, 2, NULL <unfinished ...>
22984 16:55:36.658576 <... write resumed> ) = 33
22984 16:55:36.658584 futex(0x7f3b168da760, FUTEX_WAKE_PRIVATE, 1) = 1
22981 16:55:36.658600 <... futex resumed> ) = 0
22984 16:55:36.658610 madvise(0x7f3b1110d000, 8368128, MADV_DONTNEED <unfinished ...>
22981 16:55:36.658617 futex(0x7f3b168da760, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
22984 16:55:36.658622 <... madvise resumed> ) = 0
22981 16:55:36.658628 <... futex resumed> ) = 0
22984 16:55:36.658633 exit(0 <unfinished ...>
22981 16:55:36.658639 write(1<pipe:[899143]>, "Client connected.\r\n", 19 <unfinished ...>
22984 16:55:36.658651 <... exit resumed>) = ?
22981 16:55:36.658657 <... write resumed> ) = 19
22984 16:55:36.658667 +++ exited with 0 +++
22981 16:55:36.658672 mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f3b173ea000
22981 16:55:36.658810 sendto(10<TCP:[192.168.1.181:19020->192.168.1.194:50675]>, "\0)\240D", 4, MSG_NOSIGNAL, NULL, 0) = 4
22981 16:55:36.658845 sendto(10<TCP:[192.168.1.181:19020->192.168.1.194:50675]>, "SEGGER J-Link Remote Server V6.30c compiled 17:22:50 on Feb  9 2018\0", 68, MSG_NOSIGNAL, NULL, 0) = 68
22981 16:55:36.658872 clone(child_stack=0x7f3b1190cff0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f3b1190d9d0, tls=0x7f3b1190d700, child_tidptr=0x7f3b1190d9d0) = 22986
22986 16:55:36.658931 set_robust_list(0x7f3b1190d9e0, 24 <unfinished ...>
22981 16:55:36.658939 select(10, [9<TCP:[0.0.0.0:19020]>], NULL, NULL, {tv_sec=0, tv_usec=10000} <unfinished ...>
22986 16:55:36.658952 <... set_robust_list resumed> ) = 0
22986 16:55:36.658964 getpeername(10<TCP:[192.168.1.181:19020->192.168.1.194:50675]>, {sa_family=AF_INET, sin_port=htons(50675), sin_addr=inet_addr("192.168.1.194")}, [16]) = 0
22986 16:55:36.659006 clone(child_stack=0x7f3b1110bff0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f3b1110c9d0, tls=0x7f3b1110c700, child_tidptr=0x7f3b1110c9d0) = 22987
22987 16:55:36.659039 set_robust_list(0x7f3b1110c9e0, 24 <unfinished ...>
22986 16:55:36.659047 recvfrom(10<TCP:[192.168.1.181:19020->192.168.1.194:50675]>,  <unfinished ...>
22987 16:55:36.659057 <... set_robust_list resumed> ) = 0
22987 16:55:36.659068 socket(AF_INET, SOCK_DGRAM, IPPROTO_IP) = 11<UDP:[892915]>


Looks that there is a race condition (probably aggravated when a JLinkRTTLogger is started which was the case in my first captures). If I add latency on my ethernet interface (with `tc`), it's damn slow but it works.

This post has been edited 3 times, last edit by "marto" (Feb 14th 2018, 5:17pm)


SEGGER - Nino

Super Moderator

Date of registration: Jan 2nd 2017

Posts: 716

3

Friday, February 16th 2018, 2:32pm

Hello,

Thank you for your inquiry.
Such an issue is not known to us.
How is your exact setup?
Is the Linux box int he same network as the Windows PC?
Or are you using the RemoteServer in tunneling mode to a remote location?
Does the connect generally work when using J-Link commander?

Should your setup be in the same company network we suggest the usage of a J-Link PRO over Ethernet so no timing problems appear.

Best regards,
Nino

marto

Beginner

Date of registration: Feb 14th 2018

Posts: 4

4

Friday, February 16th 2018, 6:09pm

Hello,

My two computers are on the same network, and connected with a 1Gbps switch:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
+-linux--------------+                              +-windows---------------+
|                    |                              |                       |
|                    |          +--------+          |                       |
| JlinkRTTServer     +--(rj45)--+ switch +--(rj45)--+ Keil                  |
|                    |          +--------+          |                       |
|                    |                              |                       |
+--+-----------------+                              +-----------------------+
   |                                    
 (usb)                                    
   |                                    
 +-+-----------+      +------------+       
 | j-link Base +------+ eval board |       
 +-------------+      +------------+

There is no problem with JLink.exe since it only create one connection to the JLinkRTTServer (not two as Keil is doing).

Thanks,

Marc.

marto

Beginner

Date of registration: Feb 14th 2018

Posts: 4

5

Monday, February 19th 2018, 9:24am

Hello,
Should your setup be in the same company network we suggest the usage of a J-Link PRO over Ethernet so no timing problems appear.


You mean that my setup is not supported ?

Thanks,

Marc.

SEGGER - Nino

Super Moderator

Date of registration: Jan 2nd 2017

Posts: 716

6

Tuesday, February 20th 2018, 10:58am

Hello Marc,

You write that you use a JlinkRTTServer. Can you elaborate what exactly do you mean by this? I could not find any software called like this.
Did you mean JLinkRemoteServer instead?

Multiple connections to J-Link over RemoteServer or IP are currently not supported.
This might be implemented in future if the commands come from the same client PC.

What is triggering the second connection?
You write that Keil is doing it but we are not aware of such behaviour.
Could you post a J-Link log of such a session?

https://wiki.segger.com/Enable_J-Link_log_file

Best regards,
Nino