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.
Using the TM4C129X Eval kit, the enet_lwip example works great using DHCP. Changing the call to lwIPInit from
lwIPInit(g_ui32SysClock, pui8MACArray, 0, 0, 0, IPADDR_USE_DHCP); to
lwIPInit(g_ui32SysClock, pui8MACArray, 0xC0A8A831, 0xFFFFFF00, 0xC0A8A801, IPADDR_USE_STATIC);
does not work. It eventually times out and assigns 169.254.1.0 for the IP Address.
If the DHCP server is left running even when IPADDR_USE_STATIC is specified, the the DHCP server assigns an address and the Eval kit accepts it.
BTW, this works just fine using a Stellaris part with the latest version of StellarisWare.
Please help!
Thanks,
Jeff
Also, there is an error at line 439 in lwiplib.c:
#if LWIP_AUTIP || LWIP_DHCP should be #if LWIP_AUTOIP || LWIP_DHCP
Jeff,
Here is what I did to get the enet_lwip example working with a STATIC IP address on the DK-TM4C129X.
1) In 'lwipopts.h' I changed the two defines below to 0:
#define LWIP_DHCP 0
#define LWIP_AUTOIP 0
2) In 'enet_lwip.c' I changed the call to lwIPInit to (screenshot below). This format also makes it easy to read and change the IP, Subnet, and Gateway addresses.
Since I'm testing on our LAN, I first ran the example in DHCP mode to verify a safe IP address to use. I then plugged that IP, Subnet, and Gateway into the lwIPInit call used in static mode.
Let me know if this helps.
-Joel
p.s. thanks for bringing the error to our attention, this has been corrected.
Here is a better solution to support both static and dynamic IP addressing at runtime.
in file lwiplib.h:
#define LWIP_DHCP 1 // %GLA was 1 // default is 0
#define LWIP_AUTOIP 0 // %GLA was 1 // default is 0
Make these chances to file lwiplib.c
in function lwIPServiceTimers()
//
// Service the DCHP Coarse Timer.
//
#if LWIP_DHCP
if((g_ui32LocalTimer - g_ui32DHCPCoarseTimer) >= DHCP_COARSE_TIMER_MSECS)
{
g_ui32DHCPCoarseTimer = g_ui32LocalTimer;
// %GLA do only for DHCP
if (g_ui32IPMode == IPADDR_USE_DHCP)
dhcp_coarse_tmr();
}
#endif
//
// Service the DCHP Fine Timer.
//
#if LWIP_DHCP
if((g_ui32LocalTimer - g_ui32DHCPFineTimer) >= DHCP_FINE_TIMER_MSECS)
{
g_ui32DHCPFineTimer = g_ui32LocalTimer;
// %GLA do only for DHCP
if (g_ui32IPMode == IPADDR_USE_DHCP)
dhcp_fine_tmr();
}
#endif
//
// Service the link timer.
//
#if LWIP_AUTOIP || LWIP_DHCP
if((g_ui32LocalTimer - g_ui32LinkTimer) >= LINK_TMR_INTERVAL)
{
g_ui32LinkTimer = g_ui32LocalTimer;
// %GLA do only for DHCP
if (g_ui32IPMode == IPADDR_USE_DHCP)
lwIPLinkDetect();
}
#endif
in function lwIPServiceTimers()
lwIPLocalIPAddrGet(void)
{
#if LWIP_AUTOIP || LWIP_DHCP
// %GLA do only for DHCP
if (g_ui32IPMode == IPADDR_USE_STATIC)
return((uint32_t)g_sNetIF.ip_addr.addr);
if(g_bLinkActive)
{
return((uint32_t)g_sNetIF.ip_addr.addr);
}
else
{
return(0xffffffff);
}
#else
return((uint32_t)g_sNetIF.ip_addr.addr);
#endif
}
I know it's a useless and whiny thing to say, but it seems that the Tiva lwIP port was done hastily. Pretty much every deviation from the original lwipopts.h that I tried breaks the stack (things I tried: enabling ICMP, enabling stats display).
I agree, this TCP/IP stack is trash. Convoluted code, attempting to be everything to everyone it ends up being a mess.
We've decided to write our own.
This older method of bool test works nicely, can be updated for the newer Ethernet clients. So either yes or no DHCP server exists. Watch out for the Active link variable it never seems to change state when the link drops so we made it bool too.
// Initialize LWIP, ask to use DHCP or Static IP. void EthClientInitBLDC(uint32_t ui32SysClock, bool bUseDHCP) { lwIPInit(ui32SysClock, pucMACArray, //0, 0, 0, DEF_IPADDR, DEF_GATEWAY_ADDR, DEF_NET_MASK, (bUseDHCP ? IPADDR_USE_DHCP : IPADDR_USE_STATIC)); }
// // See if there is an active link. // PHY basic mode status REG73:MR1(EPYBMSR) bHaveLink = ROM_EMACPHYRead(EMAC0_BASE, 0, EPHY_BMSR) & EPHY_BMSR_LINKSTAT; // Return without doing anything if the link state hasn't changed. // The bLinkActive=false until swtiched true if(bHaveLink == bLinkActive) { return; } // Save the new link state switch bLinkActive = true;