Rabbit Board 4000

hello, I have a rabbit board 4000 BL4S160 2m serial program flash. Basically after I power cycle the network router which connects to the board (simulating an extended power outage), the values stored in memory are lost. I have replaced the battery to no avail. I have inherited this code and controller so I am kind of new to does?

Any ideas on where to start?

I have seen something similar in my products where the Rabbit device is set to use Link Local addressing in the absence of a DHCP server.

What happens is that when the router goes down, the rabbit board changes network and then when the router is restored it changes network again. There is a bug in the TCP/IP stack which as far as I can remember, relates to how the stack stores its list of routers which can end up in a loop writing to memory beyond the end of the list. I modified the code to always clear the list of routers in this case and it solved the problem for me - I did report the issue to Digi but I don’t think they tried to get to the bottom of it.

I’m working on adding support for a GPRS module to my product and will have to revisit this whole area as the simple fix I put in place does not work if you have more than one network connection as every time the GPRS connection is dropped, all the routers are flushed.

Regards,
Peter

1 Like

OK thanks Peter. Here is my code snippet for the network handler:


//IP network handler thread
      	while(1)
         {
         	if(ifpending(IF_DEFAULT) != IF_UP)//if nextwork interface isn't up...
            {	// Start network and wait for interface to come up.
	            do
	            {
	               sock_init();//initialist TCP socket for HTTP Post commands.
                  ifdown(IF_ETH0);
                  while (ifpending(IF_ETH0) == IF_COMING_DOWN)
                  {
                  	tcp_tick(NULL);
                     yield;
                  }
                  ifconfig(IF_ETH0,
	                           IFS_DOWN,
	                           IFS_IPADDR, aton(IPAddressString),
	                           IFS_NETMASK, aton(SubnetString),
	                           IFS_ROUTER_SET, aton(DefaultGatewayString),
	                           IFS_NAMESERVER_SET, aton(DNSServerString),
	                           IFS_UP,
	                           IFS_END);

                  yield;

	               while (ifpending(IF_DEFAULT) == IF_COMING_UP)
                  {
	                  tcp_tick(NULL);
                     yield;
                  }


	            }while(ifpending(IF_DEFAULT) != IF_UP);
	            //Network must be up so initialise http server, and reserve port 80 for multiple web connections
	            http_init();
	            tcp_reserveport(80);
               printf("set up network 
");
               printf("
 done");


            }
            //run the http server daemon and process TCP services
            http_handler();
            tcp_tick(NULL);
         	yield;
         }

Could you provide a code snippet to clear the list of routers please? -Paramjit

OK thanks Peter. Here is my code snippet for the network handler:

//IP network handler thread
while(1)
{
if(ifpending(IF_DEFAULT) != IF_UP)//if nextwork interface isn’t up…
{ // Start network and wait for interface to come up.
do
{
sock_init();//initialist TCP socket for HTTP Post commands.
ifdown(IF_ETH0);
while (ifpending(IF_ETH0) == IF_COMING_DOWN)
{
tcp_tick(NULL);
yield;
}
ifconfig(IF_ETH0,
IFS_DOWN,
IFS_IPADDR, aton(IPAddressString),
IFS_NETMASK, aton(SubnetString),
IFS_ROUTER_SET, aton(DefaultGatewayString),
IFS_NAMESERVER_SET, aton(DNSServerString),
IFS_UP,
IFS_END);

              yield;

               while (ifpending(IF_DEFAULT) == IF_COMING_UP)
              {
                  tcp_tick(NULL);
                 yield;
              }


            }while(ifpending(IF_DEFAULT) != IF_UP);
            //Network must be up so initialise http server, and reserve port 80 for multiple web connections
            http_init();
            tcp_reserveport(80);
           printf("set up network 

“);
printf(”
done");

        }
        //run the http server daemon and process TCP services
        http_handler();
        tcp_tick(NULL);
     	yield;
     }

Could you provide a code snippet to clear the list of routers please? -Paramjit WSE Ltd

I fixed the problem in my case by changing the router_del_all() function in ARP.lib to the following:

// PMCS
_arp_nodebug void router_del_all(void)
{
auto unsigned i;
auto RTEntry * rte;
auto ATHandle ath;
auto ATEntry * ate;

// This function may be called pre-sock_init().  If so, then there will
// be no ARP cache entries, so flush will not be called.

LOCK_GLOBAL_IF_INIT(TCPGlobalLock);
#ifndef ARP_MINIMAL
#ifdef ARP_VERBOSE
printf("ARP: deleting all routers
");
#endif
for (i = 0, rte = _arp_gate_data; i < ARP_ROUTER_TABLE_SIZE; ++i, ++rte)
if (rte->ath) {
ath = ATH2INDEX(rte->ath);
if (ath < ARP_TABLE_SIZE)
{
ate = _arp_data + ATH2INDEX(ath);
ate->flags &= ~ATE_ROUTER_ENT; // No router any more
ate->ath = 0;
_arp_unlink_to(ate);
}

		rte-&gt;ath = 0;
	}

#else
memset(_arp_gate_data, 0, sizeof(_arp_gate_data));
#endif
UNLOCK_GLOBAL_IF_INIT(TCPGlobalLock);
}

This solved the crashing problem but will only work for boards with a single network interface. I’m going to have to figure out something better soon as I want to have a GPRS interface in addition to the Ethernet one.

I am trying this today and will let you know how it goes. Thanks.

looks like the main problem was the battery on the board needed replacing. It is now able to retain memory values after long power outage. thanks for the help.