# FP3 custom rom development based on released source code

**URL:** <https://forum.fairphone.com/t/fp3-custom-rom-development-based-on-released-source-code/56355>\
**Category:** Development\
**Tags:** twrp, gsi, lineageos\
**Created:** [December 11, 2019, 3:52pm UTC](https://forum.fairphone.com/t/fp3-custom-rom-development-based-on-released-source-code/56355 "2019-12-11T15:52:15Z")\
**Posts on this page:** 20\
**Page:** 15

<div class="post-metadata">

**Author:** ![corvuscorax](https://forum.fairphone.com/user_avatar/forum.fairphone.com/corvuscorax/32/18495_2.png) [@corvuscorax](https://forum.fairphone.com/u/corvuscorax)\
**Post date:** [January 31, 2020, 10:41pm UTC](https://forum.fairphone.com/t/fp3-custom-rom-development-based-on-released-source-code/56355/285 "2020-01-31T22:41:11Z")

</div>

thanks. I found the source of the weird strings. It’s google’s “brotli”

> <https://github.com/google/brotli/blob/master/csharp/org/brotli/dec/Dictionary.cs>

this is still weird, but at least now I know where the weirdness comes from.

---

<div class="post-metadata">

**Author:** ![corvuscorax](https://forum.fairphone.com/user_avatar/forum.fairphone.com/corvuscorax/32/18495_2.png) [@corvuscorax](https://forum.fairphone.com/u/corvuscorax)\
**Post date:** [January 31, 2020, 11:35pm UTC](https://forum.fairphone.com/t/fp3-custom-rom-development-based-on-released-source-code/56355/286 "2020-01-31T23:35:41Z")

</div>

anyone here interested into looking into this?

> [@Does the FP3 \*HAVE\* an FM radio?](https://forum.fairphone.com/t/does-the-fp3-have-an-fm-radio/52660/90):
>
> well, looking at it, there is indeed a radio driver in it - enabled with CONFIG\_RADIO\_IRIS=y CONFIG\_RADIO\_IRIS\_TRANSPORT=y under mmc adapters, which is labeled: “Driver for QTI FM Radio Transceiver” The FP3 kernel has this driver and it is enabled. It is also referenced in the dtb tree, so in theory this should work, but when I looked at the device tree source, I could not find any pin/IO connection information related. dmesg does not report the driver initializing, which would indicate it mi…

the FP3’s chipset is supposed to include a radio chip. The driver is in the kernel, but doesn’t show up in dmesg, so it might be a device tree / configuration issue. Since the “chip” is actually an integral part of the system-on-a-chip it might be possible to copy paste the config from another device with the same hardware (linked in linked thread)

---

<div class="post-metadata">

**Author:** ![hirntot](https://forum.fairphone.com/letter_avatar/hirntot/32/6_449c533f586939b6e5f246632a46421f.png) [@hirntot](https://forum.fairphone.com/u/hirntot)\
**Post date:** [February 3, 2020, 5:54am UTC](https://forum.fairphone.com/t/fp3-custom-rom-development-based-on-released-source-code/56355/287 "2020-02-03T05:54:19Z")

</div>

tl;dr  
I read a lot. but I couldn’t find an answer to: WHAT was the solution in the end? How did you get the kernel running? What was not working?

---

<div class="post-metadata">

**Author:** ![basxto](https://forum.fairphone.com/user_avatar/forum.fairphone.com/basxto/32/19302_2.png) [@basxto](https://forum.fairphone.com/u/basxto)\
**Post date:** [February 4, 2020, 1:11am UTC](https://forum.fairphone.com/t/fp3-custom-rom-development-based-on-released-source-code/56355/288 "2020-02-04T01:11:54Z")

</div>

> [@Splash logo converter for Fairphone 3](https://forum.fairphone.com/t/splash-logo-converter-for-fairphone-3/57338):
>
> I wrote a little tool for creating splash screens: [https://github.com/basxto/fp3\_splash](https://github.com/basxto/fp3_splash) The first image was taken before I fixed a bug that cut off a part of the image. Just flash them like fastboot flash splash ./splash Here a few splash screens for testing: [https://basxto.de/fp3/splash/splash.original.img](https://basxto.de/fp3/splash/splash.original.img)[https://basxto.de/fp3/splash/splash.magikarp.img](https://basxto.de/fp3/splash/splash.magikarp.img)[https://basxto.de/fp3/splash/splash.hoe.img](https://basxto.de/fp3/splash/splash.hoe.img) (FAIR HOE) [https://basxto.de/fp3/splash/splash.cy.img](https://basxto.de/fp3/splash/splash.cy.img) (cyFAIRPHONE) [h…](https://basxto.de/fp3/splash/splash.unbricked.img)

---

<div class="post-metadata">

**Author:** ![pigpig](https://forum.fairphone.com/letter_avatar/pigpig/32/6_449c533f586939b6e5f246632a46421f.png) [@pigpig](https://forum.fairphone.com/u/pigpig)\
**Post date:** [February 4, 2020, 12:40pm UTC](https://forum.fairphone.com/t/fp3-custom-rom-development-based-on-released-source-code/56355/289 "2020-02-04T12:40:58Z")

</div>

> [@\[HOW TO\] Flash a custom ROM on FP3 with GSI](https://forum.fairphone.com/t/how-to-flash-a-custom-rom-on-fp3-with-gsi/57074/52):
>
> Ah yeah, about the vbmeta --disable-verification. It seems there is a bug in aboot, we can only hope it gets fixed in an update. aboot just crashes, when verification is disabled: [1580] battery\_voltage: 4241918 [1820] MultiSlot true, partition name boot\_b [1830] AVB version 2 [1830] avb\_slot\_verify.c[1830] :[1830] 417[1830] : DEBUG: [1830] Loading vbmeta struct from partition '[1840] vbmeta\_b[1840] '. [1840] avb\_vbmeta\_image.c[1840] :[1840] 226[1840] : ERROR: [1850] Hash does not match! [185…

From [https://source.codeaurora.org/quic/la/kernel/lk/tree/platform/msm\_shared/avb/libavb/avb\_slot\_verify.c?h=LA.UM.7.6.2.r1-09200-89xx.0](https://source.codeaurora.org/quic/la/kernel/lk/tree/platform/msm_shared/avb/libavb/avb_slot_verify.c?h=LA.UM.7.6.2.r1-09200-89xx.0) line 694 :

```auto
  if (vbmeta_header.flags & AVB_VBMETA_IMAGE_FLAGS_VERIFICATION_DISABLED) {
    AvbSlotVerifyResult sub_ret;
    avb_debugv(
        full_partition_name, ": VERIFICATION_DISABLED bit is set.\n", NULL);
    /* If load_requested_partitions() fail it is always a fatal
     * failure (e.g. ERROR_INVALID_ARGUMENT, ERROR_OOM, etc.) rather
     * than recoverable (e.g. one where result_should_continue()
     * returns true) and we want to convey that error.
     */
    sub_ret = load_requested_partitions(
        ops, requested_partitions, ab_suffix, slot_data);
    if (sub_ret != AVB_SLOT_VERIFY_RESULT_OK) {
      ret = sub_ret;
    }
    goto out;
  }

```

I guess that’s load\_requested\_partitions which is broken

---

<div class="post-metadata">

**Author:** ![corvuscorax](https://forum.fairphone.com/user_avatar/forum.fairphone.com/corvuscorax/32/18495_2.png) [@corvuscorax](https://forum.fairphone.com/u/corvuscorax)\
**Post date:** [February 4, 2020, 3:43pm UTC](https://forum.fairphone.com/t/fp3-custom-rom-development-based-on-released-source-code/56355/291 "2020-02-04T15:43:13Z")

</div>

the answer is chaos-magic 😉

---

<div class="post-metadata">

**Author:** ![Matombo](https://forum.fairphone.com/letter_avatar/matombo/32/6_449c533f586939b6e5f246632a46421f.png) [@Matombo](https://forum.fairphone.com/u/Matombo)\
**Post date:** [February 4, 2020, 4:22pm UTC](https://forum.fairphone.com/t/fp3-custom-rom-development-based-on-released-source-code/56355/292 "2020-02-04T16:22:18Z")

</div>

please elaborate in more detail

---

<div class="post-metadata">

**Author:** ![corvuscorax](https://forum.fairphone.com/user_avatar/forum.fairphone.com/corvuscorax/32/18495_2.png) [@corvuscorax](https://forum.fairphone.com/u/corvuscorax)\
**Post date:** [February 4, 2020, 7:12pm UTC](https://forum.fairphone.com/t/fp3-custom-rom-development-based-on-released-source-code/56355/293 "2020-02-04T19:12:31Z")

</div>

spell that @k4y0z - magic

@k4y0z managed to get it to work. Main changes:

1. instead of compiling the kernel using the kernel build scripts, they used an android-build-environment which assembles and packages the kernel, dtb **and dtbo** containers using the scripts in

> **[minimal-manifest-twrp/platform\_manifest\_twrp\_omni](https://github.com/minimal-manifest-twrp/platform_manifest_twrp_omni/tree/twrp-9.0)**
>
> Limited manifest for building TWRP . Contribute to minimal-manifest-twrp/platform\_manifest\_twrp\_omni development by creating an account on GitHub.

in combo with @k4y0z own kernel modifications which in turn are based on @z3ntu kernel modifications of the fairphone released kernel sources which were needed to get the kernel to actually compile, boot in general and with TWRP in particular.

> <https://github.com/chaosmaster/android_kernel_fairphone_sdm632/commits/twrp-9.0>

But a big factor was probably using the android build environment instead of kernel make files to package the image with device tree in the way aboot wanted it.

for more details you have to ask the lords of chaos 🙂

---

<div class="post-metadata">

**Author:** ![k4y0z](https://forum.fairphone.com/letter_avatar/k4y0z/32/6_449c533f586939b6e5f246632a46421f.png) [@k4y0z](https://forum.fairphone.com/u/k4y0z)\
**Post date:** [February 4, 2020, 10:34pm UTC](https://forum.fairphone.com/t/fp3-custom-rom-development-based-on-released-source-code/56355/294 "2020-02-04T22:34:48Z")

</div>

Actually using the android build environment ist just way more convenient, when building TWRP.  
Im quite certain with my modifications and config it would also work using the build-scripts.

The main things to get it working where enabling (probably only needed for `fastboot boot`, not when flashing the kernel)  
`CONFIG_BUILD_ARM64_DT_OVERLAY=y`  
Which got rid of the “dtb not found” error, but requires using an external device tree compiler (DTC\_EXT).  
And patching the kernel to ignore the `skip_initramfs` flag the bootloader sets. (So it actually loads the TWRP initramfs instead of booting straight into the OS)  
My config also enables the serial console (UART) which was usefull for debugging, but not required for it to work now.

---

<div class="post-metadata">

**Author:** ![corvuscorax](https://forum.fairphone.com/user_avatar/forum.fairphone.com/corvuscorax/32/18495_2.png) [@corvuscorax](https://forum.fairphone.com/u/corvuscorax)\
**Post date:** [February 5, 2020, 7:07am UTC](https://forum.fairphone.com/t/fp3-custom-rom-development-based-on-released-source-code/56355/295 "2020-02-05T07:07:03Z")

</div>

I actually had tried that ( building the overlay with system installed dtb compiler ) but I still had eun into dtb not found, must have been how the dtbo was included unto the boot .img . There is aprox 5 different ways

---

<div class="post-metadata">

**Author:** ![k4y0z](https://forum.fairphone.com/letter_avatar/k4y0z/32/6_449c533f586939b6e5f246632a46421f.png) [@k4y0z](https://forum.fairphone.com/u/k4y0z)\
**Post date:** [February 5, 2020, 8:43am UTC](https://forum.fairphone.com/t/fp3-custom-rom-development-based-on-released-source-code/56355/296 "2020-02-05T08:43:35Z")

</div>

I tried with @z3ntu a while ago with just that option enabled and built without android environment, and that made the error disappear.  
Are you sure you used the Image.gz-dtb?

---

<div class="post-metadata">

**Author:** ![corvuscorax](https://forum.fairphone.com/user_avatar/forum.fairphone.com/corvuscorax/32/18495_2.png) [@corvuscorax](https://forum.fairphone.com/u/corvuscorax)\
**Post date:** [February 5, 2020, 9:57am UTC](https://forum.fairphone.com/t/fp3-custom-rom-development-based-on-released-source-code/56355/297 "2020-02-05T09:57:23Z")

</div>

I am pretty certain. I tried several things:

1. image.gz-dtb (which is the image.gz with dtb’s concatenated)
2. image.gz with manually concatenated dtb database created with dtbtool
3. image.gz with separate dtb in .img - as created with fastboot with --dtb option
4. image.gz with separate dtbo in .img - as created with fastboot with --dtbo option
5. the same as 3 and 4 but with dtb database created with dtbtool  
and a few combos with both dtb and dtbo in various combos. i never got past the dtb not found, but its possible i somehow missed the one working solution.  
Since we didn’t know in which form arima aboot expects the dtb(o) we were looking into the serial uart debug outputs, to get some pointers, but you got it working before I could get a 1.8V uart converter put together

---

<div class="post-metadata">

**Author:** ![pigpig](https://forum.fairphone.com/letter_avatar/pigpig/32/6_449c533f586939b6e5f246632a46421f.png) [@pigpig](https://forum.fairphone.com/u/pigpig)\
**Post date:** [February 5, 2020, 10:40am UTC](https://forum.fairphone.com/t/fp3-custom-rom-development-based-on-released-source-code/56355/298 "2020-02-05T10:40:01Z")

</div>

I think it needs one of these Image with `CONFIG_BUILD_ARM64_DT_OVERLAY=y` 🙂

---

<div class="post-metadata">

**Author:** ![k4y0z](https://forum.fairphone.com/letter_avatar/k4y0z/32/6_449c533f586939b6e5f246632a46421f.png) [@k4y0z](https://forum.fairphone.com/u/k4y0z)\
**Post date:** [February 5, 2020, 12:38pm UTC](https://forum.fairphone.com/t/fp3-custom-rom-development-based-on-released-source-code/56355/299 "2020-02-05T12:38:50Z")

</div>

> [@corvuscorax](#):
>
> 1. image.gz-dtb (which is the image.gz with dtb’s concatenated)

This with `CONFIG_BUILD_ARM64_DT_OVERLAY=y` is what you need.

> [@corvuscorax](#):
>
> but you got it working before I could get a 1.8V uart converter put together

We used a 3.3V UART which worked fine (only connected TX and GND of course)

---

<div class="post-metadata">

**Author:** ![justlurking](https://forum.fairphone.com/letter_avatar/justlurking/32/6_449c533f586939b6e5f246632a46421f.png) [@justlurking](https://forum.fairphone.com/u/justlurking)\
**Post date:** [February 7, 2020, 4:51pm UTC](https://forum.fairphone.com/t/fp3-custom-rom-development-based-on-released-source-code/56355/300 "2020-02-07T16:51:43Z")

</div>

Hi, my FP3 just arrived here today. Is there anything I should do - that would be of help to the rest of you - before I turn it on, downloading OTAs and so on?

---

<div class="post-metadata">

**Author:** ![calvofl0](https://forum.fairphone.com/letter_avatar/calvofl0/32/6_449c533f586939b6e5f246632a46421f.png) [@calvofl0](https://forum.fairphone.com/u/calvofl0)\
**Post date:** [February 7, 2020, 6:41pm UTC](https://forum.fairphone.com/t/fp3-custom-rom-development-based-on-released-source-code/56355/301 "2020-02-07T18:41:19Z")

</div>

Hi, I let the others reply to your question. But I suggest you to do at least the following:

1. Boot without SIM card and without internet conection
2. Unlock the bootloader
3. Boot into fastboot
4. Boot into TWRP without installing it
5. Open a shell on your smartphone
6. Use `dd` in order to backup the following partitions:

- aboot\_a
- boot\_a
- cmnlib64\_a
- cmnlib\_a
- devcfg\_a
- dsp\_a
- dtbo\_a
- fsc
- fsg
- keymaster\_a
- lksecapp\_a
- mdtp\_a
- modem\_a
- modemst1
- modemst2
- product\_a
- rpm\_a
- sbl1\_a
- system\_a
- tz\_a
- vbmeta\_a
- vendor\_a
- DDR
- apdp
- config
- devinfo
- dip
- dpo
- frp
- keystore
- limits
- logdump
- mcfg
- misc
- mota
- msadp
- oem
- persist
- prodinfo
- sec
- splash
- ssd
- syscfg

Doing this should guarantee that as long as you are careful to keep your system untouched in at least one of the two slots (you can experiment on the other), you would have a very hard time bricking your phone irreversibly. And if you are unhappy with some update, you should also be able to actually make a real “factory reset” of the phone.

Probably you don’t actually need to backup as much as that, but I preferred to keep on the safe side.

---

<div class="post-metadata">

**Author:** ![corvuscorax](https://forum.fairphone.com/user_avatar/forum.fairphone.com/corvuscorax/32/18495_2.png) [@corvuscorax](https://forum.fairphone.com/u/corvuscorax)\
**Post date:** [February 7, 2020, 8:46pm UTC](https://forum.fairphone.com/t/fp3-custom-rom-development-based-on-released-source-code/56355/302 "2020-02-07T20:46:29Z")

</div>

I second that. We haven’t had a backup of the original firmware of the phone, because by the time TWRP was available everyone had already installed OTA updates.

---

<div class="post-metadata">

**Author:** ![justlurking](https://forum.fairphone.com/letter_avatar/justlurking/32/6_449c533f586939b6e5f246632a46421f.png) [@justlurking](https://forum.fairphone.com/u/justlurking)\
**Post date:** [February 7, 2020, 9:22pm UTC](https://forum.fairphone.com/t/fp3-custom-rom-development-based-on-released-source-code/56355/303 "2020-02-07T21:22:06Z")

</div>

Hi,

Thanks for the advice! I was able to unlock the bootloader, enable USB debugging (to enable adb), run “adb boot bootloader” (to get to fastboot mode), and download TWRP from [Releases · chaosmaster/android\_device\_fairphone\_fp3 · GitHub](https://github.com/chaosmaster/android_device_fairphone_fp3/releases)  
But when I tried:

> $ fastboot boot twrp-3.3.1-0\_k4y0z-20200202-02-fp3.img  
> downloading ‘boot.img’…  
> OKAY [0.841s]  
> booting…  
> FAILED (remote: unlock device to use this command)  
> finished. total time: 2.063s

Edit: Okay, apparently it worked the second time. It seemed to factory reset itself the first time, but it now booted into TWRP.

As for the version that came with the phone, it lists as 8901.2.A.0110.20200109 - so if you need something older than that, I’m afraid I can’t help you.

---

<div class="post-metadata">

**Author:** ![calvofl0](https://forum.fairphone.com/letter_avatar/calvofl0/32/6_449c533f586939b6e5f246632a46421f.png) [@calvofl0](https://forum.fairphone.com/u/calvofl0)\
**Post date:** [February 7, 2020, 10:29pm UTC](https://forum.fairphone.com/t/fp3-custom-rom-development-based-on-released-source-code/56355/304 "2020-02-07T22:29:29Z")

</div>

> [@corvuscorax](#):
>
> I second that. We haven’t had a backup of the original firmware of the phone, because by the time TWRP was available everyone had already installed OTA updates.

Really? I did not install any update, and kept the Fairphone in the box, and I went through all this process of making backups yesterday evening.

Actually, to be completely honest, that is not fully true. When trying to get the URL from one update, the system actually went through the whole download and started updating itself before I noticed it. However, before it finished, I interrupted it and did a factory reset. I could check that the version was kept the same as the original one.

However, now that I could open a shell as root on it by using the TWRP image, I checked the partition images from the a slot and compared them to those of the b slot. Some images were still the same (either the update was not intending to change them or did not had the time to do it), and some were different. I assumed the aborted update was responsible for changing the non-current slot (slot b), and that the current slot (slot a) was the original. I later cloned all images from slot a into slot b (mostly as an exercise), and checked that the phone properly booted also on slot b.

So it is my impression that I still have the original version (from September 2019) on my Fairphone. That said, I found something really weird. In the processes of learning how all of this works, I used TWRP to make backups before I actually went manually with the shell and used dd to make the backups myself of all the partitions (and not just those proposed by TWRP). Later on (but without connecting the phone to the internet or installing anything myself and after a factory reset), when I did the backups manually, I compared the backups from TWRP to those I had done manually. Well, they were all the same, except for `modemst1` and `modemst2`, that are called `efs1` and `efs2` by TWRP. Any idea why?

---

<div class="post-metadata">

**Author:** ![corvuscorax](https://forum.fairphone.com/user_avatar/forum.fairphone.com/corvuscorax/32/18495_2.png) [@corvuscorax](https://forum.fairphone.com/u/corvuscorax)\
**Post date:** [February 7, 2020, 10:32pm UTC](https://forum.fairphone.com/t/fp3-custom-rom-development-based-on-released-source-code/56355/305 "2020-02-07T22:32:43Z")

</div>

> [@calvofl0](#):
>
> I compared the backups from TWRP to those I had done manually. Well, they were all the same, except for `modemst1` and `modemst2` , that are called `efs1` and `efs2` by TWRP. Any idea why?

The TWRP for FP3 is still work in progress. Best to tell @k4y0z , if there’s a mismatch with one of the partitions, its likely that TWRP has a partition link wrong or something.

[Previous page](https://forum.fairphone.com/t/fp3-custom-rom-development-based-on-released-source-code/56355.md?page=14)

[Next page](https://forum.fairphone.com/t/fp3-custom-rom-development-based-on-released-source-code/56355.md?page=16)
