The emulator runs PebbleOS on a desktop, without a watch. It is a fork of QEMU that ships with the PebbleOS SDK, and it runs the same firmware the watches do, built for the emulator board.
The emulator does not model a particular watch’s hardware. It emulates two things:
The qemu_pebble board runs the firmware of an SDK platform, with that
platform’s display, buttons and, where the platform has them, touch,
backlight color, heart rate sensor and speaker. Apps see exactly what
they would on a watch of that platform: the same screen size, color
depth, shape and capabilities. Each core of the board has a default
platform; pick another one with -DCONFIG_PLATFORM_<NAME>=y.
The board has a core for each CPU of the watches: m4, a Cortex-M4
with 256 KiB of RAM, and m33, a Cortex-M33 with 512 KiB of RAM and
16 MiB of PSRAM. The firmware is real ARM code, built with the same
toolchain. The QEMU machine, pebble, takes its CPU and memory from
the build: the memory nodes of the board’s devicetree size its SRAM and
PSRAM, so an overlay can try the firmware on less memory or more. Apps are ARM
code too, so the .pbw files built with the app SDK, including those
from the app store, install and run unmodified.
Everything below the platform is simplified. Instead of the nRF52840 or
SF32LB52 and the chips around it, the machine has a small set of devices
designed for the emulator, such as a framebuffer display, simple UARTs, an
RTC, a watchdog and an external flash, each with its own driver under
drivers/*/qemu. Hardware drivers, power management and radio timing are
therefore not exercised: use a watch for those.
Platform |
Same platform as |
Board |
Option |
|---|---|---|---|
Flint |
Pebble 2 Duo |
|
|
Emery |
Pebble Time 2 |
|
|
Gabbro |
Pebble Round 2 |
|
|
The native simulator is the other way to run the firmware on a desktop: it is faster to build and easier to debug with host tools, but it compiles for the host, so it cannot load apps.
Configure a build for the emulator board, build it and launch it, here for Emery:
pbl configure --board qemu_pebble/m33
pbl build
pbl run
A window opens with the watch’s screen, drawn inside a bezel of the watch,
and the firmware boots. Each platform offers a few bezels, in the
colors of its watches, listed in CONFIG_SOC_QEMU_PEBBLE_DECORATIONS
with the default first; --decoration picks another, or none. The terminal that launched it is the QEMU monitor;
quit with quit there or by closing the window.
--sunlight shows the colors as a watch’s panel does in sunlight, like
the native simulator’s -l:
pbl run --sunlight
The emulated watch keeps its data in two flash images in the build
directory: the internal flash, holding the firmware, and the external
flash, holding the resources, the file system and with it the installed
apps, settings and Bluetooth bondings. pbl run rebuilds both on
every launch; pass --keep-flash-image to keep the external flash, and
with it the watch’s data:
pbl run --keep-flash-image
The emulated clock follows the host’s local time.
With the window focused, the arrow keys are the watch buttons:
Key |
Button |
|---|---|
|
Back |
|
Select |
|
Up |
|
Down |
The same keys can be sent from the monitor with sendkey, e.g.
sendkey right.
On boards with touch, tap and swipe from a shell with pbl emulator:
pbl emulator touch 130 130
pbl emulator swipe 130 220 130 40
Other shells attach to the running emulator:
pbl console # the firmware's debug console
pbl emulator screenshot # writes build/screenshot.png
There is no phone attached, but pbl emulator feed writes what the phone app would, such as weather, music, notifications and calendar events, in a Pebble protocol session on the console port. The port serves one client, so it needs pbl console detached:
pbl emulator feed weather
Install an app with the pebble tool
and its phone simulator, which talks to the firmware on the console port, with
pbl console detached:
pebble install /path/to/app.pbw --qemu --qemu-console localhost:12345 --pypkjs --platform emery
Launch with --keep-flash-image to keep installed apps across launches.
The emulator’s microphone captures audio sent from the host, and silence otherwise. With dictation or an app capturing, play a tone, noise, a WAV file or your computer’s microphone into it:
pbl emulator mic --file speech.wav
See pbl emulator for the options. With the pebble tool
connected instead, use pebble emu-mic --qemu localhost:12344.
Apps need the phone to grant them the microphone, which only the SDK
emulator (pebble install --emulator) does; see
Local microphone capture.
The emulator always runs a GDB server. pbl debug attaches to it
through a proxy that walks the kernel’s thread list, so info threads and
per-thread backtraces work; GDB tutorial walks through a
session.
Endpoint |
Use |
|---|---|
The launching terminal |
Interactive QEMU monitor |
|
Socket monitor, used by |
|
Serial console, used by |
|
QEMU serial protocol, which drives the emulated hardware, used by |
|
GDB server |
|
The first UART’s output, in the repository root |
By default the NimBLE host runs against a fake controller that accepts
every command but never forms a link. To use a real radio, attach an H4 HCI
controller to the emulator’s fourth UART (QEMU pebble19 or later). An nRF52840 Dongle running
Zephyr’s hci_uart sample shows up as a USB serial port and works out of
the box:
west build -b nrf52840dongle/nrf52840 zephyr/samples/bluetooth/hci_uart
nrfutil pkg generate --hw-version 52 --sd-req=0x00 \
--application build/zephyr/zephyr.hex --application-version 1 hci_uart.zip
# press the dongle's reset button to enter the bootloader
nrfutil dfu usb-serial -pkg hci_uart.zip -p /dev/cu.usbmodemXXXX
Then build with the UART transport and pass the controller’s port:
pbl configure --board qemu_pebble/m4 -DCONFIG_NIMBLE_HCI_UART=y
pbl build
pbl run --bt-hci /dev/cu.usbmodemXXXX
--bt-hci takes any QEMU -serial spec, e.g. tcp:localhost:9000. On
macOS use the cu.* device: opening tty.* blocks until carrier detect.
The watch uses its controller’s address, or a random one that changes on
every boot if the controller has none, as an nRF52840 dongle does. Give it
one with --bt-addr, a random static address (its two top bits set), and
pass --keep-flash-image to keep existing bondings across launches:
pbl run --bt-hci /dev/cu.usbmodemXXXX --bt-addr C0:00:00:00:00:01 --keep-flash-image
The address is a property of the machine’s system controller
(-global pebble-sysctrl.bt-addr=ADDRESS), read by the firmware with
CONFIG_NIMBLE_ID_ADDR_QEMU.
Generated from PebbleOS 7416f78a1. This page is maintained in the pebbleos repository: docs/development/emulation/emulator.md.