Porting B2G onto Nexus Player (Lollipop)

This article provides an overview of the process by which B2G OS (the TV version — on which Firefox OS for TV is based) can be ported onto the Nexus Player (versions running Lollipop.)

Important: The target audience of these instructions is mainly advanced developers who are already familiar with building Firefox OS or AOSP.

Note: We cannot guarantee the reliability of ported devices. However, developers who are interested in the porting process and willing to contribute back to the program are encouraged to hack their own devices. Constructive feedback and questions are always welcome: mail us at smarttv@mozilla.com.

Note: By assuming your Nexus Player is unlocked, this article will not teach you how to root and/or unlock your Nexus Player.

Preparing the Building Environment

Currently building B2G OS for Nexus Player requires a PC running Ubuntu 14.04 LTS x64 or compatible.

You should start by running the following commands:

sudo dpkg --add-architecture i386
sudo dpkg --add-architecture amd64
sudo apt-get update
sudo apt-get install --no-install-recommends autoconf2.13 bison bzip2 ccache curl flex gawk gcc g++ g++-multilib git lib32ncurses5-dev lib32z1-dev libgconf2-dev zlib1g:amd64 zlib1g-dev:amd64 zlib1g:i386 zlib1g-dev:i386 libgl1-mesa-dev libx11-dev make zip lzop libxml2-utils openjdk-7-jdk nodejs unzip python

Configuring USB

On Linux systems a regular user can't directly access USB devices by default. You need to configure udev rules.

Create a file at /etc/udev/rules.d/51-android.rules containing the following command, then save it:

wget -S -O - https://raw.githubusercontent.com/cm-b2g/B2G/1230463/tools/51-android.rules | sudo tee >/dev/null /etc/udev/rules.d/51-android.rules; sudo udevadm control --reload-rules

The new rules take effect the next time a device is plugged in.

Note: For more detail about the relevant building environments, please refer to Firefox OS build prerequisites.

Download source code

To download the source code for the Nexus Player, first make sure you have Github installed, then execute the following commands:

git clone git://github.com/mozilla-b2g/B2G.git nexusplayer
cd nexusplayer
BRANCH=v2.6 ./config.sh nexusplayer-l

To manually download the corresponding Gecko source code, execute the following command:

git clone https://github.com/mozilla-b2g/gecko-b2g

And follow the instructions in Changing the Gecko source tree to build against a custom Gecko.

Building

Once the environment has been set up and the source code has been downloaded, building it is a simple matter of executing the following:

./build.sh

Flashing B2G to Nexus Player

Flash B2G OS to the Nexus Player with the following:

./flash.sh

Once the flashing is complete, the device should reboot and load up B2G OS. As long as nothing went wrong, you should be able to see the B2G OS TV Home screen after a short while.

Troubleshooting

Sometimes, things can and will go wrong. What follows is a list of known problems, with suggested solutions.

Fastboot cannot find Nexus Player

You might see ./flash.sh successfully reboot Nexus Player into bootloader mode but stopped at < waiting for device > message forever. This can be solved by replacing the fastboot in your system with the one under <b2g>/out/host/linux-x86/bin/ directory.

Bluetooth functionality is missing

We can’t automatically build bluetooth.default.so and libbt-vendor.so on nexusplayer-l, therefore by default Bluetooth won't work. A workaround for now is to manually build the missing files and flash them into nexusplayer-l, after which you will be able to turn on bluetooth in the Settings app.

The building steps are listed below:

Steps for building bluetooth.default.so

  1. Go to dir nexusplayer then type source setup.sh.
  2. Go to dir nexusplayer/external/tinyxml2 then type mm.
  3. Go to dir nexusplayer/external/bluetooth/bluedroid then type mm.
  4. Go to dir nexusplayer/ then type the following command:
adb push out/target/product/fugu/system/lib/hw/bluetooth.default.so /system/lib/hw

Steps for building libbt-vendor.so

  1. Go to dir nexusplayer then type source setup.sh.
  2. Go to dir nexusplayer/hardware/broadcom/libbt then type mm.
  3. Go to dir nexusplayer then type the following command:
adb push out/target/product/fugu/system/vendor/lib/libbt-vendor.so /system/vendor/lib

The TV Home screen doesn't handle mouse events

By default, the TV home screen app won't handle mouse events (see bug 1260083). For now, the recommendation is to bypass mouse usage and use the remote controller instead.

Follow these steps to get things working:

  1. Use the hardware keyboard to boot up the Nexus Player.
  2. Use the arrow keys to navigate the Home screen and go to the Settings app.
  3. Use the arrow keys to go to the Bluetooth device setup panel and pair the device with the remote controller.

Then you can use the remote controller instead. Plug the mouse in when you want to navigate within the Browser app.

Document Tags and Contributors

 Contributors to this page: Superluk, xeonchen, schien, chrisdavidmills, MashKao
 Last updated by: Superluk,