[HOWTO] ✏ Compiling Fairphone Open OS / Rooting

The log is complete this time, good. The gcc died. Normally this should not happen, so it’s a gcc bug. What gcc version were you using this time? Have you started with a clean “out” dir?
Have you ever tried building on the “bare metal” hardware without any emulation? I would suggest building on the pure os without any emulation and with gcc 4.8.5. And check your logs for hardware issues.

gcc 4.8.5 (but I also tried 4.8.4, which is the default of ubuntu 14.04)

I started with a make clean, before continuing with building the envsetup.

Well yes, but only under ubuntu 15.10 and gcc 5.2.1 (which was “expected” to fail.)

I don’t want to reinstall the whole system, but I can try to downgrade gcc…

Well, the build is a really heavy process, so you might not encounter any issues with normal use. Of course it could be an issue with the virtualization layer or whatever too. You could e.g. try running the VM with VirtualBox to see if it makes any difference. At least I’ve successfully built the FPOSOS with Ubuntu running under VirtualBox with a Mac OS X host.

It could also still be a symptom of running out of memory if you only have 6 GB of RAM regardless of swap. I don’t know how gcc uses the memory, but I can imagine memory being locked so it doesn’t get swapped out in some situations.

You can make “make clean” to rm "out/" completely. But don’t forget to also unpack the bin-blobs again. I’m sorry but nothing more comes to mind. Maybe trying other hardware or asking for the images? Maybe people will send you links to their working images if you can’t currently build your own.

I did successfully compile on kvm with a VM with 4G and 4G swap. The crash after 4 hours leads me to also suspect hardware. The laptop gets (very) warm?

35 posts were split to a new topic: Problems compiling - compile host thermal issues

First of all, thank you guys for all of the work that already went into this thread. It helped a lot to avoid some pitfalls.

I tried to build yesterday with limited success (i’ll list the steps I took below). I ended up with a successful build and was able to flash it to the FP. If I turn on the phone now, one of two things happen, and I’m not exactly sure what the conditions are under which each of them happens:

  1. Boot to the black/white Fairphone logo (fastboot)
  2. Boot to the black/white Fairphone logo (fastboot), then the blue logo shows (“start a movement”), then it goes into a grey screen with “LOADING…” flashing in white and the green LED goes on and off once in a while.

I left the phone in mode 2. over night but nothing changed.

Does anyone have an idea what to try next?


Details
For reference, here are the steps I took, and problems I ran into along the way:

My host system is a 64 bit Ubuntu 15.04, where I installed all recommended packages. For zlib1g-dev I first installed the wrong version (64 bit) which made the installation of zlib1g-dev:i386 fail. I then removed zlib1g-dev and installed zlib1g-dev:i386, which worked fine. For the jdk I first installed version 8 as recommended by the general android site the was linked from the build instructions, I then noticed that the build instructions recommend to use version 7 and installed that as well. I also installed gcc-4.8 and g+±4.8 and used update-alternatives to make them the default compiler (I also used this to select jdk version 7 of java and javac). I verified that gcc --version, g++ --version, java -version, javac -version all show the expected values (gcc/g++: 4.8.5, java/javac: 1.7.0_95). I also added export USE_CCACHE=1 to my zshrc, but that should not matter because I later switched to bash and ccache should only really help if you do make clean a lot. I also added the rules for USB access as described here: https://source.android.com/source/initializing.html

After registering an account with gerrit, adding my ssh key, I got error messages because the host was not known. The page where you add your ssh key (user preferences?) also shows a line that should be added to ~/.ssh/known_hosts. After adding this, there was a different error (can’t remember), so I retried over https, which worked fine.

Syncing the repository showed a 404 error after every subrepo but @kuleszdl mentioned those are normal. I then downloaded the blobs (version 2.0.1) extracted them and ran the shell script. This gave a warning because it only supports bash and I was using zsh so far. After switching to bash, it worked.

. build/envsetup.sh and choosecombo 1 FP2 2 worked with anything unusual, so I ran make -j4 2>&1 | tee build.log (I don’t have enough cores for -j8). The compile got stuck with the same message that @sjjh reported earlier: You have tried to change the API from what has been previously approved.. I ran make update-api followed by another call to make -j4 2>&1 | tee build.log and the compile was successful. I had a look at the build logs but did’nt read all of it (90k+ lines). I noticed a lot of warnings about uninitialized fields, implicitly defined functions and so on. Some of them sounded like code smells (uninitialized values, etc.), others sounded like legit bugs (checking that and unsigned int is >= 0 is always true, so the test probably does not have the intended effect). I don’t think they are problematic here, though, because you would probably get the same warnings in every android build.

As a next step I tried flashing the images. My user shell did not have the access rights to the Fairphone despite the USB rules, so I started a root shell (bash), repeated . build/envsetup.sh and choosecombo 1 FP2 2 and used fastboot from there. I flashed the following images in this order:
fastboot flash recovery recovery.img
fastboot flash system system.img
Then rebooted and got to the “LOADING…” screen I described above.
This morning, I tried fastboot flashall with the same result. I then booted to recovery, wiped the cache and used fastboot flashall again. Same result: I got to the “LOADING…” screen but not further.

If you read this far (thank you), I have two more questions:
Is it ok to flash the images as the root user?
Is there some way to see what’s going on during the loading screen?

I checked the recovery logs, are those the right logs to look at? The line Command: "/sbin/recovery" sounds like this is the log of the recovery itself, not the last failed boot.
Anyway, here is what I got:

E: Can't open /dev/block/platform/msm_sdcc.1/by-name/misc
(permission denied)
__bionic_open_tzdata: couldn't find any tzdata when looking for localtime!
__bionic_open_tzdata: couldn't find any tzdata when looking for GMT!
__bionic_open_tzdata: couldn't find any tzdata when looking for posixrules!
Starting recovery (pid 212) on Thu 1 23:07:12 1070
recovery filesystem table
=========================
  0 /system ext4 /dev/block/platform/msm_sdcc.1/by-name/system 0
  1 /cache ext4 /dev/block/platform/msm_sdcc.1/by-name/cache 0
  2 /data ext4 /dev/block/platform/msm_sdcc.1/by-name/userdata -16384
  3 /sdcard vfat /dev/block/mmcblk1p1 0
  4 /boot emmc /dev/block/platform/msm_sdcc.1/by-name/boot 0
  5 /recovery emmc /dev/block/platform/msm_sdcc.1/by-name/recovery 0
  6 /misc emmc /dev/block/platform/msm_sdcc.1/by-name/misc 0
  7 /bootselect emmc /dev/block/platform/msm_sdcc.1/by-name/bootselect 0
  8 /tmp ramdisk ramdisk 0

stat /dev/block/platform/msm_sdcc.1/by-name/misc try 1: No such file or directory
stat /dev/block/platform/msm_sdcc.1/by-name/misc try 2: No such file or directory
stat /dev/block/platform/msm_sdcc.1/by-name/misc try 3: No such file or directory
stat /dev/block/platform/msm_sdcc.1/by-name/misc try 4: No such file or directory
stat /dev/block/platform/msm_sdcc.1/by-name/misc try 5: No such file or directory
stat /dev/block/platform/msm_sdcc.1/by-name/misc try 6: No such file or directory
stat /dev/block/platform/msm_sdcc.1/by-name/misc try 7: No such file or directory
stat /dev/block/platform/msm_sdcc.1/by-name/misc try 8: No such file or directory
stat /dev/block/platform/msm_sdcc.1/by-name/misc try 9: No such file or directory
stat /dev/block/platform/msm_sdcc.1/by-name/misc try 10: No such file or directory
failed to stat /dev/block/platform/msm_sdcc.1/by-name/misc
E: Can't open /dev/block/platform/msm_sdcc.1/by-name/misc
(No such file or directory)
stat /dev/block/platform/msm_sdcc.1/by-name/misc try 1: No such file or directory
stat /dev/block/platform/msm_sdcc.1/by-name/misc try 2: No such file or directory
stat /dev/block/platform/msm_sdcc.1/by-name/misc try 3: No such file or directory
stat /dev/block/platform/msm_sdcc.1/by-name/misc try 4: No such file or directory
stat /dev/block/platform/msm_sdcc.1/by-name/misc try 5: No such file or directory
stat /dev/block/platform/msm_sdcc.1/by-name/misc try 6: No such file or directory
stat /dev/block/platform/msm_sdcc.1/by-name/misc try 7: No such file or directory
stat /dev/block/platform/msm_sdcc.1/by-name/misc try 8: No such file or directory
stat /dev/block/platform/msm_sdcc.1/by-name/misc try 9: No such file or directory
stat /dev/block/platform/msm_sdcc.1/by-name/misc try 10: No such file or directory
failed to stat /dev/block/platform/msm_sdcc.1/by-name/misc
E: Can't open /dev/block/platform/msm_sdcc.1/by-name/misc
(Permission denied)
locale is [en_US]
stage is []
reason is [(null)]
fb0 reports (possibly inaccurate):
  vi.bits_per_pixel = 32
  vi.red.offset   =  24   .length =   8
  vi.green.offset =  16   .length =   8
  vi.blue.offset  =  8    .length =   8
framebuffer: 0 (1080 x 1920)
  found frames = 7
       installing_text: en (277 x 33 @ 374)
          erasing_text: en (95 x 33 @ 374)
       no_command_text: en (150 x 33 @ 374)
            error_text: en (57 x 33 @ 374)
Command: "/sbin/recovery"

The log then goes on with a bunch of configuration values and ends in

I:Saving locale "en_US"

When I flashed the OS and booted (having booted the original Fairphone OS before), starting up took a long long time and actually never finished for the time I waited. After giving the phone a factory reset (wiping all data) it started allright.

1 Like

Thanks @wvengen. I think I just figured out what was wrong. When copying the log from the phone to the forum, I noticed one strange line:

So I used fastboot flash userdata userdata.img to flash the userdata and the phone booted up fine. I guess the factory reset you did had the same effect (reseting the userdata partition).

So far, I can say that WiFi, sim card and camera seem to work, I have not yet tested anything else.

Sorry for the long thread that apparently was just one step away from a solution. Hopefully, it will help someone else.

EDIT: Maybe someone with wiki access rights can add some details to the top post (e.g., about flashing userdata).

1 Like

Hello, this is how my build failed today:

Config:

  • AMDx86_64
  • Kubuntu 15.10
  • gcc-version: 4.8.5
  • python: 2.7.10
  • OpenJDK 8
  • RAM: 8GB
  • ccache: 100GB
  • swap: 10GB

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
Ignoring unused library classes…
Original number of library classes: 11515
Final number of library classes: 11515
Shrinking…

Checking API: checksystemapi-last


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.
  1. 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: recipe for target ‘out/target/common/obj/PACKAGING/checkpublicapi-current-timestamp’ failed
make: *** [out/target/common/obj/PACKAGING/checkpublicapi-current-timestamp] Error 38
make: *** Waiting for unfinished jobs…
Writing output…
Preparing output jar [/home/xaxa/fairphone_os/out/target/common/obj/APPS/ContactsProvider_intermediates/proguard.classes.jar]
Copying resources from program jar [/home/xaxa/fairphone_os/out/target/common/obj/APPS/ContactsProvider_intermediates/classes.jar]
Preparing output jar [/home/xaxa/fairphone_os/out/target/common/obj/APPS/TelephonyProvider_intermediates/proguard.classes.jar]
Copying resources from program jar [/home/xaxa/fairphone_os/out/target/common/obj/APPS/TelephonyProvider_intermediates/classes.jar]
Preparing output jar [/home/xaxa/fairphone_os/out/target/common/obj/APPS/Telecom_intermediates/proguard.classes.jar]
Copying resources from program jar [/home/xaxa/fairphone_os/out/target/common/obj/APPS/Telecom_intermediates/classes.jar]
Removing unused program classes and class elements…
Original number of program classes: 1767
Final number of program classes: 557
Preparing output jar [/home/xaxa/fairphone_os/out/target/common/obj/APPS/SystemUI_intermediates/proguard.classes.jar]
Copying resources from program jar [/home/xaxa/fairphone_os/out/target/common/obj/APPS/SystemUI_intermediates/classes.jar]
Writing output…
Preparing output jar [/home/xaxa/fairphone_os/out/target/common/obj/APPS/TeleService_intermediates/proguard.classes.jar]
Copying resources from program jar [/home/xaxa/fairphone_os/out/target/common/obj/APPS/TeleService_intermediates/classes.jar]

make failed to build some targets (03:17:35 (hh:mm:ss))

Anyone an idea what went wrong? I used -j8 and am trying with j8 right now. I will switch to -j4 in a third try maybe.

Edit: ccache-, ram-, and swap-size added

Only a first guess: As far as I remember, openjdk-7-jdk is recommended to build Android 5.

Maybe you are right. I have read it as just a recommendation rather than a strong necessity. After fail I was checking too, but I didn’t got this error-message. If my second build running right now fails too, I will change the Java-Version aswell and will report in the late evening.

Edit:
2nd build failed too, at the exact same position with the same error message. Now trying with -j2 and OpenJDK 7 as recommended (I have removed all JDK-versions I found with synaptic before)

3rd build with JDK7 and -j2 failed too. Does anybody else know this API error?

Finally the self compiled Fairphone Open Source Android works on my phone. :relieved:

The info I was missing was to not use “make -j8” when compiling, but “make” (it took 6hrs). This was already stated multiple times in this thread, however I assumed that everything went fine because the build process printed “compiled successfully”, which apparently has no meaning whether the output is usable.

I then flashed boot.img + system.img and for the first time the phone didn’t hang at the Fairphone splash with the black background but at the “loading” screen with a light background color. It was still not able to boot. This I could fix with the information of this thread by executing “fastboot -w flash system system.img”. This command cleared not only system but also the partitions userdata, cache, etc.

Afterwards the Fairphone booted directly into the OS in contrast to the stock Fairphone OS which boots into a welcome screen. :grin:

For all building with Docker on Linux: I needed to switch its storage backend to devicemapper to be able to finish building (to get around the zombies problem). More at docker/docker#18502 and SO.
This is documented in the fairphone2-build-env’s README now, but you may have missed it if you started building before the change.

congrats!

how can i send you a private message? i cant find an button for that (am i too stupid).

Click on the name of the user you want to send a PM.

thank you, but i dont get it. this is embarrassing but if i click on the username i just can see the users batches, activity… but i cant find a pm button. so sorry for my of topic postings.

What i need is an FP2 ROM. I formatted my FP2 and have no backup (yeah thats funny).

So if someone can help me out maybe you manage to send me a PM.

@tinkerweasel, could you get in contact with @dsfhoiud?

1 Like

Maybe this is the wrong thread?!

I noticed changes to the repository. Is there some kind of changelog available? Do we know if one or some of the known issues are already fixed in the Open Source sources? And how would one know if the sources available are stable for day to day usage?

Or is it to early to ask these questions and we expect something along these lines to come when Fairphone starts to publish pre-built OS versions later in Q1/2016?

To a certain extend I’m asking as I expect delivery of my FP2 and wanted to go Google-free right form the start…

Grazie mille for your thoughts… :wink: