NuttX RTOS for PinePhone: The First Year

📝 21 Jun 2023

Apache NuttX RTOS for Pine64 PinePhone

(Watch the Presentation on Google Drive)

One year ago we started porting Apache NuttX RTOS (Real-Time Operating System) to Pine64 PinePhone

Let’s look back and talk about…

Roadmap for PinePhone NuttX

§1 Roadmap for PinePhone NuttX

The pic above shows the features we planned for NuttX on PinePhone…

?Not Yet
✓ ?Partially Implemented

Over the past year we’ve carefully documented the entire porting process in a series of 24 articles (enough to fill a book)…

(Yep we targeted 1 article every 2 weeks!)

Why did we do all this?

  1. We ported NuttX RTOS to PinePhone as an Educational Experiment.

    NuttX on PinePhone could become a Teaching Tool for learning the inner workings of a Smartphone.

  2. Some folks think that NuttX might become a Benchmarking Tool.

    How fast can PinePhone actually run? Just run barebones real-time NuttX on PinePhone and measure the performance… Without any unnecessary overheads!

Is NuttX on PinePhone a Daily Driver?

We’re not quite ready for that, we’ll see why in a while.

Let’s begin with the Touchscreen Features…

PinePhone Touchscreen

§2 PinePhone Touchscreen

We’re incredibly fortunate that PinePhone’s Touchscreen runs OK with NuttX, after we built these features (pic above)…

Today with NuttX for PinePhone, we can create Touchscreen Apps that will work like a regular Smartphone App!

(But we’re not yet a Complete Smartphone, we’ll come back to this)

Let’s talk about the Sensors inside PinePhone…

PinePhone Sensors

§3 PinePhone Sensors

Our support for PinePhone’s Sensors is a little spotty…

Can we build the missing drivers with NuttX?

Most certainly! Though to me it’s starting feel a bit like “grinding”. (Like the pic at the top of the article)

But it would be a highly educational experience for Embedded Learners!

Let’s talk about the key component inside PinePhone…

LTE Modem

§4 LTE Modem

What makes PinePhone a Phone?

It’s the 4G LTE Modem inside PinePhone! Let’s walk through the features for Phone Calls, SMS and GPS (pic above)…

With the LTE Modem partially supported, we could build a Feature Phone…

Feature Phone

§5 NuttX Feature Phone

We’ve done quite a bit with the LTE Modem…

Are we a Feature Phone yet?

Almost! Let’s talk about the User Interface, Phone Calls and SMS needed for a Feature Phone (pic above)…

It’s sad that we haven’t done PCM Audio. It would’ve been a terrific educational exercise. And we’d have a working Feature Phone!

Let’s head back to our question about NuttX as a Daily Driver…


§6 NuttX Smartphone

OK we’re almost a Feature Phone…

But are we a Smartphone yet?

Sorry we’re not quite ready to be a Smartphone (pic above), because…

If we had the energy (and patience), we should definitely do LoRa with Meshtastic on PinePhone!

Our Daily Driver also needs these features…

Core Features

§7 Core Features

What else do we need for a Smartphone…

Have we missed any Core Features?

Yeah these are the Core Features needed to complete our Smartphone OS (pic above)…

Some of these features are probably supported by NuttX already. But we need to test thoroughly on PinePhone. (Hence the PinePhone Emulator)

Unfortunately we’re running out of time…

Rolling to RISC-V

§8 Rolling to RISC-V

  1. Fixing up NuttX for PinePhone…

    Surely we can do that for the next couple of months?

    Allwinner A64 SoC was released in 2015… That’s 8 years ago!

    Before Allwinner A64 becomes obsolete, maybe we should consider a newer device?

    (NuttX might still run on other Allwinner A64 handhelds)

  2. Like PinePhone Pro? Or PineTab 2?

    Well that’s more of the same same Arm64, innit?

    Just follow the exact same steps we’ve meticulously documented for NuttX on PinePhone…

    And NuttX will (probably) run on any Arm64 Device: iPhone, Samsung Phones, Tablets, Gaming Handhelds, …

    (Like the super-impressive Mobile Linux ecosystem)

  3. So we’re moving from Arm64 to RISC-V?

    Yep! We have a fresh new opportunity to teach the RISC-V 64-bit Architecture from scratch.

    And hopefully RISC-V Devices will still be around after 8 years!

  4. We’re porting NuttX to a RISC-V Phone?

    Sadly there isn’t a RISC-V Phone yet.

    Thus we’ll port NuttX to a RISC-V Tablet instead: PineTab-V

  5. But PineTab-V isn’t shipping yet!

    That’s OK, we’ll begin by porting NuttX to the Star64 SBC

    Which runs on the same RISC-V SoC as PineTab-V: StarFive JH7110

    (Hopefully we have better docs and tidier code than the older Arm64 SoCs)

  6. Hopping from Arm64 to RISC-V sounds like a major migration…

    Actually we planned for this one year ago.

    NuttX already runs OK on the (64-bit) QEMU RISC-V Emulator. (Pic below)

    So the migration might not be so challenging after all!

  7. Why not FreeRTOS? Or Zephyr OS?

    Our objective is to teach the internals of PinePhone with a very simple Operating System. NuttX is super tiny, so it works just fine!

    FreeRTOS is too bare-bones though. We’d need to build a bunch of drivers from scratch: Display, Touch Input, USB, LVGL, Accelerometer, … NuttX has many drivers that we need.

    Zephyr OS has plenty of code contributed by large companies, it’s great for writing commercial, industrial-grade firmware. But it might be too complex for learning about the internals of a smartphone.

  8. Why Pine64 gadgets? Are they sponsored?

    I bought my own PinePhone for porting NuttX. And I’ll do the same for the RISC-V Gadgets.

    Pine64 sells affordable phones and tablets for devs and learners. If you know of similar companies, please lemme know! 🙏

  9. Why not collaborate with the Pine64 Community on Matrix or Discord?

    I tried… But my sleeping hours got out of whack.

    (I’m in Singapore, time zone is GMT+8 hours)

    Pine64 Forum is probably the best place to catch me for a discussion.

  10. Why not spend a bit more time on PinePhone or PinePhone Pro?

    I’m already in my fifties and I have severe hypertension (when I get stressed)…

    I’m carefully planning my remaining days as IoT Techie and Educator :-)

    (And possibly Sourdough Hacker)

  11. What will happen to NuttX for PinePhone?

    I’m still keen to promote NuttX as a teaching tool for learning the internals of PinePhone!

    If you know of any schools that might be interested, please lemme know! 🙏

Apache NuttX RTOS on 64-bit QEMU RISC-V Emulator

Apache NuttX RTOS on 64-bit QEMU RISC-V Emulator

§9 What’s Next

NuttX on PinePhone has been an incredibly rewarding journey, thanks to the awesome NuttX and Pine64 Communities!

Please join me in the next article, as we begin our exploration of Apache NuttX RTOS on 64-bit RISC-V

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

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

§10 Notes

  1. To protect PinePhone’s MicroSD Connector from wearing out after too much MicroSD Swapping, we could use the PinePhone MicroSD Extender.