[HOWTO] ✏ Compiling Fairphone Open OS / Rooting

Can you please give some more information on your build setup? Also, please let us know which instructions you were following exactly.

BTW: Did you know that there is an official release of the same code? If you don’t want to change any code, you can just download a build from code.fairphone.com.

First, thank you for your answer. Here is my environment:

  • Kubuntu 16.04 LTS
  • AMD64
  • openJDK7-amd64
  • gcc 4.8.5
  • binblobs: 16.05
  • repo init -b refs/tags/FP2-open-16.05.0
  • I followed the instructions found here and on code.fairphone.com

The only suspicious behaviour I have observed was that I have no writing permissions in my home directory, when opening a textfile through krusader (tried to edit ~/Fairphone_Open_OS/.repo/manifests/default.xml to remove Setupwizard) It didn’t work. Tried again through terminal with gksudo. It worked, but then repo denied service at all with an cryptic error message. I already deleted the whole tree and downloaded it again :confounded: but the Linker-error persists.

And what you mention about downloading the official release. I would LOVE to do so, but I need working GPS with FPOSOS on my phone which was fixed only recently in 16.05. And code.fairphone.com doesn’t provide it yet.

Actually I do not understand that the blobs for 16.05 are available but no system release yet. How other may I use the binblobs but to compile my own version?

Well, there’s a problem if you can’t write in your home (or below). Did you do anything with sudo in your home before? This should be rectified…

I don’t know, I can’t recall something shady. Beside that I could extract sucessfully the blobs. I think the writing permissions were only restricted to kde applications which I fixed now by using chown on ~/.kde and ~/.config/katerc.

I have deleted the whole working tree and created a new folder for FP Open OS. I’ll report each step I have done afterwards.

This is what I have until now (it is downloading):

xaxa@xaxa-desktop:~$ cd FP_Open_OS
xaxa@xaxa-desktop:~/FP_Open_OS$ dir
xaxa@xaxa-desktop:~/FP_Open_OS$ sha1sum ~/bin/repo
da0514e484f74648a890c0467d61ca415379f791 /home/xaxa/bin/repo
xaxa@xaxa-desktop:~/FP_Open_OS$ chmod u+x ~/bin/repo
xaxa@xaxa-desktop:~/FP_Open_OS$ repo init -b refs/tags/FP2-open-16.05.0
Get https://gerrit.googlesource.com/git-repo/clone.bundle
Get git-repo - Git at Google
remote: Finding sources: 100% (15/15)
remote: Total 15 (delta 1), reused 15 (delta 1)
Unpacking objects: 100% (15/15), done.
From git-repo - Git at Google
79fba68…8b39fb4 master → origin/master
fatal: manifest url (-u) is required.
xaxa@xaxa-desktop:~/FP_Open_OS$ eval ssh-agent
Agent pid 2115
xaxa@xaxa-desktop:~/FP_Open_OS$ ssh-add ~/.ssh/id_rsa
Enter passphrase for /home/xaxa/.ssh/id_rsa:
Identity added: /home/xaxa/.ssh/id_rsa (/home/xaxa/.ssh/id_rsa)
xaxa@xaxa-desktop:~/FP_Open_OS$ repo init -u ssh://code.fairphone.com:29418/fp2-dev/manifest -b refs/tags/FP2-open-16.05.0
Get ssh://code.fairphone.com:29418/fp2-dev/manifest
remote: Counting objects: 26, done
remote: Finding sources: 100% (26/26)
remote: Total 26 (delta 7), reused 26 (delta 7)
From ssh://code.fairphone.com:29418/fp2-dev/manifest

  • [new branch] fp2-sibon → origin/fp2-sibon
  • [new tag] FP2-open-16.05.0 → FP2-open-16.05.0

Your identity is: xaxa
If you want to change this, please re-run ‘repo init’ with --config-name

repo has been initialized in /home/xaxa/FP_Open_OS
xaxa@xaxa-desktop:~/FP_Open_OS$ repo sync
Fetching project fp2-dev/platform/external/bson
remote: Counting objects: 743, done
remote: Finding sources: 100% (743/743)
remote: Total 743 (delta 473), reused 743 (delta 473)
Receiving objects: 100% (743/743), 121.48 KiB | 0 bytes/s, done.
Resolving deltas: 100% (473/473), done.
From ssh://code.fairphone.com:29418/fp2-dev/platform/external/bson

  • [new branch] fp2-sibon → origin/fp2-sibon
  • [new branch] fp2-sibon-2.0.1 → origin/fp2-sibon-2.0.1
  • [new branch] fp2-sibon-2.0.2 → origin/fp2-sibon-2.0.2
  • [new tag] FP2-open-16.05.0 → FP2-open-16.05.0

[…]

Fetching projects: 14% (73/519) Fetching project fp2-dev/platform/external/aac
remote: Counting objects: 1216, done
remote: Finding sources: 100% (1216/1216)
remote: Total 1216 (delta 675), reused 1216 (delta 675)
Receiving objects: 100% (1216/1216), 4.11 MiB | 6.58 MiB/s, done.
Resolving deltas: 100% (675/675), done.
From ssh://code.fairphone.com:29418/fp2-dev/platform/external/aac

  • [new branch] fp2-sibon → origin/fp2-sibon
  • [new branch] fp2-sibon-2.0.1 → origin/fp2-sibon-2.0.1
  • [new branch] fp2-sibon-2.0.2 → origin/fp2-sibon-2.0.2
  • [new tag] FP2-open-16.05.0 → FP2-open-16.05.0
    Fetching project fp2-dev/platform/packages/apps/SetupWizard
    fatal: Project not found: fp2-dev/platform/packages/apps/SetupWizard
    fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

So now, I will edit ~/FP_Open_OS/.repo/manifests/default.xml and remove the SetupWizard

Syncing work tree: 100% (518/518), done.
xaxa@xaxa-desktop:~/FP_Open_OS$ wget http://code.fairphone.com/downloads/FP2/blobs/fp2-sibon-16.05.0-> blobs.tgz
–2016-05-30 21:08:23-- http://code.fairphone.com/downloads/FP2/blobs/fp2-sibon-16.05.0-blobs.tgz
Resolving code.fairphone.com (code.fairphone.com)… 37.187.31.110
Connecting to code.fairphone.com (code.fairphone.com)|37.187.31.110|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 63268964 (60M) [application/octet-stream]
Saving to: ‘fp2-sibon-16.05.0-blobs.tgz’

fp2-sibon-16.05.0-blobs.tgz 100%[===================================================================>] 60,34M 5,74MB/s in 9,5s

2016-05-30 21:08:33 (6,34 MB/s) - ‘fp2-sibon-16.05.0-blobs.tgz’ saved [63268964/63268964]

xaxa@xaxa-desktop:~/FP_Open_OS$ tar zxvf fp2-sibon-16.05.0-blobs.tgz
fp2-sibon-16.05.0-blobs.sh
xaxa@xaxa-desktop:~/FP_Open_OS$ sh fp2-sibon-16.05.0-blobs.sh
Special License Agreement for downloading, installing and using Fairphone 2
[…]
Verifying archive integrity… All good.
Uncompressing blobs 100%
xaxa@xaxa-desktop:~/FP_Open_OS$ . build/envsetup.sh
[…]
xaxa@xaxa-desktop:~/FP_Open_OS$ choosecombo 1 FP2 2
[…]
xaxa@xaxa-desktop:~/FP_Open_OS$ make -j8

[…]

libnativehelper/JniInvocation.cpp:45: error: unsupported reloc 43
libnativehelper/JniInvocation.cpp:165: error: unsupported reloc 43
libnativehelper/JniInvocation.cpp:165: error: unsupported reloc 43
libnativehelper/JniInvocation.cpp:165: error: unsupported reloc 43
libnativehelper/JniInvocation.cpp:165: error: unsupported reloc 43
clang: error: linker command failed with exit code 1 (use -v to see invocation)
build/core/host_shared_library_internal.mk:44: recipe for target ‘out/host/linux-x86/obj32/lib/libnativehelper.so’ failed
make: *** [out/host/linux-x86/obj32/lib/libnativehelper.so] Error 1
make: *** Waiting for unfinished jobs…
host C++: dalvikvm <= art/dalvikvm/dalvikvm.cc

make failed to build some targets (01:03:44 (hh:mm:ss))

not funny! :expressionless:

I think I’ve seen “clang: error: linker command failed with exit code 1 (use -v to see invocation)”.

Can you have a look here and see if your problem is related? You will have to edit the file “build/core/clang/HOST_x86_common.mk” for this. Add the “-B” line and the backslash after sysroot as pointed out in the linked diff.

CLANG_CONFIG_x86_LINUX_HOST_EXTRA_ASFLAGS :=
–gcc-toolchain=$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)
–sysroot $($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/sysroot
-B$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/bin

After that, try make again. Just a guess, I hope it helps!

Update: And you might run into a problem with a strange little perl script (kernel/timeconst.pl) later. All you need to do is what the error message tells you … you have to remove the “defined” in the code, once.

You’re right, the download page does not list 16.05 yet. However, if you take the 16.04 link and replace the “4” with a “5”, you get a working link which should be the OTA package. Here you go.

Edit: And, btw, having these permission issues should definitely be solved before you try again. I suggest just creating a new user and trying with that one again.

1 Like

Not sure if anyone needs this info, but sometimes it helps to know that something worked for others. After fixing the problems as described in the wiki (SetupWizard) and above the 16.05.0 build here was successful.

your gcc is not compatible (Google would have told you as well :wink: ). You can use a Ubuntu 14.04 chroot for example.

Could you provide a link, just for further reference? The code compiled fine here with GCC4.8, just for the record.

Update: Here is how I see it … just for the discussion: The build environment is not so important. Yes, the GCC and java have to be older, but most of the stuff that is actually used to compile/link the code that runs on the ARM/SoC chip is complied by binaries already in the repo (see: prebuilts/gcc/).

So most stuff that fails … is the building of x86 based helper tools or the accidental use of newer host software. All the code that is in the repo … will “fit” automatically. Or do I misunderstand the way the Android images are build?

@wvengen, interesting observation, thank you. I’m battling with build setup, fixed number of issues myself, already mentioned in this thread (before I saw it), but one issue still remains. I’m going to give a try to your hint.

FYI what you did is not quite correct, instead of git checkout you should change the revision in repo manifest (see: https://wiki.cyanogenmod.org/w/Doc:_Using_manifests)

Then do ‘repo sync’ to update git repos. In your case a ‘repo sync’ dismisses your checkout, I think.

In default.xml I see <default remote="origin" revision="fp2-sibon" />, it needs to be changed to <default remote="origin" revision="fp2-sibon-2.0.2" /> but I do not know yet how to do it via roomservice.xml …

EDITED: changes in repo manifest do not work - not all repos have fp2-sibon-2.0.2 branch…

1 Like

fp2-sibon-2.0.2 is a pretty old branch which was for a release before the name “FP Open” was around. The fp2-sibon branch is the one you want (or a tag like FP2-open-16.10.0)

2 Likes

After some problems with my FP2 I wanted to downgrade it to the previous version (16.10) and decided it would be the good time to try and compile it myself on my Ubuntu.

Unfortunately, after syncing repos, most (all?) files are with Windows EOL, which messes up pretty much every step of the compilation, which I find amazing as I thought Ubuntu was to be used to compile AOSP.

I tried cherry-picking dos2unix-ing files but gave up after a few days. Now I’m basically running a find . -type f -exec dos2unix -s -k -o {} \; to convert everything back and will try make -j1 after that (I installed gcc-4.8 as well, just to be sure).

Am I the only one noticing that (I guess not)? I’m wondering the architecture FP2 devs are using to prepare the new versions, and syncing them with AOSP releases…

Hi guys!
Could someone update the wiki post above to the newest version (17.02.)?
Many thanks for considering my request!
Lukas

1 Like

@Matthieu, how are you checking out repositories and how are you building? My guess is that building from any NTFS partition will fail. Maybe build inside a virtual machine? Or completely work inside the docker image (without mapping the filesystem to a host path).

@jftr thanks for the followup. I’m building on an ext4 partition, following this page HOWTO (and the official one):

$ pwd
/data/fairphone/fairphone_os
$ mount | grep -w /data
/dev/sda4 on /data type ext4 (rw,nosuid,nodev,relatime,data=ordered)
$ repo init -depth 1 -u https://code.fairphone.com/gerrit/fp2-dev/manifest -b fp2-sibon
...
$ repo sync -c
...
$ wget https://code.fairphone.com/downloads/FP2/blobs/fp2-sibon-17.02.0-blobs.tgz
$ md5sum fp2-sibon-17.02.0-blobs.tgz
c55d9f9eb1d25b2e7633960fe3915491  fp2-sibon-17.02.0-blobs.tgz
$ tar zxvf fp2-sibon-17.02.0-blobs.tgz
$ sh fp2-sibon-17.01.0-blobs.sh # The extracted file is 17.01.0
$. build/envsetup.sh
bash: build/envsetup.sh: ligne 1: syntax error near unexpected symbol « $'{\r' » # Freely translated from french
'ash: build/envsetup.sh: ligne 1: `function hmm() {
$

Back in the old days when I was still on Windows 7, I had setup an Ubuntu VM and was able to build the whole thing without trouble. Now that I’m back on Ubuntu 16.04 for development, I was thinking I could do it directly on it, as I have most of the packages already installed anyway.

Can it be some git eol setting?

By default git is supposed to checkout files appropriate for the system you are working on. That said, apparently many people run into issues there. Stackoverflow is full of these kind of questions. Maybe you can find a solution there. Did you start from scratch or did you copy the repository from your Windows machine?

@jftr No I did it from scratch. I’ll see what I can find on SO though. Thanks!

1 Like

Is the wiki post up-to-date? If not - can anybody update it? Would be great!

I don’t think so - the last update was ~9 Months ago.

But since the build-instructions are on code.fairphone.com, there is no need to update them here:
https://code.fairphone.com/projects/fp-osos/dev/fairphone-os-build-instructions.html