Fairphone 2 and CyanogenMod / LineageOS

Great tries, @E150!
I’ll check those points today, once I have my laptop at hand, :wink:

1 Like


First of all thanks for the great work you are doing!
I don’t have any experience with building roms, but I would like to contribute if I can. I will set up my build environment this evening so I can try to compile the image myself. This way at least I could help testing.


I get your point and I think some support from Fairphone would certainly speed up things. However, from my understanding Fairphone as a company can’t focus their business on creating AND maintaining 4 or 5 different OS for a single device. It’s already great that they released the code for the Fairphone Open OS and delivering regular updates for both the standard and Open Android versions…

This is already a big step forward. We can use this as a reference to build a CM port (which is indeed based on Android). Actually is one of the things I’m currently looking at. Take in account that most manufacturers don’t even provide any source or proprietary binaries, and as far as I know CM images have been always built and maintained by the CM community, not the manufacturers.

I think it’s not that they’re not interested, it’s just that they cannot afford to hire a whole team of developers to port every ROM out there to the FP2. It’s just a too big investment in time, work and money for something that maybe only a few users would potentially use.

From my perspective I think the work has to be done now by the community. If eventually we manage to have a more or less stable CM running on the FP2 we could attract more developers, users and the company itself into it, but I would not expect it to be the other way around.


@Roboe: Good! Sometimes I feel I’m just trying random things without fully understand what’s going on, but I guess it takes some time to get familiar with the whole thing. Hopefully you can find out something else.

@Pentanch: Thanks for trying! Any contribution/feedback is welcome. I also never built roms until a few days ago, nor I am an expert in Android stuff, but I hope if everyone contributes with their part of knowledge we could make things work.


I have a few questions… Which images did you try? FP2 images? emulator is contained in the Android SDK or where?

I tried this too. I don’t know if any official boot.img should work. FPOS one doesn’t allow root access, and FPoOS one has some specific FPoOS configs too, I think. So, my next step forward was to try to build the CM boot.img successfuly, including the kernel.

Woa! I didn’t try that. What files contains the ZIP? I guess it contains the system.img extracted and maybe, boot.img extracted too.

That file comes from the initial work @keesj did, and it looks like an skeleton file (probably generated by mkvendor.sh). There are instructions for regenerating it in the CM port guide. I think we should thoroughly check it too, and the FPoOS one seems to be a good start point (or may work as is).

Yes, that’s it. I renamed FP2 to fp2 because lowercase is the standard (and we must follow the standard naming for making FP2 an officialy supported device in the future). Maybe I did wrong thinking too early about the future. But I know we somehow can add FP2 as a compatible target for flashing, but I don’t know how to automate that right now (adding a getprop("ro.build.product") case manually to META-INF/com/google/updater-script should be enough)

We’re newbies all here, trying to learn by tinkering, trying and sharing. I signed in in the CM IRC to question experts whenever necessary. I suggest you to do the same and actually ask something (mostly about the boot.img, the recovery.fstab, partitions and kernel), because my time is suddenly limited right now.

PD: Also… ¿eres español/hispano? I’m from Madrid, so we can treat minor doubts in Spanish by private messaging if you wish, :slight_smile: :flag_es:

1 Like

OK, I heard this

and I really thought before: “I don’t need CM, I can live with the limitations FPOS comes with (with Xposed and root)”.
Now, I think it’s the only way for us to get newer Android versions and good new features if we manage the FP2 to be an “official” CM device.

I’m not an Android developer at all (:frowning: ), but I’ll try my best! :wink:

Maybe this one helps, I heard that Ubuntu Touch is based on CM 12.1 (?)

The sources are on GitHub I think and their newest Image (?) has a boot.img inside, maybe you can look into this one for the fstab problems?

Oh, and I found this one, kaibutsu began to create a device config but unfortunately he didn’t say how much works.


To be an official CM device, the port should pass the Google Compatibility Test Suite, which is the same requisite some future Android 7 for FP2 wouldn’t meet. But we can have an unofficial port…

Wo! Thank you for that! Will take a look right now, :ok_hand:


No, they were the CM images I built. The emulator tool should come with either with the Android SDK or Android Studio. The interesting part came when I did as you suggested: [quote=“Roboe, post:110, topic:10399”]
we somehow can add FP2 as a compatible target for flashing, but I don’t know how to automate that right now (adding a getprop(“ro.build.product”) case manually to META-INF/com/google/updater-script should be enough)

I worked around the name check so the ZIP file can be installed from the recovery. I don’t get the error regarding the uppercase name anymore, but it fails next with the same error as emulator did before: system.img does not contain an ext4 filesystem.

So I’m guessing this could be a problem. I’m not even sure that the “manual” installation with fastboot is correct either even that it reports no errors, since the device doesn’t seem to allow yaffs2 images. There’s some tools to unpack/repack different image format, but I could not try any yet.[quote=“retsifp, post:111, topic:10399”]
Maybe this one helps, I heard that Ubuntu Touch is based on CM 12.1 (?)https://devices.ubports.com/#/FP2

The sources are on GitHub

I’m also looking into other ports for FP2. The recovery.fstab from Ubuntu Touch looks pretty much the same as the one from FPoOS (also ext4 filesystems), but still I’m not sure where this file is used in the build and how it affects the resulting images.


Yes, the FPoOS’s recovery.fstab is the way to go. I think it will affect the step when it creates the flashable images, which may result in semiworking images, maybe? Don’t know. Worth trying, :wink:

I used the Android image repacking tools before and are very straightforward, but I think it’s better to build them again with the proper fstab

1 Like

Thanks to the wiki I finally managed to get my build environment set up.
Tried a brunch fp2 yesterday (with the recovery.fstab from the FPoOS).
After changing the META-INF/com/google/android/updater-script I could flash it via TWRP.
Boot didn’t work (I’m just getting the FP logo but boot doesn’t continue).
I’m gonna have a look at the boot.img now.


I’m playing with the TARGET_OTA_ASSERT_DEVICE on BoardConfig.mk right now to solve this (I got that property from falcon device, as noted in this CM blog post). Will push it to the repo if it works as expected.

Did you achieve something? Could you access the ADB logs at that state? (i.e. adb logcat)

I’ll probably extract the kernel from FPoOS and push it to the repo too. I don’t know what kernel version @keesj used on his initial CM work and if it’s making troubles for us. We should maintain the kernel and blobs of the same FPoOS version, just in case, until we have something running.

Edit: Inspecting the device configs I found something very shameful… the target board platform is not set! That should be msm8974, as in the m8. Now it is obvious why builds didn’t work, :sweat:
Fixing it now…

Edit2: Changes pushed. I also tidied up the BoardConfig.mk file as in the m8 one.

  • Get the changes by cding into device/fairphone/fp2 and git pulling. Ensure your changes are saved to avoid conflicts (you can git stash before pull, and git stash pop after; this will avoid screwing up the git history if there’s some conflict with your previous changes, if any).
  • …or just repo sync -c --force-sync and say good bye to any change you did.

Edit3: Seems like the new config doesn’t like the dtbtool we copied before from the m8, because CM states to have some of its own. Remove it before building:

rm -rf <cm-sources-root>/device/fairphone/fp2/dtbtool

You can read some experienced ROM builder documentation while I fix the build I’ve just broken, :grin: (well, it didn’t work before, anyway, to be fair…) It went all good, ZIP file generated, let’s try, :wink:
Edit: I built it without blobs… :disappointed_relieved:


I’m getting this error building…

In file included from hardware/qcom/audio/default/post_proc/bundle.c:26:0:
hardware/qcom/audio/default/post_proc/bundle.h:21:33: fatal error: sound/audio_effects.h: No such file or directory
 #include <sound/audio_effects.h>
compilation terminated.

Tried to update BoardConfig.mk with the properties of the one to the FP Open OS 16.07.1, but still the same error. This should have be done anyway, so one down.

Edit: I misspelled BoardConfig.mk as BuildConfig.mk. It is a recurring error of mine, sorry.

I got a similar error yesterday when I tried to build (As I didn’t change much I did a complete repo sync before).
How do you debug this error? I tried searching for the missing file, but usually find multiple versions of it and even if I knew wich one to use, where to put it? Or am I going at this completely wrong?

Well, I don’t know how to debug it, :confused:. I’ll tell you what I did:
I looked for an audio_effects.h file on FP Open OS sources and I found it in kernel/include/sound. So I assume it is part of the kernel.
Kernel sources are included in our CM local sources (in kernel/fairphone/fp2), but, AFAIK, it shouldn’t be compiled yet, because we use a prebuilt kernel (TARGET_PREBUILT_KERNEL is set on BoardConfig.mk). [1]

So is something misconfigured, then? I’ll try to build with TARGET_NO_KERNEL set to true. Didn’t work.

[1] = A prebuilt kernel is the way to go until we have something that boots fine, because building the kernel can cause a lot of troubles.

1 Like

I updated the kernel to 16.07.1. repo sync -c kernel (or cd kernel && git reset --hard origin cm-12.1 if it fails for anything)

Edit: Ok, so after the kernel update (and after rm -rf out/ I did just in case) I’m no longer getting the odd audio_effects.h error. Now I’m getting this FM-related error:

make: *** No rule to make target '/home/debian/android/cyanogenmod/out/target/product/fp2/obj/KERNEL_OBJ/usr', needed by '/home/debian/android/cyanogenmod/out/target/product/fp2/obj/SHARED_LIBRARIES/libqcomfm_jni_intermediates/android_hardware_fm.o'.  Stop.

I’ll try to make it build, or maybe we can disable FM support in the meantime (and I really mean temporalily, I want a functional offline radio)


android_hardware_fm.o error seems fixed now. I made the kernel compile, and for that purpose I cherrypicked a three years old commit (Did someone said “Android fragmentation”?) to make it build out of Ubuntu 14.04 (i.e. with updated pearl compilers)

Let’s see where it breaks now, :laughing:

1 Like

With a certain amount of time, it sounds really cool to dive that deep into CM development and to PROGRESS :).

make: *** No rule to make target '/home/debian/android/cyanogenmod/out/target/product/fp2/obj/STATIC_LIBRARIES/librecovery_updater_msm_intermediates/export_includes', needed by '/home/debian/android/cyanogenmod/out/target/product/fp2/obj/EXECUTABLES/updater_intermediates/import_includes'.  Stop.
make: Leaving directory '/home/debian/android/cyanogenmod'

#### make failed to build some targets (06:54 (mm:ss)) ####


Hi guys! Do you have something new about your CM port attempt ?


Hi ! Since my attempt at building Ubuntu Touch has met with a terrible fate (it’s stalled until I understand the basics of UT debugging) I’m trying to build @Roboe’s version to see if I get the same error.

This is the local manifest I use :

<?xml version="1.0" encoding="UTF-8"?>
  <project name="Roboe/android_device_fairphone_fp2" path="device/fairphone/fp2" remote="github" revision="cm-12.1" />
  <project name="Roboe/android_kernel_fairphone_fp2" path="kernel/fairphone/fp2" remote="github" revision="cm-12.1" />
  <project name="CyanogenMod/android_device_qcom_common" path="device/qcom/common" remote="github"/>

(The last one is Cyanogenmod’s qcom/common to avoid the “dtbToolCM” error, it might be the wrong branch though).

For now, it’s building the kernel nicely.