[En-Nut-Discussion] TCP Sockets hang on certain occasions (Harald Kipp)
Adeel Ahmed Nafos
adeel at linkwisetech.com
Wed Aug 22 03:49:05 CEST 2012
OK, did not try that. Would require some engineering to bring out the
comm port, as currently it is not used.
Apart from that had to do some changes to the at91_emac.c driver to make
it work.
The problem, was that if the cable was not plugged in EmacInit() took a
long time to return, and this caused the watchdog to kick in and reset.
So we reduced the EMAC_LINK_LOOPS from 1000000 to 100, to make it return
faster, and put in the NutWatchDogRestart() calls to stop from reset.
diff -r 2d439fb3cdb9 nut/arch/arm/dev/atmel/at91_emac.c
--- a/nut/arch/arm/dev/atmel/at91_emac.c Wed Aug 15 09:54:44 2012 +0800
+++ b/nut/arch/arm/dev/atmel/at91_emac.c Fri Aug 17 16:15:07 2012 +0800
@@ -114,6 +114,7 @@
#include <dev/irqreg.h>
#include <dev/at91_emac.h>
+#include <dev/watchdog.h>
#ifdef NUTDEBUG
#include <stdio.h>
@@ -135,7 +136,8 @@
#endif
#ifndef EMAC_LINK_LOOPS
-#define EMAC_LINK_LOOPS 1000000
+//#define EMAC_LINK_LOOPS 1000000
+#define EMAC_LINK_LOOPS 100 //reducing to low value
as else it just hangs up the system
#endif
/*!
@@ -480,6 +482,7 @@ static int probePhy(uint32_t tmo)
/* Wait for auto negotiation completed. */
phy_inw(NIC_PHY_BMSR); /* Discard previously latched status. */
while (--tmo) {
+ NutWatchDogRestart();
if (phy_inw(NIC_PHY_BMSR) & NIC_PHY_BMSR_ANCOMPL) {
break;
}
More information about the En-Nut-Discussion
mailing list