Ubuntu Touch GSI for the Fairphone 3

Tags: #<Tag:0x00007f05dacbe788>

I just saw someone posting this link in the UBports telegram group: https://github.com/ubports/porting-notes/wiki/Generic-system-image-(GSI)

I’m not 100% sure but from what I understood it looks like all you need is the kernel source, apply some patches and flash a generic Ubuntu Touch base image to get UT running on Android phones that have a vendor partition.

With /e/ having released their kernel source at https://gitlab.e.foundation/e/devices/android_kernel_fairphone_FP3/ it sounds doable…

1 Like

I think I have a build environment up to actually compile the kernel (first without the patches necessary for UT; that was “hard” enough).

I had to do a few things different from the “Build and flash kernel More info” instructions:

In some working directory:

git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9
git clone https://android.googlesource.com/platform/prebuilts/misc
git clone https://github.com/WeAreFairphone/android_kernel_fairphone_sdm632.git

export DTC_EXT=$(pwd)/misc/linux-x86/dtc/dtc
export CROSS_COMPILE=$(pwd)/aarch64-linux-android-4.9/bin/aarch64-linux-android-
export ARCH=arm64 && export SUBARCH=arm64

cd android_kernel_fairphone_sdm632

make O=out clean
make O=out mrproper
make O=out lineageos_FP3_defconfig
time make O=out -j$(nproc --all) Image.gz

Will check some other day if that kernel boots…

To create the boot image with the new kernel, one first has to extract a working boot.img (e.g. from https://support.fairphone.com/hc/en-us/articles/360043337512-Install-Fairphone-OS-on-Fairphone-3-using-a-computer) and place it in the same base working dir as above. Then

wget "https://forum.xda-developers.com/attachment.php?attachmentid=5024499&d=1590190221" -O AIK-Linux-v3.7-ALL.tar.gz
tar xfz AIK-Linux-v3.7-ALL.tar.gz

cd AIK-Linux
./unpackimg.sh ../boot.img
cp ../android_kernel_fairphone_sdm632/out/arch/arm64/boot/Image.gz-dtb split_img/boot.img-zImage
./repackimg.sh --origsize

That creates an image-new.img file.
Then fastboot flash boot image-new.img, press the power button to start and the system boots with the new kernel :slight_smile:

Next step is to patch the kernel config. Back in the same working base dir as always:

wget https://github.com/erfanoabdi/halium-boot/blob/halium-9.0/check-kernel-config

cd android_kernel_fairphone_sdm632

../check-kernel-config.sh arch/arm64/configs/lineageos_FP3_defconfig -w

[manually fix a few things the script is not able to do automatically, then check again until there is no error anymore]

../check-kernel-config.sh arch/arm64/configs/lineageos_FP3_defconfig
make O=out lineageos_FP3_defconfig
time make O=out -j$(nproc --all) Image.gz

cd ../AIK-Linux
./unpackimg.sh ../boot.img
cp ../android_kernel_fairphone_sdm632/out/arch/arm64/boot/Image.gz-dtb split_img/boot.img-zImage
./repackimg.sh --origsize

Next comes the actual flashing, i.e. boot into fastboot mode and execute (again in the base working dir):

wget https://github.com/chaosmaster/android_device_fairphone_fp3/releases/download/20200202-02/twrp-3.3.1-0_k4y0z-20200202-02-fp3.img
wget https://build.lolinet.com/file/halium/GSI/tools/halium-ramdisk.zip
wget https://build.lolinet.com/file/halium/GSI/tools/apparmor_enabler.zip
wget https://build.lolinet.com/file/halium/GSI/ubports_GSI_installer_v7.zip

fastboot flash boot AIK-Linux/image-new.img
fastboot boot twrp-3.3.1-0_k4y0z-20200202-02-fp3.img

Then in TWRP

  • format data
  • sideload
    • ubports_GSI_installer_v7.zip
    • halium-ramdisk.zip
    • apparmor_enabler.zip
  • reboot

And after a while UBports is up and running :slight_smile:
ATTENTION: when you flash the boot image again, you also have to flash the halium-ramdisk and apparmor_enabler again, otherwise you’ll end up in a bootloop that always takes you back to fastboot mode.

Of course not everything works right now. Will try to fix as good as I can :wink:

Find my patched kernel sources at https://github.com/Ingo-FP-Angel/android_kernel_fairphone_sdm632/tree/ubports-gsi


Current findings/known issues with GSI v7

Some things only worked after a first reboot.


  • sometimes unity crashes
  • no phonecalls
    • didn’t work at all in the beginning, last try gave unity crash but other phone was ringing
  • no GPS
  • cannot set the timezone
    • I can search for my location but can’t select it, therefore staying on UTC
  • flash doesn’t work
  • media playback
  • screen locking a bit strange
    • pushing the power button asks to shut down, restart or cancel
    • screen does go black after a short while, though
  • when pulling down the quick settings menu, a third of the screen on the left still shows the current app (quick settings are supposed to be full screen)
  • in the app switcher carousel, wiping apps up to close them doesn’t work reliably
    • as a workaround you can first long-tap the app (has no visible effect) and then swipe it
  • entering the settings to change password/PIN etc. crashes the settings apps
  • phone automatically boots when connected to power

What works

  • WiFi
    • with GSI v7 WiFi hardware needs to be enabled (as root), then it works (until reboot)
      echo 1 > /dev/wcnss_wlan
      echo sta > /sys/module/wlan/parameters/fwpath
    • it’s possible to patch the android-rootfs.img to get WiFi up at boot automatically (see end of this post)
  • text messages (SMS)
  • camera
    • seems to cause screen flicker in app switcher carousel
  • adjusting brightness
  • accessing the SD card
  • bluetooth (?)
    • seems I could pair my BT speaker, but media playback doesn’t work, so I can’t really verify bluetooth
  • ssh to the phone via USB

To enable WiFi at boot for version 7 of the GSI, do the following steps

  • boot to TWRP
    • fastboot boot twrp-3.3.1-0_k4y0z-20200202-02-fp3.img
  • open a shell on the phone
    • adb shell
  • on the phone mount the image of the android rootfs, i.e. execute
    • mkdir /tmp/foo && mount -o loop /data/android-rootfs.img /tmp/foo/
  • get the init.halium.rc from the phone, edit on your PC, push it back to the phone
    • adb pull /tmp/foo/system/etc/init/init.halium.rc
    • edit the file so that it looks like this at the end (i.e. add “write /dev/wcnss_wlan 1”)
      on property:sys.boot_completed=1
          write /dev/wcnss_wlan 1
          write /sys/module/wlan/parameters/fwpath sta
    • adb push init.halium.rc /tmp/foo/system/etc/init/init.halium.rc
  • on the phone, unmount the android rootfs image
    • umount /tmp/foo
  • reboot the phone and wifi should be up automatically

This is great news, I got the FP3 in the first place with the intention of installing UBports or Sailfish. Hopefully it will be in a usable state at some point. Thanks!

I’ll probably put this project on hold for an indefinite time.

After continuing the “recipe” I ended up in a bootloop because I forgot to flash the halium-ramdisk.zip and apparmor_enabler.zip after my updated boot image. And ever since I’m stuck with a running UT GSI system where the screen stays fully black (as if switched off) and only ssh possible. Even after flashing back the Stock ROM temporarily and trying from scratch with the same boot image that used to work the day before.

There were some helpful people in the Halium Telegram group, but all their assistance didn’t improve the situation and I lack the experience to continue on my own.

But there seems to be another person working on the “full” Halium setup. Maybe they succeed.

1 Like

Does the screen work if you boot TWRP with fastboot?

Yes, that works, because I used it several times to flash the ZIPs I mentioned in the previous post and when I gave up to flash Lineage OS (which runs fine as far as I can see).

I’ve edited my post to indicate that the “black screen problem” occurs on UT GSI (only).