08 May 2012
Extensions to FreeRTOS bring productivity gains to embedded design engineers
Operating systems can be a major source of stress for embedded design engineers. Factors such as size, cost and support all contribute to make the development process more complex. The process can become even more fraught when engineers look to develop products with real time operating systems. An off the shelf operating system can play an important role in keeping costs and development time as low as possible.
So it will not come as a surprise to find that a free rtos with a minimal footprint has proved very popular in the nine years since its launch. FreeRTOS is a scalable real time kernel designed specifically for use in small embedded systems. According to Richard Barry, chief technical officer of Real Time Engineers and FreeRTOS' creator, it's doing well. "It's hard to put absolute numbers against progress, but an important indicator is the number of unique visitors to the website. Compared to the same time last year, the number of visitors is up by a third – and last year was a good year."
One of the reasons why Barry believes FreeRTOS is doing so well is that it's 'of its time'. "There has been a huge growth in the number of suitable microcontrollers for it to run on as people move from 8 and 16bit applications into the low end of the 32bit sector. The types of application they are writing, their communication needs and the number of peripherals means a kernel is more applicable. It's a compelling argument."
FreeRTOS is made available under a modified GNU General Public License; a move which overcomes some understandable reluctance to follow the open source route. Essentially, the exception allows applications built on FreeRTOS to remain proprietary; only modifications to the kernel itself have to be shared.
More than 77,000 downloads of the OS are made a year and support is available for a range of architectures and tool chains; at the last count, 31 architectures and 18 tool chains. "It's a win-win," he claimed. "You can download the operating system and use it free of charge, but there is commercial support available if you want it."
Since the launch of FreeRTOS, the operating system has been made available in two other versions: OpenRTOS is a commercially licensed and supported version of the OS that brings what Barry calls 'professional grade' elements; and SafeRTOS, a SIL3 version certified by TUV for use in safety critical applications.
Barry has recently expanded FreeRTOS' capabilities with the launch of the FreeRTOS+ ecosystem. "It's not a new version of FreeRTOS," he emphasised. "A large ecosystem has developed around FreeRTOS and I wanted to bring it together to show users and potential users that it exists; it's beneficial to show that FreeRTOS is more than a kernel."
Six areas in the portfolio
The FreeRTOS+ portfolio comprises six areas: IO; command line interface (CLI); safety and certification; trace; Nabto; and TCP/IP.
FreeRTOS+ IO provides an interface to peripheral driver libraries similar to that found in Linux and Posix based systems. "Most vendors provide their own driver library," Barry admitted, "but there is no standard interface. And there is a lot of naivety about how to write something which is stable for use in a multitasking environment."
FreeRTOS+IO (see fig 1) abstracts away the peripheral interface details, including the implementation of any interrupt service routines that may be required. Various different data transfer modes are catered for, using different techniques to both read and write data, making FreeRTOS+IO applicable to a range of applications. According to Barry: "Interrupt service routines are abstracted and users are left with four core functions, rather than having to define one for each peripheral in their system."
FreeRTOS+IO supports four read modes: polled, interrupt driven circular buffer, interrupt drive zero copy and interrupt driven character queue transfer modes, with the polled and interrupt driven character queue modes supporting read and write modes.
"The polled mode will prevent other tasks from running," said Barry, "while the interrupt driven mode will allow developers to say 'write so many bytes to the spi port, then carry on'. They don't have to wait for that data to be clocked out."
The FreeRTOS+IO module was developed on an NXP platform and the company has since decided to license it. "It uses an NXP driver library when it can," Barry continued.
The CLI module has been written by Barry himself. "It features 10 Posix like interfaces which can be used to write a uniform interface to peripherals. It's a way of getting characters into and out of the system and the only command you get by default is the help function, which runs through the available options."
The Nabto module (see fig 2) has been developed by the Danish company of the same name. "It's interesting," said Barry, "and I'm very enthusiastic about it. It provides a platform for innovative networking solutions and will be of big benefit to those working at the low end of the 32bit market."
Nabto uses a peer to peer communication approach similar to that of Skype. "If you have a piece of equipment in a factory, but it's behind a firewall, Nabto uses UDP hole punching to provide access. The value is that the embedded device only needs to have UDP installed." According to Nabto, an embedded web server can be implemented in only 1k of memory.
Through the use of a web browser plug in, Nabto seamlessly offloads address resolution, TCP/IP processing, static content storage, security and encryption and data throughput processing requirements from the embedded device. A separate non embedded cloud server provides all the static content, leaving the embedded device with nothing left to do except use the lightweight UDP protocol to supply dynamic data values when requested.
"If you want a feature rich web server," Barry said, "you can have all the Java and jpgs on a standard server on the internet. When you access the embedded device, it looks like it's serving, but the only thing coming out of the device is data; you've removed the need for everything else."
Also available in the FreeRTOS+ ecosystem is a run time diagnostic tool developed by Percepio. FreeRTOS+ Trace captures dynamic behaviour, which can then be displayed offline in a range of graphically interconnected views.
"It offers a primary trace view of which tasks are running and which calls are being made," he said, "but it also has some nice features, like looking at a queue history," said Barry. "You can see how many items are in a queue at any time. If the queue gets too full, you can open a trace view and analyse what happened; for example, did a task take too long to execute."
One potential use is to create a circular buffer in a product – even one deployed in the field. When or if something goes wrong, the user can see a trace of activity within the embedded system.
Concluding, Barry said: "We're bringing together a select group of FreeRTOS extensions that offer significant productivity gains while extending the kernel's capabilities through simple interfaces."