processor lock-up using Ethernet code

The EtherTen combines an Uno-equivalent Arduino-compatible board and Wiznet-based Ethernet support, along with a microSD card slot and Power-over-Ethernet support. [Product page]
Post Reply
jtd330
Posts: 3
Joined: Wed Jan 28, 2015 4:47 pm

processor lock-up using Ethernet code

Post by jtd330 » Wed Jan 28, 2015 6:06 pm

Hi all,

I am having a problem with an Etherten processor locking up in the Ethernet code. When my Etherten code is sending UDP data at approximately 30 ms, and receiving UDP data every 50 ms, I notice the Etherten processor completely locks up in about a few hours. After speeding up the UDP sends from Etherten to every millisecond, and UDP sends to Etherten to 30 ms, I notice this problem every 5-15 minutes.

I am using Arduino 1.0.6 and also Teensyduino 1.20 on top of it for some Teensy boards I am using.

I added some test code and discovered that the processor is spinning in the while loop in sendUDP under Socket.cpp:

/* +2008.01 bj */
while ( (W5100.readSnIR(s) & SnIR::SEND_OK) != SnIR::SEND_OK )
{
if (W5100.readSnIR(s) & SnIR::TIMEOUT)
{
/* +2008.01 [bj]: clear interrupt */
W5100.writeSnIR(s, (SnIR::SEND_OK|SnIR::TIMEOUT));
SPI.endTransaction();
return 0;
}
SPI.endTransaction();
yield();
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
}

Has anyone come across this issue before? Is there a solution to this? Even if I am sending or receiving data too fast, this doesn't seem to be acceptable behavior - it should just drop the packet completely.

angusgr
Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia
Contact:

Re: processor lock-up using Ethernet code

Post by angusgr » Wed Jan 28, 2015 9:23 pm

Hi jtd330,

I haven't heard of this before, but it does look like you've found a legitimate bug with the sketch<->W5100 interaction. Are you able to post the full sketch that you're running as well?


Angus

jtd330
Posts: 3
Joined: Wed Jan 28, 2015 4:47 pm

Re: processor lock-up using Ethernet code

Post by jtd330 » Fri Jan 30, 2015 10:02 pm

Hi,

Here's some code I have that does the lock-up every few minutes when I have something sending messages to it every 50 ms. I have a watchdog enabled in this code so that it will increment a counter every time this happens and just continue. The watchdog isn't the ideal fix, but it seems to recover from the error with the watchdog.
Attachments
B0p6Code.zip
(19.25 KiB) Downloaded 94 times

angusgr
Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia
Contact:

Re: processor lock-up using Ethernet code

Post by angusgr » Sun Feb 01, 2015 10:49 pm

Hi jtd330,

I'm running your test code here and I'm able to see the serial output and the UDP packets arriving (the only I changed is the IP addresses). Unfortunately the watchdog hasn't triggered yet after about 10 minutes.

I'll let it keep running today and see if it triggers, but I think there's a chance this bug is a combination of your ethernet hardware configuration somehow.

If the watchdog works for you then that's great. It may also be worth adding a delay(1) or similar after Udp.endPacket(), because at the moment the sketch flooding out UDP packets in short bursts, almost as fast as it can - which should be fine, but a small pause may help.


Angus

jtd330
Posts: 3
Joined: Wed Jan 28, 2015 4:47 pm

Re: processor lock-up using Ethernet code

Post by jtd330 » Wed Feb 04, 2015 4:25 pm

Hi Angus,

I appreciate you taking a look at this problem, and I think I found the problem.

If you read errata 1 for the W5100 chip (http://www.wiznet.co.kr/Admin_Root/UpLo ... _V250E.pdf), it exactly describes the problem I am having.

Their only suggested solution is to reset the socket upon detection, so I will go with implementing that solution.

Thanks,
Jeremy

angusgr
Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia
Contact:

Re: processor lock-up using Ethernet code

Post by angusgr » Thu Feb 05, 2015 12:43 am

Ah, chip errata. Always the last place you look. :)

Thanks for finding this, seems like a match as you say. I think a fix for this should probably be contributed back to the Arduino Ethernet library as well. I'll try and make time to take a look at it unless anyone else gets there first. :)

angusgr
Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia
Contact:

Re: processor lock-up using Ethernet code

Post by angusgr » Thu Feb 05, 2015 12:44 am

That also explains why I wasn't able to trigger the bug, I didn't have anything sending UDP to the test EtherTen.

Post Reply