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: 13978
  • Created:
  • Creator: Dietrich
  • Is current revision? No
  • Comment 29 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.

Backing up your Galaxy S2's native 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.

Building for Samsung Galaxy S2

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


Next, you will setup your build directory with the binary blobs necessary for building for your device.  With your device booted to the original Android OS, connected via USB and running:
$ make config-galaxy-s2

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

 

Flashing to Samsung Galaxy S2

Making and flashing the kernel (first time only)

$ 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"

A testing approach...

Once your system is up and running on your device, you can begin to use and debug very much like an Android phone.  You may have noticed that we use the Android Debug Bridge adb  for many purposes.    For example, if I wanted to debug telephony or SMS on my device, and I had incoming calls/SMSes coming from a number with area code "216"  I could monitor that with a command such as:
$ adb logcat | grep 216

To be sure, $ adb logcat with no params will simply output everything until you ctrl+c to close the adb session.

How  to enable debugging, for example, of radio component:
First, change DEBUG to true in gecko/dom/telephony/ril_worker.js
Next, rebuild gecko and reflash at least gecko on the device:
$ make install-gecko

and then provide $ adb logcat output
as well as
$ adb logcat -b radio

while performing the affected operation, e.g. trying to initiate a phone call from the dialer app.

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>
<h2>Backing up your Galaxy S2's native 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>
<h2>Building for Samsung Galaxy S2</h2>
<p>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><br> <br> Next, you will setup your build directory with the binary blobs necessary for building for your device.  With your device booted to the original Android OS, connected via USB and running:<br> <code>$ make config-galaxy-s2</code><br> <br> 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 to Samsung Galaxy S2</strong></h3>
<h4>Making and flashing the kernel (first time only)</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><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> <code>$ git pull origin master<br> $ cd ..</code> <code>$ make install-gaia<br> $ 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>
<h2>A testing approach...</h2>
<p>Once your system is up and running on your device, you can begin to use and debug very much like an Android phone.  You may have noticed that we use the Android Debug Bridge adb  for many purposes.    For example, if I wanted to debug telephony or SMS on my device, and I had incoming calls/SMSes coming from a number with area code "216"  I could monitor that with a command such as:<br> <code>$ adb logcat | grep 216</code><br> <br> To be sure, <code>$ adb logcat</code> with no params will simply output everything until you ctrl+c to close the adb session.<br> <br> How  to <strong>enable debugging</strong>, for example, of radio component:<br> First, change <code>DEBUG</code> to <code>true</code> in <code>gecko/dom/telephony/ril_worker.js</code><br> Next, rebuild gecko and reflash at least gecko on the device:<br> <code>$ make install-gecko</code><br> <br> and then provide <code>$ adb logcat</code> output<br> as well as<br> <code>$ adb logcat -b radio</code><br> <br> while performing the affected operation, e.g. trying to initiate a phone call from the dialer app.</p>
Revert to this revision