Page 1 of 2
Espressiv API without FreeRTOS
Posted: Tue May 24, 2022 4:19 pm
by taguniversalmachine
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.
Re: Espressiv API without FreeRTOS
Posted: Wed May 25, 2022 2:02 am
by ESP_Sprite
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.
Re: Espressiv API without FreeRTOS
Posted: Mon Sep 26, 2022 3:21 pm
by mvaragao
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?
Re: Espressiv API without FreeRTOS
Posted: Tue Sep 27, 2022 5:26 am
by ESP_Sprite
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.
Re: Espressiv API without FreeRTOS
Posted: Tue Sep 27, 2022 2:05 pm
by mvaragao
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.
Re: Espressiv API without FreeRTOS
Posted: Wed Sep 28, 2022 12:21 am
by ESP_Sprite
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.
Re: Espressiv API without FreeRTOS
Posted: Wed Sep 28, 2022 7:23 am
by ESP_igrr
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.
Re: Espressiv API without FreeRTOS
Posted: Fri Sep 30, 2022 12:58 pm
by mvaragao
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!
Re: Espressiv API without FreeRTOS
Posted: Sat Oct 01, 2022 5:47 am
by ESP_igrr
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.
Re: Espressiv API without FreeRTOS
Posted: Sat Oct 01, 2022 8:17 pm
by mvaragao
Hi!
I need to read only 1 bit, a single digital pin.
Thanks!