w5500 icon indicating copy to clipboard operation
w5500 copied to clipboard

DHCP Support

Open jonahbron opened this issue 6 years ago • 10 comments

Need to add DHCP support so that an IP address can be dynamically acquired.

jonahbron avatar Aug 02 '19 15:08 jonahbron

One needs to send and receive two UDP packages, track the intermediate state and detect the when it needs renewal: https://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol

Might be related for duration tracking: rust-embedded/embedded-hal#59

That... might help us https://github.com/Wiznet/W5500_EVB

kellerkindt avatar Aug 02 '19 17:08 kellerkindt

Good, this initial direction will help greatly, thank you.

jonahbron avatar Aug 02 '19 22:08 jonahbron

One other approach is to actually just use the W5500 in MACRAW mode and put smoltcp on top of it. In this way, you get all the goodness of smoltcp (i.e. DHCP, DNS, mDNS, etc.) without having to duplicate the implementation in this crate. Check out https://github.com/quartiq/booster/blob/main/src/hardware/external_mac.rs for a reference implementation on how to do this. It's on my TODO list to pull the external-mac operation into it's own crate as well to enable this.

ryan-summers avatar Mar 30 '23 11:03 ryan-summers

Has anyone got W5500 working with DHCP? I've got TCP working when specifying an ipaddress, but I have no idea how to get DHCP added when initializing the device.

rvdende avatar May 29 '23 15:05 rvdende

As I mentioned above, you can get DHCP working by using Smoltcp just fine, and I do this in the booster crate linked above :).

In it's current state, this crate does not support DHCP without using smoltcp.

ryan-summers avatar Jun 05 '23 10:06 ryan-summers

I tried with smoltcp-nal, not smoltcp itself. Sorry I'm a bit new to rust so its a bit daunting to init the devices. I was hoping a minimal example to get DHCP. At this stage I'm stuck having to hardcode the ip :( Heres my attempt:

So the main branch is working, the smoltcp branch is failing. this is the diff: https://github.com/netrondev/iotrs_stm32f4/compare/main...smoltcp

rvdende avatar Jun 05 '23 13:06 rvdende

@rvdende Sorry, I don't have a ton of time on my hands, so it's hard for me to review your code and tell you exactly what's wrong. If you want to review a working example used in production, check out Booster's initialization routines, which use the smoltcp-nal, smoltcp. and the W5500: https://github.com/quartiq/booster/blob/main/src/hardware/setup.rs#L283-L381 https://github.com/quartiq/booster/blob/main/src/hardware/net_interface.rs

ryan-summers avatar Jun 13 '23 12:06 ryan-summers

this is my minimal example that I take from the "booster" repo. I hope it can help you

cnmozzie avatar Jul 28 '23 09:07 cnmozzie

this is my minimal example that I take from the "booster" repo. I hope it can help you

Thank you @cnmozzie !! I'm going to try this as soon as possible.

rvdende avatar Jul 28 '23 11:07 rvdende

@cnmozzie thanks again for the example code, I got it working on my stm32F407 :)

rvdende avatar Aug 28 '23 06:08 rvdende