Page 1 of 1

ESP32 dualcore example without using FreeRTOS

Posted: Thu Apr 25, 2024 2:50 pm
by micronpn
Hello guys,
I am searching documentation and at least one example to implement a test application to execute a C function on core 0 and another function on core 1 without using FreeRTOS and Arduino framework. My intention is to test a simple solution to execute 2 functions on the different cores and possibly sharing some variables in a producer/consumer fashion.

Re: ESP32 dualcore example without using FreeRTOS

Posted: Fri Apr 26, 2024 5:08 am
by ESP_Sprite
micronpn wrote:
Thu Apr 25, 2024 2:50 pm
without using FreeRTOS and Arduino framework.
Doubt that exists. FreeRTOS is the thing already running as a RTOS on ESP-IDF (because without a RTOS you can't really run BT/WiFi), so why not use that?

Re: ESP32 dualcore example without using FreeRTOS

Posted: Fri Apr 26, 2024 2:28 pm
by micronpn
Basically because I want to know how it works as bare metal implementation and eventually to use a different RTOS. There are some RTOS more devoted to IoT applications for instance.

Re: ESP32 dualcore example without using FreeRTOS

Posted: Fri Apr 26, 2024 7:50 pm
by MicroController
It basically works like this:
Code running on core A puts core B into reset (default after power up), writes the memory address from which core B should start executing code into a special register, then un-resets core B.
This is, however, not how the cores coordinate during normal operation. For this, there are two possibilities: a) inter-core messaging, and b) software-triggered interrupts.
a) is basically just another special register to which either core can write a value ("message", usually only a pointer to the actual message/request structure in RAM), which triggers a "message received" interrupt on the respective other core to read and handle the message. b) is a more simple form of the same where software just writes a 1 to one of several software interrupt registers to trigger an interrupt, which makes the core that has registered a handler for the specific interrupt run an ISR.

Re: ESP32 dualcore example without using FreeRTOS

Posted: Fri Apr 26, 2024 11:26 pm
by micronpn
OK, perfect, do you know where can I find some docs about how can I assign one or more functions to run on the 2 cores? I already use other dual core or multicore microcontrollers, they work differently but I am able to use them without a RTOS and sharing some registers or RAM area. The difference is that I know them and when I started to use them I found documentation and examples. In general terms it is more common to design 2 different programs having both a main() function, dedicated ISR banks and dedicate some program code memory (flash or RAM) to each core.

Re: ESP32 dualcore example without using FreeRTOS

Posted: Sat Apr 27, 2024 11:00 am
by MicroController
do you know where can I find some docs
No, sorry. All I know is that some TRMs describe some of the relevant registers; the ESP32-S3 TRM seems to be a bit more 'verbose' in this regard than the "OG" ESP32's.
Apart from that I guess you'd have to look at the IDF code to reverse-engineer what you need.

I am not aware of any toolchain or the like which would let you build simplified multi-core applications as you describe for the ESP32 familiy. The documented way is to use the IDF with its FreeRTOS.