This blog post describes my successful os re-install on a fairphone 2 which was giving "flash write failure" errors when flashing it with fastboot, with the flash_FP2_factory.sh script. I'm writing down my recovery steps for this in case they are useful for anyone else.
I believe that this is caused by the bootloader code which implements fastboot not having the ability to retry recoverable eMMC errors. It is still possible to write the eMMC from Linux which can retry these errors.
So we can recover by directly fastboot-ing a recovery.img and then flashing things over adb.
Note this assumes that you've working fastboot and adb commands on your PC and connected the FP2 over a micro-USB cable.
I've chosen to use /e/OS images for this. First all we need to download both the IMG-e-x.y-...zip file which contains a full system image for flashing through fastboot since this contains images for a number of partitions which are not part of a normal ADB sideload install as well as the e-x.y-...zip file which can be used for adb sideload OS installation.
Go to https://sourceforge.net/projects/e-os-legacy-builds/files/fairphone/FP2/ and download the following 3 files:
Open a terminal on your PC run, create a temporary dir and inside that dir unzip the IMG-e-2.3-r-20250113-legacy-FP2.zip and recovery-IMG-e-2.3-r-20250113-legacy-FP2.zip files. Before continuing with the next steps run "fastboot devices" and check *one* device is listed, if not disconnect any other devices and try again.
Once everything is setup run the following commands (from the open terminal inside the temporary dir:
Wait for twrp to fully boot, this can take a long time when the eMMC contents is messed up. Inside twrp do the following:
Now we need to manually flash a bunch of smaller partitions since these are not
part of the adb sideload img and they may be corrupted.
From the terminal on your PC run:
Now start an adb shell "adb shell" and in that shell run:
Number Start (sector) End (sector) Size Code Name
1 131072 262143 64.0M 0700 modem
2 262144 263167 512K 0700 sbl1
3 263168 263231 32768 0700 dbi
4 393216 393279 32768 0700 DDR
5 524288 526335 1024K 0700 aboot
6 526336 546815 10.0M 0700 splash
7 546816 547815 500K 0700 rpm
8 655360 688127 16.0M 0700 boot
9 786432 787431 500K 0700 tz
10 787432 789479 1024K 0700 pad
11 789480 792551 1536K 0700 modemst1
12 792552 795623 1536K 0700 modemst2
...
The exact start / end sectors are not important but the order of the first 9 partitions *must* match, type q to quik fdisk, so that you're back in the adb shell and from the adb shell run:
Now move back to the twrp recovery on the phone. On the phone:
And then from a terminal on the PC run:
This will take a while after this check for errors on both the PC side and in the recovery logs on the phone screen. There should be
no errors. Then select reboot on the phone and it should now boot into /e/OS 2.3 (Android 11).
I believe that this is caused by the bootloader code which implements fastboot not having the ability to retry recoverable eMMC errors. It is still possible to write the eMMC from Linux which can retry these errors.
So we can recover by directly fastboot-ing a recovery.img and then flashing things over adb.
Note this assumes that you've working fastboot and adb commands on your PC and connected the FP2 over a micro-USB cable.
I've chosen to use /e/OS images for this. First all we need to download both the IMG-e-x.y-...zip file which contains a full system image for flashing through fastboot since this contains images for a number of partitions which are not part of a normal ADB sideload install as well as the e-x.y-...zip file which can be used for adb sideload OS installation.
Go to https://sourceforge.net/projects/e-os-legacy-builds/files/fairphone/FP2/ and download the following 3 files:
- IMG-e-2.3-r-20250113-legacy-FP2.zip
- e-2.3-r-20250113-legacy-FP2.zip
- recovery-IMG-e-2.3-r-20250113-legacy-FP2.zip
Open a terminal on your PC run, create a temporary dir and inside that dir unzip the IMG-e-2.3-r-20250113-legacy-FP2.zip and recovery-IMG-e-2.3-r-20250113-legacy-FP2.zip files. Before continuing with the next steps run "fastboot devices" and check *one* device is listed, if not disconnect any other devices and try again.
Once everything is setup run the following commands (from the open terminal inside the temporary dir:
- fastboot oem unlock
- fastboot boot twrp-3.7.0_9-0-FP2.img
Wait for twrp to fully boot, this can take a long time when the eMMC contents is messed up. Inside twrp do the following:
- Select "keep readonly"
- Goto Wipe
- Select Format Data
- Type Yes
- <wait>
- Go back 2x
- Select Advanced Wipe
- Select Dalvik Cache + Cache, slide to swipe
- Go Back 2x to return to the home screen
Now we need to manually flash a bunch of smaller partitions since these are not
part of the adb sideload img and they may be corrupted.
From the terminal on your PC run:
- adb push modem.img /tmp
- adb push sbl1.img /tmp
- adb push aboot.img /tmp
- adb push splash.img /tmp
- adb push rpm.img /tmp
- adb push boot.img /tmp
- adb push tz.img /tmp
Now start an adb shell "adb shell" and in that shell run:
- fdisk /dev/block/mmcblk0
- Inside fdisk type p <enter> to print the paritions, this should show something like:
Number Start (sector) End (sector) Size Code Name
1 131072 262143 64.0M 0700 modem
2 262144 263167 512K 0700 sbl1
3 263168 263231 32768 0700 dbi
4 393216 393279 32768 0700 DDR
5 524288 526335 1024K 0700 aboot
6 526336 546815 10.0M 0700 splash
7 546816 547815 500K 0700 rpm
8 655360 688127 16.0M 0700 boot
9 786432 787431 500K 0700 tz
10 787432 789479 1024K 0700 pad
11 789480 792551 1536K 0700 modemst1
12 792552 795623 1536K 0700 modemst2
...
The exact start / end sectors are not important but the order of the first 9 partitions *must* match, type q to quik fdisk, so that you're back in the adb shell and from the adb shell run:
- cat /tmp/modem.img > /dev/block/mmcblk0p1
- cat /tmp/sbl1.img > /dev/block/mmcblk0p2
- cat /tmp/aboot.img > /dev/block/mmcblk0p5
- cat /tmp/splash.img > /dev/block/mmcblk0p6
- cat /tmp/rpm.img > /dev/block/mmcblk0p7
- cat /tmp/boot.img > /dev/block/mmcblk0p8
- cat /tmp/tz.img > /dev/block/mmcblk0p9
- sync
Now move back to the twrp recovery on the phone. On the phone:
- Select Advanced
- Select Sideload
- Swipe to start sideload
And then from a terminal on the PC run:
- adb sideload e-2.3-r-20250113-legacy-FP2.zip
This will take a while after this check for errors on both the PC side and in the recovery logs on the phone screen. There should be
no errors. Then select reboot on the phone and it should now boot into /e/OS 2.3 (Android 11).