ESP32 dualcore example without using FreeRTOS

micronpn
Posts: 7
Joined: Sun Aug 16, 2020 12:48 pm

ESP32 dualcore example without using FreeRTOS

Postby micronpn » Thu Apr 25, 2024 2:50 pm

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.

ESP_Sprite
Posts: 9778
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32 dualcore example without using FreeRTOS

Postby ESP_Sprite » Fri Apr 26, 2024 5:08 am

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?

micronpn
Posts: 7
Joined: Sun Aug 16, 2020 12:48 pm

Re: ESP32 dualcore example without using FreeRTOS

Postby micronpn » Fri Apr 26, 2024 2:28 pm

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.

MicroController
Posts: 1760
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: ESP32 dualcore example without using FreeRTOS

Postby MicroController » Fri Apr 26, 2024 7:50 pm

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.

micronpn
Posts: 7
Joined: Sun Aug 16, 2020 12:48 pm

Re: ESP32 dualcore example without using FreeRTOS

Postby micronpn » Fri Apr 26, 2024 11:26 pm

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.

MicroController
Posts: 1760
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: ESP32 dualcore example without using FreeRTOS

Postby MicroController » Sat Apr 27, 2024 11:00 am

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.

Who is online

Users browsing this forum: No registered users and 76 guests