This project guides how to assign DHCP client with STM32 Nucleo F103RB and a W5100 Ethernet shield. When the device is attached to a network it asks for an IP address instead of being statically allocated.
<STM32 Nucleo connected with Ethernet shield>
Following library has been implemented in this project; it depends on a generic POSIX interface with no direct dependence to the hardware below.
Additionally, a wrapper for W5100 can be used to automatically configure the IP address into the Ethernet interface when the DHCP binds the device to an address.
- a Nucleo F103RB + W5100 Ethernet shield
- GCC ARM Embedded toolchain
- OpenOCD to write the program into STM32 embedded flash
- a router that offers DHCP services
How to Guide
1. Fire Wireshark on a computer that is connected to the same router, and by sniffing the packets you can look at the interactions between the Nucleo and the router, shown in the figure below.
2. At first there’s a Discover-Offer transaction between client and server that indicates an available IP address.
3. Then a Request-Ack transaction will bind the address to the client. The transactions are also used to retrieve the gateway, subnet and DNS servers that the client can configure.
<Wireshark capture of DHCP address allocation>
4. Call up the library again when the lease is expiring to be renewed.
Then you can:
- clone GitHub repository,
- change directory to `
- run `
make flash` to compile and upload program,
- wait for the Ethernet shield LEDs to indicate that the link is up,
- connect a terminal to the Nucleo serial port with baud rate 57600, for example with `
minicom -b 57600 -D /dev/ttyACM0`,
- press any key in the terminal to start DHCP address allocation.