Beginner guide to the PineTime DevKit
Getting started with the PineTime DevKit
This is an introduction how to start embedded development with the PineTime DevKit for beginner.
To get started with the Pinetime you need next to the Pinetime first and foremost
- a computer to develop (Linux, MacOS, Windows)
- a device to connect your computer to the Pinetime,
- software to connect
- some firmware g to flash to the PineTime
- sticky tape to connect the back to the watch (no, this is not water tight)
This is a development Kit and not a functioning watch. One consequence is that the back of the watch can only be loosely put to the watch and then fixed with some tape or so. If you want to glue the back of the watch to the kit you need some way to access the internal SWD ports e.g. drill a hole into the back. So please mind that whatever you do this is not a normal digital watch.
It is important to note that the original PineTime software is read-write protected, to prevent people from nicking the original software. So before you can write any new firmware to the PineTime you have to remove the write protection. Note: This will remove the original PineTime software and can not be reversed. But the idea after all is to develop super cool new software for the PineTime anyway.
Connecting to the PineTime
There are several different ways to connect to the PineTime.
There is a device called Blackmagic Probe (BMP) that does include additional functionality so that you can connect to it directly using the debugger gdb, without the need of using openocd or something else to connect to the device.
You can buy the device here.
The firmware is generously open source so it is possible to install blackmagic to other devices. One device is the STM32 Bluepill and very popular as it is often very cheap and also comes with 4 pins on the board which allow to connect to the SWD PineTime interface without soldering.
To connect with the blackmagic-bluepill you can use the software gdb.
Thanks to some excellent research from Lupyuen it is possible and in fact quite convenient to use a Raspberry Pi to connect to the PineTime.
This should work with all models. Please note that older models had a different GPIO layout and you would have to use different pins.
- Guide to set up a Rpi to connect to the PineTime is here
To connect with the Raspberry Pi you can use OpenOCD
CMSIS-DAP compatible device
Link: github page
A ST-Link is a convenient way to connect to the PineTime. It’s a quite common device so that there is a lot of documentation and also cheap clones can be found. One thing to note is that a ST-Link as it is cannot remove the write protection of the original PineTime software, so one of the other devices is needed for that.
To connect with the ST-Link you can use OpenOCD.
There are a number of Segger J-Link devices to connect to the PineTime.
The cheapest is the J-Link EDU Mini. If you use a J-Link you need some sort of breakout board to connect from the J-Link cable to the PineTime connection cable like:
To use a J-Link you can use:
Flashing the first example (WIP)
Some PineTime developer kindly have provided pre-compiled binaries of PineTime firmware, so those can be used to flash a first example without the need to set up a complete development tool chain.
Check which port is used by BMP:
/dev/ACM0. Interestingly if you unplug the bluepill from USB and plug in again you might get a different number. However you always get two devices and you need to take the lover number.
1. Start gdb
In my case I have to start it with sudo to access /dev/ACM0
2. Connect to the BMP
target extended-remote /dev/ACM0
3. Search for the PineTimee
When you scan for the first time only on e device is shown, after the original firmware is erased two devices will be shown
In both cases connect to the first device
5. Erase original firmware (once)
Note When connecting for the first time the original firmware needs to be removed.
(This command is not required after the original firmware has been successfully removed.)
6. Define new firmware
Choose a firmware e.g. Pinetime.elf. The format can also be
Upload the firmware
Start the new firmware
Disconnect form the PineTime
The new firmware should now be running on the PineTime.
These are a lot of commands. You can add e.g. the commands before
file to a file
As the ST-Link cannot remove the write protection on the original PineTime software itself this first has to be removed with one of the other mentioned solutions.