English

[HOWTO] ✏ Compiling Fairphone Open OS / Rooting

Did you follow the additions/corrections in the top most post as well? E.g. checking gcc version (you haven’t mentioned anything about your system set up and my crystal ball is a little dusty… :wink: )

Yes, I read the complete post. I did the steps about copying the missing libraries in the vendor folder but I’ve used gcc-4.9.3. I’m currently installing gcc-4.8.5 and will retry using that. More information about the system used to compile: http://dpaste.com/2K34Y4D

Reading the initial post your version is too new. So 4.8 hopefully works better. Please feel free to add additional information to the initial post once you found a working solution for you. :slight_smile:

I don’t think either (but whether FP has resources to do that or not, they probably wouldn’t. People they derive their licenses from though…). That said sharing IS an issue, since it is rendered illegal. If it was not a problem, there would be no shitty “we lend you these blobs but don’t do anything with them” clause in the license agreement.

On top of that it’s also an issue about ethics : I own my phone, I should have the right to share alternative ways to use it. Phone creators expect you to do their job (making a great OS) for them, letting you share your alternative ROM all the while maintaining a sword of Damocles on top of your head just in case they suddenly change their mind about this (or just don’t like you). Fuck this.

Yes, this should be it. Unfortunately, I reinitialized my build environment to create a “sane” patch…

As the xda thread is from Chainfire, I guess this are the same versions.

Go to your build-dir and the sub directory: frameworks/base. There run:

$ git diff

It should show you the changes that were made by running make update-api. Here it adds four new lines to “api/current.txt”. If you don’t want that, running git checkout api/current.txt should “fix” it again.

Once you are done, run “make clean”, check your compiler version and start again. Good luck! I haven’t checked 4.9, but I can ensure you that 4.8 worked here. Just give 4.9 a try, it might work. Your error message posted here is not a compiler error.

Update: I also had to run the update this time to make my build work … I think one can remove this check, but maybe it is there for a reason. I guess google ensures something with it, no clue right now.

Yes, it is – more or less – just a wrapper around git. --depth=1 gets passed to git.

That said, my computer still filled up when trying to download. I’ve had ~27GB available… I had hoped the option would reduce the downloadable part to less than that. Apparently I was wrong.

In theory it’s a problem: Fairphone is obliged to write this due to the way they licensed the source code and binaries. However in practice? As long as you don’t boast about it and do it in a small private style, I don’t think there is a problem.

About ethics, you are unfortunately right.

I just came back home and started compiling again. I can tell you in a few minutes how much space a “small” checkout with a full build will take. I estimate around ~ 33G.

Update: The full build takes around ~46G with the modified repo/git settings provided by @jftr. I also got an error message this time :slight_smile: So not sure if this is really the full build size. No time to look into this now.

I also had to run “make update-api” this time. The successful build takes around ~46G … the make clean size is around 28 GB. I will update the wiki …

1 Like

Hi @lklaus ,
I do see the su binary in the out folder as I pasted, but I installed SuperUser and it says there’s no su binary available. I just checked with ls - it is available in /system/xbin but ls says
lstat '/system/xbin/su' failed: Permission denied
I’ll see how much time I have (real life catching up), maybe repo grep will come up with something useful that sets the wrong permissions, then I can check the permissions according to what I see on the FP1.

EDIT: I saw on system/core/include/private/android_filesystem_config.h that the permissions were set to 0750 . Maybe it’s the read permission from “others” that made it unusable? I set to 06774 according to http://android.stackexchange.com/questions/55714/setting-appropriate-permissions-on-su-binary and I’m compiling the image again. Will report much later tonight though, I won’t be here when compilation ends.

The Docker image works now on my machine (I still can’t build because of lack of disk space though).

My machine runs Ubuntu 15.10 with this kernel:

$ uname -a
Linux frederik 4.2.0-23-generic #28-Ubuntu SMP Sun Dec 27 17:47:31 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

Does anyone want to try it [Edit: Possibly with some additional steps found meanwhile; e.g. update-api]? Docker would also be a very handy tool for those trying to build on Macs or Windows machines.

I can give it a try, not sure how it works, but I let it run for awhile and let you know later. :smile:

Sending build context to Docker daemon  5.12 kB
Sending build context to Docker daemon 
Step 0 : FROM ubuntu:14.04
14.04: Pulling from ubuntu
895b070402bd: Pull complete 
02e5bca4149b: Pull complete 
b2ae0a712b39: Pull complete 
af88597ec24b: Pull complete 
ubuntu:14.04: The image you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security.
Digest: sha256:098d121c6a9b39080f835563695f8e05faf765f46c174570e61d08197e82b820
Status: Downloaded newer image for ubuntu:14.04
 ---> af88597ec24b
Step 1 : RUN dpkg --add-architecture i386
 ---> Running in f946241b7607
 ---> 85e86c41d78e
Removing intermediate container f946241b7607
Step 2 : RUN apt-get update && apt-get install -y -f --no-install-recommends     openjdk-7-jdk     bison     g++-multilib     git     gperf     libxml2-utils     make     python-networkx     zlib1g-dev:i386     zip     curl     wget     ca-certificates  && apt-get clean  && rm -rf /var/lib/apt/lists/*

Notes:

Docker needs to know about DNS, else the image will not find files. Important info for people new to Docker :smile:

1 Like

Thanks.

Building the container takes some time but should be finished comparatively quickly. What takes much longer is running the container because that is when the the repo is downloaded and everything is compiled.

I’m curious whether everything works.

Yep, I also assumed it not to be a compiler issue since the build environment ships its own compilers (prebuilts/gcc and prebuilts/clang) which are used when the build system’s output contains “host C” oder “Host C++”.
Here’s the output of “git diff” after “make update-api”:

diff --git a/api/current.txt b/api/current.txt
index 144f292…f97746c 100644
— a/api/current.txt
+++ b/api/current.txt
@@ -17,6 +17,7 @@ package android {
field public static final java.lang.String ACCOUNT_MANAGER = “android.permission.ACCOUNT_MANAGER”;
field public static final java.lang.String ADD_VOICEMAIL = “com.android.voicemail.permission.ADD_VOICEMAIL”;
field public static final java.lang.String AUTHENTICATE_ACCOUNTS = “android.permission.AUTHENTICATE_ACCOUNTS”;

  • field public static final java.lang.String BACKUP = “android.permission.BACKUP”;
    field public static final java.lang.String BATTERY_STATS = “android.permission.BATTERY_STATS”;
    field public static final java.lang.String BIND_ACCESSIBILITY_SERVICE = “android.permission.BIND_ACCESSIBILITY_SERVICE”;
    field public static final java.lang.String BIND_APPWIDGET = “android.permission.BIND_APPWIDGET”;
    @@ -78,6 +79,7 @@ package android {
    field public static final java.lang.String INSTALL_SHORTCUT = “com.android.launcher.permission.INSTALL_SHORTCUT”;
    field public static final java.lang.String INTERNAL_SYSTEM_WINDOW = “android.permission.INTERNAL_SYSTEM_WINDOW”;
    field public static final java.lang.String INTERNET = “android.permission.INTERNET”;
  • field public static final java.lang.String INVOKE_CARRIER_SETUP = “android.permission.INVOKE_CARRIER_SETUP”;
    field public static final java.lang.String KILL_BACKGROUND_PROCESSES = “android.permission.KILL_BACKGROUND_PROCESSES”;
    field public static final java.lang.String LOCATION_HARDWARE = “android.permission.LOCATION_HARDWARE”;
    field public static final java.lang.String MANAGE_ACCOUNTS = “android.permission.MANAGE_ACCOUNTS”;
    @@ -101,6 +103,7 @@ package android {
    field public static final deprecated java.lang.String READ_INPUT_STATE = “android.permission.READ_INPUT_STATE”;
    field public static final java.lang.String READ_LOGS = “android.permission.READ_LOGS”;
    field public static final java.lang.String READ_PHONE_STATE = “android.permission.READ_PHONE_STATE”;
  • field public static final java.lang.String READ_PRIVILEGED_PHONE_STATE = “android.permission.READ_PRIVILEGED_PHONE_STATE”;
    field public static final java.lang.String READ_PROFILE = “android.permission.READ_PROFILE”;
    field public static final java.lang.String READ_SMS = “android.permission.READ_SMS”;
    field public static final deprecated java.lang.String READ_SOCIAL_STREAM = “android.permission.READ_SOCIAL_STREAM”;
    @@ -110,6 +113,7 @@ package android {
    field public static final java.lang.String READ_VOICEMAIL = “com.android.voicemail.permission.READ_VOICEMAIL”;
    field public static final java.lang.String REBOOT = “android.permission.REBOOT”;
    field public static final java.lang.String RECEIVE_BOOT_COMPLETED = “android.permission.RECEIVE_BOOT_COMPLETED”;
  • field public static final java.lang.String RECEIVE_EMERGENCY_BROADCAST = “android.permission.RECEIVE_EMERGENCY_BROADCAST”;
    field public static final java.lang.String RECEIVE_MMS = “android.permission.RECEIVE_MMS”;
    field public static final java.lang.String RECEIVE_SMS = “android.permission.RECEIVE_SMS”;
    field public static final java.lang.String RECEIVE_WAP_PUSH = “android.permission.RECEIVE_WAP_PUSH”;

Since not really readable here: http://dpaste.com/29RYVRP

I’m currently investigating my local Java setup since:

  • The error messages tell me something that it could be avoided by some javadoc comments
  • I forgot to run the “choosecombo”-step and it failed pretty soon with the same errors mentioned here: http://stackoverflow.com/questions/8780507/missing-symbols-building-android-on-ubuntu
  • An Gentoo uses some technique to manage several Java-versions and different jdks installed on one machine (see answer by mmigdol in the mentioned stackoverflow-link)

I’m sure it does. I thought I could work around a full test by mounting my repo into the docker image, but just to make sure for you I let the computer do a full test run :smile:

Update: The “&& sh fp2-sibon-2.0.0-blobs.sh” part needs more love, not your fault. I guess echo in a pipe will be your friend, but I’m not sure if this is even allowed … Oh, and wget could use a “-c” just in case.

I don’t don’t think what you posted is an issue. Is a checking script that gets called by the makefile to ensure the lastet API. I assume. As long as you find images in out/target/product/FP2/*.img you are good. I don’t know anything about the APIs and how they are related to the current code version and how clever this whole setup it. But I’m sure one can read up on this somewhere. :wink:

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.

Cheers!

2 Likes

Hi Vivia,

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

I quote the clarification from fp1_wo_sw_updates:

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

build/core/Makefile:
cp -R recovery/root/sbin $(TARGET_RECOVERY_ROOT_OUT)

/bootable/recovery/etc/init.rc (after ‘on init’):
export LD_LIBRARY_PATH .:/sbin
[/QUOTE]
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!
https://source.android.com/source/initializing.html

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 …

Mac

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.)