[Unofficial] Help building LineageOS for Fairphone 5

Hey, just received my Fairphone 5.

I compiled LineageOS for it. This just worked without any further modification. :partying_face:

Is there a way to get LineageOS installed using TWRP?
I tried to boot TWRP as described here:

Then tried to adb sideload the ROM File (ZIP).
But TWRP showed the following error after 47% upload:

error applying update 7 kinstalldeviceopenerror

What is the recommended way to flash a custom ROM to the Fairphone 5?

BTW, happy to share the ROM once i was able to test it.

Maybe @lucaweiss can explain/help with this?

WARNING: I have next to no experience in Android/LineageOS development

4 Likes

Iā€™m not aware of any functional LineageOS build for Fairphone 5, so Iā€™m not really sure what you compiled & tried to install on your device.

1 Like

Iā€™m trying to make a functional Build of LineageOS. But Iā€™am stuck trying to flash the ROM.

So, that is why iā€™m asking what else i need to flash a custom ROM (LineageOS or any other custom rom).

Does it depend on TWRP you are working on?

@ochorocho did you see the LineageOS FAQ for ā€˜error 7ā€™, maybe it can be of help: Frequently Asked Questions | LineageOS Wiki

Also there is this repo: GitHub - WeAreFairphone/android_device_fairphone_FP5 which looks like a LineageOS build, but there is no info if the sources produce a working image (yet).

Personally i do not have a FP5 (yet) as i am waiting for a LineageOS build. I would give it a try myself if anyone has a thorough guide on how to port LineageOS to a Fairphone?!

1 Like

Maybe some infos can be found in the FP4 topic

Thanks, i will have a look at the LineageOS FAQs once more.

Yep, iā€™m using this repo in my manifest. :slight_smile: Dunno if this is working at all.

<?xml version="1.0" encoding="UTF-8"?>
<manifest>
    <project name="WeAreFairphone/android_device_fairphone_FP5" path="device/fairphone/FP5" remote="github" revision="staging/lineage-20" />
	<project name="BLeQuerrec/proprietary_vendor_fairphone_FP5" path="vendor/fairphone/FP5" remote="github" revision="lineage-20" />
    <project name="WeAreFairphone/android_kernel_fairphone_qcm6490" path="kernel/fairphone/qcm6490" remote="github" revision="staging/lineage-20" />
</manifest>

@ochorocho: ok great and good luck :crossed_fingers: looking forward to a working LineageOS image. @yvmuell: thanks for the links, i will see what i can find in there

One question: Is there an official image from Fairphone that can be flashed to get back to a working state if flashing a custom build image fails?
Update (answering my own question): Here is the official FP5 image for download with installation instructions https://support.fairphone.com/hc/en-us/articles/18896094650513

Iā€™d love to see this progress into FP officially supporting lineage OSā€¦ (I mean, /e/OS, as lineageOS downstream already has support for the FP5)

@ochorocho Would you be open to sharing how you build your image? I tried using the LineageOS FP4 build instructions and the XML you shared as roomservice.xml, but the build command brunch FP5 fails (most likely during the kernel build). This is the last output i get:

  INSTALL techpack/display/msm/msm_drm.ko
  DEPMOD  5.4.242-qgki-g82801cb08268
make[1]: Leaving directory '/root/android/lineage/out/target/product/FP5/obj/KERNEL_OBJ'
make: Leaving directory '/root/android/lineage/kernel/fairphone/qcm6490'
depmod: WARNING: could not open modules.order at /root/android/lineage/out/target/product/FP5/obj/PACKAGING/depmod_vendor_intermediates/lib/modules/0.0: No such file or directory
depmod: WARNING: could not open modules.builtin at /root/android/lineage/out/target/product/FP5/obj/PACKAGING/depmod_vendor_intermediates/lib/modules/0.0: No such file or directory
depmod: WARNING: could not open modules.order at /root/android/lineage/out/target/product/FP5/obj/PACKAGING/depmod_vendor_ramdisk_intermediates/lib/modules/0.0: No such file or directory
depmod: WARNING: could not open modules.builtin at /root/android/lineage/out/target/product/FP5/obj/PACKAGING/depmod_vendor_ramdisk_intermediates/lib/modules/0.0: No such file or directory
00:15:57 ninja failed with: exit status 1

I want to write simple build instructions once i get a working build so maybe others can join and help make a working image.

1 Like
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
  <project name="WeAreFairphone/android_device_fairphone_FP5" path="device/fairphone/FP5" remote="github" revision="staging/lineage-20" />
  <project name="BLeQuerrec/proprietary_vendor_fairphone_FP5" path="vendor/fairphone/FP5" remote="github" revision="lineage-20" />
  <project name="WeAreFairphone/android_kernel_fairphone_qcm6490" path="kernel/fairphone/qcm6490" remote="github" revision="staging/lineage-20" />
  <project path="kernel/fairphone/sm7225" remote="github" name="LineageOS/android_kernel_fairphone_sm7225" revision="lineage-20" />
</manifest>

Do a repo sync in ~/android/lineageos

Afterwards run the following commands one by one:

cd ~/android/lineage
export USE_CCACHE=1
export CCACHE_EXEC=/usr/bin/ccache
ccache -M 100G
source build/envsetup.sh
breakfast FP5
brunch FP5

Mind the ccache -M 100G ! 50GB was not enough in my case.

INFO:
I also tried to extract the binary blob using cd device/fairphone/FP5/ && ./extract-files.sh
with the device connected and USB debugging enabled. But this build did not work.

I compared the files and it seems like it is not required because the files are already there, and the extract-files script fails to download all files anyways.

I hope this helps.

:warning: Iā€™m not sure if this is all a 100% correct as Iā€™m not an expert.

1 Like

Thank you! I will try to build using these settings.
One more question: Which distro + version did you use to build this (Ubuntu 22.04, debian 12, ā€¦)?

About the binary blobs: The ā€œproprietary_vencor_fairphone_FP5ā€ repo seems to have the blobs so i guess extracting them is not neccessary as you mentioned.

You added the ā€œsm7225ā€ kernel to the xml, i was wondering about that since the ā€œandroid_device_fairphone_FP5ā€ repo has an open pull-request which changes the used kernel for the build to ā€œqcm6490ā€.
Did you manage to boot your image yet, maybe a build using the qcm6490 kernel will work better on the FP5, what do you think?

Iā€™m building on Ubuntu 22.04.3 LTS

The sm7225 was added automatically because it is defined as a dependency. Dunno how this is done but scrolling through the logs i saw that notice.

Sorry, missed that part.
Didnā€™t try to use qcm6490 kernel yet.
When trying to install i get kinstalldeviceopenerror when using TWRP and Signature verification failed without TWRP (regular recovery)

For sake of information, was able to flash the rom after installing e/OS.
The build with sm7225 and qcm6490 both do not boot. Currently stuck at LineageOS boot animation.

Interesting read on XDA:
https://xdaforums.com/t/lineageos-for-fp5.4634848/

2 Likes

as promised here is my build guide and what i found out along the way:

  • disclaimer: i did not flash the output of my build to a phone as i do not have an FP5, the primary goal was to get the build to run
  • the guide was made on ubuntu 22.04 LTS, ubuntu is also used in the android docs so i went with it.
    if you build this on another distribution, please report back if you did something different
  • the machine you use for building must be ā€˜amd64ā€™, i tried building on ā€˜arm64ā€™ but it did not work (there are prebuild binaries used for the build and they are compiled only for amd64). if you get this to run on arm64 please tell me how to do this
  • build as normal user (non root), you only need root for the first step (and the optional second step). after that you can run the whole build as a non-privileged user
  • have fun and please report back if you find any errors or have more information on what goes on during the build. we would like to understand more about how android / LineageOS is build
# 1. bring your system up to date und install needed packages
#    (this needs root privileges, add 'sudo' if necessary)
apt update
apt upgrade --yes
apt install bc bison build-essential ccache curl flex g++-multilib gcc-multilib git git-lfs gnupg gperf imagemagick lib32readline-dev lib32z1-dev lib32ncurses5-dev libncurses5 libncurses5-dev libelf-dev liblz4-tool libsdl1.2-dev libssl-dev libxml2 libxml2-utils lzop pngcrush python-is-python3 rsync schedtool squashfs-tools unzip wget xsltproc zip zlib1g-dev --yes

# 2. [optional] create a separate builduser
#    skip this step if you want to use your already existing user
adduser builduser
su builduser

# 3. install 'adb' and 'fastboot'
#    as far as i can tell not strictly necessary for building but used later to flashing the image to a device
cd ~
wget https://dl.google.com/android/repository/platform-tools-latest-linux.zip
unzip platform-tools-latest-linux.zip -d ~

cat >> ~/.profile << EOF
if [ -d "\$HOME/platform-tools" ] ; then
    PATH="\$HOME/platform-tools:\$PATH"
fi
EOF

# 4. get the repo tool
#    used for syncing all the source files to yor build machine
mkdir -p ~/bin
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo

# 5. source this file so the $HOME/bin and $HOME/platform-tools folders will be searched for binaries
source ~/.profile

# 6. set your git info (if you want to commit changes to official repos, add your real user and mail here)
git config --global user.email "null@null.com"
git config --global user.name "null"
git lfs install

# 7. get the LineageOS repo
mkdir -p ~/android/lineage
cd ~/android/lineage
# the repo contains information about all the other software repos that are needed to build LineageOS
# uses 'lineage-20.0' branch
repo init -u https://github.com/LineageOS/android.git -b lineage-20.0 --git-lfs

# 8. sync all the source code to your build machine
#    this takes some time (depending on your machine and internet connection)
#    took me 30min to >60min on the machines i tested it
#    also uses ~160GB on disk after it finishes
repo sync

# 9. create the FP5 config file
#     since the FP5 is not an official LineageOS target yet, you need to add the config where to find kernel and device info etc. 
cd ~/android/lineage
mkdir -p ~/android/lineage/.repo/local_manifests

# option 1: (choose this when getting started)
cat >> ~/android/lineage/.repo/local_manifests/roomservice.xml << EOF
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
    <project name="WeAreFairphone/android_device_fairphone_FP5"     path="device/fairphone/FP5"     remote="github" revision="staging/lineage-20" />
    <project name="BLeQuerrec/proprietary_vendor_fairphone_FP5"     path="vendor/fairphone/FP5"     remote="github" revision="lineage-20" />
    <project name="WeAreFairphone/android_kernel_fairphone_qcm6490" path="kernel/fairphone/qcm6490" remote="github" revision="staging/lineage-20" />
</manifest>
EOF

# option 2: uses the same XML as above but change the first project entry to: name="zalox/android_device_fairphone_FP5"
#           see the open pull-request for the changes between the repos. once these changed in github are merged, just use the XML from above
#           if unsure use option 1 to get started

# 10. source this to get the android build environment commands
source build/envsetup.sh

# 11. enable ccache to speed-up subsequent builds
export USE_CCACHE=1
export CCACHE_EXEC=/usr/bin/ccache
ccache -M 100G

# 12. prepare build environment
#     from the docs: Breakfast configures your build environment with the correct variables to create your device-specific rom
#     this took me ~5min and used another 3GB on disk
breakfast FP5

# 13. change directory to the top of the tree
croot

# 14. build your image
#     this took me about 4h on a Core-i7 with 4+4 CPU cores
#     after it finished the total size used for the ~/android/lineage directory was ~280GB
#     it's possible during the build more disk space is used so plan accordingly
brunch FP5

# 15. look at the generated files
#     i did not flash this to a phone! use at your own risk
#     for flashing maybe look at the LineageOS FP4 instructions!?
#     and plase report back if you got an image to boot on an FP5
cd $OUT

thanks to @ochorocho for the XML and all the tips so far to get this working

5 Likes

Hey, there!

I am trying to replicate what @ochorocho and @chris81 have done, but on Debian 12 (Bookworm) instead of Ubuntu 22.04 LTS.

The differences for now (if anyone on Debian also wants to replicate) which I have found:

  • git lfs install failed ā†’ apt install git-lfs instead (okay, this could happened because I didnā€™t really followed @chris81 guide step by step and probably did not begin with apt install ... :sweat_smile: )
  • repo init ... failed due to not finding a python binary ā†’ add ln -s /usr/bin/python3 ~/bin/python and then repo init ... works
  • when running brunch FP5 there was an error that ~/.cache/ccache/tmp isnā€™t a directory. The reason was, that ~/.cache/ccache was created as a file and not a directory (donā€™t know why)ā€¦ deleting the ccache file and creating ~/.cache/ccache/tmp as a folder structure and rerunning brunch FP5 seemed to work

One question thoā€¦ Shouldnā€™t a working LineageOS be ā€œpretty easyā€, since /e/OS as LOS-downstream already is supporting FP5?

Add/Edit:

  • The build finished with the following line:
    #### build completed successfully (01:17:40 (hh:mm:ss)) ####
1 Like

Yep, it seemed easy. But my device isnā€™t booting atm. So dunno what to do to debug and fix this properly.

Hey,
thanks for testing on Debian 12 :sunglasses:

  • git lfs install failed
  • repo init ā€¦ failed

The ā€˜apt installā€™ in 1. of the guide contains ā€˜git-lfsā€™ and ā€˜python-is-python3ā€™ which should already have installed the git lfs subcommand and set python3 as the default python version. I tested this on a fresh debian install so this might not work if you already had git oder maybe python2 installed.

  • when running brunch FP5 there was an error that ~/.cache/ccache/tmp isnā€™t a directory.

I got that error too (sometimes). On my final build run it did not occur so i left it out of the guide. Your explanation is exactly what i did so i hope it will help others, too.

One question thoā€¦ Shouldnā€™t a working LineageOS be ā€œpretty easyā€, since /e/OS as LOS-downstream already is supporting FP5?

I am hoping the same but did not have time to look how /e/OS is being built and what sources they use. If their base is the same lineage-20.0 branch then we should hopefully figure out what changes they made to their sources so we can also built a working image.

@_elpato_9 Do you have an FP5 device to test your image?

In case your repo sync takes too long, use

repo sync -c -n -j4 --no-clone-bundle --no-tags && repo sync -c -l -j16