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
cpu/esp32: lwIP netdev #11946
cpu/esp32: lwIP netdev #11946
Conversation
a2ff21a
to
bfa160e
Compare
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.
Code-wise it looks good, however, I don't have the hardware to test. @MichelRottleuthner can you have a look?
Tried it here and compared to master it works better - but something seems to be broken.
I can do the following:
On the PC I do the following:
With wireshark I can see that there are a lot of (5000) TCP Dup ACK and Spurious Retransmissions before socat reports the error. UDP seems to work ok. (I used socat instead of netcat didn't work at all for me, but that could be because of the many different netcat versions out there) |
This seems to be rather an lwIP problem than a problem with the device integration. However if you see the packets that means the device integration works, no? |
No surprise there ^^ device support is always better than no device support ;-) |
@miri64 I agree. Just wanted to point out what my results were. And I prefer to say if something was different to it just works(TM). Also I lack the expertise on our lwip integration to judge if this actually comes from lwip or the device integration^^ |
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.
ACK
Please squash @gschorcht |
I can observe these duplicate ACKs too. Strange, the ACK repeated a thousand times is not the ACK for the data packet, but the last ACK from the three-way handshake that originated from the initiating RIOT node. |
Hm, I tried it with |
6346b88
to
bfa160e
Compare
@miri64 @MichelRottleuthner After investigating the problem of duplicate ACKs for two days, I finally found the cause. In fact, the problem was the I fixed it with commit 7941149. Now, lwIP is working with If you prefer, I could provide the fix within a separate PR and could rebase this PR to it. BTW, when I was investigating the problem, I realized that there are still other problems in |
@MichelRottleuthner Thank you for figuring out the problem with the duplicate ACKs. It was a very useful. May I ask you to test it again with the fix? |
I tested again. No more duplicate acks and now a graceful disconnect after sending data and executing
I don't mind but I'd prefer to have the fix in a separate commit so it is not completely mixed with the lwip related netdev stuff. |
cd93c1c
to
32416e6
Compare
aeb5db1
to
92369da
Compare
@miri64 After fixing and cleaning up |
cpu/esp32/Makefile.include
Outdated
@@ -122,6 +122,10 @@ ifeq ($(QEMU), 1) | |||
CFLAGS += -DQEMU | |||
endif | |||
|
|||
ifneq (,$(filter lwip,$(USEMODULE))) | |||
CFLAGS += -DTCPIP_THREAD_PRIO=2 |
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.
What is this about?
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.
If it is required, then this shouldn't be hidden in the platform code.
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.
It is platform specific. By default the lwIP's tcpip
thread has a priority of 1. However, in ESP32, the thread that handles hardware interrupts from the WiFi interface has also a priority of 1. From my point of view, the hardware driver should have a higher priority than the TCP/IP thread to be sure that hardware is always handled in time.
I figured it out and changed it when I was investigating the problem with the duplicate ACKs. This change was already covered by the test by @MichelRottleuthner.
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.
I have no doubts that it works, I just fear that it might cause problems later on, with people not expecting that something related to an external package is configured within a cpu
Makefile. How about flipping it around and putting it in pkg/lwip/Makefile.include
? Including some explanation why it is required.
cpu/esp32/Makefile.include
Outdated
@@ -122,6 +122,10 @@ ifeq ($(QEMU), 1) | |||
CFLAGS += -DQEMU | |||
endif | |||
|
|||
ifneq (,$(filter lwip,$(USEMODULE))) | |||
CFLAGS += -DTCPIP_THREAD_PRIO=2 |
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.
I have no doubts that it works, I just fear that it might cause problems later on, with people not expecting that something related to an external package is configured within a cpu
Makefile. How about flipping it around and putting it in pkg/lwip/Makefile.include
? Including some explanation why it is required.
Do you think it is better to place ESP32 specific make code in |
This is not unheard of: Lines 32 to 34 in 653c23e
Both approaches have an ugly side for sure, but I feel far more comfortable if we add a platform-specific config to an external package's configuration than configuring a platform for an external package. |
Maybe, a better place could be here RIOT/pkg/lwip/include/lwipopts.h Line 145 in 653c23e where the overridden default definitions reside in lwIP
+#ifdef CPU_ESP32
+#define TCPIP_THREAD_PRIO 2
+#endif
|
Right. With |
In either case, don't forget documenting the "why" ;-) |
The option value length of Ethernet addresses can be more than 6 byte in lwIP. Therefore, the max_len parameter is check to be greater than or equal to ETHERNET_ADDR_LEN.
To be able to access the single esp_wifi network device from lwIP adaptation layer, static keyword was removed from esp_wifi_dev variable.
The changes allow to use an esp_wifi network device of ESP32 with lwIP.
5767797
to
d27dfb3
Compare
To avoid priority conflicts with the WiFi hardware driver thread which has priority of 1, the default thread priority of lwIP's TCP/IP thread is decreased to 2.
d27dfb3
to
f5af8ac
Compare
Squashed. Unfortunately, Travis failed due to connection errors to github.com. How can we trigger Travis restart the static tests? |
Travis sems fine so did you restart yourself? You can do that by logging in with your GitHub account via OAuth. Maintainership should grant you permission to hit the restart button then. |
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.
ACK. Code looks fine and was tested by @MichelRottleuthner.
@miri64 @MichelRottleuthner Thanks for reviewing and testing it. |
Contribution description
The changes in this PR allow to use an
esp_wifi
network device of ESP32 with lwIP.Testing procedure
Compile
tests/lwip
and flash an ESP32 node with:Start
netcat
on a Linux machine in same LAN:Use a terminal to connect to the ESP32 node and use the following commands
where the address should be replaced with the address of your Linux machine.
Issues/PRs references
Fixes #11910
Depends on PR #11964Depends on PR #11967