[HOW-TO] Backup/Restore NV Data (IMEI, Serial number, Baseband...)

Search This thread

Szaby59

Senior Member
Aug 26, 2010
444
294
WARNING!

I AM NOT RESPONSIBLE IF YOU BRICK YOUR PHONE!

I've decided to create this little tutorial thread to show how can you backup some important device specific data like IMEI, WiFi/BT mac address, modem (RIL) specific data and configuration files.

If the baseband version or IMEI number gets damaged you will face with some serious network issues like dropping the network signal, no 3G, no mobile data, no roaming - so the phone is basically useless.

Special thanks to:
@fluffi444 for his help to indentify the the correct partitions: [HOW-TO] Recover FULL GT-I8160P if flashed to GT-I8160 (non-P)
@Shaaan for Temporary CWM Recovery: [JB] CWM Recovery 6

REQUIREMENTS:

  • Rooted phone
  • ADB tool for do this on PC or Terminal Emulator from Google Play
  • CWM recovery - only if you want to use the .zips

BEFORE STARTING

Before starting the backup/restore process flash back to your Official Stock Firmware!
IMEI null/null, Unknown Baseband and other issues not always caused by corrupted NV Data!

To get root permission you have to enter "su" command for every terminal/adb shell session!
There are 3 dd commands for every partition, first is for GB (2.3.6) second is for JB (4.1.2) and the third is for recovery mode - the only difference is that External SDCard is mounted to different location.
If you used vold.fstab mod to swap internal/external storage check the correct path and use it to External SDCard (possibly /sdcard)

BE AWARE! To restore broken IMEI/Serial number you must have backups from ALL 3 partitions and you must restore all of them!

Create nv_backup folder manually on your external SD-card or use this command from ADB shell / terminal:

GB/JB:
Code:
mkdir /sdcard/external_sd/nv_backup
mkdir /storage/extSdCard/nv_backup

From Recovery (if says device busy, sdcard is already mounted):
Code:
mount -t vfat -o rw /dev/block/mmcblk1p1 /sdcard
mkdir /sdcard/nv_backup


EFS partition

This partition contains: product code, BT/WiFi mac address, RIL calibration files, DRM info and some other data like language, timezone set by your provider.

NOTE: Our phone (and I guess all phones with NovaThor SoC) doesn't store IMEI and SimLock information on EFS partition (no nv_data.bin).

Create a backup from EFS partition:

In ADB/Terminal emulator enter this:

Code:
dd if=/dev/block/mmcblk0p7 of=/sdcard/external_sd/nv_backup/efs.bin
dd if=/dev/block/mmcblk0p7 of=/storage/extSdCard/nv_backup/efs.bin
dd if=/dev/block/mmcblk0p7 of=/sdcard/nv_backup/efs.bin

Restoring EFS partition:

Code:
dd if=/sdcard/external_sd/nv_backup/efs.bin of=/dev/block/mmcblk0p7
dd if=/storage/extSdCard/nv_backup/efs.bin of=/dev/block/mmcblk0p7
dd if=/sdcard/nv_backup/efs.bin of=/dev/block/mmcblk0p7

NOTES:
  • On i8160 EFS partition is the 7th partition
  • efs.bin will be exactly a 10 MB file which contains every information and files from the EFS partition

ModemFS partition:

If you got unknown baseband or XXXX as baseband (modem/phone version) you probably have problems with this one...

This partition contains: RIL calibaration files the same from /efs, and other configuration files created by the RIL.
Also the STE modem for "everyday" operations uses this partition instead of efs and cspsa, therefore the chance to loose your imei is much lower compared to other Samsung phones (because there is always a working backup from the files on efs and cspsa).

Create a backup from ModemFS partition:

In ADB/Terminal emulator enter this:

Code:
dd if=/dev/block/mmcblk0p2 of=/sdcard/external_sd/nv_backup/modemfs.bin
dd if=/dev/block/mmcblk0p2 of=/storage/extSdCard/nv_backup/modemfs.bin
dd if=/dev/block/mmcblk0p2 of=/sdcard/nv_backup/modemfs.bin

Restoring ModemFS partition:

Code:
dd if=/sdcard/external_sd/nv_backup/modemfs.bin of=/dev/block/mmcblk0p2
dd if=/sdcard/storage/extSdCard/nv_backup/modemfs.bin of=/dev/block/mmcblk0p2
dd if=/sdcard/nv_backup/modemfs.bin of=/dev/block/mmcblk0p2

NOTES:

  • On i8160 ModemFS partition is the 2nd partition
  • modemfs.bin will be exactly a 16 MB file which contains every information and files from the MODEMFS partition

CSPSA partition:

This partition contains: RIL calibaration files, IMEI, SimLock data, serial number.
Also on every system start there is a synchronization between CSPSA and Modemfs.

Create a backup from CSPSA partition:

In ADB/Terminal emulator enter this:

Code:
dd if=/dev/block/mmcblk0p6 of=/sdcard/external_sd/nv_backup/cspsa.bin
dd if=/dev/block/mmcblk0p6 of=/storage/extSdCard/nv_backup/cspsa.bin
dd if=/dev/block/mmcblk0p6 of=/sdcard/nv_backup/cspsa.bin

Restoring CSPSA partition:

Code:
dd if=/sdcard/external_sd/nv_backup/cspsa.bin of=/dev/block/mmcblk0p6
dd if=/sdcard/storage/extSdCard/nv_backup/cspsa.bin of=/dev/block/mmcblk0p6
dd if=/sdcard/nv_backup/cspsa.bin of=/dev/block/mmcblk0p6


NOTES:

  • On i8160 CSPSA partition is the 6th partition
  • cspsa.bin will be exactly a 1.5 MB file which contains every information from the CSPSA partition


PHONE/BASEBAND "UNKNOWN":

You flashed a wrong modem.img.md5, f.e. you can't flash i8160P/L modem on i8160.
Create a tar from phone part (modem.img.md5) extracted from roms built for your model (i8160/L/P) and flash just the phone.tar with odin.
Or write modem.bin.md5 (not the tar!) directly to modem/phone partition using terminal/adb (requires rooted phone):
If doesn't solves the problem flash a rom made for your model!

Code:
su
dd if=/sdcard/external_sd/modem.bin.md5 of=/dev/block/mmcbk0p13
or
dd if=/storage/extSdCard/modem.bin.md5 of=/dev/block/mmcbk0p13
reboot

If you are using a custom rom copy your original /system/lib/tee folder to the custom roms /system/lib/tee folder!

Automated ZIPs for CWM RECOVERY
  • only tested with JB and Temp. CWM
  • extract nv_backup_restore.rar to you sdcard, including the empty nv_backup folder and the 2 zips.
  • nv_backup.zip/nv_restore.zip will backup/restore all (EFS/MODEMFS/CSPSA) partitions from External SD Card/nv_backup folder.

NOTES:

  • I highly recommend to do backup/restore from recovery with update.zips or using ADB, it's much safer when the phone is not completly booted.
  • This method will not give you/change your imei, only creates a backup from the original and restores from an already created (and working) partition image!
  • There is no sollution to SimUnlock the phone, but the simlock data is on CSPSA_FS.
  • Sometimes IMEI will stays null/null or shows nothing, flash a JB firmware again might solve the issue.
  • After a complete JB flash there will be a log file in /efs/pre_recovery.log - the phone writes it when checks and restores IMEI.
  • The CSPSA and MODEMFS backup must be created from the same state, f.e: a cspsa backup from GB and a MODEMFS backup from JB (or possible even from different GB build) will NOT work!
  • If your phone's RIL needs to be replaced with a new one old backups will NOT work, you have to create new backups for the new STE MODEM, that could caused by the encryption algorithm.
 

Attachments

  • nv_backup_restore.rar
    251.6 KB · Views: 23,167
Last edited:

luigisvc

Senior Member
Sep 2, 2012
156
9
Praia Grande
Nice tutorial, it exactly the problem that I am facing with I8160L version of this ace 2

Please explain if its method could be applied in my case:

I have a I8160L version from brazil, i tried to install custom ROMs fro Kyrillos and Messi, but after update always occurs the same problem that u described. I would like to know if I can apply this method to replace the files and get back my IMEI with european ROMs or, in my case, is a different problem.


Thanks in advance.
 

Szaby59

Senior Member
Aug 26, 2010
444
294
I don't think you can bring back your imei now, because it's stored on unknown location.


If you still have that rom which caused the error then flash back to a stock i8160L rom (I think you flashed a wrong modemfs.img.md5 with rom).
Or if you are on a stock L rom and still don't have imei, then dial *#197328640# choose COMMON -> NVREBUILD and after reboot check your imei again.

If doesn't help send the phone back to Samsung and they will fix it.
 
Last edited:

NZ John

Senior Member
Jan 15, 2013
85
10
Dunedin
Nice tutorial, it exactly the problem that I am facing with I8160L version of this ace 2

Please explain if its method could be applied in my case:

I have a I8160L version from brazil, i tried to install custom ROMs fro Kyrillos and Messi, but after update always occurs the same problem that u described. I would like to know if I can apply this method to replace the files and get back my IMEI with european ROMs or, in my case, is a different problem.


Thanks in advance.

I will post back soon, my phone is also an I8160L. I will attempt to upgrade to KryillosV5 then post back. Wish me luck =3
 

Szaby59

Senior Member
Aug 26, 2010
444
294
Read the "How to install (v5)" section carefully he described how to install if you have different i8160.
I think you flashed the european i8160 modem to your i8160l, flashing back to a stock i8160l rom will solve the issue.
 
Last edited:

luigisvc

Senior Member
Sep 2, 2012
156
9
Praia Grande
I don't think you can bring back your imei now, because it's stored on unknown location.


If you still have that rom which caused the error then flash back to a stock i8160L rom (I think you flashed a wrong modemfs.img.md5 with rom).
Or if you are on a stock L rom and still don't have imei, then dial *#197328640# choose COMMON -> NVREBUILD and after reboot check your imei again.

If doesn't help send the phone back to Samsung and they will fix it.
I reflashed stock rom and my phone is working now, but i never tried to install custom ROM again, because I was affraid of permanent damage.
I tried JB, but I can´t go further because o PIT file missing for no european phones.
But now I have a hope to install others ROM and replace the files that u mentioned.
 

Szaby59

Senior Member
Aug 26, 2010
444
294
I think you will need to replace the kernel.img.md5 too and that could be a problem because some custom roms have their own custom kernel and there is a good chance it will not work with stock kernels.
 

NZ John

Senior Member
Jan 15, 2013
85
10
Dunedin
No luck. In *#1234# I get PHONE: Unknown. Baseband in About is also unknown. Maybe modem as well? Could you write how to do that too?
 
Last edited:

Szaby59

Senior Member
Aug 26, 2010
444
294
Re: [HOW-TO] Repair Baseband (XXXX/unknown) and backup some device specific data

You cant use eu roms on i8160l, try fashing l kernel and modem only or a full stock rom.


Sent from my GT-I8160 using xda app-developers app
 
Last edited:

theresth

Member
Feb 17, 2013
19
0
I have I8160L too.

I try to flash custom rom such as [ROM][GB-XXLL2] KYRILLOSv5 **Fast n' Lite**.
After flash this rom ... my phone can't detect sim card and lost imei.

then I found this post ...
I try 1.creating&restoring backup from EFS partition
2.create&restoring backup from MODEMFS partition
3.write modem.bin.md5 (not the tar) directly to modem/phone partition using terminal (I extract from I8160L Stock Rom)

but my phone can't detect sim card and lost imei.

I've tried everything I know but fail.

I want you guys some help. I want to use custom rom or I should sell my I8160L phone.

Thank you everyone

(sorry for my english)
 
Last edited:

theresth

Member
Feb 17, 2013
19
0
How do flashed an img.md5 with odin ? First you have to make a tar.
Flash back a full L rom to see if it solves the problem.

Sorry ----> 3.write modem.bin.md5 (not the tar) directly to modem/phone partition using terminal (I extract from I8160L Stock Rom)

I can flash back to I8160L Rom and it solves the problem.

But I don't want use stock I8160L rom then I try to flash with I8160 Customrom but fail.

I don't know how to flash my I8160L with custom rom of I8160 :confused:

please help me please :(
 
Last edited:

Szaby59

Senior Member
Aug 26, 2010
444
294
That's doesn't belong to this topic.
There could be several modifications (kernel, build prop, drivers) why doesn't work with different model, ask on the custom roms own topic.
 
Last edited:

theresth

Member
Feb 17, 2013
19
0
Here's what I did! ( kyrillos v5 didn't detect sim)

I found a custom ROM which detects my sim!
Replaced the tee folder ( found in /lib) with the tee folder from the rom which worked and then flashed it!
Kyrillos v5 then detected my sim :D

Its work. Thank you guys for this tip. :good::good::good:

Finally I can flash I8160 custom rom to my I8160L ---> My phone can detect sim card and doesn't lose imei.

I tried only Gingerbread custom rom ---> It's work.

But I doub if i flash jelly Bean rom with the same way ... It's still work ???

(Sorry for my english)
 
Last edited:

NZ John

Senior Member
Jan 15, 2013
85
10
Dunedin
Here's what I did! ( kyrillos v5 didn't detect sim)

I found a custom ROM which detects my sim!
Replaced the tee folder ( found in /lib) with the tee folder from the rom which worked and then flashed it!
Kyrillos v5 then detected my sim :D

Hell YES!! Thank you! I finally managed to get Kyrillos V5 on my I8160L!

Although it doesnt say Im the 'L' model in the settings :p

sc20130220201455.png
sc20130220201504.png

sc20130220201521.png


Now we just need a way to get Jelly bean to work on it! :D
 
  • Like
Reactions: kyrillos13

Top Liked Posts

  • There are no posts matching your filters.
  • 21
    WARNING!

    I AM NOT RESPONSIBLE IF YOU BRICK YOUR PHONE!

    I've decided to create this little tutorial thread to show how can you backup some important device specific data like IMEI, WiFi/BT mac address, modem (RIL) specific data and configuration files.

    If the baseband version or IMEI number gets damaged you will face with some serious network issues like dropping the network signal, no 3G, no mobile data, no roaming - so the phone is basically useless.

    Special thanks to:
    @fluffi444 for his help to indentify the the correct partitions: [HOW-TO] Recover FULL GT-I8160P if flashed to GT-I8160 (non-P)
    @Shaaan for Temporary CWM Recovery: [JB] CWM Recovery 6

    REQUIREMENTS:

    • Rooted phone
    • ADB tool for do this on PC or Terminal Emulator from Google Play
    • CWM recovery - only if you want to use the .zips

    BEFORE STARTING

    Before starting the backup/restore process flash back to your Official Stock Firmware!
    IMEI null/null, Unknown Baseband and other issues not always caused by corrupted NV Data!

    To get root permission you have to enter "su" command for every terminal/adb shell session!
    There are 3 dd commands for every partition, first is for GB (2.3.6) second is for JB (4.1.2) and the third is for recovery mode - the only difference is that External SDCard is mounted to different location.
    If you used vold.fstab mod to swap internal/external storage check the correct path and use it to External SDCard (possibly /sdcard)

    BE AWARE! To restore broken IMEI/Serial number you must have backups from ALL 3 partitions and you must restore all of them!

    Create nv_backup folder manually on your external SD-card or use this command from ADB shell / terminal:

    GB/JB:
    Code:
    mkdir /sdcard/external_sd/nv_backup
    mkdir /storage/extSdCard/nv_backup

    From Recovery (if says device busy, sdcard is already mounted):
    Code:
    mount -t vfat -o rw /dev/block/mmcblk1p1 /sdcard
    mkdir /sdcard/nv_backup


    EFS partition

    This partition contains: product code, BT/WiFi mac address, RIL calibration files, DRM info and some other data like language, timezone set by your provider.

    NOTE: Our phone (and I guess all phones with NovaThor SoC) doesn't store IMEI and SimLock information on EFS partition (no nv_data.bin).

    Create a backup from EFS partition:

    In ADB/Terminal emulator enter this:

    Code:
    dd if=/dev/block/mmcblk0p7 of=/sdcard/external_sd/nv_backup/efs.bin
    dd if=/dev/block/mmcblk0p7 of=/storage/extSdCard/nv_backup/efs.bin
    dd if=/dev/block/mmcblk0p7 of=/sdcard/nv_backup/efs.bin

    Restoring EFS partition:

    Code:
    dd if=/sdcard/external_sd/nv_backup/efs.bin of=/dev/block/mmcblk0p7
    dd if=/storage/extSdCard/nv_backup/efs.bin of=/dev/block/mmcblk0p7
    dd if=/sdcard/nv_backup/efs.bin of=/dev/block/mmcblk0p7

    NOTES:
    • On i8160 EFS partition is the 7th partition
    • efs.bin will be exactly a 10 MB file which contains every information and files from the EFS partition

    ModemFS partition:

    If you got unknown baseband or XXXX as baseband (modem/phone version) you probably have problems with this one...

    This partition contains: RIL calibaration files the same from /efs, and other configuration files created by the RIL.
    Also the STE modem for "everyday" operations uses this partition instead of efs and cspsa, therefore the chance to loose your imei is much lower compared to other Samsung phones (because there is always a working backup from the files on efs and cspsa).

    Create a backup from ModemFS partition:

    In ADB/Terminal emulator enter this:

    Code:
    dd if=/dev/block/mmcblk0p2 of=/sdcard/external_sd/nv_backup/modemfs.bin
    dd if=/dev/block/mmcblk0p2 of=/storage/extSdCard/nv_backup/modemfs.bin
    dd if=/dev/block/mmcblk0p2 of=/sdcard/nv_backup/modemfs.bin

    Restoring ModemFS partition:

    Code:
    dd if=/sdcard/external_sd/nv_backup/modemfs.bin of=/dev/block/mmcblk0p2
    dd if=/sdcard/storage/extSdCard/nv_backup/modemfs.bin of=/dev/block/mmcblk0p2
    dd if=/sdcard/nv_backup/modemfs.bin of=/dev/block/mmcblk0p2

    NOTES:

    • On i8160 ModemFS partition is the 2nd partition
    • modemfs.bin will be exactly a 16 MB file which contains every information and files from the MODEMFS partition

    CSPSA partition:

    This partition contains: RIL calibaration files, IMEI, SimLock data, serial number.
    Also on every system start there is a synchronization between CSPSA and Modemfs.

    Create a backup from CSPSA partition:

    In ADB/Terminal emulator enter this:

    Code:
    dd if=/dev/block/mmcblk0p6 of=/sdcard/external_sd/nv_backup/cspsa.bin
    dd if=/dev/block/mmcblk0p6 of=/storage/extSdCard/nv_backup/cspsa.bin
    dd if=/dev/block/mmcblk0p6 of=/sdcard/nv_backup/cspsa.bin

    Restoring CSPSA partition:

    Code:
    dd if=/sdcard/external_sd/nv_backup/cspsa.bin of=/dev/block/mmcblk0p6
    dd if=/sdcard/storage/extSdCard/nv_backup/cspsa.bin of=/dev/block/mmcblk0p6
    dd if=/sdcard/nv_backup/cspsa.bin of=/dev/block/mmcblk0p6


    NOTES:

    • On i8160 CSPSA partition is the 6th partition
    • cspsa.bin will be exactly a 1.5 MB file which contains every information from the CSPSA partition


    PHONE/BASEBAND "UNKNOWN":

    You flashed a wrong modem.img.md5, f.e. you can't flash i8160P/L modem on i8160.
    Create a tar from phone part (modem.img.md5) extracted from roms built for your model (i8160/L/P) and flash just the phone.tar with odin.
    Or write modem.bin.md5 (not the tar!) directly to modem/phone partition using terminal/adb (requires rooted phone):
    If doesn't solves the problem flash a rom made for your model!

    Code:
    su
    dd if=/sdcard/external_sd/modem.bin.md5 of=/dev/block/mmcbk0p13
    or
    dd if=/storage/extSdCard/modem.bin.md5 of=/dev/block/mmcbk0p13
    reboot

    If you are using a custom rom copy your original /system/lib/tee folder to the custom roms /system/lib/tee folder!

    Automated ZIPs for CWM RECOVERY
    • only tested with JB and Temp. CWM
    • extract nv_backup_restore.rar to you sdcard, including the empty nv_backup folder and the 2 zips.
    • nv_backup.zip/nv_restore.zip will backup/restore all (EFS/MODEMFS/CSPSA) partitions from External SD Card/nv_backup folder.

    NOTES:

    • I highly recommend to do backup/restore from recovery with update.zips or using ADB, it's much safer when the phone is not completly booted.
    • This method will not give you/change your imei, only creates a backup from the original and restores from an already created (and working) partition image!
    • There is no sollution to SimUnlock the phone, but the simlock data is on CSPSA_FS.
    • Sometimes IMEI will stays null/null or shows nothing, flash a JB firmware again might solve the issue.
    • After a complete JB flash there will be a log file in /efs/pre_recovery.log - the phone writes it when checks and restores IMEI.
    • The CSPSA and MODEMFS backup must be created from the same state, f.e: a cspsa backup from GB and a MODEMFS backup from JB (or possible even from different GB build) will NOT work!
    • If your phone's RIL needs to be replaced with a new one old backups will NOT work, you have to create new backups for the new STE MODEM, that could caused by the encryption algorithm.
    4
    Here's what I did! ( kyrillos v5 didn't detect sim)

    I found a custom ROM which detects my sim!
    Replaced the tee folder ( found in /lib) with the tee folder from the rom which worked and then flashed it!
    Kyrillos v5 then detected my sim :D
    2
    Thread updated with additional information, added automated zips for JB with CWM recovery.
    2
    Hi!

    Have you tried flashing the german JB for i8160P (or if there is a GB rom with pit for P try flashing back first to see if it's a bug caused by the different rom or the imei data has been damaged) ?
    Or at least the modem.img.md5 from a P firmware ?

    What shows for the imei ?
    Nothing or zeros or something else ?
    I'm not sure where the imei is stored, it could be on efs but flashing only the efs partition will not bring back so it's probably stored or at least cached somewhere else.
    If you have backups try with restoring modemfs and efs and after that flash a rom with re-partition (GB or JB doesn't matter) to see what happens.

    Edit: I see you have a full backup you can try to do a binary comparision with a hex editor (winhex recommended) between the 2 images to check the changes.
    Main target is the efs and modemfs folder, also there are 2 partition gaps, one gap stores the Flash Counter data, so maybe it stores the imei too or the other one.
    2
    I can´t find it....there is another folder called lib inside the tree?? I found only one lib folder in the root folder

    You have to replace the tee folder of the ROM zip file ( Rom you need to install) ! Not you current ROM!