English

[HOWTO] ✏ Compiling Fairphone Open OS / Rooting

Two things
If you did not follow the thread here on the forum, chances are that libraries are missing. E.g. libart.so
Without this the system will not boot. You might be able to see this with adb logcat
Second, when flashing system it might be better to use -w for wiping. I guess you have no data on the system yet
The bootloaders part seems to be very stable, it’s not easy to totally brick the phone

1 Like

@lklaus I just found time to try your patch - sorry it took a while, I was trying to debug the location issue first.

Compilation fails, saying that it didn’t find recovery/root/sbin . However, I do see the sbin directory in out/target/product/FP2/recovery/root … ?

vivia@talos:~/fairphone_os$ ls -l ./out/target/product/FP2/recovery/root/sbin total 816 -rwxrwxr-x 1 vivia vivia 314196 Jan 8 18:06 adbd -rwxrwxr-x 1 vivia vivia 337260 Jan 8 18:06 healthd -rwx------ 1 vivia vivia 177928 Jan 8 18:06 security_boot_check lrwxrwxrwx 1 vivia vivia 7 Jan 8 18:06 ueventd -> ../init lrwxrwxrwx 1 vivia vivia 7 Jan 8 18:06 watchdogd -> ../init vivia@talos:~/fairphone_os$

It’s missing in recovery/root/sbin. And I think I did not touch this. Will check. I am just trying to get a pristine environment, but I’m fighting how to get single files back

More failure :frowning:
I removed that line and the image compiled successfully, I do see the out/target/product/FP2/recovery/root/sbin directory on the computer somehow. However, adb sideload fails to flash SuperSU: "E: Error in /sideload/package.zip (Status 255)"
And of course the phone doesn’t appear to be rooted.
The .zip file itself seems OK, I managed to extract it. Also, I did see the “SKIP Verifying package” message.

Hello Vivia , why are you sideloading the package and not “simply” including it in the original image?

Second question:
Because you are compiling your own version that version is also signed with the default keys used in the open source build.
if so why not sign the package to sideload with that key?

1 Like

@keesj: Hi, thanks a lot for your answer! The thing is, I’m a developer, but not an Android developer. How do I include the package in the original build? I unzip the files, but where do they have to be copied to? Are there any other files (Makefiles etc) that need to be changed to account for these changes?

Hi Vivia,

sorry, I forgot I included busybox. Which was compiled from my tries from having look at TWRP. I’m right now checking how to include busybox in this recovery in a sane way. Besides, I’m not really sure whether busybox really is needed. After a failed flash, it is helpful checking the log file from recovery. Just chose the first log file, and then it’s a bit complicated finding the relevant entries, First you find the start messages (including the failed mount of misc, for orientation), then there are lots of build.prop entries listed and then you find the exact reason why the install failed.
So, there are two possible things, either the mount of /system failed, or it says “update-binary: No such file or directory”. In the last case the busybox is necessary…
This would be interesting for me…

Thanks! Here’s the (hopefully) relevant section fro the log file:

[more things]
E:Can’t open /dev/block/platform/msm_sdcc.1/by-name/misc <-- you got that too, right?
(Permission denied)
locale is [en_US]
stage is []
reason is [(null)] <-- is that the real error message?
fb0 reports (possibly inaccurate):
[…]
Command: “/sbin/recovery”

av.offload.enable = true
(more stuff)

I understood that the build instructions are currently having errors/missing pieces of information (e.g. some .so need to move somewhere, the gcc version that was successfully tested). Solutions for this problems have been posted in this thread – that is already over 150 posts long. I’m confident that the Fairphone software team will improve the build instructions once they find time for it. Until then you probably will have to read through the whole thread to collect the different bits of helpfull informations to successfully build the Fairphone Open Source OS.

To make it easier for both, the interested community as well as the Fairphone developers, to find the relevant information I’d like to ask @keesj or @paulakreuzer or anybody else from the admin staff if it would be possible to wikify the top article. We could then collect all the additions for a successful build at one location and once the Fairphone devs have a bit more time they can transfer it over to the correct section at http://code.fairphone.com

Thanks! Simon

6 Likes

Hi vivia
No, this is still way down… There are literally pages of this assignment lines like you have on the last line of your quote…

Hi i just wanted to express my appreciation for your work here!
:trophy:

1 Like

@keesj: I saw something about included apk’s while compiling and, one find and one grep later, I found that I can just place the .apk into a directory in vendor/qcom/proprietary/target/product/FP2/system/app without touching any other files and magic happens. So I included SuperUser that way and it worked, thanks! Except the su binary is still not there… :smile:

@lklaus: I will try again later when I’m back and let you know! EDIT: @lklaus I found the su binary in other places:
vivia@talos:~/fairphone_os$ find . -name su ./out/target/product/FP2/symbols/system/xbin/su ./out/target/product/FP2/obj/EXECUTABLES/su_intermediates/su ./out/target/product/FP2/obj/EXECUTABLES/su_intermediates/LINKED/su ./out/target/product/FP2/system/xbin/su ./system/extras/su vivia@talos:~/fairphone_os$
Now that I know where the Makefile is, can you tell me which su I need to pick (probably the one in system/xbin) and where it should be copied to? \o/ OK, really need to run now!


###This text is outdated! You can find the latest version on top of this thread

This is mostly for users that don’t care much about their data and just want to play with their phone :smile:
Let’s update this together (code, spelling …)

Compile your own FP2 ROM

  • Have an SSD with lots of space ready (~75 Gb for the full build with the repro checked out.)

  • Use gcc-4.8 (or 4.6) newer gcc’s will give you trouble with webkit and gcc is not loved anymore by the Android-SoC people anyway. I think there will be/is a switch to LLVM underway. Read about it. It comes with interesting implications licenses-wise. If you have issues on a Debian based system, try using update-alternatives to change the gcc-version. (Add more info on how to do this later)

Prepare you system (check the build instructions and install all the software needed) and clean up ~75 GB of space first!

Go where you have lots of free space, make a directory there and use repo to checkout the code base:

$ mkdir fairphone_os && cd fairphone_os
$ repo init -u http://code.fairphone.com/gerrit/fp2-dev/manifest -b fp2-sibon
$ repo sync

Download the evil bin blobs and run a strange script on your computer in the same directory

$ wget http://code.fairphone.com/downloads/FP2/blobs/fp2-sibon-2.0.0-blobs.tgz
$ tar zxvf fp2-sibon-2.0.0-blobs.tgz
$ sh fp2-sibon-2.0.0-blobs.sh

Load the helper functions:

$ . build/envsetup.sh

Copy the missing libs around (I’m sure this will get fixed sooner or later. I think it’s inside the stupid bin blob script. Why not just use a tar ball?)

cp -v vendor/qcom/proprietary/target/product/FP2/obj/lib/*.so \ ./vendor/qcom/proprietary/target/product/FP2/system/vendor/lib/

Start the default build

$ choosecombo 1 FP2 2
$ make -j8

If all works well, you should see something like this after an hour or more depending on your system:

(...) Creating filesystem with parameters:
    Size: 27358941184
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 8192
    Inode size: 256
    Journal blocks: 32768
    Label: 
    Blocks: 6679429
    Block groups: 204
    Reserved block group size: 1024
Created filesystem with 72/1671168 inodes and 149065/6679429 blocks
out/target/product/FP2/userdata.img maxsize=27931677312 blocksize=135168 total=142911480 reserve=282230784

#### make completed successfully (09:24 (mm:ss)) ####

The images will be found here: out/target/product/FP2/*.img

Notes:
For comparison and analysis (see @jochensp post) you can get offical image here, by looking inside the updater.xml file her: http://ota.fairphone.com/FP2/updater.zip.

4 Likes

Can you just add this to the top post? It’s wikified :smile:

3 Likes

I don’t know whether anyone would look into it if suddenly images were found on anonymous hosting sites (It doesn’t look like Fairphone even has the resources to do this). So sharing is probably not an issue. However, using such a shared issue is always a risk because you don’t know who created the ROM and towards what purpose … it might be malware.

I was wondering whether one could save lots of disk space by only checking out the latest version instead of cloning all repositories entirely. The following should do the trick (haven’t tried it yet).

$ repo init --depth=1
...
$ repo sync -c

Btw, @fp1_wo_sw_updates, I’ve included all the steps you describe in the Dockerfile

Edit: I’ve had it wrong: the --depth option is for repo init.

Hi vivia,
if you compile the OSOS on your own, you will not need the patched recovery. In the OSOS build the su is already included. (Was as I compiled it, and others confirmed). As far as I know (haven’t tried it) you would only need a “controlling” app, like SuperSu, which can be installed from a play store.

Well, I guess I have to dive deeper into the Android Makefile-system…
Who just wants to have the hack, I put a precompiled tar ball of busybox here: https://drive.google.com/file/d/0B-9cNi0ys0CMeGdhTXFlMW9qaUk/view?usp=sharing (it is GPL, the source is from https://github.com/omnirom/android_external_busybox/archive/android-5.1.zip)
Best is you tar it somewhere, and in build/core/Makefile, after “Making recovery image” you see lots of cp and so on. Check my manipulated Makefile I already shared a link.
Also, you need in recovery’s init.rc after “on init” a “export LD_LIBRARY_PATH .:/sbin”

This should be all, then

Makes sense. I have not looked into repo and I don’t know what it really does … I think it is just a wrapper for git. I hope that will work. There is way too much stuff in the repository for a person that just wants to compile the image, I think. I will test it and let you know …

Hi Klaus,

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

It’s there anything you could add for clarification regarding the use of su to the wiki on top of this thread?

Regarding SuperSu:
Is http://su.chainfire.eu/ the same as SuperSu?

I tried to follow the official instructions but the compilation always (tried make -j1 as well) with these messages:

Install: out/host/linux-x86/bin/apicheck
Checking API: checkpublicapi-last
Checking API: checkpublicapi-current
out/target/common/obj/PACKAGING/public_api.txt:20: error 5: Added public field android.Manifest.permission.BACKUP
out/target/common/obj/PACKAGING/public_api.txt:82: error 5: Added public field android.Manifest.permission.INVOKE_CARRIER_SETUP
out/target/common/obj/PACKAGING/public_api.txt:106: error 5: Added public field android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE
out/target/common/obj/PACKAGING/public_api.txt:116: error 5: Added public field android.Manifest.permission.RECEIVE_EMERGENCY_BROADCAST
******************************
You have tried to change the API from what has been previously approved.
To make these errors go away, you have two choices:
   1) You can add "@hide" javadoc comments to the methods, etc. listed in the
      errors above.
   2) You can update current.txt by executing the following command:
         make update-api
      To submit the revised current.txt to the main Android repository,
      you will need approval.
******************************
build/core/tasks/apicheck.mk:62: die Regel für Ziel „out/target/common/obj/PACKAGING/checkpublicapi-current-timestamp“ scheiterte
make: *** [out/target/common/obj/PACKAGING/checkpublicapi-current-timestamp] Fehler 38
#### make failed to build some targets (04:11 (mm:ss)) ####

Running “make update-api”, followed by “make” again generates some .img-files but I’m not sure if it’s good to do so. Anyone knows the reason and the solution to posted error messages? Thanks!