148
edits
Changes
Created page with "= B2G porting guide for new build system = This is a guide to support new device to [https://github.com/mozilla-b2g/B2G new B2G build system]. The actual porting details might d..."
= B2G porting guide for new build system =
This is a guide to support new device to [https://github.com/mozilla-b2g/B2G new B2G build system].
The actual porting details might differ a lot between different devices.
== Clone B2G repo ==
<pre>
$ git clone https://github.com/mozilla-b2g/B2G.git
</pre>
== Create local backup of the original Android system ==
<pre>
$ mkdir my_device_backup
$ cd my_device_backup
$ adb pull /system system
</pre>
== 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 [https://github.com/mozilla-b2g/b2g-manifest/tree/galaxy-s2 galaxy-s2] branch can be used as a reference.
== Create a configuration tree for new device in device/<manufacturer>/<device_id> ==
Below are minimal files in device configuration tree:
* AndroidBoard.mk
* AndroidProducts.mk
* BoardConfig.mk
* extract-files.sh
* full_<device_id>.mk
* 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.mk".
It requires some hacking/testing/debugging to know which binary blobs should be extracted.
If you can find some existing reference on [http://www.cyanogenmod.com CyanogenMod] for the device, it will speed up the porting progress.
The [http://forum.xda-developers.com XDA Forum] is also a good place to discuss and check for resource.
== Required init.rc change for boot.img ==
Basically no change is required for kernel, the purpose to rebuild boot.img is for required init.rc change.
Main things to modify on init.rc:
* Import init.b2g.rc
* chmod 755 on /system/b2g/b2g, /system/b2g/updater, /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_B2G_INIT_RC in BoardConfig.mk.
A prebuild kernel can be used, or built kernel from source by the build system.
To build rebuild kernel, add AndroidKernel.mk and kernel config in device configuration tree.
The [https://github.com/andreasgal/B2G/tree/master/glue/gonk/device/toro/maguro 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 ==
<pre>
$ ANDROIDFS_DIR=my_device_backup ./config.sh <device_id> default.xml
$ ./build.sh
$ ./flash.sh
</pre>
== Test and debug ==
Have fun!
= Frequency asked questions =
To be added.
This is a guide to support new device to [https://github.com/mozilla-b2g/B2G new B2G build system].
The actual porting details might differ a lot between different devices.
== Clone B2G repo ==
<pre>
$ git clone https://github.com/mozilla-b2g/B2G.git
</pre>
== Create local backup of the original Android system ==
<pre>
$ mkdir my_device_backup
$ cd my_device_backup
$ adb pull /system system
</pre>
== 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 [https://github.com/mozilla-b2g/b2g-manifest/tree/galaxy-s2 galaxy-s2] branch can be used as a reference.
== Create a configuration tree for new device in device/<manufacturer>/<device_id> ==
Below are minimal files in device configuration tree:
* AndroidBoard.mk
* AndroidProducts.mk
* BoardConfig.mk
* extract-files.sh
* full_<device_id>.mk
* 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.mk".
It requires some hacking/testing/debugging to know which binary blobs should be extracted.
If you can find some existing reference on [http://www.cyanogenmod.com CyanogenMod] for the device, it will speed up the porting progress.
The [http://forum.xda-developers.com XDA Forum] is also a good place to discuss and check for resource.
== Required init.rc change for boot.img ==
Basically no change is required for kernel, the purpose to rebuild boot.img is for required init.rc change.
Main things to modify on init.rc:
* Import init.b2g.rc
* chmod 755 on /system/b2g/b2g, /system/b2g/updater, /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_B2G_INIT_RC in BoardConfig.mk.
A prebuild kernel can be used, or built kernel from source by the build system.
To build rebuild kernel, add AndroidKernel.mk and kernel config in device configuration tree.
The [https://github.com/andreasgal/B2G/tree/master/glue/gonk/device/toro/maguro 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 ==
<pre>
$ ANDROIDFS_DIR=my_device_backup ./config.sh <device_id> default.xml
$ ./build.sh
$ ./flash.sh
</pre>
== Test and debug ==
Have fun!
= Frequency asked questions =
To be added.