Previously, we looked at making a decent build environment for FirefoxOS, so now we will have a look at actually checking out the code and building!
I will assume that you have git installed, but if you don’t, go and install it real quick.
Proceed to check out the B2G code:
git clone git://github.com/mozilla-b2g/B2G.git
This checkout should be quick enough, the next step is where the time goes.
Once the git checkout (clone) has completed, cd into your new B2G directory
Issue the command
which should give you a whole list of build targets. We are concentrating on Samsung S2, so choose that one.
You will notice that you can also build for an emulator, so if you would like to do that, choose either the emulator-jb for JellyBean or the emulator-kk for KitKat.
Once that is done, you are ready to start the actual build!
If you have left it a while, or you are rebuilding with updated code, don’t forget to update your repo
git pull ./repo sync
Once you are happy to start, simply kick off the build process with
cd B2G ./build.sh
Note, that this part will take quite a while, so go and get some lunch or something!
Once all is done, you should see a notice to flash to device! Congratulations, you are most of the way there!
Issue the flash command with
and ensure that you have both Heimdall and ADB installed and working.
If Heimdall fails with something along the lines of it not finding factoryfs, you will need to edit the flash.sh file and make sure that factoryfs is in uppercase, as well as all instances of kernel. The S2 has an uppercase naming convention, that, when I built FirefoxOS last for the S2 was an issue (it may be fixed now though, as I reported it and provided a fix as a good Open Source citizen)
Once that is complete, you should be golden.
If you are simply updating Gaia, then remember to also
cd gaia make reset-gaia
If you are using heimdall 1.3.2 (the latest version; use heimdall version to check), you may see an alarming error “FACTORYFS upload failed!” followed by “Heimdall flashing failed” and some additional information. This is actually a success condition, and you can ignore the advice.
To get rid of this strange behavior, grab a source copy of heimdall, downgrading to the 1.3.1 release (“git checkout fbbed42c1e5719cc7a4dceeba098981f19f37c06″), then compile it according to the README, then install that to make the error go away. However, this isn’t strictly necessary.
Sometimes Gaia doesn’t flash correctly on the first try. If that happens, do
The “developer mode” Gaia also sometimes fails in my experience, so if this happens to you too, set it to production mode and reflash Gaia
cd gaia make reset-gaia PRODUCTION=1
You should now have a working FirefoxOS phone! Congratulations! Go write an app!
Liked this post? Follow this blog to get more.