1# NuttX RTOS 2 3## What is NuttX? 4 5[NuttX](https://nuttx.apache.org/) is a mature and secure real-time operating system (RTOS) with an emphasis on technical standards compliance and small size. 6It is scalable from 8-bit to 64-bit microcontrollers and microprocessors and compliant with the Portable Operating System Interface (POSIX) and the American National Standards Institute (ANSI) standards and with many Linux-like subsystems. 7The best way to think about NuttX is to think of it as a small Unix/Linux for microcontrollers. 8 9### Highlights of NuttX 10 11- **Small** - Fits and runs in microcontrollers as small as 32 kB Flash and 8 kB of RAM. 12- **Compliant** - Strives to be as compatible as possible with POSIX and Linux. 13- **Versatile** - Supports many architectures (ARM, ARM Thumb, AVR, MIPS, OpenRISC, RISC-V 32-bit and 64-bit, RX65N, x86-64, Xtensa, Z80/Z180, etc.). 14- **Modular** - Its modular design allows developers to select only what really matters and use modules to include new features. 15- **Popular** - NuttX is used by many companies around the world. Probably you already used a product with NuttX without knowing it was running NuttX. 16- **Predictable** - NuttX is a preemptible Realtime kernel, so you can use it to create predictable applications for realtime control. 17 18--- 19 20## Why NuttX + LVGL? 21 22Although NuttX has its own graphic library called [NX](https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=139629474), LVGL is a good alternative because users could find more eye-candy demos and they can reuse code from previous projects. 23LVGL is an [Object-Oriented Component Based](https://blog.lvgl.io/2018-12-13/extend-lvgl-objects) high-level GUI library, that could fit very well for a RTOS with advanced features like NuttX. 24LVGL is implemented in C and its APIs are in C. 25 26### Here are some advantages of using LVGL in NuttX 27 28- Develop GUI in Linux first and when it is done just compile it for NuttX. Nothing more, no wasting of time. 29- Usually, GUI development for low level RTOS requires multiple iterations to get things right, where each iteration consists of **`Change code` > `Build` > `Flash` > `Run`**. 30Using LVGL, Linux and NuttX you can reduce this process and just test everything on your computer and when it is done, compile it on NuttX and that is it. 31 32### NuttX + LVGL could be used for 33 34- GUI demos to demonstrate your board graphics capacities. 35- Fast prototyping GUI for MVP (Minimum Viable Product) presentation. 36- visualize sensor data directly and easily on the board without using a computer. 37- Final products with a GUI without a touchscreen (i.e. 3D Printer Interface using Rotary Encoder to Input data). 38- Final products with a touchscreen (and all sorts of bells and whistles). 39 40--- 41 42## How to get started with NuttX and LVGL? 43 44There are many boards in the [NuttX mainline](https://github.com/apache/incubator-nuttx) with support for LVGL. 45Let's use the [STM32F429IDISCOVERY](https://www.st.com/en/evaluation-tools/32f429idiscovery.html) as an example because it is a very popular board. 46 47### First you need to install the pre-requisites on your system 48 49Let's use the [Windows Subsystem for Linux](https://acassis.wordpress.com/2018/01/10/how-to-build-nuttx-on-windows-10/) 50 51```shell 52$ sudo apt-get install automake bison build-essential flex gcc-arm-none-eabi gperf git libncurses5-dev libtool libusb-dev libusb-1.0.0-dev pkg-config kconfig-frontends openocd 53``` 54 55### Now let's create a workspace to save our files 56 57```shell 58$ mkdir ~/nuttxspace 59$ cd ~/nuttxspace 60``` 61 62### Clone the NuttX and Apps repositories: 63 64```shell 65$ git clone https://github.com/apache/incubator-nuttx nuttx 66$ git clone https://github.com/apache/incubator-nuttx-apps apps 67``` 68 69### Configure NuttX to use the stm32f429i-disco board and the LVGL Demo 70 71```shell 72$ ./tools/configure.sh stm32f429i-disco:lvgl 73$ make 74``` 75 76If everything went fine you should have now the file `nuttx.bin` to flash on your board: 77 78```shell 79$ ls -l nuttx.bin 80-rwxrwxr-x 1 alan alan 287144 Jun 27 09:26 nuttx.bin 81``` 82 83### Flashing the firmware in the board using OpenOCD: 84```shell 85$ sudo openocd -f interface/stlink-v2.cfg -f target/stm32f4x.cfg -c init -c "reset halt" -c "flash write_image erase nuttx.bin 0x08000000" 86``` 87 88Reset the board and using the 'NSH>' terminal start the LVGL demo: 89```shell 90nsh> lvgldemo 91``` 92 93## Where can I find more information? 94 95- This blog post: [LVGL on LPCXpresso54628](https://acassis.wordpress.com/2018/07/19/running-nuttx-on-lpcxpresso54628-om13098/) 96- NuttX mailing list: [Apache NuttX Mailing List](http://nuttx.incubator.apache.org/community/) 97 98