This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RM46L852: lwip example and DHCP

Part Number: RM46L852

I got the LWIP 1.4.1  example running with staic IP, but not with DHCP.

I have a DHCP-Server in my network, and I also set in the lwipopts.h

#define LWIP_DHCP 1
#define DHCP_DOES_ARP_CHECK 1

But trying DHCP i get always the following:

HERCULES MICROCONTROLLERS
Texas Instruments
Little Endian device
Initializing ethernet (DHCP)
DEBUG - Getting PHY ID....SUCCESS
DEBUG - Getting PHY Alive Status...SUCCESS
DEBUG - Getting PHY Link Status...SUCCESS
DEBUG - Setting up Link...SUCCESS
..DONE


-------- ERROR INITIALIZING HARDWARE --------

Any suggestions for my ?

  • Hi Armin,

    The error message of "ERROR INITIALIZING HARDWARE" indicates that the ip address is not provided.

    Can you try this kind of settings?

    uint8 ip_addr[4] = { 192, 168, 2, 44 };
    uint8 netmask[4] = { 255, 255, 255, 0 };
    uint8 gateway[4] = { 192, 168, 2, 254 };

    ipAddr = lwIPInit(0, macAddress, *((uint32_t *)ip_addr), *((uint32_t *)netmask), *((uint32_t *)gateway), IPADDR_USE_STATIC);

    If you get the error again, please try to use DHCP to get a dynamic IP address:

    ipAddr = lwIPInit(0, macAddress, 0, 0, 0, IPADDR_USE_DHCP);

  • Hi QJ Wang,

    as I wrote the static Ip is working, getting dynamic Ip with DHCP didn‘t work.

  • as I wrote the static Ip is working, getting dynamic Ip with DHCP didn‘t work.

    In the lwIPInit function in the lwiplib.c there is the following code:

     	dhcp_start(&hdkNetIF[instNum]);
     	count = 10;
     	/* Check for DHCP completion for 'count' number of times, each for the given delay. */
     		while(count--)
    

    With the DHCP server I was using (in a broadband router) found had to increase the count from 10 to 100 as otherwise the LwIP code failed to get an IP address within the timeout.

    Maybe increasing the value of count will help in your case.

  • Hi Chester,

    yes, increasing the value solved the problem, thanks