How I built Mozilla's BootToGecko OS on my Samsung Galaxy S II
This is my Samsung Galaxy S II running my orange theme on BootToGecko.
BootToGecko is NOT CONSUMER READY!
It's a pre-pre-pre alpha system, much like the iPhone would've been back in 2003, when the definition of 'smartphone' was a PocketPC.
Here's what it does do at the moment:
Install a selection of Mozilla Open WebApps
And now, what it DOESN'T do:
App notifications (e.g. Mail, Twitter)
Stay stable (occasional crashes send it into stock BootToGecko mode)
Play your music/video (SD card support is still being tested)
Build Environment Requirements
I'm currently using a Dell XPS 15 (L502X) which dual-boots Ubuntu 11.10 (x64) and Windows 7 (x64) and is, overall, a pretty sweet machine.
I'd suggest atleast 4GB RAM, plenty of storage space, and a strong internet connection.
If there's a problem in the steps (I might've forgotten something) or a step simply doesn't make sense, please leave a comment and I'll get back to you ASAP!
Install Ubuntu 64-bit
I created an ext2 partition for the Ubuntu installation, and an 8GB swap partition as recommended. This isn't required, however, and you can simply install inside Windows for an easier process.
Boot into Ubuntu
You won't be seeing Windows for some time, so say your goodbyes.
Install Mozilla's Build Environment packages
Just copy these commands into a Terminal and press Enter. Press 'Y' when prompted and it should take care of the rest.
sudo apt-get build-dep firefox
sudo apt-get install git mercurial libasound2-dev libcurl4-openssl-dev libnotify-dev libxt-dev libiw-dev mesa-common-dev autoconf2.13
sudo apt-get install ia32-libs gcc-multilib g++-multilib bison flex gperf lib32z-dev lib32ncurses5-dev lib32ncursesw5-dev
sudo apt-get install libidl-dev lib32gomp1 autoconf2.13 ccache libx11-dev lib32readline-gplv2-dev
sudo apt-get install openjdk-7-jre
From the Software Centre, it's easy enough to find. I used version 6 rather than 7 since it's been around longer. Mozilla recommend 7, so you can use the above command to get that version, if you want.
Download Android SDK
From the Android Developers' page, download the .tar.gz file, extract it, and copy the 'android-sdk-linux' folder to your /home directory (mine's called '/nikhil')
I've never gotten the hang of adding PATH variables, but if you do, go right ahead and perform your ./bashrc magic. I have a workaround that'll be explained later.
Edit Android config files to allow your SGS II to interact with Ubuntu
sudo gedit /etc/udev/rules.d/51-android.rules
This will open an empty file in Ubuntu's default text editor. Add the following line:
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", MODE="0666", GROUP="plugdev"
Save and close the file. Now run the following command to make the file readable.
sudo chmod a+r /etc/udev/rules.d/51-android.rules
Install Heimdall
Run the .deb file from https://github.com/downloads/Benjamin-Dobell/Heimdall/heimdall_1.3.1_amd64.deb
It's a program that easily interfaces between Ubuntu and the Galaxy S II. It's a quick download from the website, and an easy install since it's a .deb file.
Backup your Galaxy S II
My Galaxy S II has been rooted since day one, and it's time for you to do the same. ClockWorkMod's ROM Manager is a fantastic tool that eases the backup/restore process, and you should definitely get it.
Once you have it, backup your phone using the CWM app from Google Play, or reboot into Recovery Mode and make a backup there. Then, mount the SGSII as a drive via USB and copy over all the files from your phone.
Easy to find in the Ubuntu Software Centre, it's a one-click process to install.
Create a new 'BootToGecko' build folder
This is where everything will be done. I put mine in '/nikhil/B2G' but anywhere is fine.
Install 'Open in Terminal' to drastically improve your productivity
sudo apt-get install nautilus-open-terminal
nautilus -q
This feature used to be present in older versions of Ubuntu, but seems to have been removed by default, for whatever reason. It lets you open the current folder in Terminal, saving you having to manually change directory by typing.
Change working directory to the BootToGecko directory
Navigate to your BootToGecko folder, right click open space and select 'Open in Terminal'. This opens a command prompt and you enter all the subsequent commands here.
Use Git to 'Clone' the BootToGecko repository from GitHub
git clone https://github.com/andreasgal/B2G.git
This takes a few minutes, after which you can open the /BootToGecko folder and see it filled with stuff.
Use the 'make sync' command to actually build BootToGecko; this takes AGES!
TIME TO BREW A GOOD CUP OF COFFEE! From what I can tell, this command downloads the majority of BootToGecko files and then compiles them.
My internet connection died a few times during this step; this meant I had to stop the command using CTRL+C and then run 'make sync' again. The good thing is, it only restarts the interrupted file, so you only lose a few hundred megabytes, tops.
Plug in the phone and run the Galaxy S II specific commands
export ANDROIDFS_DIR=sgs2-android
make config-galaxy-s2
This pulls a lot of files from your phone, so that a suitable version of BootToGecko is built.
I had a tough time with this step, since it didn't recognize my firmware version. Eventually, an Ubuntu restart and a phone restart solved the problem. If it still doesn't work, restore your phone to the original stock firmware and try again.
Takes a few minutes, just be patient.
Reboot the Galaxy S II into 'Download Mode'
This gets the phone ready for any kernel changes. An android image should be displayed, along with some text saying 'Download Mode'.
Flash the BootToGecko kernel using Heimdall
heimdall flash --kernel boot/kernel-android-galaxy-s2/arch/arm/boot/zImage
A one-line command that should do all the work for you. Watch the phone display for a progressbar which should fill up quickly.
Reboot the Galaxy S II into 'Recovery Mode'
This should reboot into ClockWorkMod, or the equivalent Recovery manager.
Build and flash the base OS
'Gonk' is the codename for the base Operating System which BootToGecko is built upon. On top on Gonk is 'Gaia', the actual system that manages what you see on the display, such as the lock-screen/home-screens etc.
Finally, build and flash the rest of BootToGecko
Be patient, and make sure the phone is connected to the computer while this command runs. Once it finishes, it will automatically reboot the phone into Recovery mode and install the final bits of BootToGecko.
adb commands don't work, 'adb could not be found'
This is easily fixed. Go to the 'android-sdk-linux/platform-tools' folder and copy the 'adb' file. Paste it into the BootToGecko folder.
Now, whenever you need to run an adb command, add a './' to the front. The './' denotes that adb is located in the current folder, and thus links to the file you just copied.
A '500 - Server error' page is displayed
This means that BootToGecko cannot access the 'Gaia' interface, either on the phone or online. For me, this was due to an error while building BootToGecko's 'Gaia' front-end.
This command re-builds and installs the Gaia interface. Read the output to see if any error has occurred. If there is an error, it means the command was unable to find 'adb'.
Fix this problem by either adding adb to Ubuntu's PATH variables, or editing the 'Makefile' at '/B2G/gaia' and changing line 14 to:
And copying the 'adb' file to the '/B2G/gaia' folder as well. This means Gaia will now build using the copy of adb stored in its own folder.
Don't expect to use BootToGecko as an everyday OS. It's just an enthusiast's toy for now, but I'm expecting ridiculous amounts of development within the next 6 months.
Once the BootToGecko phones land in the market, expect high quality releases that will easily compete with Windows Phone, Android and iOS.
There's a ton of potential in Mozilla's BootToGecko, and here's to hoping it triumphs!