NuttX RTOS for PinePhone: What is it?

đź“ť 23 Mar 2023

Apache NuttX RTOS on PinePhone

Apache NuttX RTOS on PinePhone

(Watch the Demo on YouTube)

Over the past 5 months, we ported to Pine64 PinePhone a different kind of Operating System… Apache NuttX RTOS

(RTOS for Real-Time Operating System)

Let’s talk about NuttX for PinePhone: What is it? Why are we doing this? How will we use it?

NuttX Terminal for PinePhone

NuttX Terminal for PinePhone

1 Smaller and Simpler

What’s Apache NuttX RTOS?

Think Linux, Ubuntu, Manjaro, Arch, … But a lot smaller and simpler!

NuttX is a tiny operating system (10 MB) that boots on a microSD Card and provides a Command-Line Interface for developers. (Pic above)

(Full build in 2.5 minutes on a 10-year-old MacBook Pro)

Why “Real-Time”?

It’s a Real-Time Operating System (RTOS) because NuttX was created for tiny microcontrollers: STM32, nRF52, BL602, ESP32, …

That won’t run a General Purpose Operating System. (Like Linux)

So now we have “upsized” NuttX for Arm64 Smartphones.

Is NuttX a Daily Driver for PinePhone?

Not yet, NuttX won’t make phone calls and send text messages. It might become a Daily Driver someday… If we put a lot of work into it.

Right now it’s probably more suitable for Education: Learning what happens when a Smartphone boots, how it renders graphics on the LCD Display.

And for folks who wish to tinker Bare Metal on PinePhone.

(Turning NuttX into Daily Driver might be an interesting student project!)

Does NuttX support X11? Wayland?

Nope, only LVGL is supported. (Pic at the top)

Touch Input works fine with LVGL Apps on PinePhone.

(Watch the Demo on YouTube)

Will it run Linux apps?

Sadly nope. But NuttX is based on POSIX, so some apps might compile for NuttX.

Let’s talk about NuttX for Learners…

NuttX Display Driver for PinePhone

NuttX Display Driver for PinePhone

2 Smartphone Education

Is NuttX good for learning the internals of Smartphones?

Check out the 21 articles covering everything inside-out about NuttX on PinePhone: GPIO, UART, USB, Framebuffer, LCD Panel, Touch Panel, Boot Sequence, LVGL Graphics, Terminal App (pic below)…

And esoteric (but essential) topics too: Display Engine, MIPI Display Serial Interface, Generic Interrupt Controller, USB EHCI, Arm64 Emulation, Reduced Serial Bus, Power Management Integrated Circuit, …

(Perfect for Bedtime Reading!)

So you envision a classroom of students, cracking open their PinePhones to experiment with NuttX?

Yeah possibly? I taught Operating Systems in school… I wished we could use our phones as a Teaching Tool.

(For Retro Fans: NuttX is probably more MINIX than Linux)

Flow of LVGL Terminal for PinePhone on Apache NuttX RTOS

Can we take the NuttX source code and build our own super duper Custom PinePhone? (Maybe sell it?)

Yep please feel free to take the source code and do everything with it! The source code is Apache Licensed.

But please drop us a note to tell us if you’re using the code in your project… We’re curious to know if anyone finds our work useful!

Where did the code come from?

We created the code based on the official docs for the Allwinner A64 SoC. But some parts of Allwinner A64 are poorly documented. (Like the Display Engine)

A sizeable chunk of our code was Reverse Engineered from the p-boot Bootloader, by observing which Hardware Registers it uses.

The NuttX Community has added new drivers for Allwinner A64 SoC, like for I2C.

(We welcome your contribution to NuttX!)

Is Apache paying you to do this?

I’m proud to volunteer as a member of the Apache NuttX Project Management Committee.

I’m not paid by Apache Software Foundation. But I’m extremely grateful to my GitHub Sponsors for supporting my work on PinePhone Education!

If we’re keen to boot NuttX on our PinePhone, please read on…

Bootable microSD for PinePhone

Bootable microSD for PinePhone

3 Boot NuttX

(Watch the Demo on YouTube)

Let’s make a Bootable microSD that will start NuttX on our PinePhone…

  1. Download the PinePhone Jumpdrive Image pine64-pinephone.img.xz from…

    dreemurrs-embedded/Jumpdrive

    Write the downloaded image to a microSD Card with Balena Etcher or GNOME Disks.

  2. Download Image.gz from the NuttX Release…

    Image.gz: NuttX Image for PinePhone

    (If we prefer to build NuttX ourselves: Follow these steps)

  3. Copy the downloaded Image.gz and overwrite the file on the microSD Card.

    (Pic above)

  4. Insert the microSD Card into PinePhone and power up PinePhone.

    NuttX boots on PinePhone and shows a Test Pattern.

    (Very briefly)

  5. The LVGL Terminal App appears on PinePhone! (Like this)

    Enter help to see the available commands.

    (Watch the demo on YouTube)

  6. Scrolling and swiping won’t work right now, we’re fixing this.

    (More about this)

For developers who prefer to run NuttX Commands over a Command-Line Interface (with a Serial Debug Cable), please check out the instructions here…

NuttX Command-Line Interface for Developers

NuttX Command-Line Interface for Developers

Many Thanks to my GitHub Sponsors for supporting my work! NuttX for PinePhone wouldn’t have been possible without your support.

Got a question, comment or suggestion? Create an Issue or submit a Pull Request here…

lupyuen.github.io/src/what.md

NuttX on PinePhone with a Touchscreen App

NuttX on PinePhone with a Touchscreen App