This tutorial was made using Antergos, an Arch distro based, but can be expanded to other distros.
You need to do a B2G build for your device (eng or userdebug to get root access), as this is not properly setup with the Android build system yet. If you need more info, this is a good first place to start.
Clone the B2G repository and enter to b2g directory.
git clone https://github.com/mozilla-b2g/B2G && cd b2gConfigure USB access.
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-rulesConfigure ccache
ccache -M 50GEnable multilib on Arch and install dependencies.
sudo pacman -S --needed alsa-lib autoconf2.13 bison ccache curl firefox flex gcc-multilib git gperf libnotify libxt libx11 mesa multilib-devel wget wireless_tools yasm zip lib32-mesa lib32-mesa-libgl lib32-ncurses lib32-readline lib32-zlib lzopConfigure Python. Remember to use virtualenv every time you try to compile.
sudo pacman -S python-virtualenvwrapper
source /usr/bin/virtualenvwrapper.sh
mkvirtualenv -p `which python2` firefoxos
workon firefoxosVerify that all works.
python --versionGives as result Python 2.7.XX.
Install Android tools.
yaourt -S android-sdkOptionally you can install all the Android development tools.
yaourt -S android-sdk android-sdk-build-tools android-sdk-platform-tools android-platformPlug your phone and make a copy of propietary blobs. Ensure you device has Remote Debugging enabled in Developer settings. Confirm your device is visible with the adb devices command, you should see something similar to this:
$ adb devices
List of devices attached
ABCXXXXXXX deviceIf no device is listed, check your UDEV rules.
If you have permission issues, check that your screen is unlocked and that you have authorized access to your phone. You see a message on your device for that. If the issue persists used adb root and adb remount.
Back up the phone's partitions with the adb pull command:
adb pull /system <backup target dir>/systemDepending on the phone, you may also need to pull the /data and /vendor directories:
adb pull /data <backup target dir>/data
adb pull /vendor <backup target dir>/vendorIf the pull commands fail with an insufficient permission message, try the following:
- Check you have granted root permissions within your custom ROM (e.g. under CyanogenMod, change Settings > System > Developer Options > Root Access to Apps and ADB or ADB only).
- Verify that you have set up the udev rule correctly (see For Linux: configure the udev rule for your phone).
Remember to plug your phone. Now config, build and flash B2G on your phone. This is only necessary to build gonk, not gecko or gaia. A simple way to remove these from the build after running ./config.sh is to edit b2g.mk in gonk-misc repository and comment out the gecko and gaia lines, as shown in this git diff: https://pastebin.com/sdQG3Tki
./config.sh <device_platform_name>
./build.sh
./flash.shInstall rustup.
sudo pacman -S rustupClone the repo and enter to the servonk directory
cd .. && git clone https://github.com/fabricedesre/servonk.git && cd servonkRun to install the Rust toolchain
./bootstrap.shSet the next environment variables:
export GONK_DIR=/path/to/b2g/repository
export GONK_PRODUCT_NAME=product_nameThe product name for Android devices can bee seen here in the Device column.
The product name for FirefoxOS devices can bee seen here and here in the nickname or Name/Codename cell. This may not work depending on the device.
To build, run:
# For a Gonk build
./servonk build gonk --release
# Or for a desktop version
./servonk build glutin --releaseOn desktop run:
./servonk run glutinOn mobile/Gonk, you first need to flash your device with B2G before running:
./servonk flash gonk
./servonk run gonkThe lockscreen code is 4242.