Pinebook Pro running VSCode, connected to PineTime Smart Watch. Shot with Sony NEX-7

My First Week As Embedded FOSS Advocate

Lunar New Year has always been a depressing period for me… The old eccentric uncle who is strangely single… And has nothing in common with the rest of the family.

I have just published some tutorials on coding, building, flashing and debugging the firmware for PineTime Smart Watch. But never had the opportunity to interact with real PineTime Learners around the world.

Over the Lunar New Year holidays I decided to fully immerse myself into the PineTime Community on Matrix and Discord. Plus Twitter, LinkedIn and Mastodon.

It has been one week of intense online debates across many topics… Over bits of beef patty and 糯米鸡, inside and outside IKEA… Even during night time and weekends.

Mostly positive debates, but some were baffling. I found myself defending my use of FOSS (we’ll see why later)… And we had slightly different definitions of FOSS. Here’s what happened in my first week Fighting For FOSS…

Is PineTime Teachable?

Apple Watch is amazing. What if we could open it up, fully understand how it ticks?

Sadly we can’t.

Have humans become so greedy for profit… That we have forgotten how to teach one another and advance our species?

That’s my mission for PineTime: Create a gadget that’s as useful as Apple Watch... But yet lets you go deep and understand every piece of hardware and software inside.

Free and Open-Source Software (FOSS) is the only way to accomplish this.

Is PineTime Usable?

Unfortunately we need to manage priorities. Given two options…

  1. Implement a Bootloader with built-in Bluetooth that will be shipped with PineTime, that will download any RTOS firmware for PineTime and flash it into ROM for booting (and rollback if unsuccessful)
  2. Or implement a design that allows watch apps to be developed and flashed independently from the RTOS firmware

I would choose Option 2.

Option 1 is something we can build and when it works… That’s the end of it. It’s a feature that limits itself.

Option 2 offers more possibilities because watch apps become so much easier to create. Maybe non-coders will become enticed to create their own watch faces… Or even create a watch app that saves lives.

Why Embedded Rust? Not Embedded C or MicroPython?

I could teach Embedded C to all PineTime Learners… But then they would eventually run into crashing problems with bad pointers.

I could teach MicroPython or Embedded JavaScript… But my learners would be disappointed to discover that commercial gadgets like Apple Watch don’t run on MicroPython and JavaScript.

Rust is a good compromise. And if my learners insist on learning C, it’s quite easy to convert Embedded Rust to Embedded C, line by line.

Embedded Rust vs Rust Embedded

Is no_std a pun for unsafe sex? Always wondered.

“Rust Embedded” is the plumbing that connects to Bare Metal… It makes the Microcontroller usable by apps.

But does this plumbing connect to anything above? Since we don’t have any Rust watch apps today… How will we know what plumbing to build for the apps?

My job is to give everyone the tools and the skills to create “Embedded Rust” watch apps today. Our embedded platform needs to be reliable and stable today, so that we don’t cheese off any learners. (Sorry BBC micro:bit)

And today I would select Mynewt, RIOT-OS or Zephyr to run that reliable and stable platform for learning.

Never mind that the plumbing isn’t Rusty today… One day Rust Embedded shall eventually meet Embedded Rust.

But today, I’m ecstatic that one human every day (maybe more) discovers Rust for the very first time… on a watch.

Graphical Development Tools vs Command Line

Command-Line Tools have been around for 50 years. They have been thoroughly documented. Most of us Embedded Pros know how to code, build, flash and debug PineTime by Command Line: vi, gcc, openocd, gdb, …

But what about Graphical Development Tools? Hardly any good FOSS graphical tools exist for Embedded Development.

If I were commanding USS Enterprise, I would need lots of graphical dashboards, touchable buttons and wavy gestures… That’s how my mind works, especially when coding and debugging Rust. Not with a long stream of textual commands.

Could there be other people who share my mindset? Maybe it’s because I’m Half-Asian? And because I think some technical concepts are better communicated across cultures with icons instead of text?

I’m super glad that the PineTime Community agrees that Choice and Inclusiveness are important. So I’m adding FOSS graphical tools for PineTime, like VSCode.

Anybody From The East?

It’s easy to blame China for inventing the Coronavirus over the Chinese New Year that’s delaying the shipment of PineTime worldwide…

But have we ever considered gadget makers in the East as sisters and brothers of the PineTime family?

欢迎您加入 PineTime 社群 😀

If you’re in the East: Are there any Rust concepts that you don’t understand because of bad translation?

Do you hesitate to share your PineTime opinions openly and to critique others… Because it’s not done that way in the East?

I’m always here to help…

我永远支持您 👍

Windows Is Terrible For FOSS

My shell scripts for building, flashing and debugging PineTime firmware are now used by many learners on Raspberry Pi, Windows, macOS, Linux (x64), Pinebook Pro…

And Windows is stressing me out!

For some unknown reason, the Rust Compiler complains about missing Core Library, which is simply impossible. Happens only on one specific PC, unreproducible on my PC.

The solution: Build the Rust app on Windows Subsystem for Linux (WSL). Then head back to plain Windows for flashing and debugging PineTime.

The irony: I had earlier converted the build script line by line from Bash to Windows CMD… Because WSL was too slow for building Rust apps.

I can’t drop support for Windows because I need to be Inclusive and accommodate most learners. But Windows just doesn’t play nice with FOSS.

I have no solution for supporting PineTime on Windows… Windows will be the death of me when I’m teaching PineTime!

(I suffer from severe hypertension)

Raspberry Pi Is Perfect For FOSS

Today most PineTime Learners flash their watches with a Raspberry Pi without any problems. (Assuming they’re running Raspbian)

It used to fail intermittently. OpenOCD was sending flashing commands to PineTime via GPIO Bit Banging. Bit Banging requires precise timing and fails when our Pi is busy multitasking.

So I dug deep into OpenOCD, hacked it to send SWD flashing commands over our Pi’s (speedy and reliable) SPI port. Push out the fork, problem solved!

(I dare you… Try building OpenOCD on Windows… Impossible!)

May I make a minor complaint about Pi? Too many GPIO pins… One wrong pin and PineTime goes Poof!

So I deliberately spaced out the pins with the magic number 341: Start at the left, skip 3 pins, then 4 pins, then 1.

Today PineTime Learners are coding, building, flashing AND debugging Rust firmware with VSCode on Raspberry Pi. Just like the pros on expensive workstations! Perfect!

Hi Jim Are You Still Tickling?

Unfortunately, FOSS fails Pi.

OpenOCD depends on a software module called jimtcl. During the week a few PineTime Learners alerted me that their OpenOCD build failed, because of hosting problems with the jimtcl repository.

Should we scold Jim for not maintaining the repository? But it’s Free Open Source Software… Shouldn’t we pay Jim instead to keep on Tickling?

Yes this interdependency complicates FOSS projects. In the meantime, I scrambled and shared with the learners a binary distribution of OpenOCD (hacked with SPI), built just for Raspberry Pi.

Which leads us to another concern…

Source vs Binary Distribution

We could distribute our PineTime tools in source form (without binaries) to PineTime Learners.

But it could mean a wonky and frustrating experience for learners, like with jimtcl. We don’t want to disengage our learners… It took so much effort to get them interested… We’re not letting them go!

For Windows, source distribution is simply impossible. Because FOSS tools like OpenOCD are impossible to build on Windows.

Or we could distribute our PineTime tools as binaries. Which raises alarm bells when we already got so many IoT Security Vulnerabilities around us.

Building binaries and packaging them for each platform also requires effort on my part. (I’m doing that for Windows now) It’s much easier for me to push out the source files without binaries.

Conundrum. How?

FOSSy Vibes

With FOSS there’s No Contract, No Commitment. No Service Level Agreement, No Quality Of Service.

When adopting a piece of FOSS I need to go by Vibe and Gut Feel. Whichever FOSS Community gives out the best vibes… I’ll buzz there right away. (Thankfully I’m 100% right on PineTime!)

Apache Mynewt OS: They seem stable, reliable, friendly. They don’t have problems with me doing strange experiments, like running Rust on Mynewt! So today I’m teaching PineTime with Rust on Mynewt.

Zephyr OS: Bigger than Mynewt. Somewhat cold, somewhat aloof. But that’s to be expected from Corporates. Don’t feel the vibe yet.

RIOT-OS: Discovered them very recently, because I was crazy enough to run a RIOT-OS Live Debugging Webstream on YouTube. I feel very good vibes… Though I’m still trying to understand Europeans ;-)

Rust: Somewhat cold, aloof, critical, pontificated. And I don’t understand 50% of the Rust articles posted on Reddit! But I have a strong hunch that Rust can save us from the bad Embedded C coding that I see everywhere. So whether the Rust Community likes me or not, I’m 100% on board!

OpenOCD and jimtcl: I’m sure Jim is a very nice person… just stuck temporarily in an unfortunate situation 😀

That’s my wishy washy justification for adopting these projects. Not scientific, but that’s FOSS for you!

Is VSCode Proprietary?

Microsoft has injected some Secret Sauce into VSCode… But we may choose to use the Community Builds of VSCode that don’t have any Microsoft Secret Sauce inside and won’t expose our coding habits to Microsoft.

In my opinion, the Community Build of VSCode is FOSS and Not Proprietary. Some folks disagree.

My plea to the VSCode Community: Please rename VSCode!

Most people I’ve spoken with agree that VSCode is a terrible name… Because it has nothing to do with Visual Studio. And it links VSCode back to Microsoft.

(Some folks also think that “Visual” anything automatically associates with Microsoft… Thus VSCodium is also a terrible name)

So if nothing is done about the unfortunate naming of VSCode with its negative connotations… We shall be forced to fork VSCode and give it a more positive name… Like PineCode! ;-)

Bad New For Microsoft

In spite of all their open source initiatives, Microsoft is giving out Massively Bad Vibes, according to my heated discussions with the community beyond PineTime.

I hear this often when discussing VSCode: “Microsoft is up to no good”

Even though we can inspect every bit of code in the Community Build of VSCode… And discover exactly what no good Microsoft is up to.

(I think Microsoft’s “Evil Plan” for VSCode is to put JetBrains out of business… They certainly won me over!)

So Hello Corporates at Microsoft: You’re still giving out Cold, Evil Vibes in spite of the great work you’ve done. Can you do something about this please? Because it’s affecting my plan to teach proper embedded coding to the world with VSCode…

Your IoT Learning Journey

Is it really possible to learn IoT with only a watch?

I have organised my previous articles into a Learning Pathway that brings PineTime Learners though a list of basic embedded concepts like I2C, SPI, LED display controllers, touch controllers, …

Check the articleDebug Rust+Mynewt Firmware for PineTime on Raspberry Pi under the section “Your IoT Learning Journey”

For learners who are more advanced, I have created difficult PineTime Challenges to stretch their minds. They may be found in the same section, “Your IoT Learning Journey”

I’m still experimenting… Lemme know what you think!

FOSS vs Proprietary

So now you know my position on FOSS. In spite of what some folks think… I Really Give A D*mn About FOSS! Because without FOSS I could never teach IoT to the whole world with PineTime.

Which explains why I prefer Raspberry Pi over Segger J-Link for flashing and debugging PineTime. (Are $2 ST-Link clones considered FOSS?)

And why I prefer Apache NimBLE’s Bluetooth Stack over Nordic SoftDevice… Because some bright kid out there may have a crazy idea to overhaul the entire Bluetooth Stack into something much more meaningful!

In spite of a long, rough and hectic week… This Lunar New Year is probably my best one ever! I’m extremely grateful to…

If you would like to join me in teaching IoT the FOSSy way with PineTime, chat with me on the PineTime Community on Matrix! Just ask for lupyuen