[Galaxy Ace II Android Development] Szaby59:
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:

[MENTION=4962787]fluffi444[/MENTION] for his help to indentify the the correct partitions: [HOW-TO] Recover FULL GT-I8160P if flashed to GT-I8160 (non-P)

[MENTION=4060849]Shaaan[/MENTION] 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:

mkdir /sdcard/external_sd/nv_backup
mkdir /storage/extSdCard/nv_backup

From Recovery (if says device busy, sdcard is already mounted):

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:

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:

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:

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:

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:

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:

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!

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.