📝 21 Jun 2023
(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…
The Features that we’ve implemented
Our Plans for the future
Why we might move to a RISC-V Tablet!
The pic above shows the features we planned for NuttX on PinePhone…
✓ | Implemented |
? | 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?
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.
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…
We’re incredibly fortunate that PinePhone’s Touchscreen runs OK with NuttX, after we built these features (pic above)…
MIPI Display Serial Interface (DSI) transmits pixel data to the LCD Panel
Allwinner Display Engine renders bitmap graphics and pushes the pixels over MIPI DSI
NuttX Framebuffer exposes the rendering API to NuttX Apps
I2C Touch Panel detects Touch Input from the LCD Panel
LVGL Graphics Library renders User Interfaces and handles Touch Input
LVGL Terminal is a Touchscreen App that we created with LVGL
WebAssembly Simulator previews Touchscreen Apps in the Web Browser
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…
Our support for PinePhone’s Sensors is a little spotty…
Accelerometer and Gyroscope will detect PinePhone motion and orientation
Magnetometer, Light and Proximity Sensors are not yet supported
Front and Rear Cameras are not supported
Power Management is partially implemented.
PinePhone’s LCD Display and Sensors will power on correctly, but…
Battery Charging and Sleep Mode are not done yet
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…
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)…
Outgoing Calls and Outgoing SMS are OK, but…
PCM Audio is not implemented, so we won’t have audio
Incoming Calls and Incoming SMS: Not yet
UART Interface is ready for Voice Call and SMS Commands
USB EHCI Controller is partially done
USB OTG Controller: Not started
With the LTE Modem partially supported, we could build a 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)…
We’ve created a Feature Phone UI as an LVGL Touchscreen App
That also runs in the Web Browser with WebAssembly
We need to integrate Outgoing Calls and Outgoing SMS into our Feature Phone App
Though PCM Audio, Incoming Calls and Incoming SMS are still missing
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…
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…
Wireless Networking is completely missing: Bluetooth LE, WiFi and Mobile Data
(Which will require plenty of coding)
LoRa Networking with the LoRa Add-On Case will be really interesting, but sadly missing today
(Mesh Networking with Meshtastic would be awesome)
USB EHCI and OTG won’t work either
If we had the energy (and patience), we should definitely do LoRa with Meshtastic on PinePhone!
Our Daily Driver also needs these 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)…
Multiple CPUs are not working yet, we’re running on a Single Core today
Memory Management will be needed for Virtual Memory and to protect the NuttX Kernel
App Security needs to be implemented (similar to SELinux and AppArmor)
eMMC and microSD Storage won’t work (because we’re running in RAM)
GPU will be needed for serious graphics
PinePhone Emulator will be super helpful for testing the above features
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…
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?
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, …
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!
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
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)
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!
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.
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! 🙏
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.
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 :-)
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
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…
“64-bit RISC-V with Apache NuttX Real-Time Operating System”
“Apache NuttX RTOS for Pine64 Star64 64-bit RISC-V SBC (StarFive JH7110)”
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…
lupyuen.github.io/src/pinephone2.md