Using the B2G emulators

  • Revision slug: Mozilla/Boot_to_Gecko/Using_the_B2G_emulators
  • Revision title: Using the B2G emulators
  • Revision id: 236724
  • Created:
  • Creator: Martin1982
  • Is current revision? No
  • Comment 1 words added, 1 words removed

Revision Content

{{ B2GMain() }}

This article provides a brief guide to some key things you should know when using the Boot to Gecko emulators. This doesn't purport to be a complete user manual; instead, it simply tells you a few useful things that you might not learn on your own.

This guide assumes you've already built one of the emulators; if you haven't, rewind to Building and installing Boot to Gecko!

About the B2G emulators

There are two B2G emulators. The first, built by configuring for "emulator-x86" when running config.sh, is an x86 device emulator. While this is much faster than emulating the ARM processor, it's not as accurate a representation of what an actual device will work like. Configuring for "emulator" when running config.sh gets you the ARM device emulator.

Once you've selected, configured, and built an emulator, the rest works the same way from a user standpoint, so the rest of this guide is common to both.

Starting the emulator

To start the B2G emulator, type the following command:

./run-emulator.sh

This will handle all the emulator startup tasks for you. Now wait patiently while the emulator starts up and Boot to Gecko boots up on it. It can take a couple of minutes, so be patient.

When the emulator doesn't start up

Sometimes the emulator fails to start up. Welcome to the bleeding edge of technology! This usually happens because the adb server that handles interacting with the emulated device is either not running or has malfunctioned.

Look to see if adb is even running by doing:

ps aux | grep adb

If it's there, do this to kill it, because it's probably not working correctly.

adb kill-server

If it's not there, do this:

adb start-server

Then try running the emulator again. If it's still not working, time to drop in on #b2g on irc.mozilla.org for help.

Configuring the emulator

There are several options you can change to adjust the emulator to be more similar to the device you want to emulate. This section provides some basic information on how to do that. You can adjust the emulator's configuration by editing the run.emulator.sh script (or, ideally, a copy of it). Only a few of the most useful parameters are discussed here; you'll want to look at the qemu site for details on the others.

Tip: Create one copy of run.emulator.sh for each device you want to simulate; this makes it easy to start up with different configurations.

Changing skins

By default, the emulator starts up in HVGA mode; that's half-VGA, or 320x480 pixels. This is specified by the -skin parameter given to the emulator when started up. You can switch to a different display mode by editing the run-emulator.sh script (or, ideally, a copy of it). The provided skins are:

  • HVGA (320x480)
  • QVGA (240x320)
  • WQVGA (240x400)
  • WQVGA432 (240x432)
  • WSVGA (1024x600)
  • WVGA800 (480x800)
  • WVGA854 (480x854)
  • WXGA720 (1280x720)
  • WXGA800 (1280x800)

The skins are located in the B2G/development/tools/emulator/skins directory. It's worth noting that the format for skins is quite simple; if you look at them, they're simply folders filled with PNG files for the various user interface objects and a text file called layout which describes the layout of the interface and screen area. It's fairly simple to create custom skins if needed.

Changing memory size

Another option you may wish or need to configure is the device memory size. The default is 512 MB; however, if the device you're emulating has more or less memory, it is likely important that you adjust this setting to match, to ensure your app will run on the baseline device you want to work on. To do this, change the value of the -memory parameter to the size you need in megabytes. Other than the 512 MB default, 256 MB and 1024 MB are likely ones you'll want to test with.

To change the amount of emulated storage capacity for the device (that is, the storage space for local data, like the flash storage on a mobile phone or the hard drive on a computer), change the value of the -partition-size parameter. The default is 512 MB, but you can specify any size in MB you need in order to simulate the kind of device you need to test for.

Revision Source

<p>{{ B2GMain() }}</p>
<p>This article provides a brief guide to some key things you should know when using the Boot to Gecko emulators. This doesn't purport to be a complete user manual; instead, it simply tells you a few useful things that you might not learn on your own.</p>
<p>This guide assumes you've already built one of the emulators; if you haven't, rewind to <a href="/en/Mozilla/Boot_to_Gecko/Building_and_installing_Boot_to_Gecko" title="en/Mozilla/Boot_to_Gecko/Building_and_installing_Boot_to_Gecko">Building and installing Boot to Gecko</a>!</p>
<h2>About the B2G emulators</h2>
<p>There are two B2G emulators. The first, built by configuring for "emulator-x86" when running <code>config.sh</code>, is an x86 device emulator. While this is much faster than emulating the ARM processor, it's not as accurate a representation of what an actual device will work like. Configuring for "emulator" when running <code>config.sh</code> gets you the ARM device emulator.</p>
<p>Once you've selected, configured, and built an emulator, the rest works the same way from a user standpoint, so the rest of this guide is common to both.</p>
<h2>Starting the emulator</h2>
<p>To start the B2G emulator, type the following command:</p>
<pre>./run-emulator.sh
</pre>
<p>This will handle all the emulator startup tasks for you. Now wait patiently while the emulator starts up and Boot to Gecko boots up on it. It can take a couple of minutes, so be patient.</p>
<h2>When the emulator doesn't start up</h2>
<p>Sometimes the emulator fails to start up. Welcome to the bleeding edge of technology! This usually happens because the adb server that handles interacting with the emulated device is either not running or has malfunctioned.</p>
<p>Look to see if <code>adb</code> is even running by doing:</p>
<pre>ps aux | grep adb
</pre>
<p>If it's there, do this to kill it, because it's probably not working correctly.</p>
<pre>adb kill-server
</pre>
<p>If it's not there, do this:</p>
<pre>adb start-server
</pre>
<p>Then try running the emulator again. If it's still not working, time to drop in on <a class="link-irc" href="irc://irc.mozilla.org/b2g" title="irc://irc.mozilla.org/b2g">#b2g</a> on irc.mozilla.org for help.</p>
<h2>Configuring the emulator</h2>
<p>There are several options you can change to adjust the emulator to be more similar to the device you want to emulate. This section provides some basic information on how to do that. You can adjust the emulator's configuration by editing the <code>run.emulator.sh</code> script (or, ideally, a copy of it). Only a few of the most useful parameters are discussed here; you'll want to <a class="external" href="http://www.qemu.org/" title="http://www.qemu.org/">look at the qemu site</a> for details on the others.</p>
<div class="note"><strong>Tip:</strong> Create one copy of <code>run.emulator.sh</code> for each device you want to simulate; this makes it easy to start up with different configurations.</div>
<h3>Changing skins</h3>
<p>By default, the emulator starts up in HVGA mode; that's half-VGA, or 320x480 pixels. This is specified by the <code>-skin</code> parameter given to the emulator when started up. You can switch to a different display mode by editing the <code>run-emulator.sh</code> script (or, ideally, a copy of it). The provided skins are:</p>
<ul> <li>HVGA (320x480)</li> <li>QVGA (240x320)</li> <li>WQVGA (240x400)</li> <li>WQVGA432 (240x432)</li> <li>WSVGA (1024x600)</li> <li>WVGA800 (480x800)</li> <li>WVGA854 (480x854)</li> <li>WXGA720 (1280x720)</li> <li>WXGA800 (1280x800)</li>
</ul>
<p>The skins are located in the <code>B2G/development/tools/emulator/skins</code> directory. It's worth noting that the format for skins is quite simple; if you look at them, they're simply folders filled with PNG files for the various user interface objects and a text file called <code>layout</code> which describes the layout of the interface and screen area. It's fairly simple to create custom skins if needed.</p>
<h3>Changing memory size</h3>
<p>Another option you may wish or need to configure is the device memory size. The default is 512 MB; however, if the device you're emulating has more or less memory, it is likely important that you adjust this setting to match, to ensure your app will run on the baseline device you want to work on. To do this, change the value of the <code>-memory</code> parameter to the size you need in megabytes. Other than the 512 MB default, 256 MB and 1024 MB are likely ones you'll want to test with.</p>
<p>To change the amount of emulated storage capacity for the device (that is, the storage space for local data, like the flash storage on a mobile phone or the hard drive on a computer), change the value of the <code>-partition-size</code> parameter. The default is 512 MB, but you can specify any size in MB you need in order to simulate the kind of device you need to test for.</p>
Revert to this revision