Writing a Pebble app in 2020 Part 2 – Installing the SDK

In part one of this 4 part series we covered the prerequisites you need to know to develop for Pebble watches. Part 2 will cover installing the SDK and Pebble emulator.

Part 1
- Introduction
- Why write a Pebble app in 2020
- An explanation of the different Pebble devices & platforms
- An introduction to Pebble apps

Part 2
- Pebble SDK options
- Installing the SDK

Part 3 (Coming soon)
- Introduction to PebbleJS
- Writing your first app
- Calling an API for data

Part 4 (Coming soon)
- Writing an App configuration page
- Advanced PebbleJS concepts

Pebble SDK options

The Pebble Software Development Kit (SDK) is the set of tools we need to build our Pebble app. It manages turning our code into something that can run on the watch, as well as some testing and debug tools too. Once we’ve got this setup, we can starting writing code. This guide will cover installation on Linux (and potentially MacOS), but there are several other ways you can install the SDK.

The easiest option: Pebble VM

If you want the super easy option there’s an Ubuntu linux virtual machine (vm) available with the SDK already installed on it. You can download it here. If you have never used a virtual machine before, it’s like running a computer inside a computer. If you’re starting from scratch you need to first install virtualbox, then download the vmdk file, then open the vmdk file in virtualbox. If you pick this option you can jump straight to the next blog post in this series (coming soon).

The better option: Installing natively

Although the VM option is quickest, it’s a little bloated. If you’re happy copy-pasting commands into a terminal, a native install is the way to go. For this guide I’ll be explaining how to install on Linux (or MacOS) in the next section. If you want to install the SDK natively on Windows, see this link.

Other options

The above two options are the most straightforward, but here are a few more alternatives. There’s a docker image if containers are your thing, an install script for debian, and even a nix build system package. These are all outside the scope of this tutorial but might float your boat.

Native SDK install on Linux

For this tutorial I’m going to cover installation on Ubuntu 20.04, but it will work for any Debian based Linux distro, including Raspberry Pi OS. If you’re running MacOS the tutorial should serve as a good base guide, but you’re probably better following the guide available here.

Step 1. Update the operating system

Before we get started with anything else, lets make sure the operating system is up to date:

sudo apt update && sudo apt upgrade -y

Step 2. Install python2 and python2-pip

Because the SDK tooling isn’t python-3 compatible, we need to install the older python2 and associated pip onto our machine.

sudo add-apt-repository universe
sudo apt update 
sudo apt install python2 -y

Now python2 is installed, we can use the pypa script to install python2-pip.

curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py
sudo python2 get-pip.py

Pip will be installed globally. If you want to install it only for your user, run the command without sudo. The script will also install setuptools and wheel, which allow you to install source distributions.

You can verify the install with

pip2 --version

the output from which should look similar to:

pip 20.0.2 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)

Step 3. Install other dependencies

We need a few more dependencies, mostly for the emulator:

sudo apt install wget python-dev libsdl1.2debian libfdt1 libpixman-1-0 npm gcc -y

Step 4. Installing the SDK tools

Step 4.1 – Download and extract the SDK

Okay. Time to actually install the SDK tooling.

Navigate to your home directory and create a new directory called ‘pebble-dev’.

cd ~
mkdir pebble-dev

Change into that directory, download the SDK tooling and extract it.

(If you are on Linux 32 Bit, or MacOS, read the appendix before continuing)

cd ~/pebble-dev
wget https://rebble-sdk.s3-us-west-2.amazonaws.com/pebble-sdk-4.6-rc2-linux64.tar.bz2
tar -jxf pebble-sdk-4.6-rc2-linux64.tar.bz2

Now we have the pebble SDK tooling downloaded. Move into the directory and print your current path

cd ~/pebble-dev/pebble-sdk-4.6-rc2-linux64
pwd

the output should be something like

/home/will0/pebble-dev/pebble-sdk-4.6-rc2-linux64
Step 4.2 Installing the python dependencies

Install the required python dependencies.

python2 -m pip install virtualenv
python2 -m virtualenv .env
source .env/bin/activate
pip install -r requirements.txt
deactivate

Step 5. Add to PATH

Now the SDK is installed we need to add it to our PATH

echo 'export PATH=~/pebble-dev/pebble-sdk-4.6-rc2-linux64/bin:$PATH' >> ~/.bashrc 
~/.bashrc

The Pebble SDK tooling is now ready to go, verify with

pebble --version

If this doesn’t work, try closing and re-opening your terminal

Step 7. Install the Pebble SDK

Now we can install the actual watch SDK. Do so with:

pebble sdk install latest

If prompted if you want to enable analytics, press N. If the process crashes or exits at this point, just run it a second time and it will proceed.

If this doesn’t work, try closing and re-opening your terminal

All systems go

At this point the SDK should be installed, you can verify by cloning an example pebble project and building it. For example:

cd /tmp
git clone https://github.com/pebble-examples/cards-example
cd cards-example
pebble build
pebble install --emulator basalt

If all goes according to plan, the app should build and appear in the emulator!

That’s it for part 2. Part 3 (coming sometime before Christmas 2022) will dive into how to write your own Pebble app.

Appendix

Alternate SDK URLs

If you are running 32 bit linux, substitute the wget command in step 4.1 with:

wget https://rebble-sdk.s3-us-west-2.amazonaws.com/pebble-sdk-4.6-rc2-linux32.tar.bz2

and if you’re using MacOS, use:

wget https://rebble-sdk.s3-us-west-2.amazonaws.com/pebble-sdk-4.6-rc2-mac.tar.bz2

You will then need to substitute references to pebble-sdk-4.5-linux64.tar.bz2 and pebble-sdk-4.5-linux64 accordingly for the rest of the instructions.

References:

Thanks to the following guides & resources which were used to assemble this install guide:

Leave a Reply

Your email address will not be published. Required fields are marked *