Foxberry Pi Demo

From MozillaWiki
Jump to: navigation, search

This page describes how to install Firefox OS inside a Raspberry Pi running Raspbian, without disturbing the main Raspbian installation. The Firefox-OS-on-Raspberry-Pi project is known by the codename "Foxberry Pi".

WARNING: for the time being, this demo software is just that, literally demoware. It has no long-term support plan or API compatibility guarantees, and may eat your homework. This demo is mostly intended for developers who are prepared to deal with bleeding-edge software.

WARNING: this guide has you run large amounts of not-particularly-vetted code as root. Please ensure your Raspberry Pi isn't visible to the public Internet and is on a secure LAN.


This demo has been assembled from pieces of others' work. Thanks specifically to romaxa, trouch, and Philipp Wagner for doing the heavy lifting!


You need a Raspberry Pi, of course. Models B and B+ should work equally well. This guide assumes your Raspberry Pi (here after RPi) is running a recent Raspbian OS. Other distributions will probably work, but haven't been tested.

Install WebIOPi on your RPi. Be sure to test that WebIOPi is working correctly before proceeding.

This guide assumes your RPi is connected to the host machine via Ethernet. A connection through a wifi dongle or USB networking (or ...) should work fine, but hasn't been tested.

It's strongly recommended that you install sshfs on your host machine. On Fedora,

sudo yum install fuse-sshfs

Or on Ubuntu,

 sudo apt-get install sshfs

This guide assumes your RPi has the default user "pi" configured.

You need to be able to ssh into your RPi. This means that

  1. Your Raspberry Pi must have ssh access enabled
  2. You need to know either your RPi's hostname or IP address. The default hostname is "raspberrypi". We'll call this address $rpiaddress from here on.

Ensure that the following command, run from your host computer, allows you to log into your RPi

ssh pi@$rpiaddress

(You'll need to enter the password, which by default is "raspberry". But you changed the password, right? Right??)

Set up Firefox OS inside Raspbian

Download the Firefox OS demo files. Copy the package to your RPi and then extract it into your RPi user's home directory with

tar zxvf Foxberry-pi-demo-0.0.tar.gz

This should create a ffos folder in your RPi's home directory.

Set up your host for web development

Go to a folder you'd like to use for development on your host machine. We'll refer to that folder as $dev. Run the following commands on your host machine

cd $dev
mkdir ffos
sshfs pi@$rpiaddress:/home/pi/ffos ffos

This mounts a special filesystem on your host machine's $dev/ffos mount point. The filesystem passes reads and writes through to your Raspberry Pi's ~/ffos folder. This allows you to develop code using your host computer's editor and without needing to explicitly synchronize files. This is usually far more convenient than alternatives.

Open the file $dev/ffos/app/html/app.js in your code editor on the host machine. If you can't open that file, something has gone wrong in your sshfs or RPi setup.

Set up development circuit

This section is optional but strongly recommended. The circuit consists of

  • +5V supply from RPi conneted to breadboard +
  • Ground from RPi connected to breadboard ground
  • Push-button momentary switch connected to GPIO22, configured with a 10kΩ pull-down resistor
  • LED connected to GPIO25, with 200Ω load resistor

You can of course use whatever pins and elements you wish. However, the demo code assumes the pin configuration above.

The push-button switch is the most important element, as we'll see below.

An image of the circuit is included for reference

Dev circuit
Foxberry Pi development circuit

Run Firefox OS within Raspbian

Now that your host machine, RPi, and development circuits are set up, you can run the demo. Ensure that your RPi's HDMI out is plugged into a TV or monitor; Firefox OS draws directly to the GPU's framebuffer, it doesn't use X11. So currently the Firefox OS display can't be remoted.

The following commands start FFOS

ssh pi@$rpiaddress
sudo ./ffos/

Firefox OS runs within a chroot environment within your Raspbian installation.

You should see a lot of logging spew written to your console. Finally, Firefox OS will load the demo application. If all goes well, your screen should blink green/black every second, and the LED in your demo circuit should blink on/off approximately in unison with the screen blinking.

Finally, return to your open copy of $dev/ffos/app/html/app.js. Find the string 'green' and change it to 'pink'. Save the file.

Now we're going to reload the web app. Foxberry Pi has a "reload button" --- the literal, physical button you built for your development circuit! :) Press that button and hold it down for about a second. Your web app should reload and the background start blinking pink/black, instead of green/black.

So yes, Foxberry Pi enables save-reload web development on an embedded device.

Congratulations! You're ready to develop apps for Foxberry Pi.

Follow-up projects

  • Extend the navigator.mozGpio polyfill shim in ffos/app/html/foxberry-pi.js with APIs for
    • outputting PWM signal
    • outputting single pulses
    • SPI communication
    • i2c communication
    • serial (UART) communication
  • Build a demo circuit that includes other devices

(At this point, it's not worth trying to debug problems in the Firefox OS build itself. The code is most likely a dead end.)

Build from source

Follow the instructions here to build Firefox OS (a very old version) for Raspberry Pi. You can also download a pre-built pure-FFOS disk image from that site, if you have no need to run Raspbian.

The navigator.mozGpio API shim and example web app are hosted in this repository (along with some helper scripts for FFOS-in-Raspbian). If you take the challenge of extending the navigator.mozGpio as described above, please open pull requests at that repo to have your patches merged back! :)

The FFOS-in-Raspbian image hosted on this page was assembled by hand from Philipp's FFOS system image and the Foxberry Pi demo code.


  • The Firefox OS build included in the image is very old
  • Not all device capabilities are exposed through Web APIs
  • No mouse or keyboard support
  • Display can't be remoted
  • On at least one TV used as output display, graphics are glitchy: left side of viewport is clipped, and right side is offset from right edge of TV leaving blank space
  • Slow and buggy