[HOWTO] ✏ Compiling Fairphone Open OS / Rooting

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: frameworks - Missing symbols building Android on Ubuntu - Stack Overflow
  • 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.)

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?