[HOWTO] ✏ Compiling Fairphone Open OS / Rooting

I’m a bit at a loss here, I don’t know what the question is…

The concept behind my modifications to the stock recovery:

  • deactivate zip file verification (in install.cpp in recovery)
  • at least SuperSu in its install script mounts partition,so it needs an fstab, and does not look for recovery.fstab. I work around this by making a link from recovery.fstab to fstab (in the Makefile)
  • As the install skript is a shell skript, we need an sh interpreter in the recovery. I had a compiled busybox left over from some tests with TWRP. I saved the executables and libraries and made the rcbins.tar. This has to be untarred at some place (preferably $HOME) and will also be copied to the sbin from the recovery
  • as the busybox binaries from TWRP are dynamically compiled, the system needs to know where the libraries are. This is done by the modification to init.rc after “on init”

edit: just checked the wiki. As vivia specifies a location for rcbins.tar and delivers the Makefile, follow the wiki post and leave my remarks here as a general explanation to know whats happening

1 Like

The question from @vivia was if it is okay to share the recovery.img, or if it does contain bin blobs code. The Makefile is so big … and stuff gets copied around so it’s hard to tell without a clean (non-bin-blob) build. So the question is: Does the recovery contain any bin blob code?

Looks like I managed to compile the source now (on Gentoo btw). The “API was modified” errors are gone, didn’t do anything different than last time, just started from scratch.
Before I flash the system.img here’s one question:
I downloaded the original OTA-images (“FP2-gms36-1.1.7-ota.zip”) has a “system.new.dat” instead of the “system.img”. Can I use fastboot to flash the “system.new.dat” to restore the original ROM?

Oh wait, let me guess: you boot recovery and use adb sideload with the “FP2-gms36-1.1.7-ota.zip” (without unzipping it on the PC). Right?

Ah, I see. I do thinks that there are at least fragments from the blobs, as @Arvil also stated, there are files with qcom in it. As I do have a very slow system for compiling at the moment (have to switch to docker…) it’s not that easy to set up everything without blobs and issue a make recoveryimage to see whether it compiles or not. But I doubt it…

1 Like

Looks like java is not happy, but I’m not an expert. What versions are active on your Debian box?
$ java -version && gcc --version

Else, there is always dockerfile from @jftr :smile:

You might want to look in this thread: softbricked fp2. There’s a discussion about the suitability of the ota package

java -version && gcc --version:
java version "1.7.0_91"
OpenJDK Runtime Environment (IcedTea 2.6.3) (7u91-2.6.3-1~deb8u1)
OpenJDK 64-Bit Server VM (build 24.91-b01, mixed mode)
gcc (Debian 4.8.4-1) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO

And I took a serious look into https://github.com/justfortherec/fairphone2-build-env/blob/master/Dockerfile :smile:


P.S. Maybe the CLASSPATH is wrong, but I don’t know why it should just in my case.

Good, that was the idea! But … as a stronger workaround you could also just use docker with the dockerfile, if everything else fails! :slight_smile:

It works pretty well. You can just recycle your current working directory for that, so there would be no need to checkout all the code again, if you just want to build the image quickly.

Else, nothing comes to mind. :frowning: Is javac -version the same version? Sometimes on Debian you can end up with different versions due to the alternatives management. Maybe someone else will come along and will be able to help you!

ls -al /etc/alternatives/javac should point to java-7-openjdk-amd64/bin/javac somehow.

1 Like

Thanks vivia! I’ll give it a try. It’s great to have a working root now.

It seems that this isn’t trivial: http://su.chainfire.eu/#embed-rom
Who knows what the update-binary does.

Interesting. Can you tell what you have done to succeed? Did you need to downgrade GNU Make?

First I tried it on my main machines at home which all run ~amd64 (= unstable for all not knowing Gentoo ;)). Since it failed there (not compatible with python 3, possible not compatible with perl 5.22.1) I ran the whole thing on my rented root-server which uses the stable packages. There I had no problems except the mentioned “You have tried to change the API from what has been previously approved” stuff (#180). Finally I switched to gcc 4.8 (though it shouldn’t make a difference since the compilers used are downloaded precompiled on “repo sync”), removed everything and started over. It then worked without a flaw.
The recovery boots and I didn’t yet flash the system.img. Version of make used:

GNU Make 4.1
Built for x86_64-pc-linux-gnu

After flashing the system.img, here’s another issue: The phone tells me that the storage space is running out: http://kripton.kripserver.net/pix/SpaceLow.png
However, “df” on the shell looks good to me:

1|shell@FP2:/ $ df
Filesystem Size Used Free Blksize
/dev 919.7M 52.0K 919.6M 4096
/sys/fs/cgroup 919.7M 12.0K 919.6M 4096
/mnt/asec 919.7M 0.0K 919.7M 4096
/mnt/obb 919.7M 0.0K 919.7M 4096
/system 2.0G 421.5M 1.6G 4096
/data 25.5G 622.9M 24.9G 4096
/cache 629.5M 249.6M 379.8M 4096
/persist 4.9M 4.8M 72.0K 4096
/firmware 64.0M 56.0M 8.0M 16384
/mnt/shell/emulated 25.5G 622.9M 24.9G 4096
/mnt/shell/emulated/0 25.5G 622.9M 24.9G 4096

Anyone saw this before or knows how to fix it?

1 Like


java and javac are the same version, and [quote=“fp1_wo_sw_updates, post:256, topic:11600”]
ls -al /etc/alternatives/javac
[/quote] seems to be correct, too.

I’ve this problem with my two machines running Debian 8.2. :frowning:

The update-binary is a shell script. Somewhat long but not that bad. I looked into it to learn why it failed while testing my recovery. Also, there are a few su programs in there, it has to detect the architecture and copy the correct su

I noticed some downloads when syncing the repository again. Does this mean the sources are constantly updated?


… 7 characters


Thanks, that was an excellent hint! Now compiling on my Ubuntu 14.04 webserver (rented V-Server, so I don’t even have to pay for the energy :innocent:)

just wanted to say thanks for the guide at the top!

Compiling worked for me on a freshly set up Ubuntu 14.04.3. First had problems when repo sync got stuck because of the lousy wifi connection (cabel recommended!) which led to compling errors.

Also “flashall” did not work, said android-info.txt was missing, although it was there. Flashing single images worked fine.

Now I have a google free, rooted fairphone.

My build has some issues with the privacy impact overlay (it was not responding), but that can be deactivated in the settings.


I feel like trying to compile once again following the guide provided thanks to you guys.
Just a little question: Which directories do I need to remove (or perhaps shorter: Which directories do I need to leave?) before starting the new compilation?

Right now, I am syncing repo again even though all corresponds to delta=0 up to now, but just in case updates have been made.

I am not sure if I understood the rooting guide in the wiki, especially if it is only for the official image for now.
Do I first need to do the compilation of the GSM-free FP OSOS and flash it on the phone or can I follow the complete guide - but flash system and recovery etc?
Sorry to bother you with such profane questions, but I am a bit impatient to set up my phone :wink:

Well, in the end the guide creating a recovery allows you to root the stock image, and freedom to install a zip via recovery (if you need it on osos) on any image, the guide for the recovery is for you

1 Like

Just run make clean and you should be ready to recompile :slight_smile:

If I understand your question correctly, you want to root the self-compiled OS. In that case:

  1. Go until the point where you just finished make -j8
  2. fastboot flashall
  3. Go to recovery mode and sideload the .zip

And that should do the trick :slight_smile:

1 Like