Table of Contents

FreeRTOS Insights and Understanding the Ecosystem

What is RTOS

A Real-Time Operating System (RTOS) responds to inputs immediately, in real-time. It is where timely action on the system inputs is of utmost importance. Examples include live broadcasts of a sports event, weapons systems, and aircraft control systems. Real-time systems are typically categorized as hard real-time systems or soft real-time systems. In a hard real-time system, the deadline for generating an output or action must be met otherwise the system fails to perform its intended function. For example, in an aircraft, if the wing control actuators fail to respond to the pilot’s input within the specific time, the aircraft fails to descend for landing. On the other hand, the time constraints in a soft real-time system are not as harsh. The output result of computation may still be useful even if it does not meet its timing cut-off. The video broadcast, for example, is a soft real-time system. If a video frame is delayed or dropped, the quality of the video is degraded, but the video may still be visible.

The definition of real-time as given in the POSIX Standard 1003.1 is, “The ability of the operating system to provide a required level of service in a bounded response time”.

Common challenges using RTOS

Using RTOS is common nowadays. As compared to using the bare metal application development approach, an RTOS can provide standardized interfaces, implicit synchronization, and debugging mechanisms. There are, however, a few challenges faced by the developers when using an RTOS:

  1. Designing an optimized, efficient, and effective schedule
    Designing a good task schedule can make or break the overall system functionality. The task priorities, as well as task periodicity, need to be carefully decided depending upon the system-level impact of each of the tasks against the system-level requirements.
  2. Synchronization among different tasks
    Task synchronization is critical while implementing a data processing pipeline. E.g., in a live video streaming system, there could be different tasks responsible for capturing raw video frames, compressing, and streaming over the network/Internet. Each task must be synchronized to consume and produce video data for good quality live video stream with minimal latency.
  3. Debugging
    Debugging an RTOS-based embedded system is a major challenge. Developers spend up to 80% of their development cycle debugging their applications. An RTOS can introduce problems like priority inversion, race condition, dead-lock, and task jitter. Tracing tools can help understand the RTOS behavior, task states, and mutex lock/unlock status. They are even required to verify that the application is executing as expected.

What is FreeRTOS and Why use it?

FreeRTOS is a market-leading embedded system RTOS, which is available for many popular processor architectures. FreeRTOS supports more than 40 architectures including highly popular ARM architectures. The FreeRTOS code is written in C programming language that allows easy porting on new or custom architectures. FreeRTOS is simple, portable, royalty-free, and concise. FreeRTOS is an MIT-licensed open-source project and can be embedded in commercial products without any requirement to expose the product’s proprietary source code. It has existed since the year 2003 and it is actively maintained by Amazon. FreeRTOS has a small memory footprint and provides fast execution by reducing the RTOS overhead. It has inbuild tracing support that helps record and visualize the runtime behavior of the RTOS.

Additionally, FreeRTOS also provides cross-development support from a standard Windows host by using a windows-based simulator.

FreeRTOS Features

  1. Highly configurable kernel.
  2. Easy to use APIs for creating, configuring, and scheduling tasks.
  3. Mutex and Semaphore for synchronization.
  4. Support for thread-safe message queues.
  5. Software timers.
  6. Event groups to notify the occurrence of an event.
  7. Memory management to maintain heap memory.

FreeRTOS Features

 

FreeRTOS Advanced Features

In addition to the basic tasking and synchronization features, FreeRTOS provides additional advanced features to debug and troubleshoot problems rather quickly as compared to the other RTOS.

  1. Stack overflow detection
    FreeRTOS provides two different types of stack overflow detection mechanisms. This overflow detection functionality is enabled by setting configuration options. A callback function is implemented to take necessary actions upon detection of a stack overflow. E.g., the hook function can display the task name and relevant parameters on an output console, so that the developer can easily identify the problem and apply the corrective fix.
  2. Memory allocation failure
    The memory allocation failures are captured by implementing a predefined callback function.
  3. Trace Hooks
    The trace hooks are functions and pre-processor codes that are implemented to record important kernel events. The events data is transferred to a host computer for detailed analysis. The data is used to determine the timelines of the task execution, CPU load, and task timings.
  4. CPU Idle Hook
    The CPU idle task hook is a function that is executed each time the idle task is invoked. This allows the developer to execute low-priority functions that do not need a dedicated CPU time.
  5. Kernel Tick Hook
    The kernel tick interrupt can call an application-defined callback function. Such functions are used to implement timer functionality, for example.

FreeRTOS+

In addition to the FreeRTOS kernel, add-on libraries are available to extend the RTOS functionality. Three such libraries are explained below.

  1. FreeRTOS+TCP
    A full-fledged, thread-safe, and lightweight TCP/IP stack. The stack interfaces with FreeRTOS and provides an easy interface to the implemented platform-specific code for hardware interfacing.
  2. FreeRTOS+CLI
    This library implements an easy-to-use command-line interpreter framework. Its interpreter provides the functionality to register commands and their relevant callback functions. This is interfaced with the UART, for example, to provide a console over a serial interface, or a telnet interface is implemented to provide CLI over the network.
  3. FreeRTOS+IO
    FreeRTOS+IO provides POSIX-like interfaces to peripheral drivers. This piece of middleware fits between the user application and the device driver to facilitate the designing of a portable user application.
  4. FreeRTOS+Trace
    The Trace library provides the implementation of capturing the run-time behavior of the RTOS. This data is processed by the Tracealyzer tool to generate graphical views and plots to understand the scheduling of tasks and synchronization. Tracealyzer is a commercial tool that provides visual diagnostics of the RTOS application.

FreeRTOS alternatives

  1. Commercial
    1. LynxOS
    2. VxWorks
    3. Unison
    4. QNX / Neutrino
    5. SAFERTOS
    6. OpenRTOS
  2. Open Source
    1. eCos
    2. RTLinux
    3. MicroC/OSII

OpenRTOS

With all the rich feature sets and ease of use, you may be restricted to use FreeRTOS, if the company policy does not allow the usage of open-source software or it wants to avoid integration of open-source components with the company IP. The solution to this problem is OpenRTOS. It uses the same FreeRTOS code base but comes with a commercial license. The license includes technical support, tools, and training. The license also protects against any legal liabilities.

RTOS for Safety-Critical Applications/SAFERTOS

While FreeRTOS has its advantages, it still lacks many features and requires development/verification evidence for certifying with a highly safety-critical application (E.g., aircraft control system, automotive control system). Thus, an RTOS that can produce a predictable outcome in a specific time is needed. For such systems, SAFERTOS, an RTOS based on the functional model of the FreeRTOS kernel is available.

SAFERTOS is pre-certified to a few standards like the IEC 61508 SIL 3 and ISO 26262 ASILD. SAFERTOS comes with a Design Assurance Pack that serves as a safety manual. The manual provides instructions for SAFERTOS integration on a custom platform and the process to be followed. The package also includes all the critical certification-related artifacts. These artifacts simplify the certification process and provide sufficient evidence during the audit process.

Unlike FreeRTOS, however, SAFERTOS is not available freely and requires commercial license purchase.

eInfochips has in-depth experience working with a variety of RTOS in the consumer as well as safety-critical embedded systems. We have successfully produced end-to-end embedded systems and solutions by leveraging our software, hardware design, and mechanical design experiences in industries like medical, consumer electronics, automotive, and aerospace. Our development, verification, validation methods, and processes allow us to produce artifacts and evidence required for hassle-free certification compliance. For more information, please contact our experts today.

Resources

https://www.freertos.org/

http://www.highintegritysystems.com/openrtos/

http://www.highintegritysystems.com/safertos/

https://percepio.com/tracealyzer/

 

Explore More

Talk to an Expert

Subscribe
to our Newsletter
Stay in the loop! Sign up for our newsletter & stay updated with the latest trends in technology and innovation.

Our Work

Innovate

Transform.

Scale

Partnerships

Device Partnerships
Digital Partnerships
Quality Partnerships
Silicon Partnerships

Company

Products & IPs