Cost and business aspects of building products are key criteria, but attributes such as available libraries, security, and maintainability also play a critical role.
Embedded system developers today have a wide range of operating systems. Of course, the simplest operating system is to have no operating system! However, many systems today are complex, connected systems where an operating system may be required. If necessary, developers will often seek to use a real-time operating system (RTOS) or Linux to help manage the complexity. Unfortunately, the choice between bare metal, RTOS or Linux is not always clear. Each option has its pros and cons.
This article will explore the system features to consider when selecting your operating system. Then, in the next article, we’ll look at when it makes the most sense to use each operating system.
Lifetime product costs
Selecting the operating system for your embedded system starts with understanding the costs and requirements of your product throughout its lifetime. A trade-off must occur between bill of materials (BOM) costs and product software maintenance costs. For example, embedded systems that use Linux have an easier time taking advantage of open source software and finding developers who can write the system software. However, Linux-based systems have more complex hardware requirements than microcontroller-based systems and can have a higher BOM cost. Microcontroller-based systems may cost less, but there are also fewer developers able to design and maintain these systems successfully.
Designers must weigh both hardware and software costs to determine if it makes sense for their product to use hardware that can run Linux or if a cheaper, less CPU-intensive solution is better suited.
Physical characteristics to consider
Speaking of hardware capabilities and requirements, when selecting your in-vehicle operating system, it is also essential to look at the physical characteristic chosen by the hardware. Physical factors of a microprocessor or microcontroller that must be considered include:
- Peripheral feature set
- CPU clock speed
- Flash storage available
- Available RAM
The physical constraints imposed on your system by the hardware can immediately limit the options available to you. For example, to run a variant of embedded Linux, the processor typically must contain a memory management unit (MMU). Unfortunately, microcontrollers don’t have MMUs. Therefore, to run Linux, designers will need at least an application processor in the Cortex-A family, not a microcontroller in the Cortex-M family (although things change quickly and someone one can have microcontrollers with an MMU and a reasonable clock frequency).
To run any version of embedded Linux, the hardware must also have at least 8 GB of storage, 16 GB of RAM, and 8-16 MB of internal flash storage. A kernel like Linux also probably needs at least a 500 MHz processor. These are well above what is needed to run an RTOS, which requires a minimum of four KB of RAM, 64 KB of flash memory and a processor running at 24 MHz.
I know from experience that exploring real-time performance characteristics between bare metal, RTOS and Linux systems is a hot potato. Engineers who focus on microcontroller-based real-time systems will often tell you that you can’t get real real-time performance from a Linux system. Linux engineers will tell you that’s not true; there’s the real-time patch, which provides real-time behavior. From there, the arguments usually heat up.
It doesn’t matter which side of the fence you’re on, it’s essential to review the real-time requirements and use them to select your operating system. Evaluate how deterministic the system needs to be and rate your operating system against those needs. I’ve seen real-time Linux variants that work just fine; others who do not. There is no universally correct answer, just one suitable for your application.
Software Library Integration
One of the significant differences between using bare metal, an RTOS, or Linux is the availability and level of integration of software libraries available to developers. In the bare metal space, you are alone. Either write your software from scratch or integrate third-party libraries yourself. An RTOS, on the other hand, will come with a suite of libraries already built into the RTOS. For example, one can find circular buffers, memory management tools, file systems, etc. Other libraries are available and built in, but it may still be necessary to do some of the work yourself.
When you look at Linux, you get the impression that the developers have an almost unlimited number of libraries available and already built into the system. The most attractive and value-added feature of embedded Linux is the availability and integration of software libraries. Developers have an operating system as a whole. It is powerful but also potentially dangerous.
Don’t forget about safety
Today, many designers are building connected systems that must have a secure solution. The operating system plays an important role in security solutions. For example, if a vulnerability is found in a standard library used by the Linux kernel, every Linux device until patched has the vulnerability. Chances are that a bare metal or RTOS-based system won’t have the same vulnerability. Specific operating systems are more targeted by hackers than others due to the tools they have to hack into those devices. For example, I’ve put embedded systems that use an RTOS directly on the internet unprotected, and they’ve gone weeks without ever being compromised. I once put a Linux based system on the internet, and it got hacked and became part of a Chinese botnet within 48 hours. In defense of Linux systems, I think the default password was always set, but it shows that if you don’t take the time to properly configure your OS, it doesn’t take much to hack it .
Developers need to consider many features when selecting their operating system. The first characteristics are more related to the costs and commercial aspects of construction products. However, the most important attributes such as available libraries, security, maintainability, etc. also play an essential role. So which operating system should you use and under what circumstances? In the next article, we’ll explore this question and provide guidelines for using bare metal, an RTOS, and Linux.
|Jacob Beningo is an embedded software consultant specializing in real-time systems based on microcontrollers. He actively promotes software best practices through numerous articles, blogs, and webinars on topics such as software architecture design, integrated DevOps, and implementation techniques. Jacob has 20 years of experience in the field and holds three degrees, including a Masters in Engineering from the University of Michigan.|
To learn more about Embedded, subscribe to Embedded’s weekly email newsletter.