yashsingh1/xdaforums huggingface dataset:
[Moto G Q&A, Help & Troubleshooting] ol_st:
For me it was not so difficult task after finding the solutions, so:

1. Setup adb on your laptop/PC.

2. If you have rooted phone you will have issues with running `adb root` command, so, I set up `adb insecure` on my Moto G from http://xdaforums.com/showthread.php?t=1687590. If your phone wasn't rooted, skip this step.

3. Download images hob.img, dhob.img and fsc.img:

3. Connect your phone and laptop/PC and flash hob.img, dhob.img and fsc.img using adb:

"adb root"

"adb remount"

"adb push hub.img /sdcard/hob.img "

"adb push fsc.img /sdcard/fsc.img"

"adb push dhob /sdcard/dhob.img"

"adb shell"

"dd if=/sdcard/hob.img of=/dev/block/platform/msm_sdcc.1/by-name/hob"

"dd if=/sdcard/dhob.img of=/dev/block/platform/msm_sdcc.1/by-name/dhob"

"dd if=/sdcard/fsc.img of=/dev/block/platform/msm_sdcc.1/by-name/fsc"

"reboot"

Your phone will reboot and you have to have the signal. You could correct IMEI, if necessary, using Xposed.

I am attaching images for XT1033 and apk with adb insecure, if needed.
[Moto G Q&A, Help & Troubleshooting] PuLKit4xd:
[MENTION=5973547]ol_st[/MENTION] What happens when you don't use Xposed IMEI changer, the signal persists or not?

As far as i know the Xposed runs a fake Framework.jar only.
[Moto G Q&A, Help & Troubleshooting] prosodyspeaks:
xt1039 imgs?

so this is me joining the "wish i didn't erase all' club....

anyone got / know where to get HOB DHOB and FSC for xt1039?

or alternatively know of interchangeable variants?

poo.
[Moto G Q&A, Help & Troubleshooting] wxyzaid:
Which OS you using and which country you reside from ??
[Moto G Q&A, Help & Troubleshooting] vitruss:
I managed to get the carier back on my XT1039 flashing the files imgs.rar in this topic (from XT1033). After that had to clean the caches from recovery, because the phone didn't boot. The IMEI is replaced using Xposed to my original one. Not shure about 4g, the coverage is not so good in my home area. Hope to test it tomorrow.
[Moto G Q&A, Help & Troubleshooting] Cryoera:
i flashed that imgs but could not got any signal

i am at istanbul - turkey
[Moto G Q&A, Help & Troubleshooting] zeusalmighty:
Sorry to be hijacking this thread but does anyone think this could be transferred to Moto G 2015 (XT1541)? I tried flashing using dd but those directories are not available...
[Moto G Q&A, Help & Troubleshooting] gplambi:
Okay, i got in here. I have moto g 2015 (XT1550) and used erase all. getvars returns imei (only 1) but *#06# provides 0. Tried to flash stock rom, Other custom roms, flashed imgs.rar but no luck. Is there anything else i could try.
[Moto G Q&A, Help & Troubleshooting] Ht0312:
Same situation...
[Moto G Q&A, Help & Troubleshooting] gplambi:
Hi There, I come across a link gizdev.com/repair-imei-snapdragon-device. Unfortunately i am having windows 10 and its not providing COM Port information in device manager. I am not able to use QPST or above mentioned tool. If anybody having win 7 or earlier please give a try. I will also try the same using vmware.
[Moto G Q&A, Help & Troubleshooting] wxyzaid:
any updates ?
[Moto G Q&A, Help & Troubleshooting] gplambi:
No but i still have that handset with me, dead though... The last time i tried to replace the other system partitions with files from others which eventually locked my bootloader and so i am not able to do anything further. With locked bootloader its not even allowing me to flash stock rom.
[Moto G Q&A, Help & Troubleshooting] ol_st:
Nothing happens. It is just to make you not to worry, anything else :)
[Moto G Q&A, Help & Troubleshooting] ol_st:
By now custom Android 6.0 (identity crisis 6), Ukraine.
[Moto G Q&A, Help & Troubleshooting] ol_st:
Can you describe step-by-step.
[Moto G Q&A, Help & Troubleshooting] betatan:
about what? I just went back to stock.
[Moto G Q&A, Help & Troubleshooting] ol_st:
Your model of the phone (mine is xt1033 dual), the reason, why you lost IMEI (I made `erase all`), and how you recovered the stock.
[Moto G Q&A, Help & Troubleshooting] betatan:
I haven an xt1032, the .bat that came with the firmware had an "erase all", it was a .tar.gz file, ready to flash.

Correct firmware was a xml.zip file, only containing .bin and .img files, and I used mfastboot to flash them manually one by one. I did all of this without the SIM card inserted.
[Moto G Q&A, Help & Troubleshooting] skyguy126:
If they are write protected then why can fastboot erase all erase it?
[Moto G Q&A, Help & Troubleshooting] lost101:
I'm not sure 'write-protected' is the correct term. The partitions are only accessible in fastboot mode. And because of that you are limited in your options of how you access them. No way to back up, no way to restore.
[Moto G Q&A, Help & Troubleshooting] skyguy126:
Then why not flash a custom bootloader that allows access to those specific partitions.
[Moto G Q&A, Help & Troubleshooting] lost101:
The partitions are already accessible to current bootloader. The problem is that therefore you can only use fastboot commands. Look at the full list of fastboot cmds, and you will appreciate why this is so limiting.
[Moto G Q&A, Help & Troubleshooting] skyguy126:
That's all true but with a NAND dump we can modify the partition and do a fastboot flash. In this case modify the imei located in the partition. I'm not talking about retrieving the partition via fastboot.
[Moto G Q&A, Help & Troubleshooting] lost101:
No custom bootloader exists and making one may require significant effort and possibly a reward.
[Moto G Q&A, Help & Troubleshooting] skyguy126:
Prisecly.
[Moto G Q&A, Help & Troubleshooting] skyguy126:
Ok this is probably a n00b reply but today I flashed cm12 on my xt1032 and I was just messing around when I came across /proc/config To my surprise there was an imei folder there. I opened it up and it contained 3 files, raw, ASCII, and type. I opened up the ASCII file and sure enough it had my imei. Has this been discovered already and is it of any help?

Edit: there's another folder called "all" and inside it is a file (new and raw) with (what I think) are physical NAND locations. Under [imei:str] there are 15 of these things; [0x3Y]

The Y is a number in between 1 and 10.
[Moto G Q&A, Help & Troubleshooting] ol_st:
I found this information without flashing to cm12: the folder /proc/config/imei consists several files, 'ascii' file contains my imei (only one). The strings in the file 'new' you have found are the hex-digits of your imei.

I have to add, that I can see my imei by choosing 'Bar code' in bootloader menu.

Question: why this information is not accessible?

PS I tried to wite imei using QPST and found that the NV is READONLY.... :(
[Moto G Q&A, Help & Troubleshooting] skyguy126:
Is there a way to make it writeable? Can someone tell me how to do a NAND dump because I'm pretty sure it will help with this issue. We can modify the imei partition and reflash it through fastboot.
[Moto G Q&A, Help & Troubleshooting] lost101:
In the post below, I detail all partitions available and how to dump them. It is suspected that the actual 'imei partition' is not on this list because it is not available in Android, and can be only flashed to (and not dumped) via fastboot mode. I hope you can prove otherwise.

http://xdaforums.com/showpost.php?p=56454537&postcount=40​
[Moto G Q&A, Help & Troubleshooting] skyguy126:
I believe there are more partitions than what you indicated. Go to /proc/partitions and open it with a text editor. Are the other partitions dumped the same way via the dd command?

EDIT: the link you gave me did not work. The output is:

dd: /sdcard/Partitions/DDR.img: No such file or directory
[Moto G Q&A, Help & Troubleshooting] bludotos:
Hm.. In the "all" folder, my files are empty. Could you maybe upload those files for me?
[Moto G Q&A, Help & Troubleshooting] skyguy126:
Yeah I could but tell me this, did you mess up your imei?

If yes then restoring the files could bring it back...
[Moto G Q&A, Help & Troubleshooting] bludotos:
Yup, messed up imei. Shows in bootloaders barcode but not in "fastboot getvar all" and in the android settings. Also noticed my serial number is wrong.
[Moto G Q&A, Help & Troubleshooting] rootr:
Hello. If "fastboot erase all" messed up your imei then there is no way to get it back. Trust me i have spent a considerable time to retrieve it back. First all as i have mentioned earlier and with lost101, we agreed on the following:

1. fastboot erase all deletes IMEI

2. The following partitions are erased with above command: hob,dhob,fsc,modemst1,modemst2,fsg

3. fsg,modemst1,modemst2 are restored when flashing stock rom but not hob,dhob,fsc which implies IMEI is stored in one of those.

4. modem requests for read/write permission to dhob and hob on bootup further strengthening theory.

5. These partitions do not get mounted on bootup only in fastboot. So unless you have custom bootloader that can access these partitions in boot mode, there is probably no way to get IMEI back.

But, if you messed up your radio and your IMEI is "Unknown", then there is very much chance to get back your IMEI. Just flash compatible radio. This case happens mostly when flashing cyanogens or other custom firmwares. As you can read on other posts people flashed their stock back and hence their IMEI is restored which actually was never erased and was there the whole time.

Lastly, trying to write IMEI with NV writing method such as DFS or any other tool will not bring back IMEI as it doesnt really write anything. IMO NV_550 variable which holds IMEI in most devices is useless in MotoG as i checked with DFS, it gave error unknown variable meaning MOTO G does not support it.

Hope that helps. :)
[Moto G Q&A, Help & Troubleshooting] bludotos:
Unfortunately I knew all this :( was going to see if I can decompile the nonhob.bin file. (A look at it shows it does some interesting things. Maybe modify it to flash a backed hob or something?).
[Moto G Q&A, Help & Troubleshooting] skyguy126:
Can we modify momdest to mount hob and dhob on boot. Or even make it so that once it has write access make it write the imei. Can someone please tell me how to unpack/decomplie momdest and motoboot. I am using my moto g as a test bench so I am pretty willing to do these things. :)

Update:
[Moto G Q&A, Help & Troubleshooting] rootr:
The thing is these partitions are unmountable as they have no file system. Now trying to open with binary reader and figuring out stuff is too pro and nightmare for me. So another dead end here. Sorry but there is no way around here except to get your board replaced. :/
[Moto G Q&A, Help & Troubleshooting] skyguy126:
We should ask pro devs for help like the guys at cyanogen or the people who make sunshine...
[Moto G Q&A, Help & Troubleshooting] rootr:
It's unlikely that they will spent considerable amount of time on this as it is very rare case and definitely not an easy one.
[Moto G Q&A, Help & Troubleshooting] skyguy126:
I'm looking to JTAG my phone for a NAND dump. Any idea where I can do this?
[Moto G Q&A, Help & Troubleshooting] bludotos:
A lot of info in NON-HLOS.bin. I'm close to decompiling it. It does unlock the phone for us to modify it. Possibly reflash the hob and dhob partitions. If I can decompile it, I can compile it back. Its in C by the way.
[Moto G Q&A, Help & Troubleshooting] skyguy126:
I just used a ext4 Unpacker and used HxD. But you seem really far ahead to helping us.

Cheers! :D

Edit: Do you mind sharing how you decompiled it?
[Moto G Q&A, Help & Troubleshooting] bludotos:
I didn't decompile yet (not enough time and finals week) but I know enough about it to decompile it. Its an elf 32 bit executable and in C. I work all day today and have a final tomorrow. I'll decompile it this weekend.
[Moto G Q&A, Help & Troubleshooting] NextGenGTR:
I had a problem before when my imei was 0 and my sim wasnt connecting to any network, i fixed it by flashing again a different build, i think i flashed a retail one which messed my imei till i flashed a three network which fixed it.
[Moto G Q&A, Help & Troubleshooting] skyguy126:
While we are waiting for the decompile to happen I might be able to help a bit. You mentioned there is an nv variable that holds the imei correct? There are several nv variable names in the momdest binary. I could list them in this thread and you could try and write to the different variable names. Can't hurt to try since you already lost your imei...
[Moto G Q&A, Help & Troubleshooting] rootr:
I would surely have helped you but I already changed my motherboard. :/ Didn't have any option, I had to get my sim working. But please share your work as it can help others :)
[Moto G Q&A, Help & Troubleshooting] skyguy126:
I definitely will, I found some more information while examining the binary. There is a mode called "trusted boot" where all partitions are accessible and writeable. There might be a way to put your phone into trusted boot, but for that I need to examine motoboot.img The ext4 unpacker does not work on this file and nor do any iso extractors. Does anyone know how I can extract/decompile motoboot.img?
[Moto G Q&A, Help & Troubleshooting] rootr:
How do u know that with trusted boot all partitions are writeable?
[Moto G Q&A, Help & Troubleshooting] skyguy126:
I said maybe because the bits and pieces of code I could read meant that all partitions are fully mounted. I found really weird things in the bootloader, gonna try and translate the information for you guys.

There are many things talking about a RAM DUMP and how to properly do it...

Let me post some screenshots... Might have found something huge!

There is a hidden command to pull partitions: fastboot oem ramdump enable

then fastboot oem ramdump pull

Unfortunately it's restricted and I'm trying to find out how to enable it!

EDIT: There are a load of hidden fastboot oem commands but they are all restricted.

Done for today, gonna do some more work this weekend. Anyone else feel free to help me.
[Moto G Q&A, Help & Troubleshooting] skyguy126:
Running fastboot oem cid_prov_req gives an unlock code similar to the bootloader unlock. But I believe there is another process that will put the device into production mode by using that code... In production mode we can do ramdumps and imei changes. Haven't figured out how to use that code though, working on it...

Does anyone know how to write to bootloader variables?
[Moto G Q&A, Help & Troubleshooting] skyguy126:
Wut?!?!

Is this too good to be true......

Look at the attachment!

Popped it in HxD and yep the binary is there, its not a blank file. Looks like its encrypted though, but by examining the binary the encryption keys are stored in dhob. (Or maybe its the other way around :P)
[Moto G Q&A, Help & Troubleshooting] rootr:
Its a 512 kb file.....Probably a file system file.....try opening with ext2 or ext3?
[Moto G Q&A, Help & Troubleshooting] skyguy126:
No, I opened it with HxD and all the text is readable. Looks like some sort of encryption keys. (Which I know because of examining the radio image, hob contains encryption keys to decrypt dhob which contains the imei and other stuff) I also got dhob but it is unreadable in HxD probally because its encrypted. Has anyone already managed to extract the file or am I the first one?

EDIT: I even opened up the file with notepad++ and the text is still readable:

Here is an example (I replaced all the numbers and stuff because might contain personal information regarding my personal device):

<element>
<id>00000</id>
<index>0</index>
<size>000</size>
<data>
fjkahfjksdhfkjsadhfkjasdfhalsdfhkjasdfhvbcxznvbxmnvb,xmcz
</data>
</element>

Anyone know how to decrypt dhob if I have the encryption keys
[Moto G Q&A, Help & Troubleshooting] rootr:
From where did you extract this hob file?
[Moto G Q&A, Help & Troubleshooting] skyguy126:
After long struggles and stuff I was like "k lets try the easy way out" and went into twrp. Hit file manager. Copied the hob and dhob partitions onto the sdcard. Believe it or not it worked... as far as I know. They are just simple "text" files and they contain a lot of information. They do not have a filesystem as you mentioned earlier...
[Moto G Q&A, Help & Troubleshooting] rootr:
did u "fastboot erase all"? If u did that should have wiped hob. But your examination shows it still has contents inside. What about it?
[Moto G Q&A, Help & Troubleshooting] skyguy126:
No I did not fastboot erase all, my phone is intact.

So now do you agree that I have the right dhob and hob partitions or did i mess up :D. Anyways you can give it a try yourself.

So at this point what do you suggest I do, I have 0 experience with cryptography. How do you propose I use the encryption keys to decrypt dhob. Forgot to mention, I strongly believe that dhob is the partition that contains the imei. Also I need to figure if these partitions once edited to a user's need, if they are flashable in fastboot at all. I suspect not but we might be able to use the twrp method I mentioned earlier. But I'll cross the bridge when I get there :D.
[Moto G Q&A, Help & Troubleshooting] rootr:
Sorry bro, i have no idea about cryptography but lets just say if you get the keys even then how will you decrypt? This is near impossible stuff. -_-
[Moto G Q&A, Help & Troubleshooting] skyguy126:
There aren't too many forms (algorithms) of encryption so I guess its just trial and error. Plus I can further examine the radio binary and hopefully it will contain what encryption method is used. It is almost certain some binary will contain the decryption method or else how is the phone gonna read the imei? There is always a way around, nothing is impossible, never give up my friend! We got this far and many people thought it was impossible to say the least. I feel that I am really really close to solving this problem. Gonna keep going, but in the meantime do you mind trying to get more people to help with this topic?

Also, on the thread "header" (first post) you mentioned that the only way to fix this is to change the motherboard. Can you please add at the bottom there might be a software fix or something like that.

EDIT: Now I know for sure how hob and dhob are functioning I can try and make the radio to write the imei by using the init scripts. If [MENTION=5383643]bludotos[/MENTION] can decompile the radio it would help a lot!
[Moto G Q&A, Help & Troubleshooting] skyguy126:
For the time being I'm going to write a backup and restore script for dhob, hob, and fsc. For people who have already lost their imei, don't know what to say at this moment in time. I need to be able to take a look at the decompiled radio to make any suggestions.

I also know the kernel or radio is mounting and unmounting hob and dhob at boot. But in recovery all the partitions are mounted. Can you look through all the kernel init stuff and see if there is anything, anything at all regarding, hob, dhob, and the radio?
[Moto G Q&A, Help & Troubleshooting] rootr:
I did check inits.....I think I have posted regarding them on the first page...
[Moto G Q&A, Help & Troubleshooting] skyguy126:
Yes I saw, but I meant in the kernel not /etc

Unless they represent the same thing :D
[Moto G Q&A, Help & Troubleshooting] rootr:
Its the same..... init is first process to execute after Linux loads into memory....
[Moto G Q&A, Help & Troubleshooting] skyguy126:
Ok I looked through ALL the init files on my phone and none of them specifialy does anything with hob and dhob. So now it is clear the radio has the binary to access hob and dhob. I'm just hoping [MENTION=5383643]bludotos[/MENTION] can decompile the radio.
[Moto G Q&A, Help & Troubleshooting] bludotos:
No. I didn't decompile yet. Two more finals and I can work on it. Just wanted to put out that even though my imei is 0, I still get service (but signal is now not as good). I've been hearing you guys don't get service? I have unlocked gsm version. Using a Sim card.
[Moto G Q&A, Help & Troubleshooting] skyguy126:
For now good luck on your finals :D. But keep us updated when you start decompiling the radio. If we can accomplish this, its gonna help a lot of people to say the least...
[Moto G Q&A, Help & Troubleshooting] joaoricardo.rm:
Restore IMEI

Man, you gave me some hope.

As you say, if the IMEI is showing unkown, perhaps can be restored, right? In the screenshots show IMEI unknown and UNKNOWN: 0 in one of the fields. That could be this case? and I can see my IMEI number if I use fastboot getvar all. I've done the command "erase all" (DON'T DO IT). :(

If I get the radio from another device, could work? or even WiFi could work, or it needs IMEI as well?

Ps. "Desconhecido" means "Unknown".

Screenshots:

imgur . com / tafXtkI (remove spaces)

imgur . com / yhF9AZN

Sorry by the english.

Thanks.

Moto G 2º gen. XT1088
[Moto G Q&A, Help & Troubleshooting] skyguy126:
Read my posts on page 7. We are really close to finding a fix...
[Moto G Q&A, Help & Troubleshooting] rootr:
Please tell me more about your problem. Is your WiFi working? If not then you have a good chance of getting back imei. You need to format your fsg partition to ext4 I guess, that's what it supports. And then flash radio to this partition. Using custom recovery and some scripts. You can explain here what caused the issue, then only I can help you :)
[Moto G Q&A, Help & Troubleshooting] joaoricardo.rm:
Hmmm, my WiFi is NOT working, that is good, right? :)

Well, I think I ran the erase all command, because I thought it could do the same as "clear data" and "clear cache" of the Clockworkmod, but I discovered that I could be used fastboot clear userdata and cache (I'm so dumb :|).

After reinstall de ROM Lollipop and KitKat, WiFi and 3G signal work, actualy, when I turn on the wifi switcher, stays with the message "Turning Wi-Fi on...". And the operator network stays with a disabled switcher.

If is that "good", could I do what you say, and this modem I have to get from another device via backup, or a custom rom has it? (I'm downloading the ROM AndroX right now, the only I've found for my model).

Thanks again, I hope you understand me.
[Moto G Q&A, Help & Troubleshooting] rootr:
Well I am sorry if u gave " fastboot erase all", then as of now there is no solution, but if there was another reason such as flashing wrong kernel or modem which almost always causes WiFi, radio to stop and IMEI to "unknown" because radio is not functioning, then there was a chance to get IMEI back. But if you have used erase all then you are in the same boat.

Sorry about that.
[Moto G Q&A, Help & Troubleshooting] joaoricardo.rm:
Okay. So I'll wait for updates from the thread.

Thanks for all.
[Moto G Q&A, Help & Troubleshooting] skyguy126:
If anyone has intact hob and dhob partitions can you please upload on this thread so I can do some testing. I would like to verify the encryption keys are the same across devices.
[Moto G Q&A, Help & Troubleshooting] hunterhere:
Please come forward

Guys who have got their devices intact please please come forward and help the devs.... So, that we who did this "erase all" can get our devices back to life.... Please help by providing images and/or files....

Thank you
[Moto G Q&A, Help & Troubleshooting] hunterhere:
How much you paid? I went today to service center they said they will do it for free (under warranty) but my Worst fortune my sim card pins were damaged.... The guys there don't know the price... So can u tell me how much you paid?

And now after getting your MB changed are the IMEI(S) same or they got changed?

---------- Post added at 10:07 PM ---------- Previous post was at 10:03 PM ----------

I think there is some specific tool some software with motorola guys through which they flash IMEI(S). That is what we need to have... or else develop...
[Moto G Q&A, Help & Troubleshooting] rootr:
I paid Rs 6000 (INR) or $100 (i dont know which country you are from). IMEI gets changed. You practically get a new device. Memory, imei, device serial number and all related information is changed.