Networking on the DK-S7G2

I'm trying to get networking working on a project based on the Blinky ThreadX example. Using the NETX_DUO_Webserver as a reference, I added nxd and sf_el_nx to my project configuration. I've added a tx_application_define_user function which roughly mirrors that in the web server demo, but though I'm able to ping the host board when running the web server, I can't when I'm running my new project. I also try pinging out from the board, but never see any outgoing traffic on the network (no ARP requests or anything). Any thoughts on what I might be missing? My development machine and the demo board are on the same subnet (and same switch). I've actually plugged them directly together with a cross-over cable to make sure the switch wasn't doing something with the packets, and I'm still not seeing any outgoing traffic. 

 

 

void tx_application_define_user(void *first_unused_memory)
{
    UINT status;
NX_PACKET * resp; /* Initialize the NetX system. */ nx_system_initialize (); /* Create a packet pool. */ status = nx_packet_pool_create(&pool_0, (CHAR* )"NetX Main Packet Pool", (1536 + 32), packet_pool_area, sizeof(packet_pool_area)); status = nx_ip_create(&ip_0, (CHAR* )"NetX IP Instance 0", SERVER_IP_ADDRESS, 0xFFFFFF00UL, &pool_0, nx_ether_driver_eth1, &NETX_TP, 2048, 1); status = nx_ip_fragment_enable (&ip_0); status = nx_arp_enable (&ip_0, (void *) &NETX_ARP, 1024); status = nxd_icmp_enable (&ip_0); status = nx_tcp_enable (&ip_0); nx_icmp_ping(&ip_0,IP_ADDRESS(192,168,2,15),"TEST",4,&resp,NX_WAIT_FOREVER); }

Thanks much,

-Chris

  • I don't see:
    /* Enable UDP traffic. */
    status = nx_udp_enable(&ip_0);

    in there anywhere. Since PING is UDP, I don't think you'll get far without it.

    Probably good to do this before doing anything with the network...

    /* Ensure the IP instance has been initialized. */
    status = nx_ip_status_check(&ip_0, NX_IP_INITIALIZE_DONE, &actual_status, 10);

    And while not necessary for what you are doing right now, I think you might want one of these in there:

    status = nx_ip_gateway_address_set(&ip_0, LOCAL_GATEWAY);

    where LOCAL_GATEWAY is your router. Unless you do DHCP (which I don't see in there either)...

    Give that a shot and see what happens.
  • In reply to wflynn:

    Hello Chris,

    Have you enabled the interrupt for your Ethernet channel in properties for sf_el_nx? Is the board address in the same subnet as the device you're pinging it from? Keeping UDP disabled should be fine for ping, as it uses ICMP, however if you wish to enable DHCP client later on, you'll need UDP as well.

    Have a look at the following project, configuring both Ethernet channels on DK-S7 to act as a gateway (ETH1 for public interface and ETH0 for private): s7_dk_nxd_nat_1_2_0b1.zip. I'd also like to point that if you're not using IPv6 or NAT capabilities, there's no point in using NetX Duo over NetX (NetX Duo modules are also absent from the "Threads" tab in 1.2.0-b.1).

    Regards

  • In reply to Renesas Karol:

    > Have you enabled the interrupt for your Ethernet channel in properties for sf_el_nx

    That was it! I got to the point where I could see outgoing ARP requests, and though there was an ARP reply, the ARP response counter never incremented above 0. Missing the interrupt then makes sense. I seem to be able to send and receive traffic (at least ARP requests and pings) now, so I think I'm well on my way. Thanks for the quick response!
  • In reply to ChrisB:

    I'm running in to an issue when trying to connect to an echo server using the NetX client API. I'm trying to connect using the following:

    nx_system_initialize ();
    status = nx_packet_pool_create(&pool_0, (CHAR* )"NetX Main Packet Pool", (1536 + 32), packet_pool_area, sizeof(packet_pool_area));
    status = nx_ip_create(&ip_0, (CHAR* )"NetX IP Instance 0", SERVER_IP_ADDRESS, 0xFFFFFF00UL, &pool_0, nx_ether_driver_eth1, &NETX_TP, 2048, 1);
    status = nx_ip_fragment_enable (&ip_0);
    status = nx_arp_enable (&ip_0, (void *) &NETX_ARP, 1024);
    status = nx_icmp_enable (&ip_0);
    status = nx_tcp_enable (&ip_0);
    status = nx_tcp_socket_create(&ip_0, &clientSocket, "Echo client socket", NX_IP_NORMAL, NX_FRAGMENT_OKAY, NX_IP_TIME_TO_LIVE, 100, NX_NULL, NX_NULL);
    status = nx_tcp_client_socket_bind (&clientSocket, NX_ANY_PORT, NX_WAIT_FOREVER);
    status = nx_tcp_client_socket_connect (&clientSocket, IP_ADDRESS(192, 168, 2, 15), 8888, NX_WAIT_FOREVER);
    

    Everything seems to go OK until the socket_connect call. I see the following in a packet capture (2.140 is the dev board, and 2.15 is the echo server IP).

    121	9.645588	2e:09:0a:00:76:c8	Broadcast	ARP	60	Who has 192.168.2.15? Tell 192.168.2.240
    122	9.645615	WistronI_2c:41:c8	2e:09:0a:00:76:c8	ARP	42	192.168.2.15 is at 3c:97:0e:2c:41:c8
    123	9.645774	192.168.2.240	192.168.2.15	TCP	62	30000 ? 8888 [SYN] Seq=0 Win=100 Len=0 MSS=1460
    124	9.645831	192.168.2.15	192.168.2.240	TCP	54	8888 ? 30000 [ACK] Seq=1 Ack=1 Win=64240 Len=0
    142	10.645621	192.168.2.240	192.168.2.15	TCP	62	[TCP Spurious Retransmission] 30000 ? 8888 [SYN] Seq=0 Win=100 Len=0 MSS=1460
    143	10.645705	192.168.2.15	192.168.2.240	TCP	54	[TCP Dup ACK 124#1] 8888 ? 30000 [ACK] Seq=1 Ack=1 Win=64240 Len=0
    162	11.645562	192.168.2.240	192.168.2.15	TCP	62	[TCP Spurious Retransmission] 30000 ? 8888 [SYN] Seq=0 Win=100 Len=0 MSS=1460
    163	11.645623	192.168.2.15	192.168.2.240	TCP	54	[TCP Dup ACK 124#2] 8888 ? 30000 [ACK] Seq=1 Ack=1 Win=64240 Len=0
    ...
    

    I'm not seeing a SYN-ACK from the Synergy board, so I'm guessing that some part of the network stack isn't getting that packet. ARP resolution works because I can ping fine using the same setup code. I'm comparing the project configuration between my project and several examples, but I'm not certain which differences are pertinant. I can't seem to find examples of the click_socket_bind and client_socket_connect in use, so I may be missing something obvious.

  • In reply to ChrisB:

    I forgot to mention, nx_tcp_client_socket_connect is returning 56 (0x38) which doesn't appear as one of the return values in the API docs.
  • In reply to ChrisB:

    Hi Chris,

    You should add:

    nx_ip_interface_status_check (&g_ip0, 0, NX_IP_INITIALIZE_DONE, &g_ip0_actual_status, NX_WAIT_FOREVER);

    after your nx_tcp_enable() call to make sure that the stack has initialized and is ready.

    The 0x38 is documented and is defined as: NX_NOT_CONNECTED (0x38) Socket is not in a connected state.

    -Gary
  • In reply to garyj:

    Hi Gary,
    I've added a call to nx_ip_interface_status_check , which returns without error, but I'm still seeing the same behavior. I also have a call to nx_ip_status_check before I try connecting.
  • In reply to ChrisB:

    I had a similar problem, it worked once. After a disconnect and trying to connect again I did not see any SYN or ACK anymore and also received a 0x38 as return value, indicating "No Connection".

    I solved the problem by increasing the stack and heap size, of the bsp and the stack size of the thread that called the nx_tcp_client_socket_connect routine. Just for trial you might use a rather big value lets say 0x10000 (64k) that you might reduce again, when you got it working.

    In addition I had trouble with the port 30000 which is chosen when you select NX_ANY_PORT. The NAT obviously got in conflict with it. So I did choose a free port 1030 to avoid that conflict.

    Good luck and let us know if you solved the issue.
  • In reply to ChrisB:

    In SSP 1.2.0 b1, from the file synergy/ssp/inc/framework/el/nx/nx_api.h :-

    #define NX_NOT_CONNECTED 0x38

    There is a problem using nx_ip_interface_status_check() when using the synergy ethernet driver.

    This call will return even if the Ethernet cable is unplugged:-

    status = nx_ip_interface_status_check(&g_ip0, 0, NX_IP_LINK_ENABLED,
    &actual_status, TX_WAIT_FOREVER);

    To check the ethernet link is actually enabled, you have to use something like :-

    extern NX_REC nx_record[];
    #define ETH_CHANNEL 1

    while(NX_TRUE != nx_record[ETH_CHANNEL].link_established)
    {
    tx_thread_sleep(5);
    }

    To wait for the PHY to report the link has been established. The PHY status check is done in the file synergy/ssp/src/framework/sf_el_nx/nx_hw_init.c
  • In reply to Jeremy:

    Jeremy and ramo, thank you for the quick responses! Jeremy's solution turned out to be a fix for the issue that I was running in to. Waiting for the link_established flag seems to allow me to connect as expected. Thank you again!