Wifi in tasks -- What's needed in a PR? #3013
Replies: 4 comments 8 replies
-
It's a bit more work than that, unfortunately. LWIP doesn't do multithreading and really doesn't do SMP. We've got both here, so it's very important to be strict about keeping things proper. The way LWIP crashes is you get a failure well after memory is corrupted so debugging is a real PITA. There's already pretty good locking around the LWIP calls. It's automagically done by GCC and lwip_wrap.cpp. The issues with FreeRTOS come in with interrupts and periodic tasks (same thing). Two big issues come into play w/FreeRTOS and LWIP (and the WiFi driver):
The suggested architecture for using LWIP with FreeRTOS from the LWIP folks is to implement a single task that does all LWIP calls. Set up a work Queue and let it process calls as they become available. This way only 1 task ever calls LWIP and it's effectively the nice and single core, single thread it wants. I did some hacking on this (we can use the wrappers to replace calls with a Now, any Ethernet device can raise an IRQ when an Ethernet packet is ready for processing. These are processed, obviously, in an IRQ context (see wall of text above). But they'd all need to be broken into multiple stages for full FreeRTOS integration. You still have the IRQ callback, but all it does is disable the IRQ (but not clear it!) and Getting both these would remove 1. and 2. above since the only thing in IRQ-time is a small "wake up a task" shim. I did something similar in the ESP32 BackgroundAudio-L271 since we couldn't actually decode in the IRQ without killing the WiFi. Latency is worse, but if you're using FreeRTOS latency is not generally something you care about. Speaking of WiFi, the CYW43 WiFi driver in the SDK would also need to be changed for this because the bare metal version handles the IRQs/PIO-SPI/etc. itself. The 3 other WiFi and 6 other Ethernet drivers here in the core are fully self-contained and could be modified w/o opening up libpico. |
Beta Was this translation helpful? Give feedback.
-
I am digging into this -- its just a lot because of the surface area |
Beta Was this translation helpful? Give feedback.
-
Just to verify, you're using platform IO as the IDE?
…On Sat, Jun 28, 2025, 1:00 PM Earle F. Philhower, III < ***@***.***> wrote:
Good luck! You might want to start with one of the wired Ethernet
interfaces (W5100, etc.) which have every line of code under our own
control in the core. They have the same issue as the CYW43 WiFi related to
LWIP/etc. but without the SDK internals.
—
Reply to this email directly, view it on GitHub
<#3013 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABAZH3STDIY77OO65EENVL3F3J27AVCNFSM6AAAAACABKNTDSVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTGNRQGYYTEMY>
.
You are receiving this because you authored the thread.Message ID:
<earlephilhower/arduino-pico/repo-discussions/3013/comments/13606123@
github.com>
|
Beta Was this translation helpful? Give feedback.
-
Now I need to go digging. I can't stand platform io's build system
screwing with mu vscode configuration.
…On Sat, Jun 28, 2025, 1:11 PM Earle F. Philhower, III < ***@***.***> wrote:
Is VIM an IDE? 😆 Plus GDB from the command line when things go really
pear shaped.
I didn't normally run p.io, just a mix of adrduino-cli and IDEs 1.8 and
2.x. The libs are cmake based since that's what the SDK requires.
That shouldn't really affect any coding, though.
—
Reply to this email directly, view it on GitHub
<#3013 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABAZH2TV3EEFUJ3LKSMW4D3F3LF5AVCNFSM6AAAAACABKNTDSVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTGNRQGYYTOMY>
.
You are receiving this because you authored the thread.Message ID:
<earlephilhower/arduino-pico/repo-discussions/3013/comments/13606173@
github.com>
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
The documentation states
FreeRTOS is supported only on core 0 and from within setup and loop, not tasks, due to the requirement for a very different LWIP implementation. PRs always appreciated!
Is this about needing locks around the underlying lwip calls but only when the calls are not coming from a lwip callback?
Beta Was this translation helpful? Give feedback.
All reactions