Search | Sailfish OS | Running | PineTime | All Posts

Interview with Lup, creator of PineTime's bootloader

June 05, 2021 — Nico Cartron

After the interview I did with JF, I am now discussing with Lup Yuen, who created the first bootloader for our beloved PineTime.


About you

Nico: Hi Lup, it's a pleasure doing this interview with you! For those who don't know you, could you introduce yourself?

Lup: Thanks Nico! I'm Lup (rhymes with "up") from sunny Singapore. I worked in Enterprise IT for 25 years and taught IoT for 5 years. I'm taking a break from work due to bad health (hypertension). Nowadays I'm coding and writing about open-source IoT.

Genesis:

Nico: How did you encounter the PineTime initially? Were you already a Pine64 enthusiast?

Lup: I have done lots of coding and writing about STM32 Blue Pill. Just as I started coding on Nordic nRF52, the kind folks at Pine64 sent me a PineTime for evaluation. (Thanks TL!) And that's how I started coding on PineTime.

That was the first time I've heard of Pine64, and I'm really glad I'm part of the Pine64 Community. Pine64 cares about making products that we can take apart and learn what makes them tick.

Nico: You started really early, since the watch had barely got announced, first dev kits sent, and the documentation almost inexistent. What motivated you to take on such a challenge and hop on a bus with no driver and no clear destination?

Lup: Moving from STM32 Blue Pill to PineTime was sheer pleasure... So much RAM and Flash Memory, plus a touchscreen! I had lots of fun making things (like Rust) work on PineTime, and writing about my experiences. Challenges won't stop us when we're having fun, I guess?

The bootloader:

Nico: You started the project alone, and worked without much help for most of the bootloader development period; how did you start from a "blank page": did you already have an idea of what you wanted to implement and how to do it, or did you learn walking by crawling?

Lup: Fortunately for me the page wasn't totally blank. When PineTime was released, the Nordic nRF52832 SoC was already well-known in the embedded world. And MCUboot was one of the popular bootloaders for nRF52832. So I reused MCUboot on PineTime with minimal modifications.

Nico: I admire the quality and depth of the documentation you've produced for this project - what does it take to do that? I mean, a lot of developers are not super interested in documenting their work, and would rather spend time coding than writing documentation - why do you do that? Is that so that others can benefit from it/reuse it? Or to help you make progress in the project/not forget some things?

Lup: I taught IoT and Embedded Programming for 5 years. My students (part-time adult learners) had difficulty finding open-source embedded code that was adequately documented. And so many embedded concepts are important but poorly understood: Multitasking, Memory Utilisation, Bootloaders, Bluetooth, LoRa, etc.

I decided to take on the mission of helping others understand every single embedded thing that I do. My lasting legacy for the IoT world... I hope?

Nico: The bootloader is a pretty low-level piece of software - could you summarise in a few words what its goal is, and in the case of the PineTime, how important it is?

Lup: The bootloader is the first thing that runs when we power on our PineTime watch. It updates the PineTime firmware (like InfiniTime) and it rolls back the firmware if the new firmware fails. The bootloader is a Mission Critical firmware module: If it fails to boot, our watch gets bricked.

Nico: I'm not asking whether there were challenges, cause I know it was the case - but if you were to describe us the 2 or 3 most challenging tasks you had to deal with when building the bootloader for PineTime, what would they be?

Lup: The thing about the PineTime bootloader that truly terrifies me: it needs to be 100% reliable or PineTime will get bricked during updates. I had to rely on the wisdom of the MCUboot creators and change MCUboot as little as possible. And we did lots of testing: firmware upgrade, rollback, disrupted upgrade, etc.

Nico: Such a project is a bit special, since it's really low-level development - would you have any advice to give to a junior developer who'd like to get his hands dirty on such a project?

Lup: I'm sad that I can longer maintain the PineTime bootloader because of my bad health (hypertension) and my wrong timezone (Singapore). When making changes to the bootloader, we need to be mindful: "Could this change possibly brick the watch?" I have written a few articles about the bootloader, I hope they will help you understand why the bootloader was designed that way. Please test the bootloader rigorously... The PineTime Community will help!

New project and moving forward:

Nico: Can you tell us more on what you're working on now? I think I've seen you playing with some LoRa stuff?

Lup: Yes! I have been coding and writing about LoRa on the BL602 RISC-V + WiFi SoC. I hope that people will feel inspired to create their own IoT gadgets with BL602, sending all kinds of meaningful sensor data wirelessly with LoRa. Check out my updates in The RISC-V BL602 Book

Nico: Are you still following PineTime and InfiniTime developments?

Lup: Most definitely! JF, Sravan, and the PineTime Community are doing an awesome job. I'm always happy to see the new things that they create.

Nico: One last question - are you using a PineTime yourself? :)

Lup: This will surprise most people... But I don't wear a watch! (I wore a watch only when serving my military reserve duty) Sadly I'm not wearing a PineTime now. When I start losing track of time... Perhaps!


Tags: PineTime


I don't have any commenting system, but email me (nicolas at ncartron dot org) your comments!
If you like my work, you can buy me a coffee!