Espressiv API without FreeRTOS

taguniversalmachine
Posts: 1
Joined: Tue May 24, 2022 4:15 pm

Espressiv API without FreeRTOS

Postby taguniversalmachine » Tue May 24, 2022 4:19 pm

Hi,

If I am using my own operating system on the ESP-32 is there any code available that does not contain FreeRTOS, or do I have to write the drivers from scratch?

I am writing performance-critical code that must be able to read/write to the hardware without triggering a jump anywhere especially not to FreeRTOS.

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

Re: Espressiv API without FreeRTOS

Postby ESP_Sprite » Wed May 25, 2022 2:02 am

No, there is not. The WiFi and BT drivers and the IP stack are dependent on a RTOS to work, so the drivers in ESP-IDF also work under the assumption of an RTOS being there. Can I ask what your drivers are supposed to do that is so performance-critical? Perhaps it can be solved in another way.

mvaragao
Posts: 5
Joined: Mon Sep 12, 2022 5:04 pm

Re: Espressiv API without FreeRTOS

Postby mvaragao » Mon Sep 26, 2022 3:21 pm

Hello,
If it's not possible to use without Freertos, is there any way to suspend interrupts for 30us?
I'm doing pin readings that need high frequency.

Code: Select all

void IRAM_ATTR sync_horizontal() {
  noInterrupts();
  if ( vsync_line>2 && vsync_line<7  ) {
    for ( pos_array=0; pos_array<160; pos_array++ ) {
      mem[lyne_horizontal+(pos_array>>3)] |= ((GPIO.in >> 4) & 0x1)<<(8-pos_array&7);
    }
    line_horizontal += 20;
  }
  interrupts();
}
OR:
Could I perform the bit readings and only then use the RTOS features like wifi etc?

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

Re: Espressiv API without FreeRTOS

Postby ESP_Sprite » Tue Sep 27, 2022 5:26 am

Generally: Don't do that, there's no real way to guarantee proper timings (aside from FreeRTOS, you could also have e.g. cache evictions and loads and activity on the other core leading to jitter). There's likely better ways to solve this using peripherals: RMT, I2S, SPI all sound like they may serve you better here.

mvaragao
Posts: 5
Joined: Mon Sep 12, 2022 5:04 pm

Re: Espressiv API without FreeRTOS

Postby mvaragao » Tue Sep 27, 2022 2:05 pm

Thanks!
I have cost constraint for this project and cannot use external hardware.
Anyway, I appreciate the information that there is no other way to solve it and this may indicate the use of another processor, which does not use RTOS.

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

Re: Espressiv API without FreeRTOS

Postby ESP_Sprite » Wed Sep 28, 2022 12:21 am

I am not talking about external hardware. The ESP32 has a lot of peripherals that are very flexible in how they are used; it is very likely that one of them can do the thing you want without depending on software timings.

ESP_igrr
Posts: 2067
Joined: Tue Dec 01, 2015 8:37 am

Re: Espressiv API without FreeRTOS

Postby ESP_igrr » Wed Sep 28, 2022 7:23 am

Finding a hardware peripheral on the ESP32 to read the pins at high frequency is probably the best solution here! From your code example, it looks like you are reading some kind of video signal; we use the parallel I2S interface in the esp32-camera project for this use case, and it works pretty well.

That said, for the people who might find this forum topic later based on its title, I'd like to note that there are options to use ESP32 without an RTOS, while still having Wi-Fi connectivity:

- Zephyr RTOS supports AMP (asymmetric multiprocessing) mode on the ESP32 now, which allows running the RTOS and the networking stack on one CPU core, while running a simple bare metal application on another. (https://www.espressif.com/en/news/Zephyr_updates, https://github.com/zephyrproject-rtos/zephyr/pull/44645)

- There is an experimental support for Wi-Fi in bare-metal Rust ecosystem for the ESP32, https://github.com/esp-rs/esp-wifi.

mvaragao
Posts: 5
Joined: Mon Sep 12, 2022 5:04 pm

Re: Espressiv API without FreeRTOS

Postby mvaragao » Fri Sep 30, 2022 12:58 pm

Wow! Thanks!
That was quite a help!

I tried to find something with I2S, but I didn't find anything about doing 1-bit reading.
What I found was always dedicated to capturing audio and analog signals, for this reason, they didn't achieve the sampling between 5 and 10MHz that I need.
Could you indicate something like this?

Again thank you very much!

ESP_igrr
Posts: 2067
Joined: Tue Dec 01, 2015 8:37 am

Re: Espressiv API without FreeRTOS

Postby ESP_igrr » Sat Oct 01, 2022 5:47 am

1-bit reading sounds more like a job for SPI or RMT, as the (parallel) I2S input is 8 or 16 bits wide. Frequency you have mentioned should not be a problem, for example the camera driver works fine with 16 or 20 MHz DVP input clock.
On the other hand, if the number of bits you need to read is not very high, you might still use parallel I2S, connecting just one line, and then extract the bits you need from the LSB of the received bytes.


Maybe if you showed the approximate waveform or the signal you are trying to read, it would be easier to give you a more specific suggestion.

mvaragao
Posts: 5
Joined: Mon Sep 12, 2022 5:04 pm

Re: Espressiv API without FreeRTOS

Postby mvaragao » Sat Oct 01, 2022 8:17 pm

Hi!

I need to read only 1 bit, a single digital pin.
Thanks!

Who is online

Users browsing this forum: No registered users and 62 guests