How Tasks are distributed between Cores of ESP32S

An online source says that the Arduino Sketch is executed by Core1 (the Secondary Core) of 30-pin ESP32S Microcontroller. Another online source has said that GPIO2 is connected with Core 0 (the Primary Core) and GPIO23 is connected with Core 1.

To verify the above propositions, I have designed the following Arduino sketch containing codes to alternately blink two LEDs which are connected with GPIO2 (LED2 belongs to Core 0) and GPIO23 (LED23 belongs to Core 1). I have thought that the sketch will not be compiled or LED2 will not be blinking. The sketch is uploaded and blinking the both LEDs alternately at my surprise!

Would appreciate if someone explains the mechanism of how Core 1 does activate LED2 that belongs to Core 0.

void setup()
{
  pinMode(2, OUTPUT);
  pinMode(23, OUTPUT);
}

void loop()
{
  digitalWrite(2, HIGH);
  digitalWrite(23, LOW);
  delay(1000);
  //--------------
  digitalWrite(2, LOW);
  digitalWrite(23, HIGH);
  delay(1000);
}

It's a matter of the underlying firmware (FreeRTOS?) how resources are managed.

If you want to find out more you can write a sketch that toggles the different pins as fast as possible and measure the pulse width. If a pin is really under control of another core then a considerable delay should be noted.

where did you read this? seems weird to me. from a chip design perspective, GPIO are peripherals and are separated from the the Cores. I'm unaware that the Arduino initialisation code would affect this specifically

They have Restrictions for certain GPIOs and RTC_GPIOs as documented in the technical docs (Input only pins, allocated for communication with in-package flash/PSRAM and NOT recommended for other uses or Strapping pins / JTAG interface / UART interface.

(GPIO2 is one such designated strapping pin)

Datasheet

From ChatGPT:

GPIO2 drives the onboard Blue LED.

If you are using the Espressif ESP32 core for Arduino, then everything runs on Core 0, whether you want it to or not.

GPIOs are NOT assigned to Cores.

Fairy tales are not topic in this forum.

1 Like

Then what does this pin mapping (Fig-1: among 48-pin LX6 Processor, 38-pin RF-Shielded Module, and 30-pin ESP32S) say?


Figure-1:

Nonsense:

And you can wrote code to run on either core: xTaskCreatePinnedToCore

You mean ChatGPT is not a reliable source - it delivers fake information? Should we always consult the bureaucratic data sheets?

I had a very strong dislike for the ChatGPT at the very beginning; now, getting interested into it as it delivers some preliminary information in a simple write-up style which could be checked against the tested tutorials of the net and manufacturer's data sheets.

Moreover, ChatGPT does not fabricate information from its own; it searches at a tremendous speed all the available data bases in the net to collect information that matches with the request of a client/questioner.

Right, I forgot but it only runs on one core only.

Please highlight where it says that GPIO23 is connected to Core 1

Here:

Well, first there is no such thing as ESP32S (S2 or S3 yes) to my knowledge.

did you challenge chatGPT on this ? I did and got

I apologize for any confusion. To clarify, there is no specific ESP32S variant recognized by Espressif Systems, the manufacturer of the ESP32 microcontroller. The ESP32 module comes in different versions and variations, but "ESP32S" is not a standardized or official term used to describe any specific ESP32 module.

It's possible that "ESP32S" refers to a custom or clone module developed by a third-party manufacturer, which may have its own pinout or features specific to that module. Without more specific information about the particular ESP32S module you are referring to, it's challenging to provide accurate details about its pin distribution or functionality

then I challenged it on the pins assignment and got

I apologize if the previous response was not accurate or did not meet your expectations. As an AI language model, I strive to provide accurate information, but I can occasionally make mistakes or misunderstand the context. I'll provide a revised and accurate answer for you.

The ESP32 microcontroller has a flexible GPIO (General Purpose Input/Output) architecture, allowing you to configure the IO lines to different cores based on your requirements. In general, both Core 0 and Core 1 can access and control all the GPIO pins on the ESP32. The assignment of IO lines to a specific core is programmatically determined by your application code.

Here is a corrected response regarding the GPIO pins on the ESP32:

The ESP32 microcontroller typically has multiple GPIO pins available, and you can configure them to be controlled by either Core 0 or Core 1. The specific mapping of GPIO pins to cores depends on your programming setup.

When using the ESP-IDF (Espressif IoT Development Framework), which is the official development framework for ESP32, you can assign GPIO pins to a specific core using functions like xTaskCreatePinnedToCore() or gpio_install_isr_service(), specifying the target core.

Please note that the GPIO mapping and assignment can vary based on the development framework or libraries you are using. It's always recommended to consult the documentation specific to your development environment for accurate information on how to configure and assign GPIO pins to the desired core on the ESP32 microcontroller.

then I told chatGPT that

xTaskCreatePinnedToCore does not assign a pin to a core

and he answered

You're correct, and I apologize for the confusion in my previous response. I apologize for the mistake.

The xTaskCreatePinnedToCore() function in the ESP-IDF framework is used to create a FreeRTOS task and assign it to a specific core, not to assign a pin to a core. It is not directly related to pin assignment.

To clarify, the GPIO (General Purpose Input/Output) pins on the ESP32 microcontroller are not tied to specific cores. Both Core 0 and Core 1 have access to and can control all the GPIO pins available on the ESP32.

The assignment of tasks and pin configurations are independent of each other. The ESP-IDF framework allows you to create tasks and assign them to a specific core using xTaskCreatePinnedToCore(), but it does not directly relate to pin assignment.

To assign specific pin functions or configure GPIO pins for input/output, you can use functions such as gpio_set_direction(), gpio_set_level(), or other GPIO-related functions provided by the ESP-IDF framework. These functions allow you to configure and control the behavior of individual GPIO pins on the ESP32.

Once again, I apologize for the confusion caused by my previous response, and I appreciate your understanding.

➜ long story short, don't use ChatGPT if you want a trusted answer. Read the datasheet yourself, don't rely on a statistical model that is right only 75% of the time and take whatever you get as the truth.

2 Likes

This is the back side of my ESP32S Board, which shows ESP32S in laser engraving:
ESP32SbackPic

well find it's datasheet like one of those then:

they also have PICO-D4, C5, C6, P4, ... but not just S to my knowledge

In Fig-1 (I have created it consulting Espressif's documents) of post #7, GPIO23 of the LX6 Processor is connected with D23 of 30-pin ESP32S Module.

Now, the question is: How do I know -- which Core's (Core 0 or Core 1) GPIO23 is connected with D23-pin of the ESP32S Board? I tried to get the answer from Espressif/Google without luck and then I asked the ChatGPT.

not really. The training might have included sources from internet, but the answers are calculated --> Large language model - Wikipedia

2 Likes

It can be accessed by either core.
It's not hardwired to a specific core.

I went with the marking ESP-WROOM-32 on the RF-Shield and had got the following pin diagram (Fig-1) from Espressif documents and then I created the pin mapping diagram (Fig-2).

When I have come to know that there are two identical LX6 Processors inside the ESP32S Module, then I have fallen down into trouble as to the assignment of ESP32S's 30-pin with Core 0/Core 1.


Figure-1:


Figure-2:

as shown above, chatGPT probably inferred from the function name xTaskCreatePinnedToCore() that it has to do with a pin and only when caught it realised that it was the task that was pinned to a core.

➜ guess work

Note that The picture states ESP32 not ESP32S.

which 23 are your referring to?

as documented above

the GPIO (General Purpose Input/Output) pins on the ESP32 microcontroller are not tied to specific cores. Both Core 0 and Core 1 have access to and can control all the GPIO pins available on the ESP32