-
Notifications
You must be signed in to change notification settings - Fork 422
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
Rewrite PicoW LWIP interface, major stability increase #916
Merged
Commits on Oct 14, 2022
-
Disable interrupts while in the memory manager
Fixes random crashes while on the PicoW with WiFi. The system malloc/etc. is not re-entrant, so it is not safe to do any memory (de)allocation from an interrupt. The LWIP stack is configured not to use the memory manager, but it may end up calling callback functions in userspace which may well use new or malloc() (i.e. to manage a new connection info or process a UDP packet like in MDNS). This could cause unpredicatable crashes due to memory corruption at some random time after the interrupt/malloc occurred. Avoid the issue completely by locking interrupts out while in the memory manager. Inter-core will be protected by the malloc_lock already in Newlib. This should not have any effect on absolute performance of the system.
Configuration menu - View commit details
-
Copy full SHA for 4ccc0c4 - Browse repository at this point
Copy the full SHA 4ccc0c4View commit details -
Configuration menu - View commit details
-
Copy full SHA for 20a3a71 - Browse repository at this point
Copy the full SHA 20a3a71View commit details
Commits on Oct 15, 2022
-
Individually wrap all LWIP calls
Brute-force protect all LWIP calls from re-rentrancy
Configuration menu - View commit details
-
Copy full SHA for b5ecb9f - Browse repository at this point
Copy the full SHA b5ecb9fView commit details -
Only stuff WiFi packets if we're not in LWIP
Was causing memory corruption during long, high frequency, multi-client workloads. It is illegal to call netif->input() from an IRQ while in LWIP code. For now, throw them out and let upper layer handle a re-transmit.
Configuration menu - View commit details
-
Copy full SHA for 84f69a8 - Browse repository at this point
Copy the full SHA 84f69a8View commit details -
Configuration menu - View commit details
-
Copy full SHA for 57bdaac - Browse repository at this point
Copy the full SHA 57bdaacView commit details -
Configuration menu - View commit details
-
Copy full SHA for 8785bab - Browse repository at this point
Copy the full SHA 8785babView commit details -
Skip LWIP callbacks during ClientContext teardown
During a ClientContext we set TCP connection arguments to nullptr and then turn off all the callbacks. It is possible for an interrupt to occur between setting the arg nullptr and the clearing of all CBs. The the CB function will get nullptr as (this), causing a crash like: ```` Thread 1 received signal SIGTRAP, Trace/breakpoint trap. isr_hardfault () at /home/earle/Arduino/hardware/pico/rp2040/pico-sdk/src/rp2_common/pico_standard_link/crt0.S:98 98 decl_isr_bkpt isr_hardfault (gdb) where e/Arduino/hardware/pico/rp2040/libraries/WiFi/src/include/ClientContext.h:619 ries/WiFi/src/include/ClientContext.h:612 raries/WiFi/src/include/ClientContext.h:671 ) at /home/earle/Arduino/hardware/pico/rp2040/pico-sdk/lib/lwip/src/core/tcp_in.c:541 ) at /home/earle/Arduino/hardware/pico/rp2040/pico-sdk/lib/lwip/src/core/ipv4/ip4.c:743 rdware/pico/rp2040/pico-sdk/lib/lwip/src/netif/ethernet.c:186 buf=0x20001b7a <cyw43_state+226> "(\315\301") at /home/earle/Arduino/hardware/pico/rp2040/libraries/lwIP_CYW43/src/utility/CYW43shim.cpp:132 2040/pico-sdk/lib/cyw43-driver/src/cyw43_ll.c:1212 cores/rp2040/lwip_wrap.cpp:163 e/ClientContext.h:85 /libraries/WiFi/src/WiFiClient.cpp:81 /libraries/WiFi/src/WiFiClient.cpp:78 rver.cpp:284 ico/rp2040/libraries/WebServer/src/WebServerTemplate.h:86 ```` Avoid by checking and silently ignoring CBs who have a nullptr arg.
Configuration menu - View commit details
-
Copy full SHA for ca9a096 - Browse repository at this point
Copy the full SHA ca9a096View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7a85036 - Browse repository at this point
Copy the full SHA 7a85036View commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.