mozilla

Revision 13994 of Building B2G for Samsung Galaxy S2

  • Revision slug: Mozilla/Boot_to_Gecko/Building_B2G_for_Samsung_Galaxy_S2
  • Revision title: Building B2G for Samsung Galaxy S2
  • Revision id: 13994
  • Created:
  • Creator: benadida
  • Is current revision? No
  • Comment 40 words added

Revision Content

It is assumed you've already setup your build environment and cloned the repositories

It is advisable to follow the instructions in the order presented.

Note: There are several models with the name Samsung Galaxy S2. The one that works with these instructions is the GT-i9100. Other variants, including GT-i9100G are not supported (yet) as the hardware is different. See issue 215

Putting Your Phone in Development Mode

Before you plug your phone into your USB port, put it USB dev mode.

Under Settings > Applications > Development, turn on USB debugging.

Then, plug it in.

Backing up your Galaxy S2's vendor OS

You'll want to back up your phone's factory image before attempting to build or flash anything to it.  As it happens, the builds or flash process itself can be unstable and you don't want to end up with a brick.

These instructions assume that you have already installed heimdall.

From some other directory than where you have B2G installed:
$ cd /tmp
$ wget http://cmw.22aaf3.com/c1/recovery/re...4-galaxys2.tar
$ tar xvf recovery-clockwork-*tar
$ adb reboot download


When your phone is in "download" mode, it's ready to be flashed using Odin protocol.

To Flash Clockworked (and backup image):
With your phone in "download" mode, run the following:
$ heimdall flash --kernel zImage

Next, reboot the phone to recovery mode.
$ adb reboot recovery

With the phone in recovery mode, follow the on-screen instructions to make a backup image.

After creating the backup image, reboot into Android and backup the system files to your local machine for use later. 
$ mkdir sgs2-android
$ cd sgs2-android
$ adb pull /system system
$ adb pull /vendor vendor

Building

Do NOT run any of the following commands as root!  From the directory to where you've cloned your git repositories:

$ cd B2G
$ make sync

Important: Do not proceed until the adb pull commands from the previous section have completed.  You can run the make sync command in parallel with adb pull, but the make config-galaxy-s2 command below kills the adb server, which will cause the pulls to abort prematurely.

Next, you will setup your build directory with the binary blobs necessary for building for your device. ANDROIDFS_DIR should be set to the path you saved the Android system files to above. With your device connected via USB and running:

$ export ANDROIDFS_DIR=sgs2-android
$ make config-galaxy-s2

Now, build gonk backend and the system itself:
$ make gonk
$ make

 

Flashing

Making and flashing the kernel (first time, or if installing after a Clockworkmod restore, of if kernel isn't working)

$ make kernel
$ adb reboot download
$ heimdall flash --kernel boot/kernel-android-galaxy-s2/arch/arm/boot/zImage

Flashing B2G

$ adb reboot recovery
$ make flash-only


Building and flashing Gaia frontend

Assuming you're in the root of B2G repo, pull files from the remote repo and merge them to your local repo.  Next install gaia (by copying files from remote repo to your device):
$ cd gaia
$ git pull origin master
$ cd ..
$ make install-gaia
$ make kill-b2g

Building and flashing Gecko only

$ make install-gecko
$ make kill-b2g

Forcing GIT repo into clean state

Sometimes it's necessary to do this - but cloning a fresh repo and running make sync takes too much time
$ make sync; git clean -xfd; git submodule foreach "git clean -xfd"

Alternately, you can try:

$ make mrproper

Revision Source

<p>It is assumed you've already <a href="Setting_Up_Boot_to_Gecko_Build_Environment" rel="internal" title="https://developer.mozilla.org/en/Mozilla/Boot_to_Gecko/Setting_Up_Boot_to_Gecko_Build_Environment">setup your build environment and cloned the repositories</a></p>
<p>It is advisable to follow the instructions in the order presented.</p>
<p><strong>Note:</strong> There are several models with the name Samsung Galaxy S2. The one that works with these instructions is the GT-i9100. Other variants, including GT-i9100G are not supported (yet) as the hardware is different. See <a class=" link-https" href="https://github.com/andreasgal/B2G/issues/215" title="https://github.com/andreasgal/B2G/issues/215">issue 215</a></p>
<h2>Putting Your Phone in Development Mode</h2>
<p>Before you plug your phone into your USB port, put it USB dev mode.</p>
<p>Under Settings &gt; Applications &gt; Development, turn on USB debugging.</p>
<p>Then, plug it in.</p>
<h2>Backing up your Galaxy S2's vendor OS</h2>
<p>You'll want to back up your phone's factory image before attempting to build or flash anything to it.  As it happens, the builds or flash process itself can be unstable and you don't want to end up with a brick.<br> <br> These instructions assume that you have already <a href="/en/Mozilla/Boot_to_Gecko/Setting_Up_Boot_to_Gecko_Build_Environment#Installing_Heimdall" title="https://developer.mozilla.org/en/Mozilla/Boot_to_Gecko/Setting_Up_Boot_to_Gecko_Build_Environment#Installing_Heimdall">installed heimdall</a>.<br> <br> From some other directory than where you have B2G installed:<br> <code>$ cd /tmp<br> $ wget <a class=" external" href="http://cmw.22aaf3.com/c1/recovery/recovery-clockwork-4.0.1.4-galaxys2.tar" rel="freelink">http://cmw.22aaf3.com/c1/recovery/re...4-galaxys2.tar</a><br> $ tar xvf recovery-clockwork-*tar<br> $ adb reboot download</code><br> <br> When your phone is in "download" mode, it's ready to be flashed using Odin protocol.<br> <br> To Flash Clockworked (and backup image):<br> With your phone in "download" mode, run the following:<br> <code>$ heimdall flash --kernel zImage</code><br> <br> Next, reboot the phone to recovery mode.<br> <code>$ adb reboot recovery</code><br> <br> With the phone in recovery mode, follow the on-screen instructions to make a backup image.</p>
<p>After creating the backup image, reboot into Android and backup the system files to your local machine for use later. <br> <code>$ mkdir sgs2-android<br> $ cd sgs2-android<br> $ adb pull /system system<br> $ adb pull /vendor vendor</code></p><h2>Building</h2>
<p style="margin-left: ;">Do NOT run any of the following commands as root!  From the directory to where you've cloned your git repositories:<br> <br> <code>$ cd B2G<br> $ make sync</code></p>
<p style="margin-left: 40px;"><strong>Important:</strong> Do not proceed until the <code>adb pull</code> commands from the previous section have completed.  You can run the <code>make sync</code> command in parallel with <code>adb pull</code>, but the <code>make config-galaxy-s2</code> command below kills the <code>adb</code> server, which will cause the pulls to abort prematurely.</p>
<p>Next, you will setup your build directory with the binary blobs necessary for building for your device. ANDROIDFS_DIR should be set to the path you saved the Android system files to above. With your device connected via USB and running:</p>
<p><code>$ export ANDROIDFS_DIR=sgs2-android</code><br> <code>$ make config-galaxy-s2</code></p>
<p>Now, build gonk backend and the system itself:<br> <code>$ make gonk<br> $ make</code></p>
<p><a class="external" href="http://4.bp.blogspot.com/-IaDmq-AlC_I/TydgNEkHvAI/AAAAAAAAAMs/G2DJfdUkIts/s320/Make.tiff"><img alt="" class="default" src="http://4.bp.blogspot.com/-IaDmq-AlC_I/TydgNEkHvAI/AAAAAAAAAMs/G2DJfdUkIts/s320/Make.tiff"></a></p>
<p> </p>
<h3><strong>Flashing</strong></h3>
<h4>Making and flashing the kernel (first time, or if installing after a Clockworkmod restore, of if kernel isn't working)</h4>
<p><code>$ make kernel<br> $ adb reboot download<br> $ heimdall flash --kernel boot/kernel-android-galaxy-s2/arch/arm/boot/zImage</code></p>
<h4>Flashing B2G</h4>
<p><code>$ adb reboot recovery<br> $ make flash-only</code></p>
<h4><a class="external" href="http://2.bp.blogspot.com/-Cw8CGBVxAbM/TydgXiJA5hI/AAAAAAAAAM0/qbV_5QapWi4/s320/flashing+OS.tiff"><img alt="" class="default" src="http://2.bp.blogspot.com/-Cw8CGBVxAbM/TydgXiJA5hI/AAAAAAAAAM0/qbV_5QapWi4/s320/flashing+OS.tiff"></a></h4>
<h4><br> Building and flashing Gaia frontend</h4>
<p>Assuming you're in the root of B2G repo, pull files from the remote repo and merge them to your local repo.  Next install gaia (by copying files from remote repo to your device):<br> <code>$ cd gaia</code><br> <code>$ git pull origin master</code><br> <code>$ cd ..</code><br> <code>$ make install-gaia</code><br> <code>$ make kill-b2g</code></p>
<h4>Building and flashing Gecko only</h4>
<p><span style='font-family: "Courier New",Courier,monospace;'>$ make install-gecko</span><br> <span style='font-family: "Courier New",Courier,monospace;'>$ make kill-b2g</span></p>
<h4>Forcing GIT repo into clean state</h4>
<p>Sometimes it's necessary to do this - but cloning a fresh repo and running <code>make sync </code>takes too much time<br> <span style='font-family: "Courier New",Courier,monospace;'>$ make sync; git clean -xfd; git submodule foreach "git clean -xfd"</span></p>
<p>Alternately, you can try:</p>
<p><code>$ make mrproper</code></p>
Revert to this revision