WIZnet Developer Forum

W5500 DHCP client doesn't accept DHCP Offer

Hi all,

I have been struggeling with this all day and I can not figure it out what the problem is.
I made a application with a STM32L431CC and a W5500. Using the ioLibrary Drivers I’m trying to assign a IP address to my device.

From a cold boot of the system the following (simplefied version) will happen:

w5500_init(); // Initialize the w5500 with the SPI settings and a MAC address.
w5500_version(); // Check the version (check if the SPI is communicating correctly)
w5500_init_dhcp(); // Init the DHCP and set the callbacks (Socket is 0 and buffersize is 2048 byte)

while(1) {
  DHCP_run()
}

The system will boot up and produce the following debug output:

w5500_init() called!
Registering W5500 callbacks...
Calling wizchip_init()...
Version is: OK
DHCP enabled
Init DHCP
Registering DHCP callbacks...
> Send DHCP_DISCOVER
<<timeout>> state : STATE_DHCP_DISCOVER 
> Send DHCP_DISCOVER
...

When watching the trafic in Wireshark I see the following:

src dst Protocol Size Comment
0.0.0.0 255.255.255.255 DHCP 590 DHCP Discover - Transaction ID 0x12345679
192.168.2.1 255.255.255.255 DHCP 342 DHCP Offer - Transaction ID 0x12345679
0.0.0.0 255.255.255.255 DHCP 590 DHCP Discover - Transaction ID 0x12345679
192.168.2.1 255.255.255.255 DHCP 342 DHCP Offer - Transaction ID 0x12345679

And this in a continous loop.

Strange thing is; when I’m resetting the microcontroller (and thus re-initializing the W5500 without power loss) It will receive a IP no problem. But resetting the microcontroller everytime from a cold boot is a no go.

Does anyone have any idea what the problem could be?

Thank you in advance!

I am wondering if you are using the most recent ioLibrary.
IoLibrary has been updated by finding a bug similar to yours.

The parseDHCPMSG() function should contain the following.

Hi Becky,

I’m currently using the most recent ioLibrary. As I was starting to write you about this the DHCP client started to do it’s job without changing the software. I think you have a positive impact on my software.

For now, thank you!

Copyright © 2017 WIZnet Co., Ltd. All Rights Reserved.