ESP32 : Introduction to FreeRTOS
|Introduction:
In IOT field, there are many reasons to go for constrained OS than full OS.
- Limited Space – so that small size devices can be made
- Low Power – so that coincells can be used as power source
- Optimization of features – to make more value
- Cost – So that product is market competitive
What is Operating system (OS) : It hides all the difficult computation with the hardware which software do on the backend. We are presented a computer screen that we can work on and all other details that is the communication between software and hardware is hidden form us. So an operating system is a type of software which communicates between application software and hardware.
What is RTOS : A real time operating system is the type of system which uses maximum time and resources to output exact and on the time result. There is no difference between the results when same problem run on different occasion on same machine. There is no late or early execution on that operating system and is done on fixed time as suggested.
RTOS is preferred choice for many embedded device manufactures and embedded programmers. So RTOS is being used in applications like
- Automatic system of the robots machines that are manufacturing cars.
- Aircrafts i.e. during launch of aircraft on space and landing of aircraft.
- Other tasks and operation done by aircraft on space is controlled by the RTOS.
There are many RTOS flavors available. FreeRTOS is widely followed by practitioners. We will take more details about freeRTOS in this blog
Features of the freeRTOS (as listed in freertos.org)
- Free RTOS scheduler
- The SafeRTOS provides better code integrity.
- Includes a tickless mode for low power applications.
- RTOS objects (tasks, queues, semaphores, software timers, mutexes and event groups) can be created using either dynamically or statically allocated RAM.
- Tiny footprint — RAM less than 500 bytes, ROM 5-10 kb
- Official support for >30 embedded system architectures (counting ARM7 and ARM Cortex-M3 as one architecture each).
- Designed to be small, simple and easy to use. Typically a RTOS kernel binary image will be in the region of 4K to 9K bytes.
- Very portable source code structure, predominantly written in C.
- Supports both real time tasks and co-routines.
- Direct to task notifications, queues, binary semaphores, counting semaphores, recursive semaphores and mutexes for communication and synchronisation between tasks, or between real time tasks and interrupts.
- Free development tools for many supported architectures.
- Free embedded software source code.
- Royalty free.
- Cross development from a standard Windows host.
Why freeRTOS?
- Provides a single and independent solution for many different architectures and development tools.
- Is known to be reliable.
- Is feature rich and still undergoing continuous active development.
- Has a minimal ROM, RAM and processing overhead. Typically an RTOS kernel binary image will be in the region of 6K to 12K bytes.
- Is very simple – the core of the RTOS kernel is contained in only 3 C files.
- Is truly free for use in commercial applications
- Comes with a porting, platform development, or application development service should it be required.
- Is well established with a large and ever growing user base.
- Contains a pre-configured example for each port.
- Has an excellent, monitored, and active free support forum.
- Has the assurance that commercial support is available should it be required.
- Provides ample documentation.
- Is very scalable, simple and easy to use.
- FreeRTOS offers a smaller and easier real time processing alternative for applications
ESP32 and freeRTOS:
Many manufacturers produce SoC with freeRTOS support. Expressif included freeRTOS in its latest version ESP – IDF. There are currently two methods to program the ESP32: the ESP-IDF and the ESP32 arduino Core. Espressif IoT Development Framework is a set of open source libraries and tools to facilitate deployment of apps to ESP32s FreeRTOS.
Though there are two options, freeRTOS is better choice as stated by Tomerweller here
Ring oscillator tests done by Tomerweller showed that the Arduino program is about 65% slower than the lower level FreeRTOS program (1.63 Mhz vs 1.03 Mhz)
Follow us to know more about making free RTOS tasks and freeRTOS programming on ESP32 module, to see how to setup dev environment checkout following posts
Setting up ESP – IDF for ESP 32: Getting Started with ESP32
MicroPython on ESP 32 : ESP32 – Getting started with MicroPython
You can also use eclipse for development – ESP IDF : Setting up eclipse for ESP 32
Use Arduino IDE for ESP 32 – Setting up arduino to program ESP 32
Great explanation about the freeRTOS and its applications! Embedded systems still seem to be a niche area (even though IOT has been booming from a few years) compared with other areas such as mobile and web development. Sometimes there’s little information for those whom would like to seriously dive into microcontroller development. What would be your best advice to people with some programming experience who would like to explore this field?
I think you should have checked his math! He made a mistake in calculating the percentage difference between the Arduino and ESP. If the Arduino code was 50% slower, the frequency would have been ~0.815MHz. The formula is (1 – 1.05MHZ/1.63MHz x 100)% which is ~35% — Still a significant difference
Step down from higher 1.63 to 1.05 is 35%. Step UP from 1.05 to 1.63 is 50+%. His math seems fine. Must be the language.
Thanks for all the initiative and sharing such valuable information. Looking forward to learning more from you.
In short – IOT, ML, AI and Big Data processing – You sow the seeds now and reap the long term benefits later 🙂
These are not short term things, need mature hands on techies to invest in these now so that we see mature outcomes within the next 5 years.
Thanks Siva for sharing RTOS related stuff, this has been another long awaited technology, again if you invest now the results would fetch great returns – someday 🙂