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: 13997
  • Created:
  • Creator: philikon
  • Is current revision? No
  • Comment 351 words added, 295 words removed

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.

Creating a local copy of the original Android system

The phone ships with numerous binary blobs that B2G requires as well. It is therefore recommended, to create a local copy of the phone's Android system directories:

$ mkdir sgs2-android
$ cd sgs2-android
$ adb pull /system system
$ adb pull /vendor vendor

Building and flashing the kernel

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 we can build the kernel:

$ make kernel

Once that's done, reboot the phone into download mode:

$ adb reboot download

Once you see the download screen, flash the kernel with the following command (these instructions assume that you have already installed heimdall).

$ heimdall flash --kernel boot/kernel-android-galaxy-s2/arch/arm/boot/zImage

Backing up the original Android system on the phone

Before you flash B2G onto the phone, it's highly recommended to create a backup of the original Android system on the phone. This is so that you can always go back to Android and retrieve the binary blobs in case you lose your local copy in ANDROID_FSDIR.

Reboot the phone to recovery mode:

$ adb reboot recovery

Then follow the onscreen instructions for making a backup image. The backup image will be stored on the phone's internal SD card.

Building and flashing B2G

Now we can build B2G. When you're building for the first time, you will also have to build the Gonk target (this is not required on subsequent builds):
$ make gonk
$ make

Once you're done building, reboot the phone into download mode and flash the B2G image onto the phone:

$ adb reboot download
$ make flash-only

Building and flashing the Gaia frontend only

Gaia is part of the B2G image, but it can be updated separately.

Assuming you're in the root of B2G repo, pull files from the remote repo and merge them to your local repo:

$ cd gaia
$ git pull origin master
$ cd ..

Then you can update Gaia on the phone with the following commands:

$ make install-gaia
$ make kill-b2g

Building and flashing Gecko only

In case you make changes to Gecko and want to put those on the device, you don't have to go through the entire flash cycle. The following steps will live-update Gecko running on the phone:

$ make install-gecko
$ make kill-b2g

Forcing the 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 mrproper

Important: This will reset your B2G repository completely. It will appear as if you just checked out. You will lose all local modifications and files not tracked by Git!

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>Creating a local copy of the original Android system</h2>
<p>The phone ships with numerous binary blobs that B2G requires as well. It is therefore recommended, to create a local copy of the phone's Android system directories:</p>
<p><code>$ mkdir sgs2-android<br> $ cd sgs2-android<br> $ adb pull /system system<br> $ adb pull /vendor vendor</code></p>
<h2>Building and flashing the kernel</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 we can build the kernel:</p>
<p><code>$ make kernel</code></p>
<p>Once that's done, reboot the phone into download mode:</p>
<p><code>$ adb reboot download</code></p>
<p>Once you see the download screen, flash the kernel with the following command (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>).</p>
<p><code>$ heimdall flash --kernel boot/kernel-android-galaxy-s2/arch/arm/boot/zImage</code></p>
<h2>Backing up the original Android system on the phone</h2>
<p>Before you flash B2G onto the phone, it's highly recommended to create a backup of the original Android system on the phone. This is so that you can always go back to Android and retrieve the binary blobs in case you lose your local copy in ANDROID_FSDIR.</p>
<p>Reboot the phone to recovery mode:</p>
<p><code>$ adb reboot recovery</code></p>
<p>Then follow the onscreen instructions for making a backup image. The backup image will be stored on the phone's internal SD card.</p>
<h2>Building and flashing B2G</h2>
<p>Now we can build B2G. When you're building for the first time, you will also have to build the Gonk target (this is not required on subsequent builds):<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>Once you're done building, reboot the phone into download mode and flash the B2G image onto the phone:</p>
<p><code>$ adb reboot download<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>
<h3>Building and flashing the Gaia frontend only</h3>
<p>Gaia is part of the B2G image, but it can be updated separately.</p>
<p>Assuming you're in the root of B2G repo, pull files from the remote repo and merge them to your local repo:</p>
<p><code>$ cd gaia</code><br> <code>$ git pull origin master</code><br> <code>$ cd ..</code></p>
<p>Then you can update Gaia on the phone with the following commands:</p>
<p><code>$ make install-gaia</code><br> <code>$ make kill-b2g</code></p>
<h3>Building and flashing Gecko only</h3>
<p>In case you make changes to Gecko and want to put those on the device, you don't have to go through the entire flash cycle. The following steps will live-update Gecko running on the phone:</p>
<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>
<h2>Forcing the Git repo into clean state</h2>
<p>Sometimes it's necessary to do this - but cloning a fresh repo and running <code>make sync </code>takes too much time. </p><p><code>$ make mrproper</code></p> <p style="margin-left: 40px;"><strong>Important:</strong> This will reset your B2G repository completely. It will appear as if you just checked out. You will lose all local modifications and files not tracked by Git!</p>
Revert to this revision