# Ubuntu Touch GSI for the Fairphone 3

**URL:** <https://forum.fairphone.com/t/ubuntu-touch-gsi-for-the-fairphone-3/61569>\
**Category:** Development\
**Tags:** ubuntu\
**Created:** [May 29, 2020, 7:08pm UTC](https://forum.fairphone.com/t/ubuntu-touch-gsi-for-the-fairphone-3/61569 "2020-05-29T19:08:05Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ingo](https://forum.fairphone.com/user_avatar/forum.fairphone.com/ingo/32/10025_2.png) [@Ingo](https://forum.fairphone.com/u/Ingo)\
**Post date:** [May 29, 2020, 7:08pm UTC](https://forum.fairphone.com/t/ubuntu-touch-gsi-for-the-fairphone-3/61569/1 "2020-05-29T19:08:05Z")

</div>

I just saw someone posting this link in the UBports telegram group: [https://github.com/ubports/porting-notes/wiki/Generic-system-image-(GSI)](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/](https://gitlab.e.foundation/e/devices/android_kernel_fairphone_FP3/) it sounds doable…

---

<div class="post-metadata">

**Author:** ![Ingo](https://forum.fairphone.com/user_avatar/forum.fairphone.com/ingo/32/10025_2.png) [@Ingo](https://forum.fairphone.com/u/Ingo)\
**Post date:** [June 3, 2020, 6:46pm UTC](https://forum.fairphone.com/t/ubuntu-touch-gsi-for-the-fairphone-3/61569/2 "2020-06-03T18:46:19Z")

</div>

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](https://forum.xda-developers.com/android/software-hacking/reference-how-to-compile-android-kernel-t3627297)” instructions:

In some working directory:

```auto
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](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

```auto
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 🙂

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

```auto
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):

```auto
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 🙂  
**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 😉

Find my patched kernel sources at [https://github.com/Ingo-FP-Angel/android\_kernel\_fairphone\_sdm632/tree/ubports-gsi](https://github.com/Ingo-FP-Angel/android_kernel_fairphone_sdm632/tree/ubports-gsi)

---

<div class="post-metadata">

**Author:** ![Ingo](https://forum.fairphone.com/user_avatar/forum.fairphone.com/ingo/32/10025_2.png) [@Ingo](https://forum.fairphone.com/u/Ingo)\
**Post date:** [June 6, 2020, 12:03pm UTC](https://forum.fairphone.com/t/ubuntu-touch-gsi-for-the-fairphone-3/61569/3 "2020-06-06T12:03:02Z")

</div>

Current findings/known issues with GSI v7

Some things only worked after a first reboot.

Issues

- 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”)

```auto
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

---

<div class="post-metadata">

**Author:** ![sm01man](https://forum.fairphone.com/user_avatar/forum.fairphone.com/sm01man/32/17848_2.png) [@sm01man](https://forum.fairphone.com/u/sm01man)\
**Post date:** [June 7, 2020, 5:03pm UTC](https://forum.fairphone.com/t/ubuntu-touch-gsi-for-the-fairphone-3/61569/4 "2020-06-07T17:03:58Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Ingo](https://forum.fairphone.com/user_avatar/forum.fairphone.com/ingo/32/10025_2.png) [@Ingo](https://forum.fairphone.com/u/Ingo)\
**Post date:** [June 15, 2020, 3:42pm UTC](https://forum.fairphone.com/t/ubuntu-touch-gsi-for-the-fairphone-3/61569/5 "2020-06-15T15:42:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![AnotherElk](https://forum.fairphone.com/user_avatar/forum.fairphone.com/anotherelk/32/7680_2.png) [@AnotherElk](https://forum.fairphone.com/u/AnotherElk)\
**Post date:** [June 15, 2020, 3:58pm UTC](https://forum.fairphone.com/t/ubuntu-touch-gsi-for-the-fairphone-3/61569/6 "2020-06-15T15:58:54Z")

</div>

> [@Ingo](#):
>
> And ever since I’m stuck with a running 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.

Does the screen work if you boot TWRP with fastboot?

---

<div class="post-metadata">

**Author:** ![Ingo](https://forum.fairphone.com/user_avatar/forum.fairphone.com/ingo/32/10025_2.png) [@Ingo](https://forum.fairphone.com/u/Ingo)\
**Post date:** [June 15, 2020, 4:03pm UTC](https://forum.fairphone.com/t/ubuntu-touch-gsi-for-the-fairphone-3/61569/7 "2020-06-15T16:03:33Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![Luksus](https://forum.fairphone.com/user_avatar/forum.fairphone.com/luksus/32/19853_2.png) [@Luksus](https://forum.fairphone.com/u/Luksus)\
**Post date:** [September 29, 2020, 12:30pm UTC](https://forum.fairphone.com/t/ubuntu-touch-gsi-for-the-fairphone-3/61569/8 "2020-09-29T12:30:02Z")

</div>

Interestingly, I could not even get the “stock” lineage kernel get to boot (after compiling it). I am not sure, what I did wrong.

But the Halium way did work for me. For reference:

> **[Fairphone 3 (FP3)](https://forums.ubports.com/topic/4964/fairphone-3-fp3?_=1601277763588)**
>
> This is a port for the Fairphone 3. Currently only the GSI (Generic System Image) -way is working. Sources Kernel: https://github.com/luksus42/android\_kernel\_fairphone\_sdm632 Device: https://github.com/luksus42/android\_device\_fairphone\_FP3 Vendor:...

@Ingo FYI: After a heavy flashing session, multiple different GSIs, I encountered similar problem like you described, with black screen for example.  
Only a complete reflash of a working android image (eOS in my case) did solve the problems.  
After that I was able to flash a working ubtouch again.  
Thanks for your pioneers work btw. 🙂

---

<div class="post-metadata">

**Author:** ![Ingo](https://forum.fairphone.com/user_avatar/forum.fairphone.com/ingo/32/10025_2.png) [@Ingo](https://forum.fairphone.com/u/Ingo)\
**Post date:** [September 29, 2020, 12:49pm UTC](https://forum.fairphone.com/t/ubuntu-touch-gsi-for-the-fairphone-3/61569/9 "2020-09-29T12:49:06Z")

</div>

Ok, I might try again if you say you found a way out of the “only black screen after boot” situation.  
IIRC I did try to revert to stock ROM first and then trying my kernel again.

---

<div class="post-metadata">

**Author:** ![nchrome](https://forum.fairphone.com/user_avatar/forum.fairphone.com/nchrome/32/19274_2.png) [@nchrome](https://forum.fairphone.com/u/nchrome)\
**Post date:** [March 1, 2021, 9:41am UTC](https://forum.fairphone.com/t/ubuntu-touch-gsi-for-the-fairphone-3/61569/10 "2021-03-01T09:41:21Z")

</div>

This is great news, really glad that some people who know how managed to get it up, at least to that point where its at. Would love to see postmarketOS on a FP in the near future

---

<div class="post-metadata">

**Author:** ![Ingo](https://forum.fairphone.com/user_avatar/forum.fairphone.com/ingo/32/10025_2.png) [@Ingo](https://forum.fairphone.com/u/Ingo)\
**Post date:** [August 30, 2021, 9:41pm UTC](https://forum.fairphone.com/t/ubuntu-touch-gsi-for-the-fairphone-3/61569/11 "2021-08-30T21:41:32Z")

</div>

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
