[Galaxy Note 4 General] magix01:
Hello,

I have posted on various threads that i can fix DRK (Device root key), but after large demand in PM for the fix i have decided to make a tutorial, since i don't have much time to help everyone, this tutorial is only tested on SM-N910C, could work on other variants of Exynos, perhaps snapdragon but NOT TESTED!!!!

So how is DRK broken? Usually when you flash roms and stuff you should have EFS backup as its most important thing while rooting samsung phones, but some people just dont do that, other people use boxes like z3x for unlocking and they wipe EFS, while unlocking phones the process sometimes changes IMEI number and leaves device root key wiped. These modifications sometimes make it hard to revert back to stock and i personally had problems with device suddenly rebooting etc... with this tutorial we will try to mitigate these problems.

PLEASE DO NOT PROCEED WITHOUT SHELL/ADB KNOWLEDGE IF YOU MESS SOMETHING UP YOU WILL LOOSE IMEI AND WILL HAVE A BRICK! You have been warned and i am not to be held liable!

First we need to make backup of your EFS, we will use TAR and shell which is most reliable way (Partition Backup is good too), with adb shell:

1. su

2. cd /efs

3. tar czf efsbackup.tgz *

4. mv efsbackup.tgz /data/media/0/

Now go to your internal memory in My Computer and there should be file called efsbackup.tgz copy it somewhere safe on your PC. This is your efs backup!

Now we need to take two files which we will reuse latter, you can extract them from efsbackup.tgz but this is easyer:

1. su

2. cd /efs

3. cp nv_data.bin /data/media/0/

4. cp nv_data.bin.md5 /data/media/0/

Now go to your internal memory and copy nv_data.bin and nv_data.bin.m5 to your desktop, we will need these files later. These files contain your imei!

Now we need to reboot to TWRP and format EFS partition via terminal (We are doing this to force radio to recreate the files we lost while flashing and make system more stable, no reboots etc..)

TWRP --> Advanced --> Terminal type these (These will also fix "Failed to mount /efs (Invalid Argument)) Don't missspell, if you get error no mount in fstab, that is ok!

1. mke2fs /dev/block/mmcblk0p3

2. mount -w -t ext4 /dev/block/mmcblk0p3

3. reboot

Now the system will be booting, once done when you dial *#06# you will see generic IMEI and it's not yours, don't freakout this is how its supposed to be. Radio also recovered your default values in FactoryApp folder which is nice. Now reboot phone twice!

Let's restore nv_data and restore imei, assuming you still have those files in your internal memory do this with ADB:

1. su

2. cd /efs

2. rm -rf /efs/nv_data.bin

3. rm -rf /efs/nv_data.bin.md5

4. mv /data/media/0/nv_data.bin* /efs/

5. chmod 700 /efs/nv_data.bin*

6. chown radio:radio nv_data.bin*

7. reboot

After phone reboots your factory IMEI is back and registering to network properly, now we have achieved stable device no random reboots and clean remade factory EFS!!!

DRK REPAIR PART!

Now lets go to the part of fixing DRK Device Root Key and dm-verity error! I have attached file called prov_data.zip, extract the prov_data folder to your internal memory (This is not a flashabe zip) And run these commands with your ADB Shell:

1. su

2. cd /efs

3. mv /data/media/0/prov_data /efs/

4. chmod -R 755 /efs/prov_data

5. chown -R root:root /efs/prov_data

Device root key is now present in your device but not yet active/validated, in order to validate this, you need to flash your factory firmware with ODIN, go to factory recovery and wipe data/factory reset, and dm-verity error is now gone!

SERIAL NUMBER FIX PART

I have attached file called serial_no.zip (Not a flashable zip file), extract the file from it called serial_no open it with notepad or whatever text editor you use and replace XXXXXXXXXXX with your own serial number that is written behind your phone. Now copy serial_no file to your internal memory again and with adb we do this:

1. su

2. cd /efs

3. mv /data/media/0/serial_no /efs/FactoryApp/

4. chmod 700 /efs/FactoryApp/serial_no

Reboot and done, you have your serial number back *#06#!

FACTORY CSC FIX PART

Download the file called csc_repair.zip, inside you will see the file called mps_code.dat, open it with notepad or whatever text editor you use, type in your factory CSC instead of XXX in my file and save. If you cant find your factory CSC, go to Kies or SmartSwitch, initialize firmware, type in your serial number and device model it will show your factory CSC for reinstall, this is your CSC. Now copy mps_code.dat file to your internal memory and again we run ADB Shell:

1. su

2. cd /efs

3. mv /data/media/0/mps_code.dat /efs/imei/

4. chown root:root /efs/imei/mps_code.dat

5. chmod 755 /efs/imei/mps_code.dat

This is it, if you can follow these steps you can get clean factory remade EFS partition, with your own IMEI, Serial Number, CSC Code, DRK/dm-verity fixed. Flashing factory ODIN firmware after this will make your phone work as it should!