pebble
  • Tutorials
  • Get the SDK
  • Guides
  • Documentation
  • PebbleOS
  • Mobile App
  • Examples
  • Index 01
  • Community
  • Blog
  • More
Privacy
Cookies
Publish

PebbleOS

  • Overview
  • Start here
    • Getting started guide
  • Pebble Firmware
    • Overview
    • Playground
    • Application SDK
  • Development
    • The pbl CLI
    • Build system
    • Samples
    • Emulator and simulator
    • Testing
    • Debugging
    • Conventions
  • System
    • Architecture overview
    • Kernel
    • Drivers
    • Subsystems
    • Libraries
    • Third-party
      • LVGL
      • Moddable JS Engine
      • Software bill of materials
  • Hardware
    • Boards
    • Board Add-ons
    • Programmers
  • Community
    • Contribution Guidelines
  • Reference
    • Reference
    • Kconfig options

Moddable JS Engine

PebbleOS supports the Moddable SDK’s XS JavaScript engine. The Moddable integration provides a lightweight sandbox for running JavaScript applications and watchfaces on Pebble hardware.

Building with Moddable

Moddable is enabled on the boards whose firmware configuration, pebble/boards/<board>_normal.conf, sets CONFIG_MODDABLE_XS=y. You can override this at configure time by passing -DCONFIG_MODDABLE_XS=y or -DCONFIG_MODDABLE_XS=n to pbl configure. The recovery firmware (PRF) cannot enable it.

Installable applications

The JavaScript is stored in a resource. A small native C application bootstraps JavaScript execution by calling moddable_createMachine.

The JavaScript itself is a Moddable SDK mod, which is a precompiled collection of modules. The modules are compiled using the mcrun tool in the Moddable SDK. See Moddable’s Pebble Examples repository for further details. The Pebble resource containing the precompiled mod is currently loaded into RAM for execution; eventually, it should be executed directly from flash (this is what the Moddable SDK does on most platforms).

Sandbox

The JavaScript in installable applications runs inside a lightweight sandbox, which can limit access to certain JavaScript global variables and modules.

Installable applications can be either a normal application or a watchface. The sandbox prevents watchfaces from subscribing to the Pebble hardware buttons (which is slightly redundant since PebbleOS also blocks them — but PebbleOS blocks them silently, whereas the sandbox throws an exception, which is more clear to developers).

Generated from PebbleOS 7416f78a1. This page is maintained in the pebbleos repository: docs/third_party/moddable.md.

Overview

  • Building with Moddable
  • Installable applications
  • Sandbox