Richard Tenney

Adding DHCP to ColdFire_Lite demo

Discussion created by Richard Tenney on May 27, 2006
Latest reply on Jul 8, 2006 by Eric Gregori
At the recent ColdFire Ethernet Seminar, a ColdFire_Lite program that provided a web server was used as a demo of the M52233DEMO board. It had a fixed IP address of However, there are bits and pieces in the code that almost allow the program to use DHCP to obtain its IP address. Just a few changes are necessary.

The ones below have worked for me, but I have not stress tested them and don't know, for example, what would happen if the DHCP server didn't serve up an IP address.

I'd appreciate any feedback.

In main.c, replace the code used to set the address to to read as follows:

#ifdef DHCP_CLIENT // 24 May 06 -- rlt
// zero out info to be provided by DHCP
netstatic[0].n_ipaddr = (0x00000000);
netstatic[0].n_defgw = (0x00000000);
netstatic[0].snmask = (0x00000000);

/* hardcode FEC IP address for now. We set it in netstatic, and
* Ip startup code will initialize net[] from it.
#elif 1 // EMG
// added gateway as to allow pinging beyond LAN
netstatic[0].n_ipaddr = (0xC0A80163);
netstatic[0].n_defgw = (0xC0A80101); // 24 May 06 -- rlt
netstatic[0].snmask = (0xffffff00);
#else //jpw
netstatic[0].n_ipaddr = (0xC0A80203);
netstatic[0].n_defgw = (0xC0A80201);
netstatic[0].snmask = (0xffffff00);
#endif // DHCP_CLIENT

In dhcsetup.c, in the dhc_setup() function, just before the test

if (!(nets[iface]->n_flags & NF_DHCPC))


nets[iface]->n_flags |= NF_DHCPC ; /* use DHCP Client on each iface */ // rlt 26 May 06

To make this work, you have to uncomment the definition of DHCP_CLIENT in ipport.h to read

#define DHCP_CLIENT 1 /* include DHCP client code */

To restore the project to its original (except for my added gateway) just comment out the #define of DHCP_CLIENT. If you don't want the gateway, change 0xC0A80101 to 0x00000000.

- Richard

P.S. Sorry about the lack of indenting in the code, but that's the way the forum's software formats it.