[HOWTO] ✏ Compiling Fairphone Open OS / Rooting

Same problem as @andy problem when compiling with fairphone2-build-env, which uses openjdk-7.

$ java -version
java version "1.7.0_95"
OpenJDK Runtime Environment (IcedTea 2.6.4) (7u95-2.6.4-0ubuntu0.14.04.2)
OpenJDK 64-Bit Server VM (build 24.95-b01, mixed mode)

If I comment the line containing maybeMarkCapabilitiesRestricted(), compilation continues, but I get another error:

packages/apps/Settings/src/com/android/settings/applications/InstalledAppDetails.java:444: error: cannot find symbol
      int mode = appOpsManager.checkOpNoThrow(AppOpsManager.OP_SU, mAppEntry.info.uid, mAppEntry.info.packageName);
                                                           ^
  symbol:   variable OP_SU
  location: class AppOpsManager

I noticed that the checked-out branch of frameworks/opt/telephony was fp2-sibon. The upstream branch fp2-sibon-2.0.2 was different. Perhaps we need to repo init ... -b fp2-sibon-2.0.2 … ?

edit I was able to compile only after running this after repo sync

find . -name \*.git -execdir git checkout fp2-sibon-2.0.2 \;

It worked!! Not sure precisely what I did that fixed it…

First I updated my Ubuntu vm (which I hadn’t done since February) and actually removed the out folder instead of just counting on make clean to clear it out. Then:
repo sync -c
. build/envsetup.sh
choosecombo 1 FP2 2
make

This was after adding the new sibon blob (as mentioned in my other post).

Edit:
I’m using java-7-openjdk-amd64

1 Like

I’m just wondering: On the download site http://code.fairphone.com/projects/fp-osos/dev/fp2-blobs-download-page.html , binary blobs are available in version 16.04.0. In both this article and the official build instructions http://code.fairphone.com/projects/fp-osos/dev/fairphone-os-build-instructions.html , version 2.0.1 is linked.
The new tgz file is 47mb, whereas the old one is 199mb.

Why is that so? What’s the difference and should I use the old one or the new one?

I have downloaded the blobs via bash unpacked them but when I try to run I get the following:

~/Fairphone_Open_OS$ s̶h̶ ̶f̶p̶2̶-̶s̶i̶b̶o̶n̶-̶1̶6̶.̶0̶5̶.̶0̶-̶b̶l̶o̶b̶s̶.̶t̶g̶z̶
fp2-sibon-16.05.0-blobs.tgz: 3: fp2-sibon-16.05.0-blobs.tgz.1: Syntax error: Unterminated quoted string

Can anybody tell me where this comes from?

Edit: Okay I got it. Fairphone Team should update the build instructions on code.fairphone.com. It has to be:

sh fp2-sibon-16.05.0-blobs.sh

of course. :sweat_smile:

Can anyone help please?

libnativehelper/JniConstants.cpp:138: error: unsupported reloc 43
libnativehelper/JniConstants.cpp:139: error: unsupported reloc 43
libnativehelper/JniConstants.cpp:140: error: unsupported reloc 43
libnativehelper/toStringArray.cpp:21: error: unsupported reloc 43
libnativehelper/toStringArray.cpp:21: error: unsupported reloc 43
libnativehelper/JniInvocation.cpp:40: error: unsupported reloc 43
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 StaticLib: libsigchain_32 (out/host/linux-x86/obj32/STATIC_LIBRARIES/libsigchain_intermediates/libsigchain.a)
make: *** wait: No child processes. Stop.

make failed to build some targets (57:27 (mm:ss))

I really try to be and keep patient, but I slowly get sick that even following instructions and tutorials is running into errors :unamused:

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…