[HOWTO] ✏ Compiling Fairphone Open OS / Rooting

In theory :slight_smile: this works without messing up your system. I had my system setup also, and didn’t want to redo all. If you flash recovery, it does not mess up the system. But I’m no expert for recovery, so I can’t say how good my patch for the recovery really is or whether it’s done with a sledgehammer… I wanted my phone setup as soon as possible, but also Fairphones description on how to root will be out rsn, as I understand

Maybe a stupid question - if I compile from source, would I have Android’s file system layout available before creating the images in a last step? So that I could manually do all the steps a given update.zip (such as SuperSu or OpenGAPPS) would do when ran from recovery? Or will I run into trouble with users, groups and permissions? (Obviously this post is inspired by the strange discussion on rooting…) Thank you a lot!

FYI: I yesterday got a reply from the technical support regarding my question about the release date of the Fairphone FOSS OS:

calculate within the first quarter of 2016. The software team is quite
busy these days. The best chance to get in touch with them is to be a
active member in the forum.

Thanks for your ideas. We currently
working on minor software fixes of the current FP2 release. Than we will
focus an updates and the open source tasks from our side.

If nothing happens till mid of February please remind me to pressure it a little!

4 Likes

I compiled Fairphone OS by following the instructions on http://code.fairphone.com
Took about 90min until it said everything was successful.

After fastboot flashall succeeded the phone restarted into recovery, NOT into the OS.

When I boot the phone now the following happens:

  1. short vibration
  2. fairphone splash screen shows
  3. popup in ubuntu that “Android” connected (because usb cable was connected)
  4. short vibration
  5. fairphone splash screen shows
  6. screen goes black
  7. recovery mode is active

At the bottom of the screen there is an error message:

E:Can't open /dev/block/platform/msm_sdcc.1/by-name/misc
(Permission denied)

I tried “wipe data/factory reset”, but it didn’t help. I have read that it only resets data, not the OS itself, but I tried it nonetheless.

In the recovery logs the error message from above appears several times.

How can I analyze/fix this?

The error itself is not a problem, it happens on stock and on my own build too. Have you tried flashing the images one by one ? On top of “flashall” (which I don’t use, I flash each image sequencially) I also flashed cache.img and userdata.img (just to be sure, it should be enough to wipe them but I did it anyway).

I flashed these images in sequence: boot, cache, persist, recovery, splash, system and userdata.
Still it won’t boot.
Can check additional logs? How do OS developers debug these errors?

Does the fact that I am still able to flash it mean that there is hope that the phone can eventually be rescued?

I can’t help you much for the first part without having the phone in front of me (there might be logs on the phone that you can retrieve while in recovery mode through adb yes).

For the second part, definitely. You will be able to flash a working ROM (sadly it’s currently a breach of license agreement to publish ROMs built with the binary blobs…) when you have one.

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