B2G porting guide for new build system
This is a guide to support new device to new B2G build system. The actual porting details might differ a lot between different devices.
Clone B2G repo
$ git clone https://github.com/mozilla-b2g/B2G.git
Create local backup of the original Android system
$ mkdir my_device_backup $ cd my_device_backup $ adb pull /system system
Add new device in config.sh
You may refernece "galaxy-s2" in config.sh as a template.
Create manifest file "default.xml" for new device
Add all required repos to manifest file for the new device. You can reference https://github.com/mozilla-b2g/b2g-manifest as a template, there are different branches for each device. The Galaxy-S2 branch can be used as a reference.
Create configuration tree for new device
You need to create a new configration tree for new device at device/<manufacturer>/<device_id>
The tree should include at least:
- idc files for touchscreen
- init files (init.rc, init.<target>.rc, uevent.rc...)
The content might differ a lot between devices, especially "BoardConfig.mk" and "extract-files.sh". It requires some hacking/testing/debugging to know which binary blobs should be extracted. If you can find some existing reference on CyanogenMod for the device, it will speed up the porting progress. The XDA Forum is also a good place to discuss and check for resource.
The need to rebuild boot.img
Basically no change is required for kernel, the purpose to rebuild boot.img is for required init.rc change.
Required change on init.rc
The init.rc is not the one provided by b2g, it has to be pulled from the phone.
Main things to modify on init.rc:
- Import init.b2g.rc
on early-init start ueventd import /init.b2g.rc
- chmod 755 on /system/b2g/b2g, /system/b2g/updater, /system/b2g/plugin-container (put these after mounting system read/write)
chmod 0755 /system/b2g/b2g chmod 0755 /system/b2g/updater chmod 0755 /system/b2g/plugin-container
You might want to modify from init.rc of new device, instead of using the init.rc provided by the build system. In this case, you need to set TARGET_PROVIDES_INIT_RC in BoardConfig.mk.
Prebuilt kernel vs building kernel from source
A prebuilt kernel can be used, or you may also build kernel from source by the build system. To build kernel by build system, add AndroidKernel.mk and kernel config in device configuration tree.
The maguro on old build system is an example that builds kernel from source.
Add new device in flash.sh
Add the new device, depending on what flash tool required by new device.
Config/build/flash for new device
$ ANDROIDFS_DIR=my_device_backup ./config.sh <device_id> default.xml $ ./build.sh $ ./flash.sh
Test and debug
Frequency asked questions
To be added.