Coffee Space


Flashing #PineTime

Preview Image


This covers part one of the process, where we setup the Orange Pi Zero and discuss some of the work required to make the project come together. More to come in the coming weeks as parts arrive.


This is to document my efforts in trying to flash the PineTime using an Orange Pi Zero I have laying around. This should be fun.

The purpose is to get it flashing the PineTime, we’ll worry about debugging, etc, at a later date. The ultimate goal is to get it in a position where I can close the case somehow and have the watch as a daily driver.

Orange Pi Zero Setup

I’m running the Orange Pi on Arbian - it’s more up to date than the official images, more open source and closer to Raspbian (the names are similar and everything).

Some details about the setup:

First step is to upgrade the OS:

0001 sudo apt-get update; sudo apt-get upgrade

This thing is a beast:

Device specifications

Next we want to try and turn on SPI, according to the docs this can be done via arbian-config:

0002 sudo armbian-config

Creates a display like so:

Armbian config

You want to edit system settings:

Armbian system config

And the hardware settings like so, to switch on the SPI:

Armbian system hardware config

You’ll now want to reboot to allow those settings and updates to come into affect.

NOTE: You may also need to add param_spidev_spi_bus=0 to /boot/armbianEnv.txt, apparently there is some legacy bug which will require another reboot.

Software Setup

To tackle the software aspect, we first look to write a generic flashing script and then look to wrap that around OpenOCD to use the SPI pins of the Orange Pi Zero.

Flashing Scripts

The basic concept here is that you have some device to flash your PineTime with, but it needs to be setup to actually flash the images. Lupyuen has done some great work in this space getting the Raspberry Pi to flash the PineTime, but we separate our work efforts as not to pile on top of the awesome rust efforts ongoing there. Step-in the start of PineTime Flash, as basic script to flash using a variety of SMBs.

The basic planned features are (lifted from the help command):

0003 check      Check dependencies
0004 device     Set the device type <DEV>
0005              DEVice:
0006                RPI3  Raspberry Pi 3
0007                OPIZ  Orange Pi Zero
0008 dump       Dump the contents of memory
0009 erase      Erase the device's currently memory
0010 flash      Flash the device <LOC> <BIN>
0011              LOCation:
0012                BOOT  Write image to boot memory
0013                APP   Write image to application memory
0014              BINary: Location of image to be flashed
0015 protect    Toggle device protection <STATE>
0016              STATE:
0017                ON   Turn memory protection on
0018                OFF  Turn memory protection off
0019 setup      Setup this flashing device
0020 target     Set the target device <TARG>
0021              TARGet:
0022                PTDEV  Pine Time v1 Dev

OpenOCD Extension

OpenOCD unfortunately won’t work out of the box, but again Lupyuen has made some great progress on this and I look to extend his work. The requirement here is a “rare” processor feature to have bi-directional SPI to support the ARM SWD protocol.

Next Steps

I attempted to solder the PineTime SWD header - but unfortunately the provided cable fell apart at the heat (~300 degrees Celsius) that I needed to solder the pins. I then attempted to bodge a cable together out of random things I happened to have around me during the lockdown, but the 1mm pitch proved too difficult to overcome. I have therefore ordered a JST female and male pairing connector/cable combo pack and hopefully I should be able to properly solder the PineTime SWD header.

Once this is done I can the test out the code for the Orange Pi Zero and potentially recommend that the JST connectors are added to future PineTime development.

After that I would be very interested in working on getting some basic apps up and running and turning this into a watch I would like to use. Personally I am yet to be convinced of Rust, but I quite like some of the C++ based efforts. Even being in a position to test different firmwares will very much make me feel better about being able to work on this project.