-
-
Notifications
You must be signed in to change notification settings - Fork 346
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
esp32 network code runs in different task #2912
Comments
Option (4) is a lot of work and would involve removing the entire After digging about in the code I can't think of a way to implement options (1) or (2). That leaves option (3). I tried getting rid of the Sming task and hooking into the However, lwip conveniently provides the This means all Sming code (in a non-interrupt context) runs in the tiT task, and the Sming task remains only to service the IDF task queue and watchdog timer. Stack sizes will require adjusting: tiT is currently 8192, Sming is 16384. My current fix still has messages posted to the Sming event queue, which are then dispatched into the tcpip event queue. This two-step mechanism obviously makes it less efficient but it's necessary as other IDF components such as WiFi require the queue, and the messages must be serialised correctly along with everything else. Non-network applications ( |
This PR addresses the issue raised in #2912 by pushing events into the tcpip thread for handling. Network applications therefore 'live' in the tcpip task and the **Sming** task is created only for non-networked applications. Sming uses a separate event callback queue instead of the IDF one. - Use custom queue for sming messaging - Serialise idf messages to sming queue in networking code - Use idle task watchdogs instead of custom one - Push task callbacks to tcpip thread in network builds - Fix stack sizes. Network builds just use default size for event task stack - Use heap for initial partition table load. Not enough room on event task stack for this. - Add a semaphore to `smg_uart_write` so debug output doesn't get garbled between tasks (e.g. wifi).
Closing due #2913 being merged in |
I'm getting unpredictable hangs and crashes with an esp32-s2 project which communicates with an SPI touch display.
The details aren't relevant as this issue applies to any resource which isn't thread-aware, so that's pretty much everything in the framework.
The problem is because Sming code is split across two tasks, not just one.
Referring to PR #2371, all code runs in the Sming task except for stuff coming in over the network, which runs in the tiT (tcpip) task.
The FreeRTOS scheduler runs both these tasks in a round-robin fashion.
If an SPI request is executing inside the tiT task (as a result of, say, an incoming websocket command request) it can get pre-empted by the higher-priority Sming task, resulting in a crash/hang.
The whole point of Sming is that it avoids these multitasking issues,
but as previously discussed the IDF black-boxes the WiFi stack which itself depends on a FreeRTOS environment.Fortunately the lwip/tcpip stuff is accessible forhackinginspection and revision.Possible solutions include:
I modified the debug output to include the current task handle. In combination with
TaskStat
this shows the issue.The text was updated successfully, but these errors were encountered: