0

With ESP8266 there is a requirement to not block the CPU execution for longer than few ms and then yield to networking stack and internal functions that are executed after each iteration of loop(). If you block CPU for too long, network will misbehave. If you block it for longer than ~3 seconds SWDT resets the MCU.

Now with ESP32 you have 2 CPU cores and RTOS running in the background that has full multithreading support. Is the Arduino framework for ESP32 taking advantage of this? Is the whole "user program" running as separate task besides the network and system stack? Would blocking the CPU in main loop cause similar problems as ESP8266?

From xPortGetCoreID() we can see that both setup and loop run always from core 1, not core 0, so I assume that user program is by default pinned to core 1 and network stack runs on core 0? Can someone confirm that?

This is just hypothetical question, I am just curious about internal ESP32 architecture and Arduino implementation, not making anything specific.

3
  • In the Arduino IDE you can select on which core the user program shall run, but yes, the default is 1. Commented Sep 16, 2022 at 11:07
  • @PMF ok, but does that mean the network stack is running separately in core 0, or is it done in same "everything in 1 thread" way as in ESP8266? Commented Sep 16, 2022 at 14:24
  • As far as I know it runs on its own thread (the ESP32 uses a FreeRTOS kernel in the back). I have a project where I run quite expensive operations on the "user" core while a connection is maintained automatically. It should be easy to test this, shouldn't it? Commented Sep 16, 2022 at 14:56

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.