Boot to Gecko (FirefoxOS) uses a kernel derived from Android, with a Gecko-based user interface on top of it. This article provides a basic guide to how to go about porting the operating system to new devices.
This guide assumes you're porting to a new device that already runs Android; if you're porting to another device, the job is going to be more involved.
Set up your build system
The first step is to configure your build system; you can follow the guide in B2G build prerequisites.
Clone the B2G repository
The first step is to clone the B2G repository.
git clone https://github.com/mozilla-b2g/B2G.git
Create a local backup of the original Android system
Next, you should back up your Android device before you start nuking it with your test builds of B2G. In addition, some of these bits will be needed by the build and install process.
mkdir my_device_backup cd my_device_backup adb pull /system system
Add a new device to config.sh
The next step is to add a new device to
config.sh; you can use the existing ones as a template. This basically involves providing the instructions for fetching the correct files to do the build.
Create the manifest file for the new device
Now you need to add the required repos to the manifest file for the new device; this manifest file is called default.xml. Refer to the
b2g-manifest file on github for a template. Each device has its own branch; you can use the
galaxy-s2 branch as a reference.
Create a configuration tree for the new device
Create a new configuration tree for the new device. This should be at
device/<manufacturer>/<device_id>. This tree should include, at least:
- idc files for touchscreen
- init files (
The content here may differ a great deal from one device to another. In particular, BoardConfig.mk and extract-files.sh may differ significantly. This part requires a lot of hacking, testing, and debugging to figure out which binary blobs should be extracted.
Once you have all that done, you need to rebuild the boot image. This isn't usually needed for the kernel itself, but to pick up the changes to
Changes to init.rc
The init.rc you use is not the one provided by B2G; instead, you need to pull it from the device.
The main things you'll need to modify are:
Add the following lines to import
on early-init start ueventd import /init.b2g.rc
Correct the permissions on the files
/system/b2g/plugin-container; this should be done after the lines that mount the filesystem read/write:
chmod 0755 /system/b2g/b2g chmod 0755 /system/b2g/updater chmod 0755 /system/b2g/plugin-container
You might want to start by modifying the
init.rc from the new device instead of using the
init.rc provided by the build system; if so, you need to remember to set
Prebuilt kernel vs. building the kernel from source
You can use a prebuilt kernel, or you may build the kernel from source. To build the kernel from source, add AndroidKernel.mk and the kernel config to the device configuration tree.
The maguro on the old build system is an example that builds the kernel from source.
Add the new device to flash.sh
Add the new device to
flash.sh; the specifics of how to do this will depend on what tools need to be used to flash the new device.
Configure, build, and flash the new device
Now you can try building for and flashing to your new device:
ANDROIDFS_DIR=my_device_backup ./config.sh <device_id> default.xml ./build.sh ./flash.sh
Test and debug
We need some details added here; indeed, this entire article could use some help.