[En-Nut-Discussion] How to make "Ethernut Device registration" more save??

Dominik Schröder dominik.schroeder at bh-informativ.de
Thu Aug 12 16:19:31 CEST 2010


Hello

 

I`m using Ethernut on an AT91SAM7X. My program is something like the httpd
example. At the beginning of my program I do something like this:

 

/* Hard coded network configuration. */

#define MY_MAC  "\x00\x06\x98\x30\x00\x36"

#define MY_IP   "192.166.30.30"

#define MY_MASK "255.255.0.0"

#define MY_IPGATE "192.166.10.11"

 

int main (void)

{

                uint8_t mac[6] = MY_MAC;

                uint32_t ip_addr = inet_addr(MY_IP);

                uint32_t ip_mask = inet_addr(MY_MASK);

                uint32_t ip_gate = inet_addr(MY_IPGATE);

.

.

.

                init_dio();

                init_debugUART();

                NutThreadCreate("t2", WatchdogThread, 0, 512);

                

                retval = initEthernet(mac, ip_addr, ip_mask, ip_gate);

                if(retval == SUCCESS){  

                               printf("Now you can ping " MY_IP " on your
PC\n\r");

                }

                else{

                               printf("Ethernet Error\n\r");

                }

}

 

int initEthernet(uint8_t mac[], uint32_t ip_addr, uint32_t ip_mask, uint32_t
ip_gate)

{

                if(NutRegisterDevice(&DEV_ETHER, 0, 0))

                {

                               printf("Cannot register DEV_ETHER_NAME");

                               return E_ETHERNET;

                }

                else if(NutNetIfConfig(DEV_ETHER_NAME, mac, ip_addr,
ip_mask))

                {

                               printf("Configuring Ethernet failed");

                               return E_ETHERNET;

                }

                else

                {

                               if(ip_gate) {

                               printf("hard coded gate...");

                               NutIpRouteAdd(0, 0, ip_gate, &DEV_ETHER);

        }

                               return ETHERNET_SUCCESS;

                }

}

 

My problem is, when I disconnect the Ethernet cable and then put on the
system, the hole system seems to hang of. I don`t get any debug prompts on
UART. After some time my external Watchdog forces the system to reset and so
on and so on...

If the system starts with an connected Ethernet cable, everything works
fine.

Is there anybody how knows an solution for this?

 

Best regards

 

Dominik Schröder




 




More information about the En-Nut-Discussion mailing list