Refurbed Fairphone 4 purchase. Returning to default OS

Hi, sooo I finally purchased a Fairphone 4 that I could afford. The phone as purchased, is a refurbished Fairphone 4 with Ubuntu Touch installed. I have been trying Ubuntu Touch, but while there are a lot of things that I like, it isn’t a perfect match for me. So, I am planning to return the Fairphone to the default OS, when it arrives.

Could someone direct me to links that I will need to consult for this process? I have flashed a couple of phones from my Fedora desktop before, so I have the android-tools package and android-udev-rules installed to my system. It is everything after that which I will be needing instructions for.

You should find everything here:

From what you write you already have some of the prerequisites ticked off :+1:

4 Likes

Two pitfalls the documentation does not tell you about:
Beware that android-tools might not work correctly (it does not on Arch Linux). If you encounter an error when flashing the super partition, DO NOT turn your phone off as the message suggests but rather try a different fastboot binary (e.g., included with iodéOS). This is how I bricked my FP5.
And if you want to lock the bootloader, be sure to check the output of
fastboot flashing get_unlock_ability – only lock if it is 1, which is the case before first boot on Fairphone OS. Otherwise your phone might be bricked if the OS you flashed was somehow corrupted or does not match the AVB key.
Have fun!

4 Likes

Well, I haven’t gotten very far for some reason:

$ adb devices
List of devices attached
b96db9a6        device
$ adb reboot bootloader

At this point, the Fairphone 4 shuts down, but doesn’t reboot. I have to ctrl c out of the last command, or it just sits there, waiting. I have also tried:

adb -d reboot bootloader

with the same result.

Note that the bootloader is already unlocked, and that I have set Ubuntu Touch in developer mode.

So it just turns off? That’s strange. I mean bootlader is a special mode so it should not reboot into the OS of course :wink:

Normally the command should get back directly and not wait for anything.
It triggers the boot into bootlader not more.

Alternatively turn off your phone and start in bootloader mode manually:

With the device powered off - hold Volume Down, then plug a power attached USB-C cable . Release Volume Down when you see the Fairphone logo

and check if it accepts fastboot commands like:
fastboot devices

1 Like

I got a long way, however the flashing didn’t succeed:

$ ./flash_fp4_factory.sh

*** Fairphone 4 flashing script ***

INFO: The procedure will start soon. Please wait...
INFO: The package type is "user-factory"
INFO: The build number is "TP29"
INFO: You are using a Linux distribution.

INFO: Validating the integrity of the package.
      This might take a while. Please wait...
INFO: Validation complete.
WARNING: Flashing this image wipes all user data and settings on the phone.
         It will also remove the Google factory reset protection.
         Are you sure you want to continue?
         Type "Yes" (case sensitive) and press enter to continue: Yes
INFO: Looking for connected device(s)...
INFO: One Fairphone 4 in fastboot mode found (serial number: b96db9a6).
INFO: The device is fully unlocked.
INFO: Proceeding to flash the device.
INFO: flashing partitions...
Sending 'abl_a' (152 KB)                           OKAY [  0.005s]
Writing 'abl_a'                                    OKAY [  0.011s]
Finished. Total time: 0.028s
Sending 'abl_b' (152 KB)                           OKAY [  0.006s]
Writing 'abl_b'                                    OKAY [  0.002s]
Finished. Total time: 0.018s
Sending 'aop_a' (174 KB)                           OKAY [  0.015s]
Writing 'aop_a'                                    OKAY [  0.002s]
Finished. Total time: 0.029s
Sending 'aop_b' (174 KB)                           OKAY [  0.014s]
Writing 'aop_b'                                    OKAY [  0.002s]
Finished. Total time: 0.027s
Sending 'bluetooth_a' (940 KB)                     OKAY [  0.033s]
Writing 'bluetooth_a'                              OKAY [  0.007s]
Finished. Total time: 0.053s
Sending 'bluetooth_b' (940 KB)                     OKAY [  0.028s]
Writing 'bluetooth_b'                              OKAY [  0.004s]
Finished. Total time: 0.044s
Sending 'boot_a' (98304 KB)                        OKAY [  2.403s]
Writing 'boot_a'                                   OKAY [  0.599s]
Finished. Total time: 3.013s
Sending 'boot_b' (98304 KB)                        OKAY [  2.420s]
Writing 'boot_b'                                   OKAY [  0.541s]
Finished. Total time: 2.971s
Sending 'core_nhlos_a' (111900 KB)                 OKAY [  2.775s]
Writing 'core_nhlos_a'                             OKAY [  0.606s]
Finished. Total time: 3.461s
Sending 'core_nhlos_b' (111900 KB)                 OKAY [  2.772s]
Writing 'core_nhlos_b'                             OKAY [  0.498s]
Finished. Total time: 3.351s
Sending 'devcfg_a' (42 KB)                         OKAY [  0.008s]
Writing 'devcfg_a'                                 OKAY [  0.001s]
Finished. Total time: 0.020s
Sending 'devcfg_b' (42 KB)                         OKAY [  0.006s]
Writing 'devcfg_b'                                 OKAY [  0.001s]
Finished. Total time: 0.018s
Sending 'dsp_a' (65536 KB)                         OKAY [  1.606s]
Writing 'dsp_a'                                    OKAY [  0.255s]
Finished. Total time: 1.872s
Sending 'dsp_b' (65536 KB)                         OKAY [  1.602s]
Writing 'dsp_b'                                    OKAY [  0.237s]
Finished. Total time: 1.850s
Sending 'dtbo_a' (24576 KB)                        OKAY [  0.620s]
Writing 'dtbo_a'                                   OKAY [  0.083s]
Finished. Total time: 0.727s
Sending 'dtbo_b' (24576 KB)                        OKAY [  0.621s]
Writing 'dtbo_b'                                   OKAY [  0.089s]
Finished. Total time: 0.733s
Sending 'featenabler_a' (84 KB)                    OKAY [  0.007s]
Writing 'featenabler_a'                            OKAY [  0.001s]
Finished. Total time: 0.027s
Sending 'featenabler_b' (84 KB)                    OKAY [  0.004s]
Writing 'featenabler_b'                            OKAY [  0.002s]
Finished. Total time: 0.018s
Sending 'hyp_a' (399 KB)                           OKAY [  0.015s]
Writing 'hyp_a'                                    OKAY [  0.003s]
Finished. Total time: 0.028s
Sending 'hyp_b' (399 KB)                           OKAY [  0.014s]
Writing 'hyp_b'                                    OKAY [  0.003s]
Finished. Total time: 0.027s
Sending 'imagefv_a' (524 KB)                       OKAY [  0.024s]
Writing 'imagefv_a'                                OKAY [  0.010s]
Finished. Total time: 0.046s
Sending 'imagefv_b' (524 KB)                       OKAY [  0.025s]
Writing 'imagefv_b'                                OKAY [  0.005s]
Finished. Total time: 0.042s
Sending 'keymaster_a' (257 KB)                     OKAY [  0.011s]
Writing 'keymaster_a'                              OKAY [  0.002s]
Finished. Total time: 0.025s
Sending 'keymaster_b' (257 KB)                     OKAY [  0.014s]
Writing 'keymaster_b'                              OKAY [  0.003s]
Finished. Total time: 0.028s
Sending 'modem_a' (149596 KB)                      OKAY [  3.697s]
Writing 'modem_a'                                  OKAY [  0.669s]
Finished. Total time: 4.468s
Sending 'modem_b' (149596 KB)                      OKAY [  3.703s]
Writing 'modem_b'                                  OKAY [  0.876s]
Finished. Total time: 4.681s
Sending 'multiimgoem_a' (13 KB)                    OKAY [  0.009s]
Writing 'multiimgoem_a'                            OKAY [  0.001s]
Finished. Total time: 0.023s
Sending 'multiimgoem_b' (13 KB)                    OKAY [  0.004s]
Writing 'multiimgoem_b'                            OKAY [  0.001s]
Finished. Total time: 0.018s
Sending 'qupfw_a' (53 KB)                          OKAY [  0.005s]
Writing 'qupfw_a'                                  OKAY [  0.001s]
Finished. Total time: 0.018s
Sending 'qupfw_b' (53 KB)                          OKAY [  0.006s]
Writing 'qupfw_b'                                  OKAY [  0.001s]
Finished. Total time: 0.018s
Sending 'recovery_a' (98304 KB)                    OKAY [  2.415s]
Writing 'recovery_a'                               OKAY [  0.529s]
Finished. Total time: 2.955s
Sending 'recovery_b' (98304 KB)                    OKAY [  2.428s]
Writing 'recovery_b'                               OKAY [  0.532s]
Finished. Total time: 2.971s
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::compare: __pos (which is 917456) > this->size() (which is 0)
./flash_fp4_factory.sh: line 214:  3257 Aborted                 (core dumped) ( "${FASTBOOT_BIN}" -s "${1}" flash "${2}" "${3}" )
ERROR: Could not flash the super partition on device b96db9a6.

ERROR: Please unplug the phone, take the battery out, boot the device into
ERROR: fastboot mode, and start this script again.
ERROR: (To get to fastboot mode, press Volume-Down and plug in the USB-C)
ERROR: (cable until the fastboot menu appears.)
ERROR: Aborting now (press Enter to terminate).

This has now happened twice.

This is the bug I talked about. Do NOT turn off your phone or it will be bricked!
Download fastboot from SDK Platform Tools release notes  |  Android Studio  |  Android Developers and try with that.

Yes, unfortunately I turned off the phone. Is there any way to recover?

Well… sorry to say, but I 'm afraid not. If you cannot enter the bootloader mode, you need to flash using EDL. As Fairphone does not release any files for this, you will most likely have to send your phone in.

The phone is currently in fastboot mode.

Phew, then you are most likely fine. Just retry with the fastboot linked above.

1 Like

What do I do with it?

Alternatively, there are some /e/ os images here:

Extract the archive to a folder and prepend the directory with fastboot to your PATH variable, like this: PATH=/path/to/tools:$PATH ./flash-all.sh

/e/OS includes a fastboot binary with their image (at least on FP5), so it should be fine as well.

No such thing:

~/platform-tools$ ls
adb       fastboot    lib64      make_f2fs_casefold  mke2fs.conf  source.properties
etc1tool  hprof-conv  make_f2fs  mke2fs              NOTICE.txt   sqlite3

~/platform-tools/lib64$ ls
libc++.so

Sorry, I was a bit unclear. Run the command PATH=~/platform-tools:$PATH ./flash-all.sh from your extracted Fairphone OS image directory. Then it should use the fastboot binary from the directory you showed me.

There is a ./flash_fp4_factory.sh, but I don’t see any ./flash-all.sh

Yeah, that one. Sorry, I’m pretty tired ATM. This should be correct now:
PATH=~/platform-tools:$PATH ./flash_fp4_factory.sh

1 Like

Wow. Fantastic. I am now in the Fairphone OS setup. Many thanks. The phone rebooted after the script completed, and I needed to see if the flashing had actually worked. Can I wipe the Fairphone OS preferences and then try to lock the bootloader?

If you want to lock the bootloader, I would advise you to flash the OS again (technically you only need the frp partition) so that “fastboot flashing get_unlock_ability” returns 1. Then, do “fastboot flashing lock_critical”, keep Volume Down pressed while confirming to reboot into the bootloader and finally do “fastboot flashing lock”. That way, you should be safe from bricks.

2 Likes