DHCP client on STM32 Nucleo and W5100

details

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.

nucleo_w5100

<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.

Parts

  • 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.

Screenshot_2015-12-07_20-43-54

<Wireshark capture of DHCP address allocation>

4. Call up the library again when the lease is expiring to be renewed.

5. To manage time, implementation of POSIX time functions, that use Cortex-M SysTick interrupt to count the passage of time.

Then you can:

  1. clone  GitHub repository,
  2. change directory to `tests/dhcp_allocate`,
  3. run `make flash` to compile and upload program,
  4. wait for the Ethernet shield LEDs to indicate that the link is up,
  5. connect a terminal to the Nucleo serial port with baud rate 57600, for example with `minicom -b 57600 -D /dev/ttyACM0`,
  6. press any key in the terminal to start DHCP address allocation.

Source : https://balau82.wordpress.com/2015/12/07/dhcp-client-on-stm32-nucleo-and-w5100/#comments

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.

nucleo_w5100

<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.

Parts

  • 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.

Screenshot_2015-12-07_20-43-54

<Wireshark capture of DHCP address allocation>

4. Call up the library again when the lease is expiring to be renewed.

5. To manage time, implementation of POSIX time functions, that use Cortex-M SysTick interrupt to count the passage of time.

Then you can:

  1. clone  GitHub repository,
  2. change directory to `tests/dhcp_allocate`,
  3. run `make flash` to compile and upload program,
  4. wait for the Ethernet shield LEDs to indicate that the link is up,
  5. connect a terminal to the Nucleo serial port with baud rate 57600, for example with `minicom -b 57600 -D /dev/ttyACM0`,
  6. press any key in the terminal to start DHCP address allocation.

Source : https://balau82.wordpress.com/2015/12/07/dhcp-client-on-stm32-nucleo-and-w5100/#comments

COMMENTS

Please Login to comment
  Subscribe  
Notify of