[Galaxy Ace II Android Development] ChronoMonochrome:
Hey guys! This thread for such difficult cases when IMEI (CSPSA parittion) is lost and you don't have any backups for this partition.

It's a long story, how exactly I recently turned my phone into a tablet without RIL working but the long story short - both EFS and CSPSA parrtitions were messed up without any obvious ways to recover the latter, since I had no backup.

First of all, I should thank [MENTION=5840412]ace2nutzer[/MENTION] since he first found in JB firmware utility, that sets the IMEI to default one (15 zeros). The below is code taken from one of JB codinap firmware:

#TA Loader to write default IMEI
service ta_load /system/bin/ta_loader recovery
user root
group radio
oneshot

The legality of the use of this I'll leave out the scopes of this topic (and thus this is up to Samsung / ST-Ericcson vendors since this utility was developed by them) - remember that this guide is not about how to change IMEI, but only to recover your original one. Also remember that changing IMEI is illegal in many of countries.

Ok, let's go to the work, but remember, any even more serious damage that you can do to your phone is not my responsibility!

There are some of prerequisites that must be met in order to recover IMEI:

at least JB 4.1.2 or any newer firmware (2.3.6 is not tested) - device must be rooted

your phone is still able to boot the system (the described below is likely not to work in recovery mode)

baseband and signal level are showed in settings, but *#06# combination shows nothing and thus your phone can't be registered in the network

Android terminal emulator installed or adb

stock CSPSA partition from XXLK2 codina / codinap . The below linked this parittion for codina (I'm not sure if codinap users can use it as well, in such case you need to download XXLK2 2.3.6 firmware and extract this partition manually): http://www.xda.mister-freeze.eu/XDA-files/ChronoMonochrome/misc/cspsa/cspsa_stock.img

proper EFS partition (or backup) - I'll leave EFS recovery out of this topic, since I haven't found much variants of recovery of this parittion other than to ask someone to upload their EFS parition. Over the Internet, you can also find some EFS partitions for Ace 2, but I haven't tested them.

ta_loader binary - can be taken from any 4.1.2 (or higher) firmware (see the path above)

Below is how I finally managed to recover IMEI: (attention! everything listed below is only for those who have messed up CSPSA partition. If you're not sure that this is the case for you - don't follow steps written below.)

firstly, backup your CSPSA partition just in case (if you are sure that this is not usable at all and is not useful anymore for anything - you can skip this step):

dd if=/dev/block/mmcblk0p6 of=/sdcard/cspsa_backup.img bs=512000

flash cspsa partition from XXLK2 stock:

dd if=/sdcard/cspsa_stock.img of=/dev/block/mmcblk0p6 bs=512000

and reboot the phone

backup /system/bin/ta_loader to some place (e.g. /sdcard or /ramdisk) and replace sequence of 15 zeroes to your original IMEI (can be found back under the battery) using sed:

sed -ie "s,000000000000000,<15_digits>," /ramdisk/ta_loader
sed -ie "s,<15_digits>0,<16_zeroes>," /ramdisk/ta_loader

I've used sed twice, because there are two occurences of 15 zeroes in ta_loader binary and we want to change only one of them (the rest occurence is not related to IMEI at all),

<15_digits> stands for your IMEI -> second sed command reverts an unwanted change.

Warning! Don't ever try to change IMEI to a non-original this way, it won't work!

now just type

/ramdisk/ta_loader recovery

, this will reboot your phone to recovery

reboot to system and voila! Original IMEI is there!

If this guide have saved your bacon then please consider donating to [MENTION=5840412]ace2nutzer[/MENTION] or me!