B2G/QA/Tips And Tricks

From MozillaWiki
< B2G‎ | QA
Jump to: navigation, search


B2G Tips Tricks

A collection of QA's tips and tricks on how to test Firefox OS. See here for List of Terms

ADB Tips

  adb shell cat /system/build.prop | grep 'ro.build.version.incremental'
  adb shell cat /system/build.prop | grep 'ro.build.date='


  adb shell getprop ro.build.version.incremental
  adb shell getprop ro.build.date

Installing ADB on your machine


For 2.1 are taken via power button + volume down button

For 2.0 it remains power button + home

Internal Storage

If you have an SD card in the device, the internal storage will be at /mnt/sdcard2/screenshots .

Or you can follow the steps below to find the internal/external storage mapping.

  • Start a remote shell in your phone
 $ adb shell
  • List detail information of /sdcard folder.
 root@android:/ # ls -l /sdcard                                                  
 lrwxrwxrwx root     root              1980-03-20 00:12 sdcard -> /mnt/sdcard
  • Display the filesystems
 root@android:/ # df
 Filesystem             Size   Used   Free   Blksize
 /system                503M   186M   317M   4096
 /data                    1G    19M     1G   4096
 /cache                 188M     4M   184M   4096
 /mnt/sdcard2             1G    93M     1G   4096
 /mnt/sdcard              3G   396M     3G   32768
 root@android:/ #
  • The /mnt/sdcard mounted to /sdcard, which should be the external storage (SD card). And /mnt/sdcard2 should be the internal storage.

Conversion tool to change file formats

Checking Hardware versus Software Graphics Rendering

  • Currently there is no implementation for a frame rate counter for hwc. This allows us to check software versus hardware rendering by turning on the frame rate counter.
    • to turn on the frame rate counter, go to settings -> device information -> more information -> developer -> show frames per sec...
    • to turn off the hwc :
adb root
adb pull /system/b2g/defaults/pref/user.js .
echo 'pref("layers.composer2d.enabled", false);' >> user.js 
adb remount
adb push user.js /system/b2g/defaults/pref
adb shell sync && adb reboot

Wifi Logging

  • turn on the wifi debug message in Settings/Device

information/More Information/Developer/Wi-Fi output in adb,

  • attach the debug message using "adb logcat". You need to turn off/on the wifi to

output the debug message.

Packet Sniffing


HTTP logging


Addon to Firefox web browser to see Firefox OS Simulator


Launching Desktop B2G on mac with profile

 $ git clone git://github.com/mozilla-b2g/gaia
 $ make -C gaia profile
 $ /path/to/b2g -profile gaia/profile
 (eg. Tonys-MacBook-Air:MacOS tchung$ ./b2g -profile /Users/tchung/Desktop/DailyB2G/07172012_desktop/gaia/profile)


of the RIL (Software Module Structure)


Setting the system clock

 $ adb shell date -s 20120731.172200  (for 5:22pm)
  • In order to print the format the same on the mac:
  date -j "+%Y%m%d.%H%M%S"
  • Placing them together :
  adb shell date -s `date -j "+%Y%m%d.%H%M%S"`

Tricking b2g emulator to see network

 1) launch emulator ./run-emulator.sh
 2) adb shell setprop net.dns1

Sending class-0 message w/ emulator

 $ ./run-emulator.sh &
 $ telnet localhost 5554
 > sms pdu 00000191F10010001010000000000141

See https://mxr.mozilla.org/mozilla-central/source/dom/mobilemessage/tests/marionette/test_message_classes.js#57

To get the Device IP

 $ adb shell netcfg

This will list of the devices with the ips on which it is running. If you are unable to check the device by name, then check by the mac address which is listed in the last column of the output

For changing the preference:

1. adb root
2. adb remount
3. adb pull /system/b2g/defaults/pref/user.js .
4. edit the file and change : 
     pref("geo.gps.supl_server", "test.supl.svc.ovi.com");
     pref("geo.gps.supl_port", 7276);
     pref("geo.gps.supl_server", "supl.google.com");
     pref("geo.gps.supl_port", 7276);
5. adb push user.js /system/b2g/defaults/pref
6. adb reboot

Media Files Repository

Can be found here: http://hg.mozilla.org/mozilla-central/file/tip/content/media/test

Importing Contacts via Device (manually)

  • First, export your contacts in your old phone to the SIM card.
    • Some phones have this feature built-in, check your Contacts app or phone settings.
    • Android: To export Google contacts onto a SIM card (which Android does not do by default), install the free app Contact2Sim. Open the app, select the phone, and in the options menu choose "Copy missing to SIM".
    • iPhone: No easy solution. You could probably sync iPhone to Mac Address Book, and sync that to Google, and then find an Android phone to export those to your sim card.
  • Second, put the SIM card in your Firefox phone, open the Contacts app and click the "Import SIM contacts" button.

Adding CA certs to Firefox OS

Getting prefs of the device

You can use edit-prefs.sh to get the prefs on device. It's located in the B2G repo: https://github.com/mozilla-b2g/B2G/blob/master/edit-prefs.sh

Changing preferences


 PREFS_JS=$(adb shell echo -n "/data/b2g/mozilla/*.default")/prefs.js
 adb pull $PREFS_JS
 edit prefs.js
 adb shell stop b2g
 adb push prefs.js $PREFS_JS
 adb shell start b2g
  • things to change :
    • For email debugging, setting this pref to set true : "browser.dom.window.dump.enabled"

User.js Examples:

RIL Debugging

The below example turns RIL debugging on

 adb pull /system/b2g/defaults/pref/user.js .
 < edit user.js and set "ril.debugging.enabled" to true >
 adb remount
 adb push user.js /system/b2g/defaults/pref
 adb shell sync && adb reboot
 1. adb root
    adb remount
 2. Pull omni.ja from DUT
    adb pull /system/b2g/omni.ja
 3. Unzip omni.ja 
    unzip omni.ja -d Omni
 4. Find ril_consts.js in Omni/modules/
 5. Open ril_consts.js and update this.DEBUG_ALL = false to true.
    sed -i 's/this.DEBUG_ALL = false;/this.DEBUG_ALL = true;/g' Omni/modules/ril_consts.js
 6. cd Omni, zip all files
    zip -r omni.ja *
 7. Push it back to DUT then reboot it.
    adb push omni.ja /system/b2g
    adb reboot

Alternative way to turn on ril debugging from settings

Settings > Developer Developer > RIL output in ADB

User Agent

 adb root
 adb pull /system/b2g/defaults/pref/user.js .
 echo 'pref("general.useragent.override", "Mozilla/5.0 (Android; Mobile; rv:22.0) Gecko/22.0 Firefox/22.0");' >> user.js 
 adb remount
 adb push user.js /system/b2g/defaults/pref
 adb shell sync && adb reboot

MMS debuging

  • Add 'pref("mms.debugging.enabled", true);' to turn MMS debugging on
 adb forward tcp:9999 tcp:9999
 netcat localhost 9999
 navigator.mozSettings.createLock().set({'wifi.debugging.enabled': true})
  • to turn it back off, just set it to false:
 navigator.mozSettings.createLock().set({'wifi.debugging.enabled': false})

Source : bug 806611

  • to turn system system updates off; set gaia.system.checkForUpdates to false

Backing up the Profile and Restoring it after flash

To note : this works for the same version to same version. If you skip a version or if you're migrating from one version to the next, this may not work if it skips the database migration code of those apps.

1. back up your profile:

 <go to a temp folder somewhere on your computer >
 adb pull /data/local local
 adb pull /data/b2g b2g

2. restore your profile:

 adb push local /data/local
 adb push b2g /data/b2g


Getting crashes off the Device

by web app for version 1.2+


To install on your device, follow these steps:

  1. Enable remote debugging on your device with your device plugged in
  2. Run "adb forward tcp:6000 localfilesystem:/data/local/debugger-socket"
  3. Open the App Manager in Firefox under Tools --> Web Developer --> App Manager
  4. Download the about crashes app & extract it locally
  5. Add the about crashes extracted folder as a packaged app
  6. Select connect to localhost:6000
  7. After the connection is established, select the about crashes app & hit update

Reference Documentation: https://developer.mozilla.org/en-US/Firefox_OS/Using_the_App_Manager

command line to get the crash ids

  • adb shell ls -l /data/b2g/mozilla/Crash\ Reports/submitted/

if you have a long list of crashes and want them sorted by date, use this:

  • adb shell busybox ls -ltr /data/b2g/mozilla/Crash\ Reports/submitted/

getting/verifying the crash report

  1. copy the filename without the extension
  2. go to http://crash-stats.mozilla.org
  3. paste the filename without the extension in the upper right hand search box

This should get you to the crash report you have submitted.

How to Force a crash

how to run GDB script for b2g

  • Start the gallery app on the phone.
  • $ adb shell b2g-ps
 Note the pid of the gallery app
  • $ ./run-gdb.sh attach <pid>
  • Cause the crash
  • (gdb) bt

[Courtesy of jlebar]




Download and unzip the tarball, cd to busybox-b2g, and run install.sh


All of the busybox utilities get symlinks in /system/bin, so you can just run e.g. 'ping' directly

adb shell ping   => ping command 
adb shell ifconfig wlan0 => check tx/rx bytes  
adb shell cat /proc/net/route    => check the default route
adb shell iptables -t nat -nvL   => check if the packets are sent from application to IP layer, check Chain OUTPUT (policy ACCEPT 2 packets, 168 bytes)


Here is the way to provide more logs. dbus-log.txt Usage in ubuntu linux:

  1. Unzip File:Dbus-tool.zip
  2. adb root
  3. adb push dbus-monitor /system/bin
  4. adb shell chmod 777 /system/bin/dbus-monitor
  5. adb push dbus-uuidgen /system/bin
  6. adb shell chmod 777 /system/bin/dbus-uuidgen
  7. Before running dbus-monitor, you need to run "dbus-uuidgen --ensure" in unagi first.
  8. adb shell dbus-monitor --system "type='signal'" |tee dbus-log.txt
  9. Start to test. Now dbus log will be recorded.


  1. . Why we use it : http://en.wikipedia.org/wiki/D-Bus
  2. . example and instructions from : bug 828860

Rooting a production device

Partner production builds often come with unrooted access. You can follow these steps if you have a special rooted boot image from the partner.

  • Pre-setup: receive a rooted boot.img from the partner. This usually means root=true.

Buri Device

start up in normal adb mode.
 $ adb reboot bootloader  //enter into fastboot. you should see a White splashscreen
 $ fastboot flash boot boot_rooted.img  //flash the boot_rooted.img onto the boot partition
   sending 'boot' (4506 KB)...
   OKAY [  0.410s]
   writing 'boot'...
   OKAY [  0.727s]
   finished. total time: 1.137s
 $ fastboot reboot   //reboot the image
 $ adb shell
   root@android:/ #    

cmd line prompt "root@android:/ #" means you're in rooted mode.

Flame Device

if you are using a user build on a Flame device and you need have root access. All you need is flashing boot.img from engineering build on top of it, and you'll get the root access.

Enable Graphics Performance Indicator

Go to Settings app, select Developer -> Developer HUD and enable 'Frames Per Second.' This will trigger the display of framecount values, as well as a warning that shows whether a transaction was out of budget.

Refer to: http://benoitgirard.wordpress.com/2014/08/29/visual-warning-for-slow-b2g-transaction-landed/ for more info.

Also note, the red rectangle that appears on the top right corner means the system uses sync scrolling, instead of APZC. Refer to bug 1053992 for more info.

Find the Pixel Ratio

In WebIDE, Runtime choose your device(it needs to turn on the debugging via USB from device in Developer's page of Settings app) then Open the system app. In the console tab, enter "window.devicePixelRatio" in command line to get the pixel ratio of screen.


Outdated scripts

Incomplete Script

Hardware Cheat codes

  • System Recovery Utilities:
    • Inari: reboot, power-on+ volume up
    • Hamachi/Buri : reboot, turn on, volume up
  • System Recovery Only UI:
    • Hamachi/Buri : reboot, power-on+volume-up
  • Fastboot mode: (mode that allows flashing on the device without setting remote debug on)
  • upload mode (visual screen change):
    • Inari : plug in, power on, hold volume up+down
    • Leo: take out battery, hold up volume button, plug into computer
    • Hamachi/Buri :take out battery, hold volume up + volume down , plug into computer
  • FTU Mode :
    • Inari : plugin, power on, power + volume down

  • Calibrating the Proximity sensor
    • Inari
      1. load the image to the device
      2. start the Dialer app
      3. Input "*983*0#" and press "send". The device should start vendor engineering test app
      4. Press "Down" and Select "Sensor"
      5. Press "Calibrate" button to do prox sensor calibration
      6. The device will show "Calibrate OK", when the calibration is complete.
      7. Then you can test the sensor.
        1. block the sensor, the screen will show "Proximity:true"
        2. unblock the sensor, the screen will show "Proximity:false"
      8. Press "Back", "Quit" to quit this app, and check whether the sensor can work in voice call.

( Source : https://bugzilla.mozilla.org/show_bug.cgi?id=857484 )

  • Getting IMEI info:
    • dial *#06# in the phone app.

  • Getting Touchscreen Info:
 $ adb shell cat /proc/touchscreen/ts*

  • Geeksphone unlocking bootloader

If you run into the issue of not being able to flash the device:

 1. get to fastboot via "adb reboot bootloader" 
 2. try to do fastboot devices... if you get the message "lock state: locked", it means your bootloader is locked.

To unlock it :

 1. adb reboot bootloader
 2. fastboot oem unlock
 3. press the "Vol+" key to accept, and validate by pressing Power. 
 4. The device will reboot, issue another: adb reboot bootloader.
 5. run the flash script again.

Devices that don't allow for adb root/adb remount

If you do a |adb shell getprop ro.secure| it should return 1. You basically have to repack which is complicated, or get a different boot.img.

The things that are blocking is the default.prop which has to be set to: ro.secure=0 ro.debuggable=1 persist.service.adb.enable=1

Unforuntately without mount/remount/root it's difficult.

ADB tricks

  • command to run and check the system directory:
  while true; do clear; adb shell mount | grep "system";sleep 1;done
  • a different log to check why mounting and other possible system issues:
 adb shell dmesg

Help I bricked my phone/Unagi



   Name: T-Mobile
   APN: epc.tmobile.com or fast.tmobile.com (for LTE devices)
   Proxy: <Not set>
   Port: <Not set>
   Username: <Not set>
   Password: <Not set>
   Server: <Not set>
   MMSC: http://mms.msg.eng.t-mobile.com/mms/wapenc
   MMS proxy: <Not set>
   MMS port: <Not set>
   MMS protocol: WAP 2.0
   MCC: 310
   MNC: 260
   Authentication type: <Not set>
   APN type: <Not Set> OR Internet+MMS (depending on software version)
    • AT&T :
   Name: can be anything
   APN: wap.cingular
   Proxy: leave blank
   Port: leave blank
   Server: leave blank
   MMSC: http://mmsc.cingular.com
   MMS Proxy: wireless.cingular.com
   MMS Port: 80
   APN Type: leave blank


  adb logcat | grep -E 'MCC|MNC'

COMRIL vs MOZRIL checking

  • changes were made in COMRIL, that should be available in AU 112(v 1.0.1)/AU 103 (for v1.1) and beyond, where if the comril fails, it fails over to the mozril. You must have ril debugging turned on in the preference. See https://wiki.mozilla.org/B2G/QA/Tips_And_Tricks#Changing_preferences
    • With Gecko RiL debugging enabled in Developer Settings, run |adb logcat| , if QContentHelper is present you are on COM RiL, otherwise you're utilizing MozRiL

Dealing with the Commercial RIL

If the bundles are in the distribution folder, then it will use that RIL:

  • adb shell ls /system/b2g/distribution/bundles/

To revert and use mozril, delete the bundles folder:

  • adb root
  • adb shell mount -o remount,rw /system
  • adb shell rm -r /system/b2g/distribution/bundles
  • adb shell mount -o remount,ro /system
  • adb shell sync && adb reboot

Locating the Firmware version on your Device

  • adb shell cat /proc/version
 Linux version 3.0.21-perf (jeremy.kim@LGEARND8B7) (gcc version 4.4.3 (GCC) ) #1 PREEMPT Mon May 13 14:20:36 KST 2013

Flashing only Gecko and Gaia bits over your base image

These are steps if you only want to apply gecko and gaia over your device Gonk or Commercial RIL.

  • Pre-setup:
  • Flash the base Leo build on the device, so you have the vendor binaries
  • download the Gaia.zip and b2g-18.0.en-US.android-arm.tar.gz from the Device directory's location. (Leo example)
  • Extract both into a temp directory
  $ adb root
  $ adb shell stop b2g
  $ adb remount
  //Updating gecko (make sure you push the b2g directory not the b2g app, 
  //ie be at the directory one level above the unzipped b2g-18 zip file instead of inside the b2g folder)
  $ adb push b2g /system/b2g
  //If gaia doesn't work the first time around, do the steps above and the following and then do the gaia update portion; 
  // otherwise skip this and go to the updating gaia portion:
  $ adb shell rm -r /cache/*
  $ adb shell rm -r /data/b2g/*
  $ adb shell rm -r /data/local/webapps
  $ adb shell rm -r /system/b2g/webapps
  //Updating gaia:
  $ adb push gaia/profile/webapps /system/b2g/webapps
  $ adb push gaia/profile/settings.json /system/b2g/defaults/
  $ adb push gaia/profile/user.js /system/b2g/defaults/pref/
  // restart
  $ adb shell sync
  $ adb shell reboot

Removing RIL + flashing Gecko + flashing Gaia and reseting profile

Instructions for updating currently:

  • Pre-setup:
  • Flash the base Leo build on the device, so you have the vendor binaries
  • download the Gaia.zip and b2g-18.0.en-US.android-arm.tar.gz from the Device directory's location. (Leo example)
  • Extract both into a temp directory
  $ adb root
  $ adb shell stop b2g
  $ adb remount
  // remove the RIL
  $ adb shell rm -r /system/b2g/distribution/bundles 

  //Updating gecko (make sure you push the b2g directory not the b2g app, 
  //ie be at the directory one level above the unzipped b2g-18 zip file instead of inside the b2g folder)
  $ adb push b2g /system/b2g
  //If gaia doesn't work the first time around, do the steps above and the following and then do the gaia update portion; 
  // otherwise skip this and go to the updating gaia portion:
  $ adb shell rm -r /cache/*
  $ adb shell rm -r /data/b2g/*
  $ adb shell rm -r /data/local/webapps
  $ adb shell rm -r /system/b2g/webapps
  //Updating gaia:
  $ adb push gaia/profile/webapps /system/b2g/webapps
  $ adb push gaia/profile/settings.json /system/b2g/defaults/
  $ adb push gaia/profile/user.js /system/b2g/defaults/pref/
  // restart
  $ adb shell sync
  $ adb shell reboot



  • Enable NFC log (1)
  $ adb remount
  $ adb pull /system/b2g/omni.ja
  $ unzip omni.ja -d Omni
  $ sed -i 's/this.DEBUG_ALL = false;/this.DEBUG_ALL = true;/g' Omni/modules/nfc_consts.js
  $ cd Omni
  $ zip -r omni.ja *
  $ adb push omni.ja /system/b2g
  $ adb reboot
  • Enable NFC log (2)
  Settings -> Developer -> NFC output in ADB
  • How to check if phone ever been suspend mode
  $ adb shell dmesg
 <6>[  109.614777] msm_pm_enter: power collapse
 <6>[  109.614777] msm_pm_enter: return
 <6>[  109.615516] Enabling non-boot CPUs ...
 <6>[  109.621578] CPU1 is up
 <6>[  109.625297] PM: noirq resume of devices complete after 3.675 msecs
 <6>[  109.630210] PM: early resume of devices complete after 3.334 msecs
 <6>[  109.632733] mmc1: slot status change detected (0 -> 1), GPIO_ACTIVE_LOW
 <6>[  109.634477] as3647 2-0030: Resuming AS364X
 <6>[  109.714609] PM: resume of devices complete after 84.359 msecs
 <6>[  109.718752] Restarting tasks ... done.
 <6>[  109.721717] PM: suspend exit 2014-07-31 00:15:52.031242786 UTC
 <6>[  109.721750] PM: suspend entry 2014-07-31 00:15:52.031280129 UTC
 <6>[  109.721760] PM: Syncing filesystems ... done.
 <6>[  109.723166] Freezing user space processes ... (elapsed 0.01 seconds) done.
 <6>[  109.743083] Freezing remaining freezable tasks ... (elapsed 0.02 seconds) done.
 <6>[  109.763799] Suspending console(s) (use no_console_suspend to debug)
 <6>[  109.799106] as3647 2-0030: Suspending AS364X
 <6>[  109.806458] PM: suspend of devices complete after 37.257 msecs


  • How to setup wifi environment with EAP-SIM/EAP-TTLS/EAP-PEAP/EAP-TLS enabled

Required equipments:

  • One Access Points with Radius supported
  • Card reader for reading SIM card
  • One desktop with Ubuntu for radius server
  • Wifi Environment setup:
    • Follow the "Compile freeradius with EAP-SIM/AKA support" section in http://bit.ly/1guIKyb to setup freeradius server in ubuntu 12.04.
    • Add below information in /etc/freeradius/users
  "sqa"     Cleartext-Password := "password"
  Service-Type = Administrative-User,
  Reply-Message = "Radius Login Success"
    • The IMSI read by SIM card reader is 15 digits. Take 466923003314697 as an example.
  In simtriplets, the format of IMSI should be 1+IMSI+@wlan.mnc092.mcc466.3gppnetwork.org. So, it will be 1466923003314697@wlan.mnc092.mcc466.3gppnetwork.org.
    • After above steps, the
   /etc/freeradius/eap.conf , 
   and /etc/freeradius/users 
   are all configured.
    • The EAP-SIM, EAP-TTLS, EAP-PEAP are all enabled.
    • Start the freeradius server.
  $ sudo /usr/sbin/freeradius -X
  • Steps to enable EAP-TLS
    • 1. Generate CA files
     $ cd /usr/lib/ssl/misc/
     $ su
     $ ./CA.pl -newca, follow the steps to generate certificate in ./demoCA directory
     $ cd /demoCA
     $ openssl x509 -outform der -in cacert.pem -out cacert.crt  => This CA certificate can be installed in devices.
    • 2. Generate server side certificate
     $ openssl req -new -nodes -keyout srv_key.pem -out srv_req.pem -config ../openssl.cnf 
     $ openssl ca -config ../openssl.cnf -policy policy_anything -out srv_cert.pem -infiles ./srv_req.pem
     $ cat srv_key.pem srv_cert.pem > srv_keycert.pem
    • 3. Generate client side certificate
     $ openssl req -new -keyout cli_key.pem -out cli_req.pem -config ../openssl.cnf
     $ openssl ca -config ../openssl.cnf -policy policy_anything -out cli_cert.pem -infiles ./cli_req.pem
     $ openssl pkcs12 -export -in cli_cert.pem -inkey cli_key.pem -out cli_cert.p12 -clcerts
    • 4. Generate 2 required files that TLS needs
     $ openssl dhparam -check -text -5 512 -out dh
     $ dd if=/dev/urandom of=random count=2
    • 5. put srv_keycert.pem in default cert directory of freeraidus. In this example, the directory is /etc/freeradius/certs
    • 6. put cacert.pem in default cert directory of freeraidus. In this example, the directory is /etc/freeradius/certs
    • 7. put dh & random files in default cert directory of freeradius
    • 8. Modify the below information in /etc/freeradius/eap.conf
     private_key_password = whatever (the one you input in generating certificate)
     private_key_file = ${certdir}/srv_keycert.pem (the output of STEP 2)
     certificate_file = ${certdir}/srv_keycert.pem (the same as above)
     CA_file = ${cadir}/cacert.pem (this file is in demoCA/)
     dh_file = ${certdir}/dh (the output of STEP 4)
     random_file = ${certdir}/random (the output of STEP 4)
    • 9. Restart freeradius server
     $ sudo /usr/sbin/freeradius -X
    • 10. Upload a CA certificate to device, this certificate can be used by EAP-TTLS/PEAP
     - $ adb push /usr/lib/ssl/misc/demoCA/cacert.crt /sdcard/Download (generate in STEP 1)
     - Goto Settings -> Location & Security -> Install from SD card on android device
     - Click on cacert.crt file
     - Enter a name for this certificate
    • 11. Configure device to Test EAP-TLS
     Install a user certificate
     - $ adb push /usr/lib/ssl/misc/cli_cert.p12 /sdcard/Download (generate in STEP 3)
     - Goto Settings -> Location & Security -> Install from SD card on android device
     - Click on cli_cert.p12 file
     - Enter the password to extract the certificates when prompted


  • Cellbroadcast and CMAS currently can be tested by emulator.

Building Gecko/Gaia

B2G Compiling Gecko

  • Follow the instructions on : https://github.com/mozilla-b2g/B2G
  • if you have all the prereqs, you just need to clone the repo
  • use the config.sh to config what you're building, use the Branch variable to switch branches, use the device name to build for the specific devices
    • BRANCH=master ./config.sh peak
    • BRANCH=v1-train ./config.sh leo
  • build gecko
    • ./build.sh gecko

Small incremental changes after compiling Gecko one time

Run the following script :
<b2g directory>/scripts/fastxul.sh

if there are IPDL changes, you will have to use "./build.sh gecko" first

B2G Compiling Gaia

Importing contacts, dial data, sms, and media via USB

  • You can do this by just cloning the gaia repo and switching to master branch:
 git clone https://github.com/mozilla-b2g/gaia.git
 git checkout origin/master
 git checkout master

And then run the script to populate sqlite db

Note: the following steps below assumes that you have built your own gecko and gaia repo. If you havent done that first, you cannot run these steps. See Instructions on building your B2G Repo. Average time it takes to sync and build is around 5-8 hours

  • Start by syncing and updating your Gaia repo
 ./repo sync gaia
 Cd gaia
  • run the script that populates your sqlite db
 $ make reference-workload-x-heavy 
 Images:          250
 Songs:           250
 Videos:           50
 Contacts:       2000
 Sms Messages:   2000
 Dialer History:  500
 $ make reference-workload-medium
 Images:           50
 Songs:            50
 Videos:           10
 Contacts:        500
 Sms Messages:    500
 Dialer History:  100
 $ make reference-workload-light
 Images:           20
 Songs:            20
 Videos:            5
 Contacts:        200
 Sms Messages:    200
 Dialer History:   50

Reference : https://developer.mozilla.org/en-US/Firefox_OS/Platform/Gaia/Hacking#Reference_Workloads

Hi DPI builds

  • Currently supported screens:
    • qHD: ~540×960, device pixel ratio = 1.6875
    • WVGA: ~480×800, device pixel ratio = 1.5

How to:

  • You need to set GAIA_DEV_PIXELS_PER_PX=1.5 when using any make command


  • GAIA_DEV_PIXELS_PER_PX=1.5 make reset-gaia
  • GAIA_DEV_PIXELS_PER_PX=1.5 make install-gaia
  • GAIA_DEV_PIXELS_PER_PX=1.5 BUILD_APP_NAME=contacts make install-gaia

Other Gaia compilation commands

    • turn on privacy panel
    • to make branded; default 0
  • make production
    • production build versus engineering
    • dogfood is turned on
  • make profile
    • makes only the profile
  • make reset-gaia, keeps your old profile
    • resets gaia
  • make install-gaia
    • installs gaia, brand new
  • APP=<app name>
    • installs the specific application in the gaia directory
  • make clean
    • removes the generated profile; will be available when bug 874774 lands.
  • make really-clean
    • removes the generated profile and removes the directory's xul-runner; run when things seemed borked.

Example : if you want the production dogfood build that's branded: MOZILLA_OFFICIAL=1 DOGFOOD=1 make production

See : https://developer.mozilla.org/en-US/docs/Mozilla/Firefox_OS/Platform/Gaia/Build_System_Primer Also see : https://developer.mozilla.org/en-US/Firefox_OS/Customization_with_the_.userconfig_file and https://github.com/mozilla-b2g/gaia/blob/master/Makefile#L489


From kgrandon: bug 864751

We've recently landed a gaia patch which will use a different folder for DEBUG profiles compared to PRODUCTION profiles. 
By default, the new folder is now located in gaia/profile-debug. It's possible to override this by passing in your own 
folder name, e.g.: DEBUG=1 PROFILE_FOLDER=awesomeprofile make 

If you are using some aliases to start gaia in Firefox, you will likely need to update these. 
Here is what I have in my .bash_profile (on OSX) that works well for me:

alias gaiaff="/Applications/FirefoxNightly.app/Contents/MacOS/firefox -profile ~/workspace/gaia/profile-debug"

Customized UI

Customized UI allows people change their:

  • animation when boot and shutdown,
  • default ring tones,
  • wallpapers,
  • built-in bookmarks for browser,
  • built-in contacts,
  • default cost control setting,
  • home screen,
  • settings,
  • adding sms black list
  • and the working in support page.

For more detail, you can have a look on https://wiki.mozilla.org/B2G/MarketCustomizations

To setup a customized build, in the root Gaia directory, run:

MOZILLA_OFFICIAL=1 GAIA_DISTRIBUTION_DIR=sample_folder_path make production

Where sample_folder_path contains a customization. An example customization is here.

Building Profile

Building Gaia for l10n v1.1 for Geeksphone

After Compiling

  • to find the repo rev versions : look at: <compile dir>/out/target/product/leo/system/sources.xml


The make statement to create a tablet version requires GAIA_DISTRIBUTION_DIR=distribution_tablet: ie : make clean && GAIA_DISTRIBUTION_DIR=distribution_tablet DEVICE_DEBUG=1 make reset-gaia

See more info in the readme for the distribution_tablet: https://github.com/mozilla-b2g/gaia/blob/master/distribution_tablet/README.md

More info on tablet building, etc : [ from Asa ]

Generate Gaia/Gecko OTA Update Package

To generate complete Gaia/Gecko OTA update package and update.xml file, please follow the steps.

  • Prepare the B2G project, then config it.
  • Generate B2G build and update package.
 $ cd $b2g
 $ <ENV_VARS> ./build.sh 
 $ <ENV_VARS> ./build.sh gecko-update-full
  • Generate update.xml file for update package.
 $ ./tools/update-tools/build-update-xml.py -o out/update.xml -u <dest_url>/b2g-gecko-update.mar -v <app_ver> -V <platform_ver> \
  • Copy update package to http server.
 $ cp objdir-gecko/dist/b2g-update/b2g-gecko-update.mar <dest>
 $ cp out/update.xml <dest>

For more detail, you can have a look on https://wiki.mozilla.org/B2G/Updating

Debugging Web Apps

  • When a developer asks for information about the manifest file, run this command: adb shell cat /data/local/webapps/webapps.json

Debugging OOMs

background information about memory

Getting About Memory Logs for a Bug

The directions below summarize the steps to get an about memory log for a bug.

  1. git clone https://github.com/mozilla-b2g/B2G.git
  2. cd tools
  3. Right before the bug reproduces, run "./get_about_memory.py"
  4. Zip up the directory that was generated & attach it to the bug

(Note: bug 1057565 allows us not to need MOZ_IGNORE_NUWA_PROCESS=1 anymore )

More Information

Other commands

  • adb shell top
  • adb shell b2g-ps
  • adb shell b2g-procrank
  • adb shell b2g-info

Other tools


Regression Window Process

The following process summarizes how you can get a regression window for a regression in Firefox OS.

Using knowledge of knowing the last version this bug didn't reproduce on and knowledge of what build you reproduced the bug on, start downloading & flashing builds on the first affected version to your device and reproduce the target bug. If the bug doesn't reproduce, then you move forward in time to download the next build. If the bug does reproduce, then you move backwards in time to download the next build. Eventually, you will get to a point where you've narrowed down the regression range to a 12 hour time span.

At this point, you should look and see if there are tinderbox builds within that target regression range. If there are tinderbox builds available for the target version in question, then you should further bisect this using the same bisection process you did before down to a regressing changeset.

Next, you'll want to determine if the regression was a Gaia or a Gecko regression. This can be done by trying to reproduce the bug on a build with the last working Gaia on top of the first broken Gecko and on a build with the first broken Gaia on top of the last working Gecko. If the bug reproduces on the first broken Gaia with the last working Gecko, then the bug is a Gaia regression. If the bug reproduces on the last working Gaia with the first broken Gecko, then the bug is a Gecko regression. If both tests either cause the bug to either reproduce in both cases, then the testing is inconclusive to determine if it's a Gaia or Gecko regression.

Then, if you've determined that the bug is a Gecko regression, then you'll want to study the push log to see if the regressing changeset came from a b2g-inbound merge. To generate a push log, you'll want to form a link of the following form:

Where c0f85061c7d3 & 71a8786c3815 are examples of the last working changesets in gecko and cd3e9359fd64 & e8f6bdf8db3d are examples of the first broken changeset in gecko.

Next, you will want to figure out if you can take advantage of b2g-inbound tinderbox engineering builds to do an even deeper bisection. To determine this, you need to be in one of two situations:

  • The bug was determined to be a Gaia regression
  • The hg link reveals that there are b2g inbound changesets in the bugs in the push log

If either of these situations apply, then you'll want to bisect even further using b2g-inbound tinderbox builds to find a regression window.

At this point, you'll have all of the data you need to present a regression window on a bug. Here's an example of a presentation of a Gecko regression window:

 Last Working Environmental Variables:
 Device: Buri
 BuildID: 20140122004001
 Gaia: 744fb691c2b2a25a07c5d19fabf5748ae9aba4d9
 Gecko: 71a8786c3815
 Version: 28.0a2
 Base Image: V1.2-device.cfg
 First Broken Environmental Variables:
 Device: Buri 
 BuildID: 20140123004001
 Gaia: 6fbeac2415f07f10de181f0877ddf67ee299b885
 Gecko: e8f6bdf8db3d
 Version: 28.0a2
 Base Image: V1.2-device.cfg
 Last Working Gaia/First Broken Gecko: Issue DOES Reproduce
 Gaia: 744fb691c2b2a25a07c5d19fabf5748ae9aba4d9
 Gecko: e8f6bdf8db3d
 First Broken Gaia/Last Working Gecko: Issue Does NOT Reproduce
 Gaia: 6fbeac2415f07f10de181f0877ddf67ee299b885
 Gecko: 71a8786c3815
 Push Log: http://hg.mozilla.org/releases/mozilla-aurora/pushloghtml?fromchange=71a8786c3815&tochange=e8f6bdf8db3d

Here's an example of a presentation of a Gaia regression window:

 Last Working Environmental Variables:
 Device: Buri
 BuildID: 20140215095648
 Gaia: 8ac5dc6b76709e742cb923c58d1f4b415b3e08fb
 Gecko: 9394396013a8
 Version: 30.0a1
 Firmware Version: v1.2-device.cfg
 First Broken Environmental Variables:
 Device: Buri
 BuildID: 20140215100248
 Gaia: f75b9dac351c0676f0fc696fa36330933985ed36
 Gecko: 4ebfb26de52c
 Version: 30.0a1
 Firmware Version: v1.2-device.cfg
 Last Working Gaia/First Broken Gecko: Issue does NOT reproduce
 Gaia: 8ac5dc6b76709e742cb923c58d1f4b415b3e08fb
 Gecko: 4ebfb26de52c
 First Broken Gaia/Last Working Gecko: Issue DOES reproduce
 Gaia: f75b9dac351c0676f0fc696fa36330933985ed36
 Gecko: 9394396013a8
 Push Log: https://github.com/mozilla-b2g/gaia/compare/8ac5dc6b76709e742cb923c58d1f4b415b3e08fb...f75b9dac351c0676f0fc696fa36330933985ed36


backup and restoring contacts, music, etc.

  • There's an app in the marketplace that helps do this:


verifying patches before they land for gaia

From bug 1134649: just to note, this is an example of one way to verify patches before they land on a branch. Make sure you have space on the hard drive for the code, patch and building before attempting.

In order to verify that the patch works:

  1. flash a flame with the latest 2.2 eng build
    • reason: to get the latest gonk/gecko ; engineering build as it has root access and simplifies things.
  2. git clone -b v2.2 https://github.com/mozilla-b2g/gaia.git v2.2_gaia_git
    • reason: need to get the latest gaia for v2.2, -b v2.2 signifies the branch; if you already have a gaia 2.2, then just do a "git pull" on it. v2.2_gaia_git is somewhat arbitrary. you can have a different name, just keep it consistent with the next line ( cd )
  3. cd v2.2_gaia_git
  4. git checkout -b fix-clock-load
    • reason: branch out to a different branch to pull the patch in in case we need to reuse this local repo; this also autoswitches you to that branch after creating the branch. you can verify with: git branch ; fix-clock-load is arbitrary. You can have it different like bug_1134649
  5. git pull https://github.com/mcav/gaia.git fix-clock-load
    • reason: need to pull mcav's fix; should be fine so long as he didn't make any changes on top of this fix in the branch. Otherwise you would have to cherry pick the fix. That might be a separate wiki entry...
  6. save the commit, if you're in vi then 'esc' :wq
    • reason : 'esc' key then :wq will save the commit, we just need to save a comment and the patch locally.
  7. MOZILLA_OFFICIAL=1 make install-gaia
    • reason: to build and install gaia on the device. This assumes that your flame device is connected, awake, no screenlocked and has adb access. MOZILLA_OFFICIAL=1 is only to brand it mozilla. There's no real need to do the MOZILLA_OFFICIAL=1.

General Testing on Mobile devices