Fairphone 2 and CyanogenMod / LineageOS

Hi all,

it’s been a while since I’ve last posted here - I cancelled my FP2 preorder because my old phone still works. So from a ecological perspective it doesn’t make much sense to buy a new phone then (even if it’s produced “fair”).
But i’m still interested in the project and once my old phone dies, I’ll most probably buy a Fairphone.

Regarding the CyanogenMod discussion I’d like to add a few points.


Official OSes vs. community projects

Please stop asking the Fairphone Devs to officially create a port of CyanogenMod for FP2 - they almost certainly can’t, because of legal reasons. Licensing of the SoC vendors tends to be really strict in general, so you can’t blame Fairphone for that.
CyanogenMod has always been a community project, there has never been any support by SoC vendors or phone manufacturers for a port (at least I never heard of any support).
The only chance I see to make CyanogenMod happen on FP2 is that members of this (great!) community get their hands dirty and start hacking! (And this is the main point of free software, actually…)

Starting a port

(the following parts could later be turned into a wiki-post for easier collaborative editing)

Things may look complicated at the beginning, but there are a lot of technically skilled people here that should be able to create a port together.
I’m not a CyanogenMod developer myself, but there is plenty of documentation available, which helps to set up a build environment on Linux.

I started with the Build HowTo for the HTC One M8 (which uses the same SoC as FP2, this might come in handy later)

On a Debian/Ubuntu System:

# Install dependencies (on a 64-bit build machine)
sudo apt-get install repo android-tools-adb android-tools-fastboot ccache bison build-essential curl flex git gnupg gperf libesd0-dev liblz4-tool libncurses5-dev libsdl1.2-dev libxml2 libxml2-utils lzop maven openjdk-7-jdk openjdk-7-jre pngcrush schedtool squashfs-tools xsltproc zip zlib1g-dev g++-multilib gcc-multilib lib32ncurses5-dev lib32z1-dev
# configure git
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
# prepare source directory
mkdir cm12_fp2
cd cm12_fp2
repo init -u https://github.com/CyanogenMod/android.git -b cm-12.1
repo sync

The last step pulls about 30G (yes gigabytes!) of source code, so this might take a while depending on your connection.

Now you can for example do a

source build/envsetup.sh
breakfast m8

to download all the files needed to build CM for the HTC One M8 (and analyze them later).

@keesj from Fairphone already did most of the work stated in the CM porting guide and you can download his work from github

# fetch Fairphone 2 specific files
git clone https://github.com/keesj/cm12-device-fairphone-fp2.git device/fairphone/FP2

Now you have everything to build and test a FP2 recovery image

source build/envsetup.sh
lunch cm_FP2-userdebug
make recoveryimage

Build errors

I encountered two error-messages during build.
If you get something like:

make: *** No rule to make target
'out/host/linux-x86/bin/dtbToolCM' needed by
'out/target/product/FP2/dt.img'.

use the following to fix the error (you probably need to run breakfast m8 before):

cp -r device/qcom/common/dtbtool device/fairphone/FP2/

If you get

chmod: cannot access 'out/target/product/FP2/dt.img': No such file or directory
make: *** [out/target/product/FP2/dt.img] Error 1

use

cp device/fairphone/FP2/blobs/dt.img out/target/product/FP2/

The makefiles probably need to be modified to handle the FP2 device tree correctly - I’m just starting to learn about the Anroid/CM build system.
After these fixes the recovery image builds fine for me.

The blob problem

The next steps of porting involve FP2 binary blobs. If you download the blobs from Fairphone (or any other manufacturer) you have to accept a license which prohibits redistribution of these blobs (and pretty much doing anything interesting with them).
This is why CM uses a trick: using a script called extract-files.sh, the blobs are extracted directly from the device, without the need to accept a license.

For new devices it’s necessary to tell the script which files it needs to fetch and put their location (on the phone) in a file called proprietary-files.txt
Since FP2 uses the same SoC as the HTC One M8, this list might be a good starting point:


As I said before, I don’t own a Fairphone 2, so I can’t assist any further, but I hope this might be a good starting point for a CM port. Once I have a FP2 I’ll happily join the effort!
Until then: Happy hacking - if you really want CM on the Fairphone you can do it!

Greetings
Zapp

20 Likes