-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add IPv4 support for LWIP-stm32 #12903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
dc30c58
to
488e259
Compare
fc8d453
to
60e541a
Compare
Thanks for putting the style fix in a separate commit! Your commit messages should however make clear that you are modifying lwIP here. Have a look at our contributing guidelines for how our best practices regarding that are. Once that is done and I can get some test results (don't have the hardware to test myself, but maybe @toonst can do so?), I think we can go ahead merging this.
60e541a
to
2e2352a
Compare
I asked @kaspar030 to test this as he as both an stm32 with on-board Ethernet and a self-administered router in his office. |
@kaspar030 you can activate the DHCP client by using the |
I'm just wondering - is this something that should be only done for |
@benpicco Good point! However, this is done in a separate preprocessor conditional for all supported devices, and thus this follows the same design choice. You could argue that we could move the netif_add of all interfaces outside of their conditionals and simply always run the netif_add, because indeed... the called functions are identical. But I think doing so would cause 3 other effects:
So to be honest, I think the design choice wasn't that bad. |
How about adding it for |
The design choice was based on my laziness, so I wouldn't say it is good either. If you want to take care of it go ahead. Just know that @jia200x's netif rework will include some generalized device initialization, so your rework might not stick for long. |
@benpicco So you mean like this? #if esp: It's entirely possible, but I'm not sure if I agree that this will be an improvement. It would remove a clear seperation between the different hardware families. @miri64 there's always room for improvement ofcourse, but at the moment there's a clear seperation between all hardware devices (whether that's a good thing or not leaves room is still open for debate, but not all that relevant here), breaking this clear seperation for only two of all the devices will create confusion and is not really an improvement imo. |
@wosym I thought more of adding the same chunk of code to the esp_wifi block so when someone comes around to refactor this they note the similarity and see a general solution is needed 😉 No need to do something clever. |
@benpicco Oooh, I entirely misunderstood you! I thought you meant to move the esp and stm code out of their preprocessor-blocks :) |
2e2352a
to
f37ed8a
Compare
I work for a company that sells devices to end users, so we have no control over their networking infrastructure. Like it or not, we have to support IPv4. So, I agree that lwip IPv4 support for other devices is worthwhile. I (and a number of people) have an esp_wifi device, and would be happy to test. |
@kb2ma Go ahead! The esp-code is already pushed! :) |
I tried to run tests/lwip_sock_udp. I was unable to compile because arch_esp8266 is blacklisted in Not one to let a little thing like a blacklist get in the way, I found two issues: The test Makefile was setting a CFLAG for The test Makefile also set a macro value However, when running the test, I see the failure below. Maybe @gschorcht or @miri64 has some insight. Perhaps it's not feasible to use with sock. Assuming there is not some serious incompatibility with esp8266, @wosym I see you have used
|
@kb2ma Yes, I also used lwip in that PR, but because it's an entirely different issue that is being fixed in that patch, I didn't apply any of the unmerged IPv4 changes there yet. It's entirely tested on IPv6. However, I did use LWIP IPv4 in the code of an unrelated project for a customer. All I had to do is add the following modules: You might also want to enable DHCP (unless you want to assign the IP's static, which is also possible): |
@benpicco FYI, We have start to create a minimal IPv4 stack using Riot GNRC. The branch is not in an active development currently but we will finish it as soon as possible. We have ARP requests support, IPv4 (send broadcast, send unicast, and receive demux). We have test it on an ESP32 board with UDP client & server tests packages. We need to finish the TCP part (seem broken in RIOT when we try it). The branch is not very clean, we rush that on few days. |
f37ed8a
to
53d2544
Compare
Reverted to the original state by removing the ESP-code, and added a comment after the else preprocessor directive. |
@wosym Why did you remove the ESP-code? |
53d2544
to
eda0099
Compare
@gschorcht: Whoops, looks like I misinterpreted the previous comments. I added it again. |
@wosym Thanks. |
8dd1ae7
to
a3145a0
Compare
ACK from my side. Tested on ESP32. What should we do with STM32 test? I don't have the hardware but I would guess that it also works on STM32. It's a very small change that has been proven with ESP32 so that a successful compilation for STM32 should be suffiecient. |
What STM32 test do you mean? Test if IPv4 works? I did not however add it to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How did you test this change in |
@wosym Do you have a version of |
I'm currently working on an implementation of the DoIP protocol for a customer. I used it on IPv6 first, but needed IPv4 support as well. after applying the changes of this PR, and changing the used modules in the DoIP example (and the used ip-addresses) everything worked like a charm. Wireshark confirmed this.
Not at the moment, no. But I can alter the existing code with some preprocessor conditionals to allow toggling between IPv4 and IPv6 if you want. |
I had planned to create a PR because it makes sense to have |
Nope, currently don't have any code for that written. Go ahead :) |
Excellent! Please consider posting this work as a WIP PR. For fundamental work like this, it's important that it fits well in the stack. It might save everyone some time to get an early view of the implementation approach. |
Did not read the whole discussion, but I'm not surprised that a test does not run 100% as intended, if you add modules it doesn't need (the |
That's what I thought too. The only test that has to work with real netif is probably |
yepp |
@wosym How can I test this? When I ran the test (for a nucleo-f207zg) under
|
@JannesVolkens It's been a while since I used this, so my memory might be clouded. But is it possible that you need to set up a DHCP server in order for it to work? This PR doesn't really change |
Contribution description
netif_add() for ipv4 uses an entirely different function prototype, and thus is not compatible with the lwip_ipv6 modules. Added a preprocessor conditional to pass the correct (number of) arguments to the netif_add() function, depending on what lwip module is loaded.