W5500 cannot open socket in UDP mode for DHCP
Ethernet Chips
No replies yet. Be the first to reply.
Join the discussion.
Ethernet Chips
No replies yet. Be the first to reply.
Join the discussion.
Share projects and connect with makers.
Joined before the site update? first.
New to WIZnet Makers?
We sent a verification link to your address. Open it to activate your account, then log in.
Accounts from this email provider are reviewed by an administrator after verification. Approval usually takes one business day.
Already have an account?
Enter your email address. If it belongs to an account, we'll send a link to set a new password. Members who joined before the site update use this to set their password.
If an account uses that address, we sent a link to set a new password. The link works once and expires in 30 minutes.
Know your password?
Need an account?
RE: W5500 cannot open socket in UDP mode for DHCP
by Eugeny ·
Use correct MAC address (mind bits 1 and 0 for first octet), and set source IP address and subnet mask. In best case gateway IP address too.
RE: W5500 cannot open socket in UDP mode for DHCP
by CPC ·
The first octet of the MAC address is 0x2E which gives b0 = 0, unicast and b1 = 1, locally administered, which I thought should be the way to go. The ioLibrary has a temporary address with first octet of 0x00, which I also tried with same results. Further, the ioLibrary zero the source IP, Gateway and subnet mask addresses. This socket will be used in UDP for DHCP communication so the Source IP and subnet should be zero but, what should the gateway be set to when it is not know and needs to be discovered too?
RE: RE: W5500 cannot open socket in UDP mode for DHCP
by Eugeny ·
Ok, agreed, my advises were nonsense
and it is good to see you know purposes of those bits.
The first suggestion is to check how hardware reset is performed (circuit, timing?), and perform software reset using MR register. Can you explain how these are done in your setup?
By the way, what board is it?
RE: W5500 cannot open socket in UDP mode for DHCP
by CPC ·
The module I use is the ETH WIZ click with the W5500 chip.
The boot sequence is as follow:
1 - write a logic 0 to the RSTn pin of the W5500
2 - do some other boot requirements which took 1200ms
3 - write a logic 1 to the RSTn pin of the W5500 and wait 600ms before doing anyting else.
4 - do a software reset using the MR register and wait another 400ms just to be sure.
5 - now run through all the register setup, initialization of the common registers and some general socket registers
6 - in the main loop, monitor the link bit (0) in the PHYCFGR register for an active link
7 - when an active link is present, start the DHCP routines (initialize, run)
8 - with a DHCP run the first is to open a socket in UDP mode to send the discover packet
This is where the code gets stucked due to the command not being executed.
What are the possibillity that a power surge/spike can occurr in the physical part of the chip when opening a socket that may corrupt some registers? A bit far fetch I geuss but, just want to cover all corners…
RE: RE: W5500 cannot open socket in UDP mode for DHCP
by Eugeny ·
You set MR[7], and then wait until it clears reading MR in loop?
RE: W5500 cannot open socket in UDP mode for DHCP
by CPC ·
That is right, I set bit 7 and wait until it clears followed by another delay of 400ms.
RE: RE: W5500 cannot open socket in UDP mode for DHCP
by Eugeny ·
Thanks. I have just realized that it was you having issues with the power supply and PHY being stuck.
Does the current issue happen to the same module? Do you have another module to try?
Have a look at this. While it states about closing the socket, this may well apply to opening the socket. That’s why it would be the best to try another module and see if it works. it if does - this module is an issue, if it does not, we must dig deeper.
If we are going to troubleshoot this module further, can you do two things please:
RE: W5500 cannot open socket in UDP mode for DHCP
by CPC ·
It is the very same module with the current issue. I did not received my spare module yet, so meanwhile I have to troubleshoot this module further.
I tried all 8 sockets, all of them with the same results.
Attached is the file with the addresses and their values. The first section was dumped before any initialization and the second just after initialization but before socket open function.
The socket open function writes 3 registers namely socket mode register (Sn_MR = 0x02) for UDP mode selection, source port reg (Sn_PORT = 68) for client DHCP and destination port reg (Sn_DPORT = 67) for server DHCP. These values read back as they were written.
W5500 register dump.pdf (34.7 KB)
RE: RE: W5500 cannot open socket in UDP mode for DHCP
by Eugeny ·
Then I would expect at least one socket having its Sn_MR=0x02, and Sn_PORT=0x44. In the dump all the sockets are having nulls. Can you take snapshot just before you set Sn_CR for opening, a second after it happens, and after timeout happens. The timeout formula is listed on the page 39 of the datasheet, and uses 0x7d0 and 0x8. Your chip is having 0xfa0 and 0xa. Not to bother with calculations set them to the value as in datasheet (0x7d0 an 0x08) and wait ~40s … 1m and then make a dump again.
Edit: before you initialization chip has 0x7d0 and 0x08, and I see you modify it. Please do not do it and leave this register as default. And anyway please set first byte of MAC address to 0x2c, at least for the test. And do not change INTLEVEL if it is not critical. And in general leave all the unneeded registers as they are.
RE: W5500 cannot open socket in UDP mode for DHCP
by CPC ·
I found the problem!
There was a mixup in register addressing ending up in reading the wrong block in memory (common registers) rather than any of the sockets, my bad, I appologize!
At least I know the module is functioning. I can open the socket now and run tha dhcp discover routine and received a 616 byte packet back. I rather close this subject/post and open another if issues with the dhcp routines arises. Thanks for the help.