[HOWTO] ✏ Compiling Fairphone Open OS / Rooting

I set the /system/xbin/su permissions to 6774 in system/core/include/private/android_filesystem_config.h and it didn’t work :frowning: I still get permission denied errors…
EDIT: @lklaus I looked at the log files again, it turns out I do have to install Busybox. But I didn’t understand how to include it into the recovery image, can you explain it to me again?

Good morning!

I compiled the OS and noticed a couple of minor things that might add value to the Wiki. Let me know if you think it would be OK to add.

a) When preparing the build environment on Ubuntu 14.04 LTS, I encountered problems with apt-get install zlib1g-dev:i386. Solved this by installing repo first (on Ubuntu 14.04 repo is included in phablet-tools, sudo apt-get install phablet-tools).

b) The one-line copy statement to copy the libs from the blobs archive seems to be broken - the backslash is not necessary when this is one line only, right?

In addition - would it make sense & add value to add a short description of how to flash the resulting *.img to the phone? Which *.img in which order? Personally I’m a bit overwhelmed by the multitude of files in the out directory… :wink: I assume this information could help other rookies as well.



Hi Vivia,

in the logfiles, did you see a successful mount of /system?

I quote the clarification from fp1_wo_sw_updates:

I assume you used the busybox to fill up sbin with links to it? So it would be like this:

cp -R recovery/root/sbin $(TARGET_RECOVERY_ROOT_OUT)

/bootable/recovery/etc/init.rc (after ‘on init’):
export LD_LIBRARY_PATH .:/sbin
Right now I have to figure out how to compile busybox as external add on so I can include it into the recovery image “the right way”. I had a compiled version from early tests with TWRP.

I first have to understand the build system…

Sure, just go! Have fun! Maybe you could just state your OS and give some hints?

This is an example only!

Ubuntu 14.04 system setup

$ sudo apt-get install openjdk-7-jdk bison g++-multilib git gperf \
  libxml2-utils make python-networkx zlib1g-dev:i386 zip

Ubuntu 15.10 system setup

 sudo apt-get install ....

Debian 8.2 System setup
sudo apt-get install …


Get docker or use Xcode and brew/macports

I don’t have a FP2 here, so I’m careful about writing things I cannot test. I think @lklaus can help here. And there is also a lot info about it on xda. But you’re right, the info in the ‘flash!’ section is not enough.

1 Like

What kind of issues were those? I’m on Ubuntu 14.04 LTS, too, and I don’t think I encountered any. I’ve installed repo from https://storage.googleapis.com/git-repo-downloads/repo as described in the build instructions, though I don’t remember whether I did that before or after apt-getting zlib1g-dev:i386. (I think it was after, though.)

In the beginning I did the flashall as described on code.fairphone.com, but I think it is better to only flash what you really need, i.e.

  • recovery: fastboot flash recovery recovery.img
  • system: fastboot flash system system.img

In the latter case fastboot flash -w … might be interesting, this wipes the partition and settings, so if the two ROMs are not fully compatible there won’t be any problems.
If you want to use flashall, you need boot.img, recovery.img and system.img as well as the file android-info.txt, if you don’t flash from your environment
(edit: put this in the wiki also)

1 Like

I’ve encountered the same problem when creating the Docker image. I was able to solve it by adding a dpkg --add-architecture i386 before calling apt-get.

BTW: The Docker image is now on Docker hub. You can get it as simply as

$ docker pull jftr/fairphone2-build-env

Don’t forget to add the fixes! :slight_smile:

Thanks for pointing it out, I missed your update.

I’l add the -c.

What is wrong with the && sh fp2-sibon-2.0.0-blobs.sh part? Do you mean I should extract fp2-sibon-2.0.0-blobs.tgz to stdout and directly pipe it into sh? Why?

Everyone, feel free to send me pull requests on GitHub.

I tried to build on Gentoo. Everything seemed to work at first, but finally I also got the „out/target/common/obj/PACKAGING/checkpublicapi-current-timestamp“ error. Maybe it is caused by the newer version of Make.
To go round any other incompatibilities I go on with jftr’s Docker image now. Thanks for that!

Just started building. I realized some messages about missing unzip command. Is it required or missing in Docker image respectively?

1 Like

apt-get install unzip is missing :slight_smile: I had the same problem. But @jftr fixes much fast than I can report stuff :wink:

Indeed, it is not available. Does the makefile need it? gunzip is available though. Are these errors or info messages? The build script could for instance first try unzip and – if not available – fall back to gunzip.

I can easily add it if it is necessary.

Edit: Since I’m already at it: Is anything else missing?

1 Like

+ && make update-api \

I have no clue what it does … I assume it updates the API list. We need someone who will test the images created here ;). Could you update the wiki so that people will understand the difference between a normal build and the one inside docker and how they can get their files?

Building was successful for me. And also flashing worked without problems.
Unfortunately phone doesn’t boot. It’s stuck on the boot screen.
I already tried to wipe with “-w” but no success too. Does anybody have an idea?
Fastboot in Docker can’t find my phone. So I needed to do it in my host system. May that be the problem?

Did you do a factory reset after flashing (from the recovery)?

I’ve tried now. But didn’t help.

Maybe you forgot to put the blobs in there before building? Did you compare the image / zip sizes with the ones posted here previously by others?

These are the sizes of my img files:
-rw-r–r-- 1 root root 15257600 Jan 10 15:17 out/target/product/FP2/boot.img
-rw-r–r-- 1 root root 12820796 Jan 10 14:58 out/target/product/FP2/cache.img
-rw-r–r-- 1 root root 5828608 Jan 10 14:54 out/target/product/FP2/dt.img
-rw-r–r-- 1 root root 5088376 Jan 10 14:55 out/target/product/FP2/persist.img
-rw-r–r-- 1 root root 1419949 Jan 10 15:15 out/target/product/FP2/ramdisk-recovery.img
-rw-r–r-- 1 root root 2821304 Jan 10 15:14 out/target/product/FP2/ramdisk.img
-rw-r–r-- 1 root root 13856768 Jan 10 15:17 out/target/product/FP2/recovery.img
-rw-r–r-- 1 root root 6221312 Jan 10 14:50 out/target/product/FP2/splash.img
-rw-r–r-- 1 root root 440520572 Jan 10 15:32 out/target/product/FP2/system.img
-rw-r–r-- 1 root root 142911480 Jan 10 15:32 out/target/product/FP2/userdata.img

Where should I add it? After what other step? Is that necessary even if one does not change anything?

The Docker image is only meant for compiling and not for a connection to your smartphone. It could probably be added but I have not done it yet. I don’t know how easily it is possible to connect to a USB device from Docker.