Restoring EFS partition / IMEI-information

Short version:
By some… unfortunate user error, I did overwrite my EFS partition with a backup from another phone. Now only one SIM works at a time (in any slot) and IMEIs are set to zero. Is there a way to restore them?

Long version:
I experienced some hardware issues on my FP3+. Since they were located on the mainboard, exchanging modules was not an option. As I didn’t want to go through the hassle of setting up a new phone from scratch and rather like my FP3, I bought a used phone and planned to simply transfer a TWRP backup.

Unfortunately, I didn’t learn from past experiences and did not make a backup of the new phone before restoring my backup. After booting, I discovered that

  1. Only one of two SIM is connected to the mobile network. It’s independent of the slot (both slots work if the other one is empty) and of the SIM I insert
  2. IMEI1 and IMEI2 are both set to zero
    Everything else (including mobile data on the usable SIM, texting, Wifi) works, as far as I’ve tested it.

After some research, I narrowed it down to my second mistake: I restored all partitions from my backup, including EFS. As far as I understand it, this means that I flashed unique hardware information from my old phone to my new one, where it is useless and leads to errors.

So far, I’ve tried the following:

  1. Factory reset and manually installing stock ROM
  2. Installing LineageOS
  3. Resetting IMEIs to the ones printed on the back; The IMEIs did get updated, but connectivity didn’t change
  4. Erasing modemst1, modemst2 and persist; after erasing just modemst1 and modemst2, nothing changed; when erasing persist, too, the phone doesn’t boot anymore and get’s stuck at the loading animation until I restore the partition image from my old phone.
  5. Changing IMEI using Qualcomm QPST; didn’t get this to work at all (phone not found in QPST)

Is there some other way to restore the lost information? Or is there some other source to the problem that I’m missing entirely?

I just purchased a FP2 on Ebay and decided the first thing I would do is attempt to put a custom ROM on it. Being new to android ROMS I went with LineageOS and followed this tutorial on installing LineageOS. After doing so I inserted my SIM card and was greated to my IMEI1 and IMEI2 being all zeros. After this I rooted the system with Magski then I put TWRP on it through the app. Opening up TWRP I was greeted to no EFS partition in the backup which lead me to believe my problem is not having an EFS partition!!!

I am now beating myself up over not immediately putting my sim card in to know weather I screwed it up or if it came to me screwed up. I think the only way to fix the system is to do as fabian says:

But I think we also need to get the persist.img for each respective phone for it to flash the right EFS structure. Then like it says in fabians step 4 link to PlayingPoiseuse on XDA you need to:

fastboot flash persist [location to your persist.img on your computer]

So we need to get the persist.img for our phones, and I think this can be done by anyone with a rooted FP2 or FP3+ with access to a terminal.

Open Terminal Emulator on Rooted FP
type su
grant Super User permissions

then type: dd if=/dev/block/by-name/persist of=/sdcard/persist_backup.img

this will copy your persist partition to sdcard and name it persist_backup.img then proceed with uploading it.

If anyone has any advice or can link to any resources to help that would be much appreciated. If you are willing to backup your persist.img and upload it or send it to me or have any ideas on how this could be done, please reach out or comment.

Or please tell me if this is hopeless… :frowning: