You are on page 1of 6

(Apache) NuttX

A Linux-like RTOS for Microcontrollers

Alan Carvalho de Assis Alin Jerpelea


Senior Embedded System Engineer Senior Open Source Software Architect
Espressif Systems Brazil , Sony Europe

Abstract— Linux has followed a long and amazing journey to Soon after that Linux started to be used on some embedded
become the standard OS when people think about a "Feature applications as well. In fact, in 1997 Dave Cinege created the
Rich Embedded" OS, but yet it has its drawbacks: it requires a Linux Router Project [29] that was considered the first real
processor with MMU (the no-mmu/uClinux has many embedded Linux project [28].
limitations that will be discussed during the article); it requires
a lot of RAM and Flash memory to run; its power- In the following year (1998) a new important milestone for
consumption is high; its boot time is long (dozens of seconds Linux in the embedded system arena was reached: Kenneth
to minutes), and the list goes on. These limitations make Albanowski and D. Jeff Dionne began working on the uClinux
Linux not the best choice for resource-constrained devices. project. uClinux was a port of Linux kernel to processor
without MMU (Memory Management Unit). The initial port
In order to correct many of these limitations, in 2007 Mr. was to the Motorola MC68328 DragonBall processor that was
Gregory Nutt released an RTOS he had created from scratch, used by PDAs (Personal Digital Assistant) [27] such as 3Com
called NuttX (just like Linux also refers to its creator, Linus PalmPilot and Pilot III.
Torvalds). NuttX was implemented from scratch to be small,
fast, POSIX and ANSI compliant, and run on small Then in 2002 a company called SnapGear Inc that was
microcontrollers and even on 64-bit Intel/AMD, RISC-V and contributing to the uClinux project and using it in their
ARM processors. And most importantly: to be Unix/Linux- products submitted the uClinux patches to kernel mainline that
like RTOS. were included on Linux 2.5.46 [26]. Since then in the Linux
source code tree there is a "no-mmu" directory that enables the
I. INTRODUCTION (Heading 1) Linux kernel to run on processors without MMU.
Linux is everywhere nowadays. It runs on TVs [1], WiFi
routers [2], Smartphones [3] [4], Smartwatches[5], Cars[6], Despite the fact of Linux been used on many embedded
Refrigerators[7] and even on SpaceX Falcon [8][9]. But Linux system projects it has some drawbacks and limitations, just to
success didn't happen overnight. list some: 1) it requires at least 2MB Flash and 4MB RAM to
Linux was created more than 30 years ago as a general run [25]; 2) its boot time is too long for some applications
purpose operating system for PCs. In 1991 Linus Torvalds, (there are some hacks that try to improve it, like saving a
creator of Linux, released his famous message in the minix booted image on disc/flash and just load it directly to the
usergroup announcing about his project: RAM); 3) it is not a Realtime kernel (although there are
patches that can be applied to the kernel to improve its
“Hello everybody out there using minix – realtime capabilities, it still best effort scenario, the kernel
wasn't designed from scratch to be realtime); 4) it is not a
I’m doing a (free) operating system (just a hobby, won’t be good option for low power applications because it needs to run
big and professional like gnu) for 386(486) AT clones. […] It on processor that consumes too much power and scaling down
is NOT portable (uses 386 task switching etc), and it probably the CPU frequency to few MHz is not an option because the
never will support anything other than AT-harddisks, as that’s kernel by itself requires too many CPU cycles to do its job; 5)
all I have :-(.” [31] and most importantly the GPL license is a source of concern
for some companies because they need to release the source
From his words it was clear what were Linux's limitations at code [32].
the time, it was not planned to run on anything other than an
Intel 386 processor that Linus was using to write it. Actually It's important to note that although Linux can run on
that statement proved to be wrong and just four years later the processors without MMU it cannot run on low-cost
Linux kernel was ported to Alpha DEC [30], SUN Sparc and microcontrollers that have few KB of RAM and Flash,
MIPS. because its size is too big to fit in the Flash and it requires too
much RAM memory to start-up.

www.embedded-world.eu
8051 and Z80 to confirm that NuttX was small enough to run
So, to solve these issues in 2007 Gregory Nutt released the on 8-bit microcontrollers [20].
NuttX RTOS. This RTOS is what Linux should be for
microcontrollers. In the next sections we will discuss what Currently NuttX supports dozen of hardware architectures
NuttX is, which problems NuttX solves. (i.e.: arm, arm64, avr, hc, mips, misoc, or1k, m16c, risc-v (32-
bit and 64-bit, with or without MMU), sh1, sim, sparc, x86,
x86_64, xtensa, z16, z80) and hundreds of microcontrollers
I.What is NuttX? and microprocessors [19].

According with Wikipedia


[https://en.wikipedia.org/wiki/NuttX]: II. Which features does NuttX have to offer for
Embedded System Developers
"NuttX is a free and open-source Real-Time Operating System
(RTOS) with an emphasis on technical standards compliance Since NuttX is a POSIX RTOS then an embedded system
and on having a small footprint. Scalable from 8-bit to 64-bit developer can write an application in a POSIX operating
microcontroller environments, the main governing standards system such as Linux, MacOS or even Windows using
in NuttX are from the Portable Operating System Interface Cygwin or WSL (Windows Subsystem for Linux) and validate
(POSIX) and the American National Standards Institute it and compile it to run on NuttX without learning a new API.
(ANSI)."
Also because of this strict POSIX compatibility the developers
NuttX also has many subsystems similar to those existent on don't need to create an application from scratch, they can grab
Linux. Several examples include Virtual File System (VFS), some small Linux libraries and perform some minor
Memory Technology Device (MTD), Audio subsystem and modifications to get them working on NuttX [18]. In some
USB system with USB composite support [24]. Some of the cases they don't even need to modify anything when the
most important characteristics of NuttX are: library is truly POSIX compatible.

Modular Besides this inherent advantage of being POSIX, NuttX also


Fully preemptible has many drivers and features that help developers during their
Naturally scalable embedded project development. Let's to enumerate some of
Highly configurable NuttX features and drivers by subsections for make it easier to
Easily extensible to new processor architectures follow:
Real-time
Deterministic
Support for priority inheritance a. File Systems:
Support for On-Demand Paging VFS - Virtual File System
Flexibles memory modes: FLAT, PROTECTED and FAT File System (including FAT12, FAT16
KERNEL modes and FAT32);
HOSTFS - Allow to mount a host computer
NuttX started as a personal project of Gregory Nutt that he directory as a file system of NuttX
released as open-source on February 27 of 2007 in the LittleFS - LittleFS was integrated on NuttX
sourceforge [23]. Greg had previous experience creating kernel
RTOS for military, aerospace and consumer electronics NFS - Network File System, to mount a FS
applications [22] and he also worked developing embedded exported over the network
systems with embedded Linux. So he used that previous NXFFS - NuttX Flash File System, original
knowledge to create NuttX. NuttX FS to use with NOR Flash
PROCFS - Similar to Linux's ProcFS, it
He worked uninterruptedly from 2007 to 2019 adding new exports kernel information over the FS
features and improving the system. Then in 2019 the project ROMFS - Similar to Linux's ROMFS, low
was donated to Apache Software Foundation and on to mount a read-only FS embedded in the FS
November 17 2022 it became a Top Level Project of Apache RPMSGFS - RPMSG File System, to
[21]. Side note: just like some people defend that Linux needs mount remote directories to local
to be called GNU/Linux, there are people that defend that SPIFFS - Port of the SPIFFS file system
NuttX needs to be called Apache NuttX. by Peter Andersson
TMPFS - Similar to Linux's TMPFS, allow
The initial NuttX version 0.0.1 released in 2007 had only to mount RAM memory as FS
support for ARM7 (TMS320C5471) and for Linux user mode UNIONFS - Special FS that allow to fuse
simulator, but less than one year later he added support for two FS in a simple mount point
USERFS - Similar to Filesystem Userspace ADB - allow a NuttX board to be debugged
(FUSE) of Linux as a Android Debug Bridge
CDC/ACM - allow a NuttX board to
b. Network Protocols and Resources behavior like a USB/Serial device
6LoWPAN - IPv6 over Low power Mass Storage - allow a NuttX board to
Wireless Personal Area Networks behavior like a USB Thumb drive
ARP - Address Resolution Protocol RNDIS Ethernet - allow a NuttX board to
Bluetooth - Bluetooth Low Energy use USB for network communication
ICMP - Internet Control Message Protocol CDC-ECM - another option to use USB for
IGMP - Internet Group Management network communication
Protocol version 2 Composite - allow a NuttX board to
IP - Internet Protocol (supports IPv4 and behavior like multiple USB devices
IPv6)
MLD - Multicast Listener Discovery
NAT - Network Address Translation f. Audio support
ROUTING - Packet routing between Ringtone - create audio similar to those
different network interfaces used on old features phones
SOCKET - Unix/Raw Socket support Audio codecs - such as: VS1053, CS4344,
TCP - Transmission Control Protocol CS43L22, ES8388, WM8776,
UDP - User Datagram Protocol WM8994, etc
USRSOCK - User-space networking stack NXPlayer - audio player for WAV and
API MP3, able to play local file or stream from
(There are other protocols that are internet
implemented in user space instead of kernel space).
There are many other features and drivers outside these above
categories, for example: Peripheral drivers for: SPI, I2C, 1-
c. Graphics support Wire, I2S, ADC, DAC, PWM, SDIO/SDCard/MMC,
Framebuffer - similar to Linux Quadrature Encoder, RFID, NFC, and many others sensors
Framebuffer and devices using these peripherals; Power Management
LCD - support to LCD devices support for low power; Tickless kernel mode; Dynamic Binary
OLED - support to OLED devices Loader; Pseudo Terminal; Kernel Module for load/unload
NX Server - minimalist X11 like graphic drivers dynamically; Syslog; Symmetric Multi Processing
server (SMP); I/O Redirect; GSM Modem (GPRS, 3G, 4G/LTE, NB-
NX Libs - graphic library for drawing on IoT, Cat-M1) and the listing goes on.
NX server
NXWidget - high-level NX components Differently from Linux, NuttX doesn't require a bootloader to
LVGL - external LVGL graphic library boot. It means that the kernel itself is responsible for
VNC - VNC server initializing the microcontroller's clock, memory and
everything else. But that doesn't forbid the developer from
using an external bootloader.
d. USB Host support
CDC/ACM - allow to detect and use Actually there is an integration of MCUBoot [17] bootloader
external USB/Serial devices on NuttX already. It means that a company planning to do
CDC/MBIM - allow to detect and use remote firmware update Over The Air could use NuttX and
external USB Modem MCUBoot to accomplish it. Another option is using a second
Mass Storage - allow to detect and use instance of NuttX itself as bootloader to update the flash area
external USB Thumb drivers where the main NuttX and application resides. It option brings
HID Keyboard - allow to detect and user more flexibility than that offered by MCUBoot.
external USB Keyboards
HID Joystick - allow to use external
joysticks III. Projects and Companies using NuttX RTOS
HID Mouse - allow to use external mouses
USB HUB - allow to use USB HUB to There are many projects and companies using NuttX for many
expand number of USB ports different purposes and applications. In [33] the researchers
developed a solution to help people with Parkinson's Disease
in their writing rehabilitation process. Their solution uses a
e. USB Device support digital pen connected to an STM32F4Discovery board over

www.embedded-world.eu
USB and they developed a C++ library called FiMoSDK that the NuttX project. Masayuki from Sony presented this new
implements the handwriting logic and exercises. platform in the Embedded Linux Conference Europe in 2019
[12].
In [34] NuttX was used to create the RT-ROS (Realtime
Robot Operating System) project. They used the ROS But Sony is not the only semiconductor company submitting
framework as base and extended it to support realtime time support to their chips to the NuttX mainline: Espressif
application using a multi-core processor approach: running Systems is also actively contribution code to the project, they
non-realtime ROS applications on Linux in a core and realtime already included ESP32, ESP32-C3, ESP32-C6, ESP32-S2
control applications in another core running NuttX. and ESP32-S3 into NuttX mainline; NXP also submitted
support to some other their chip to the mainline. And slowly
In [35] researchers from Bosch present the micro-ROS project other companies are starting to contribute.
[16], a ROS framework developed to work on
microcontrollers. In this article they explained about their NuttX also was used as the backbone of Google Project Ara
micro-ROS Executor that uses NuttX's Sporadic Scheduler and, although Google didn't release any commercial product
(SCHED_SPORADIC) as base. based on it, their source code was used by Motorola to create
the Moto Z series Snap Covers powered by NuttX [40].
An open-source computing platform for robot control is
presented in [36]. Their platform is based on the NXP More recently a new company called Wilderness Labs created
LPC4337 microcontroller, but because it was developed over a .NET C# ecosystem for microcontrollers called Meadow
NuttX they can replace the microcontroller without modifying [42] that runs over the NuttX RTOS. They created their own
their application. implementation using Mono as a starting point. They
contributed their advancements in the Dynamic Library
The first successful open-source project with a broad audience Loader back to the NuttX community [43].
to use NuttX was the PX4 Autopilot and Flight Controller for
drones [15]. The PX4 project was created by Dr. Lorenz Meier Another company developing products with NuttX is Xiaomi,
from ETH Zurich in 2011 [37] and it evolved very fast to which uses it in their Vela platform [41]. Xiaomi is very active
support many devices [14]. in the NuttX community submitting a huge amount of patches
every single day.
The next project that brought NuttX attention to the many
companies was ThingSee One from Haltian. They created a
very advanced IoT device and a successful campaign on IV. Conclusion
Kickstarter [13] and commented that they developed it on top
of NuttX (at video position 2:22). Haltian contributed many of NuttX was implemented from scratch to be a POSIX
their developed features back to the NuttX community, compliant RTOS. It means everything on NuttX was
including the USRSOCK subsystem. developed with this idea in mind, even internal APIs of the
kernel also follow this approach. This approach makes even
Soon after that Sony announced during the ARM TechCon the kernel driver development a task more orthogonal for
2016 that they were developing audio product using NuttX developers, because then they don't need to learn some strange
[11] : API.

"Sony has released audio products based on Cortex-M3. Also the similarities with Linux kernel subsystems makes the
Considering development efficiency, code reusability and transition to NuttX something more pleasant for developers.
feature enhancements, we ported POSIX based open source Embedded Linux developers normally can trace parallels on
RTOS named NuttX onto the MCU by ourselves, modified the solutions they created for Linux and apply those concepts
NuttX for fast ELF loading, introduced minimum adb (Android when developing similar applications to run on
debug bridge) protocols for testing purpose, DVFS in microcontrollers.
autonomous mode, wake_lock and stack trace which are
popular in Linux/Android worlds. Middleware and Another important thing to keep in mind is that as main
Applications were developed in C++11 with libc++ which are desktops processors moved to 64-bit the Linux focus to 32-bit
also popular for large software systems. To debug the is slowly being left to the second plan, as discussed here [38].
software, we implemented NuttX support for OpenOCD so that In fact, the support for Intel 386, the processor where Linux
we can debug multi-threaded applications with gdb." was created, was already removed 10 years ago [39].

In the sequence Sony released the Sprense platform [10] also Bibliography
running NuttX. It is based on Sony Multicore (6x ARM
Cortex-M4F) CXD5602. They submitted support to NuttX
mainline and since then Sony became a constant contributor to
[1] D. Neary, "Did you know Linux is in your TV?", [15] "PX4 Open Source Autopilot for Drone Developers",
OpenSource.com, 24 February 2023, DroneCode, 23 February 2023, https://px4.io
https://opensource.com/article/18/5/places-find-linux
[16] "micro-ROS puts ROS 2 onto microcontrollers", ROS
[2] "OpenWrt Project", OpenWrt, 23 February 2023, Foundation, 22 February 2023, https://micro.ros.org
https://openwrt.org/
[17] "MCUBoot", MCUBoot Page, Linaro, 22 February 2023,
[3] "Android", Android Project, Google Inc, 23 February https://www.mcuboot.com/
2023, https://www.android.com
[18] A. Assis, "What is the NuttX RTOS and why should you
[4] J. Gloor, "Are There Any Linux Phones?", How-To Geek, care?", Embedded, 15 August 2017,
23 February 2023, https://www.howtogeek.com/790014/are- https://www.embedded.com/what-is-the-nuttx-rtos-and-why-
there-any-linux-phones/ should-you-care/

[5] "AsteroidOS: Free your wrist", AsteroidOS Project, 23 [19] "NuttX arch/ directory", Github NuttX Repository,
February 2023, https://asteroidos.org/ Microsoft, 23 February 2023,
https://github.com/apache/nuttx/tree/master/arch
[6] "Automotive Grade Linux", The Linux Foundation
Projects, 23 February 2023, https://www.automotivelinux.org/ [20] "NuttX Release Notes", Github NuttX Repository,
Microsoft, 23 February 2023,
[7] "Linux community touched by the touchscreen on https://github.com/apache/nuttx/blob/master/ReleaseNotes
Electrolux fridge", Electrolux Group, 23 February 2023,
https://www.electroluxgroup.com/en/linux-community- [21] "The Apache Software Foundation Announces Apache®
touched-by-the-touchscreen-on-electrolux-fridge-8873/ NuttX™ as a Top-Level Project", Apache Software
Foundation, 23 February 2023,
[8] "SpaceX Sent NASA Astronauts Into Orbit Using Linux", https://news.apache.org/foundation/entry/the-apache-software-
The Byte, Futurism.com, 23 February 2023, foundation-announces-apache-nuttx-as-a-top-level-project
https://futurism.com/the-byte/spacex-nasa-astronauts-linux
[22] G. Nutt, "NuttX RTOS Beginnings", Youtube Video, 23
[9] S. Vaughan-Nichols, "From Earth to orbit with Linux and February 2023,
SpaceX", ZDNET, 23 February 2023, https://www.youtube.com/watch?v=KF_9yOsNH2s
https://www.zdnet.com/article/from-earth-to-orbit-with-linux-
and-spacex/ [23] "NuttX Real-Time Embedded Operating System",
SourceForge, Slashdot Media, 22 February 2023,
[10] "Sony’s multicore microcontroller technology with global https://sourceforge.net/projects/nuttx/
LTE connectivity", Sony, 23 February 2023,
https://developer.sony.com/develop/spresense/ [24] A. Sharma, "Porting NuttX Real-Time Operating System
on PolarFire® SoC FPGA", 22 February 2023,
[11] "ARM TechCon 2016 Schedule", ARM TechCon / https://riscv.org/blog/2023/02/porting-nuttx-real-time-
recovered from archive.org, 23 February 2023, operating-system-on-polarfire-soc-fpga/
https://web.archive.org/web/20170402115031/http://schedule.
armtechcon.com/session/developing-audio-products-with- [25] E. Barbieri, "What is embedded Linux? Part I", 22
cortex-m3nuttxc11 February 2023, https://ubuntu.com/blog/what-is-embedded-
linux
[12] M. Ishikawa, "NuttX for Embedded Linux Developers",
Embedded Linux Conference Europe 2019, 23 February 2023, [26] M. Gillham, "uClinux and Linux set to merge", 23
https://elinux.org/images/8/84/NuttX_for_Embedded_Linux_d February 2023, https://www.linux.com/news/uclinux-and-
evelpers_20191026_without_video.pdf linux-set-merge/

[13] "Thingsee One: The Smart Developer Device", [27] "Personal digital assistant", Wikipedia, Wikimedia
Kickstarter, 23 February 2023, Foundation, 26 February 2023,
https://www.kickstarter.com/projects/haltian/thingsee-one-the- https://en.wikipedia.org/wiki/Personal_digital_assistant
smart-developer-device-for-mobile
[28] C. Simmonds, "Embedded Linux timeline", 26 February
[14] "Flight Controller (Autopilot) Hardware", DroneCode, 23 2023, https://2net.co.uk/embedded-history
February 2023, https://docs.px4.io/main/en/flight_controller/

www.embedded-world.eu
[29] "Linux Router Project", Wikipedia, Wikimedia [41] "Xiaomi launches a new IoT Software Platform Xiaomi
Foundation, 25 February 2023, Vela based on NuttX OS", GizmoChina, 24 February 2023,
https://en.wikipedia.org/wiki/Linux_Router_Project https://www.gizmochina.com/2020/11/05/xiaomi-launches-a-
new-iot-software-platform-xiaomi-vela-based-on-nuttx-os/
[30] J. Paradis, "Porting Linux to the DEC Alpha",
https://www.linuxjournal.com/article/1177 [42] "Enterprise-Grade IoT Full .NET, Real Embedded Secure
& Scalable", Wilderness Labs, 24 February 2023,
[31] L. Torvalds, "LINUX's History", https://www.wildernesslabs.co/
https://www.cs.cmu.edu/~awb/linux.history.html
[43] "ICYMI: Meadow demos at NuttX Workshop 2022",
[32] S. Yegulalp, "Why GPL still gives enterprises the jitters", Wilderness Labs, 24 February 2023,
https://www.infoworld.com/article/2608340/why-gpl-still- https://blog.wildernesslabs.co/icymi-meadow-demos-at-nuttx-
gives-enterprises-the-jitters.html workshop-2022/

[33] Guardati, L., Casamassima, F., Farella, E., & Benini, L.


"Paper, pen and ink: an innovative system and software
framework to assist writing rehabilitation," In W. Nebel & D.
Atienza (Eds.), Proceedings of the 2015 Design, Automation
& Test in Europe Conference & Exhibition, DATE 2015,
Grenoble, France, March 9-13, 2015 (pp. 1473–1478). ACM.
http://dl.acm.org/citation.cfm?id=2757153

[34] Wei, H., Shao, Z., Huang, Z., Chen, R., Guan, Y., Tan, J.,
& Shao, Z. (2016). RT-ROS: A real-time ROS architecture on
multi-core processors. Future Generation Computer Systems,
56, 171–178.
https://doi.org/https://doi.org/10.1016/j.future.2015.05.008

[35] Staschulat, J., Lange, R., & Dasari, D. N. (2021). Budget-


based real-time Executor for Micro-ROS. arXiv.
https://doi.org/10.48550/ARXIV.2105.05590

[36] Pessacg, F., Nitsche, M., Teijeiro, A., Martın, D., &
Cristoforis, P. D. (2017). Open-source embedded framework
for unmanned ground vehicle control using CIAA. 2017 Eight
Argentine Symposium and Conference on Embedded Systems
(CASE), 1–6. https://doi.org/10.23919/SASE-
CASE.2017.8115372

[37] L. Meier, D. Honegger, and M. Pollefeys, “PX4: A node-


based multithreaded open source robotics framework for
deeply embedded platforms,” 2015 IEEE ICRA, pp. 6235–
6240, 2015.

[38] A. Bergmann, "The future of 32-bit Linux", Online,


https://lwn.net/Articles/838807/

[39] M. Larabel, "Linux Kernel Drops Support For Old Intel


386 CPUs", Online,
https://www.phoronix.com/news/MTI0OTg

[40] "Modular Moto Z Android phone supports DIY and RPi


HAT add-ons", LinuxGizmos.com, 24 February 2023,
https://linuxgizmos.com/modular-moto-z-android-phone-
supports-diy-and-rpi-hat-add-ons/

You might also like