Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 5 months ago. This question has been closed. Reason: Duplicate question
K64F and ethernet seem very unstable
Hi All,
I've started working on ethernet on a Freescale F64F (Version: 0202 Build: Apr 24 2014 15:04:52). I've created the following program with the latest revisions of these libs included:
http://mbed.org/users/mbed_official/code/EthernetInterface/ http://mbed.org/users/mbed_official/code/mbed-rtos/ http://mbed.org/users/mbed_official/code/mbed-src/
#include "mbed.h" #include "EthernetInterface.h" DigitalOut green(LED_GREEN); DigitalOut blue(LED_BLUE); EthernetInterface eth; int main() { blue=0; eth.init(); //Use DHCP eth.connect(); blue=1; while (true) { green = 1; wait(1); green = 0; wait(0.1); } }
The program boots. After a few seconds the blue led turns blinking green indicating it has an IP. I can indeed ping the IP, but only about 5 times, after that the device stops responding to ping, but the green led keeps blinking.
ping -c 10 192.168.1.29 PING 192.168.1.29 (192.168.1.29) 56(84) bytes of data. 64 bytes from 192.168.1.29: icmp_seq=1 ttl=255 time=6.82 ms 64 bytes from 192.168.1.29: icmp_seq=2 ttl=255 time=9.83 ms 64 bytes from 192.168.1.29: icmp_seq=3 ttl=255 time=7.87 ms 64 bytes from 192.168.1.29: icmp_seq=4 ttl=255 time=5.83 ms 64 bytes from 192.168.1.29: icmp_seq=5 ttl=255 time=8.83 ms --- 192.168.1.29 ping statistics --- 10 packets transmitted, 5 received, 50% packet loss, time 9009ms rtt min/avg/max/mdev = 5.836/7.841/9.830/1.415 ms
Also when sending a large packet (which will require fragmentation), the device will hang after trying to send it's response in just 1 packet and the green led will stop blinking:
ping -s 4096 -c 2 192.168.1.29 PING 192.168.1.29 (192.168.1.29) 4096(4124) bytes of data. 4104 bytes from 192.168.1.29: icmp_seq=2 ttl=255 time=6.11 ms --- 192.168.1.29 ping statistics --- 2 packets transmitted, 1 received, 50% packet loss, time 1008ms rtt min/avg/max/mdev = 6.118/6.118/6.118/0.000 ms
It seems that (at least ICMP) on these devices is *very* unstable. I've made some first steps in debugging the issue and was able to 'workaround' the second problem by dropping large packets in the ip_output_if function in ip.c (line 572). So it seems the device will hang on sending such a large packet, not on receiving).
What to do now? There is a lot of debug information mentioned in the code, is there any way for me to get this debug output somehow?
1 Answer
10 years, 5 months ago.
Hello Marius:
Can you try my code? http://mbed.org/users/sscaglia/code/
I just tested it again and it works fine (1000 pings and/or 4096-sized packets) and I don't see your problem.... Just change the DHCP configuration in case you need (I think it's using static IP in the main.cpp, but just change it as needed.
Regards; Sergio
Hello Sergio,
Your version of ethernetInterface works better in that it keeps responding to pings. However your version still crashes the mbed with a ping packet of 4096 bits.
To test replace from line 30 in your code:
//UDPSocket echo; //echo.bind(ECHO_SERVER_PORT); //Endpoint host_send; //Endpoint host_rcv; // First time only: detect host IP //int n = echo.receiveFrom(host_send, buffer, sizeof(buffer)); //host_rcv.set_address(host_send.get_address(), 8); //echo.sendTo(host_rcv, buffer, sizeof(buffer)); while(1) { // int n = echo.receiveFrom(host_send, buffer, sizeof(buffer)); // echo.sendTo(host_rcv, buffer, sizeof(buffer)); pc.printf("test\r\n"); wait(0.5); }
once you send a :
ping -s 4096 192.168.1.20
the 'test' outputs will stop ( the while loop will not be traversed again, it's not just serial that stops )
Regards, Marius
posted by 01 Jun 2014
Hi,
there's LWIPOPTS header file, where you can enable messages. A snippet from that file
The messages should be send via USBTX, USBRX, so you should see it on your console. Let us know if you get the debug messages activated.
Regards,
posted by Martin Kojtal 30 May 20140xc0170
Hi Martin,
When I set the define of the debug and set the flags to LWIP_DBG_ON the device never passes the connect() phase. This is all the output I'm getting:
New Thread: tcpip_thread netif_set_ipaddr: netif address being changed netif: IP address of interface set to 192.168.1.20 netif: netmask of interface set to 255.255.255.0 netif: GW address of interface set to 192.168.1.1
Regards, Marius
posted by Marius Karthaus 01 Jun 2014