Setup Guide for PineTime on Librem 5
Introduction to PineTime
I have been using the Librem 5 (L5) with a PineTime for about 4 months at the time of writing. It functions as a good, cheap companion for those with low expectations for a smartwatch. It can tell the time, show you notifications, and start a timer, everything else is something that falls into the “oh neat” category for me.
The battery life on the watch has been great and regularly exceeds its rated 1 week life. The max brightness setting is enough for glaring sunlight. Connection range is about 3 meters with no obstructions, and it will connect from pocket to wrist. However I do find the connection to be prone to dropped packets and occasion reconnects if my L5 is in the opposite pocket of my wrist.
Bluetooth Setup
The PineTime uses Bluetooth 5 in Low Energy mode, abbreviated “BLE”. The RS9116 chip on the L5 claims to support this mode, but a few steps are necessary to enable it. The following procedure is what worked for me and my devices, but they are known good working on PureOS Byzantium updated on the date of this post.
Upgrading RS9116 Firmware
This step may or may not be necessary, but I do not want to downgrade firmware versions to test older versions. You can check which version of the firmware you have by running,
sudo dmesg | grep redpine
and you should expect to see something similar to this,
redpine_91x: ================ RSI Version Info ==============
redpine_91x: ================================================
redpine_91x: FW Version : 1.2.0.16
redpine_91x: RSI FW Version : 1610.1.2.ab.ffbf
redpine_91x: Driver Version : RS9116.NB0.NL.GNU.LNX.OSD.2.0.0.0024
redpine_91x: Operating mode : 13 [Wi-Fi STA + BT DUAL]
redpine_91x: Firmware file : RS9116_NLINK_WLAN_BT_IMAGE.rps
redpine_91x: ================================================
in the output.
Currently the latest firmware is nonfree, but that is only because of a possible mistake on Redpine’s part. The instructions to update are hosted here
sudo apt install wget
wget https://source.puri.sm/Librem5/firmware-rs9116-nonfree/-/raw/debian/master/Firmware/RS9116_NLINK_WLAN_BT_IMAGE.rps
sudo mv RS9116_NLINK_WLAN_BT_IMAGE.rps /lib/firmware
And then restart the phone. After running
sudo dmesg | grep redpine
you should see,
redpine_91x: ================================================
redpine_91x: ================ RSI Version Info ==============
redpine_91x: ================================================
redpine_91x: FW Version : 1.2.0.16
redpine_91x: RSI FW Version : 1610.1.2.ab.ffbf
redpine_91x: Driver Version : RS9116.NB0.NL.GNU.LNX.OSD.2.0.0.0024
redpine_91x: Operating mode : 13 [Wi-Fi STA + BT DUAL]
redpine_91x: Firmware file : RS9116_NLINK_WLAN_BT_IMAGE.rps
redpine_91x: ================================================
in the output. If Operating mode isn’t 13, that’s fine, we’ll fix that in the next step.
Changing the Operating Mode to 13
While troubleshooting connecting my PineTime I got inspiration from this post to attempt to change the operating mode so BLE would work.
In order to change the operating mode you’ll need to edit a file. If you don’t have a preferred text editor, then the following command will open the file in a GUI text editor,
SUDO_EDITOR=gedit sudoedit /etc/modprobe.d/librem5-devkit.conf
Inside of the file you should see a line like this,
options redpine_91x dev_oper_mode=7 rsi_zone_enabled=1 antenna_diversity=1 wlan_rf_power_mode=0x00
Note that this has redpine_91x
in it. Inside of this line change dev_oper_mode=
from it’s current value (7 in this example) to 13. Save and then exit your text editor.
In order to enact these changes you’ll need to either flip your HKS for Wifi and reload the modules, or just restart your phone.
Installing InfiniTime Daemon
InfiniTime Daemon is the program that will be run in the background to connect with and sync notification to your PineTime. It can also be used to upgrade your PineTime watch.
In order to install first download the debian release that from the Release Page to your L5. You should download the latest stable release, and the file you are looking for ends with -aarch64.deb
For example the latest version of writing is itd-0.0.8-linux-aarch64.deb
.
Then you’ll want to install that file, which is typically
sudo apt install ~/Downloads/itd-0.0.8-linux-aarch64.deb
Installing the InfiniTime GUI
This part is optional, but a nice to have.
sudo apt install gcc libgl1-mesa-dev xorg-dev git
sudo rm -rf /usr/local/go
wget https://go.dev/dl/go1.19.2.linux-arm64.tar.gz
sudo tar -C /usr/local -xzf go1.19.2.linux-arm64.tar.gz
export PATH=/usr/local/go/bin:$PATH
git clone https://gitea.arsenm.dev/Arsen6331/itd
cd itd
go build ./cmd/itgui
Then to make it a desktop icon
mkdir -p ~/.local/bin/
cp itgui ~/.local/bin/
echo 'export PATH=${HOME}/.local/bin:${PATH}' >> ~/.bashrc
Then you’ll need to log out and back in (restart your phone) for the PATH setting to take effect. Finally create the file
~/.local/share/applications/itd_gui.desktop
with the contents,
[Desktop Entry]
Name=PineTime
Type=Application
Icon=pda
Exec=itgui
Categories=Utility;
X-Purism-FormFactor=Workstation;Mobile;
Connecting to the PineTime
Ensure your PineTime watch is powered on and in range. Next open the L5’s Bluetooth settings. Enable Bluetooth, then wait for the InfiniTime to show up. If it shows up as “Disconnected” rather than “Not Set Up”, click on it and “Remove Device”. Do not click on the InfiniTime device to manually pair it. InifiniTime Daemon will automatically connect it for you.
Next you should enable and start InfiniTime Daemon. After running this command it will always be running in the background, even after restarts.
systemctl --user start itd
systemctl --user enable itd
You should be prompted to enter the PIN displayed on your watch to pair the devices.
At this point your watch should be paired, which will mean
- The time is correct (or at least the same as your L5)
- A Bluetooth icon has appeared on the watch face (maybe not all of them)
- A notification should appear saying “Successfully Connected”
Upgrading your PineTime Firmware
With the latest release of PineTime, a “resources” packet is part of the process. Currently the GUI does not support this yet, so I recommend using the command line to update, at least until the GUI gets support for it.
You should download the latest release from the InifiniTime releases page.
You want both .zip files, infinitime-resources-*.*.*.zip
and pinetime-mcuboot-app-dfu-*.*.*.zip
At this point I recommend keeping your L5 fairly close your PineTime, which should be on its charger. Then run, substituting the latest version number, if yours is different.
itctl fw upg -a ~/Downloads/pinetime-mcuboot-app-dfu-1.11.0.zip -r ~/Downloads/infinitime-resources-1.11.0.zip
This may take awhile, and the command may look initially hung. Give it some time. If it fails, it was likely just a dropped packet or incorrect checksum, so just try it again a few times before asking for help.
After the firmware update succeed the watch will reboot, then you’ll have to
re-pair. This involves removing the old InfiniTime entry from your Bluetooth
Settings and waiting for InifiniTime Daemon to reconnect to it. If the daemon
doesn’t initiate the reconnection, you can run the following to restart it,
systemctl --user restart itd
If the resource don’t load correctly (some watch faces are greyed out), then
you can run the following to try them again,
itctl res load ~/Downloads/infinitime-resources-1.11.0.zip
Although currently there might be an issue.
Staying Connected to the Pinetime
One of the problems I encounter with InfiniTime Daemon is that it gives up on
reconnecting quite quickly.
I believe the default is to just try once every minute for five minutes after a disconnect or after Bluetooth connection is restored. This is likely to save on battery from not reconnecting.
In order to get it going again, if you miss the five minute window is to either
flip the hardware kill switch off/on, or run the previously mentioned,
systemctl --user restart itd
However neither method is great.
My solution was to create an app icon, which just runs the latter command.
First create a local bin folder,
mkdir -p ~/.local/bin
Then add it to your PATH, you can skip this step if you already did it for the GUI
echo 'export PATH=${HOME}/.local/bin:${PATH}' >> ~/.bashrc
Next create the file,
~/.local/bin/reconnect-pinetime
with the following contents
#!/bin/bash
systemctl --user restart itd
Then set its permissions
chmod 0755 ~/.local/bin/reconnect-pinetime
Finally create a desktop file
~/.local/share/applications/reconnect_pinetime.desktop
with the following contents,
[Desktop Entry]
Name=Reconnect Pinetime
Type=Application
Icon=mail-send-receive-symbolic
Exec=reconnect-pinetime
Categories=Utility;
X-Purism-FormFactor=Workstation;Mobile;
Then you’ll need to log out and back in (restart your phone) for the PATH setting to take effect.
Now you’ll just be able to click the Icon to reconnect to your PineTime.