Join MDN and developers like you at Mozilla's View Source conference, 12-14 September in Berlin, Germany. Learn more at

编译Firefox OS的系统需求

在获取用于编译Firefox OS的代码之前,你需要设置好所需的编译环境。目前可在64位Linux或Mac OS X下编译Firefox OS。

注意:要构建firefox OS到手机上,开始时不要把你的手机连接到电脑上,当需要连接的时候我们会告诉你把手机插入到电脑上。



等级 1


Unagi是被用来作为中低端智能手机测试和开发平台的一个手机,许多核心Firefox OS开发者都使用Unagi。
Otoro是被用来作为中低端智能手机测试和开发平台的一个手机,许多核心Firefox OS开发者都使用Otoro。
Pandaboard是一个基于OMAP(开放式多媒体应用平台,Open Multimedia Application Platform)4架构的开发用电路板,用于移动平台上的开发工作。
模拟器(ARM和x86)Emulator (ARM and x86)
你也可以构建Firefox OS的桌面版本;这种方式在XULRunner应用中运行Gecko,接着你就可以在其中使用Gaia用户界面了。




Samsung Nexus S
已知的Nexus S设备中可用的产品型号为GT-I9020A和GT-I9023,其他型号也许可以用。
Samsung Nexus S 4G


Firefox OS可以在这些设备上构建,但是他们并不是核心开发者积极工作的基础设备。他们的可靠性和功能设置可能会明显的落后于等级1设备甚至于等级2设备。

Samsung Galaxy S2
Samsung Galaxy Nexus
重点: 仅支持至少运行Android 4(又称Ice Cream Sandwich)的设备,如果你的设备在上面列出来了,但是运行的是低版本的安卓系统,请先升级在进行操作。


在Linux系统下构建Firefox OS,要求如下:

To build on Linux, you'll need to have a system configured with:

  • An installed 64 bit GNU/Linux distribution (we recommend Ubuntu 12.04).安装64位GNU/Linux发行版(我们推荐Ubuntu12.04)
  • At least 4 GB of RAM/swap space.(至少有4GB内存或交换分区空间)
  • At least 20 GB of available hard disk space.(至少有20GB的空白硬盘空间)

This is more than the bare minimum, but sometimes building fails just because it's missing resources.【这已经超过最低限度,但是有时构建失败只是因为缺少资源】

It's possible to use other distributions, but we recommend Ubuntu 12.04 since it's the most common system people use successfully. Distributions that might not work: 32 bit distros and recent distros ( Ubuntu 12.10, Fedora 17/18, Arch Linux because of gcc 4.7).【可以使用其他发行版本,但是我们建议使用Ubuntu 12.04,因为他是人们成功使用最常用的。可能无法正常工作的发行版有:32位和最近发型版本(Ubuntu 12.10,Fedora 17/18,因为linux分支gcc 4.7-可能版本过高吧)】

You will also need the following tools installed:


  • autoconf 2.13
  • bison
  • bzip2
  • ccache
  • curl
  • flex
  • gawk
  • git
  • gcc / g++ / g++-multilib (4.6.3 or older)
  • make
  • OpenGL headers
  • X11 headers
  • 32-bit ncurses
  • 32-bit zlib

64 bit install examples:

Ubuntu 12.04 / Linux Mint 13 / Debian 6

$ sudo apt-get install autoconf2.13 bison bzip2 ccache curl flex gawk gcc g++ g++-multilib git ia32-libs lib32ncurses5-dev lib32z1-dev libgl1-mesa-dev libx11-dev make zip

When building on 64-bit Ubuntu, you may find that you need to add symlinks for the 32-bit versions of and

$ sudo ln -s /usr/lib/i386-linux-gnu/ /usr/lib/i386-linux-gnu/
$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/ /usr/lib/i386-linux-gnu/

Ubuntu 12.10

$ sudo apt-get install autoconf2.13 bison bzip2 ccache curl flex gawk gcc g++ g++-multilib gcc-4.6 g++-4.6 g++-4.6-multilib git ia32-libs lib32ncurses5-dev lib32z1-dev libgl1-mesa-dev libx11-dev make zip

In addition to the steps above needed to fix issues with the 32-bit versions of the and libraries, you will need to specify GCC 4.6 as the default host compiler before building. After having retrieved the sources, see here how to do it.

In a fresh Ubuntu 12.10 install, you'll get an error about unmet dependenceis for ia32-libs. The following steps fix it.

sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install ia32-libs

Fedora 16:

$ sudo yum install autoconf213 bison bzip2 ccache curl flex gawk gcc-c++ git glibc-devel glibc-static libstdc++-static libX11-devel make mesa-libGL-devel ncurses-devel patch zlib-devel ncurses-devel.i686 readline-devel.i686 zlib-devel.i686 libX11-devel.i686 mesa-libGL-devel.i686 glibc-devel.i686 libstdc++.i686 libXrandr.i686 zip

Fedora 17/18:

$ sudo yum install autoconf213 bison bzip2 ccache curl flex gawk gcc-c++ git glibc-devel glibc-static libstdc++-static libX11-devel make mesa-libGL-devel ncurses-devel patch zlib-devel ncurses-devel.i686 readline-devel.i686 zlib-devel.i686 libX11-devel.i686 mesa-libGL-devel.i686 glibc-devel.i686 libstdc++.i686 libXrandr.i686 zip perl-Digest-SHA

In addition to the above you will need GCC 4.4 in order to compile the project. You can find a pre-compiled version here. Download it and install it to /opt with the following command:

$ wget
$ sudo tar -x -a -C /opt -f gcc-4.4.7-bin.tar.xz

You will need to specify this compiler as the default host compiler before building. After having retrieved the sources, see here how to do it.


Arch Linux (not functional yet):

$ sudo pacman -S --needed alsa-lib autoconf2.13 bison ccache curl firefox flex gcc-multilib git gperf libnotify libxt libx11 mesa multilib-devel wireless_tools yasm lib32-mesa lib32-ncurses lib32-readline lib32-zlib

By default, Arch Linux uses Python3. You'll have to force it to use the old python2:

$ cd /usr/bin

$ sudo ln -fs python2 python

Mac OS X系统需求

To build Firefox OS on Mac OS X, you need to install Xcode's Command Line Utilities.

You can download just the Command Line Utilities from Apple's developer downloads page for your particular version of OS X.

However, if you would like the entire Xcode suite of applications, you can install Xcode through the Mac App Store. 

Install Command Line Utilities via XCode 4.3.1 and newer

Xcode 4.3.1 (OS X 10.7 "Lion") and other newer versions such as 4.4.1+ (that is, Mac OS X10.8 "Mountain Lion"), won't necessarily include the required Command Line Utilities. When you install Xcode, make sure to go into Preferences, then the Downloads panel, and install the Command Line Utilities. In addition, make sure you have at least 20 GB of free disk space.

Screenshot of Xcode Downloads Command Line Tools

Note: The Firefox OS emulator requires a Core 2 Duo processor or later; that is, a system that is compatible with Mac OS X 10.7 "Lion." You do not actually have to be running Lion, you just have to be compatible with it. You can, however, build any Firefox OS build on many older Macs.

Firefox OS Mac Bootstrap

Open a terminal and run the following command:

curl -fsSL | bash

It will pull and run a bootstrap script that makes sure you have all the prerequisites met to build the emulator. It will also prompt you for permission to install anything you're missing. The script will check for and install the following items:

  • git
  • gpg
  • ccache
  • yasm
  • autoconf-213
  • gcc-4.6
  • homebrew


If you have already upgraded to Xcode 4.4+ and get the message that Xcode is outdated, check the Xcode path with:

xcode-select -print-path
If it still points to /Developer you can update the path with:
sudo xcode-select -switch /Applications/
Next to that be sure that you have the Mac OS X 10.6 SDK available at:

If it cannot be found there you will need to extract and copy it from the Xcode 4.3 DMG file which is available at the Apple Developer portal. You can use the utility Pacifist to extract the 10.6 SDK. Be sure to add a symlink to it to the /Applications/ directory. (We can drop the 10.6 SDK requirement after bug 784227 has been fixed, and our version of platform_build has been updated.)

Mountain Lion

If you are building on OS X 10.8 "Mountain Lion" (Xcode 4.4.1 or later) and encounter the following error:

external/qemu/android/skin/trackball.c:130:25: error: 'M_PI' undeclared (first use in this function)
Edit the file: B2G/external/qemu/ and add in line 78:
MY_CFLAGS += -DM_PI=3.14159265358979323846264338327950288   #/* B2G_fix: not finding M_PI constant */
If you are on Mountain Lion and you receive an error during the installation of the dependencies via homebrew, such as:
clang: error: unable to execute command: Segmentation fault: 11
... try reinstalling the dependency manually adding the --use-gcc flag, for example:
brew install mpfr --use-gcc

Samsung Galaxy S2

If you plan to build for the Samsung Galaxy S2, you will also need to install heimdall. See Installing heimdall for details. This is not done for you by the bootstrap script!

Note: If you have installed the Samsung Kies tool, which is used to manage the contents of many Samsung phones, you will have to remove it before you can flash Firefox OS onto your device. You can use the standard application removal process on Windows; on Mac, the Kies install disk image has a utility to fully remove Kies from your system. Flashing will not work if you have Kies installed. If you forget to remove Kies, the build system will detect it and remind you to uninstall it. Note also that the uninstall tool does not correctly remove the folder ~/Library/Application Support/.FUS, and leaves a reference to a utility there in your user startup items list. You will want to remove these manually.
Note: Mac OS X uses a case insensitive filesystem by default, which will prevent you from building Firefox OS down the road (EDITOR'S NOTE: I have never had a problem with this).  You should create a case sensitive sparse disk image work from within that directory.  To buld the case sensitive disk image:
hdiutil create -type SPARSE -fs 'Case-sensitive Journaled HFS+' -size 40g ~/firefoxos.dmg

Mount the drive with:

open ~/firefoxos.dmg

Change into the mouted drive with:

cd /Volumes/untitled/

Fix libmpc dependency if broken

gcc 4.6 was built with libmpc 0.9; if you then use homebrew to update packages, libmpc gets updated to version 1.0, but homebrew doesn't rebuild gcc 4.6 after the library version changes. So you need to create a symlink to make things work again, like this:

cd /usr/local/lib/
ln -s libmpc.3.dylib libmpc.2.dylib

Optional: Install HAX

Intel provides a special driver that lets the B2G emulator run its code natively on your Mac instead of being emulated, when you're using the x86 emulator. If you wish to use this, you can download and install it. It's not required, but it can improve emulation performance and stability.


在构建B2G之前,需要从手机的安卓安装上拷贝下来二进制对象(当然,除非你要构建模拟器)。为此,你需要安装adb,安卓调试桥(Android Debug Bridge)。安装adb这篇文件中讲解了如何安装adb。

在你将来使用adb时请注意:为了调试你的手机,adb需要手机的锁屏处于解锁状态(至少在最新的Firefox OS中是这样的)。你最好禁用锁屏(我们在以后的构建指导中说明如何来做)。


Heimdall is a utility for flashing the Samsung Galaxy S2. It's used by the Boot to Gecko flash utility to replace the contents of the phone with Firefox OS, as well as to flash updated versions of B2G and Gaia onto the device. You'll need it if you want to install Firefox OS on a Galaxy S2; it is not needed for any other device. For other devices, we build and use the fastboot utility instead.

Note: Again, it's important to note that this is only required for installing Firefox OS on the Samsung Galaxy S2.

There are two ways to install heimdall:

Note: Building the latest Heimdall from source currently produces errors. It is better to instead use the 64bit packaged version from the Ubuntu 14.04 repos. i.e. don't use heimdall-flash:i386 if you can avoid it.

配置 ccache


ccache --max-size 10GB

针对Linux:为你的手机配置udev 规则

注意: 这一节是针对Linux用户;OS X用户已经安装了必要的设备权限。


你可以通过运行lsusb来获得你插入的手机的 USB供应商编号(USB vendor ID) ,通常是Google 18d1, Samsung 04e8, ZTE 19d2, Geeksphone/Qualcomm 05c6。


SUBSYSTEM=="usb", ATTR{idVendor}=="XXXX", MODE="0666", GROUP="plugdev"


SUBSYSTEM=="usb", ATTR{idVendor}=="19d2", MODE="0666", GROUP="plugdev"

对于Firefox Flame,内容如下:

SUBSYSTEM=="usb", ATTR{idVendor}=="05c6", MODE="0666", GROUP="plugdev"

请注意fastboot设备(flash时使用)可能有一个不同的供应商ID(vendor ID),故你需要为它添加一条规则。例如Firefox Flame也需要谷歌的供应商ID

SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666", GROUP="plugdev"



sudo chmod a+r /etc/udev/rules.d/android.rules



sudo service udev restart

Fedora 20

sudo systemctl restart systemd-udevd.service


sudo udevadm control --reload-rules

注意: 这也许需要稍长的时间,取决于你的发行版本,类似于:

sudo vi /etc/udev/rules.d/android.rules
sudo service udev restart
sudo /etc/init.d/udev restart
sudo reload udev
sudo udevadm trigger



在你把你的手机插回USB端口上之前,让其处于USB开发者模式,这允许你调试并更新(flash)你的手机,在你的手机上启动开发者设置 中的 远程调试(在老版本中称为开发者模式)来启动开发者模式。一旦勾选了这个选项,远程调试即启动,然后你就可以继续了。

现在,通过USB连接你的手机和电脑(如果你在之前创建了一个udev规则,这将会触发udev检测你的手机并创建相应权限的设备节点)。现在你可以检查你是否可以通过adb devices命令来列出你的设备(谨记adb只可以在你的手机处于解锁时看到它)。如果一切OK,你应该可以看到类似于下面的输出(下面这个是对于一个极客手机Keon来说):

$ adb devices
List of devices attached
full_keon       device



注意: 如果你没有已存在的系统备份,在构建系统之前你必须做这一步,因为在构建期间有许多库会被引用,这些库可能是专有的以至于我们不能在基础代码中提供他们。



adb pull /system <backup target dir>/system

 你可能还需要拷贝出/data 和/或 /vendor目录,不过这取决于手机:

adb pull /data <backup target dir>/data
adb pull /vendor <backup target dir>/vendor


  • 停止并重启adb服务器
  • 确保在你自定义的ROM中你有adb工具的root权限(比如:在桌面时钟(CyanogenMod)下,改变设置 > 系统 > 开发者选项 > 赋予应用和ADB root权限 or 仅仅是ADB)
  • 确定你已经正确设置了udev规则

On to the next step

At this point, you should be ready to fetch the Firefox OS code!


 此页面的贡献者: chrisdavidmills, baiyangcao, ziyunfei, oneonce, smith_zhong, iwo
 最后编辑者: chrisdavidmills,