[ODIN][VRALJB][VRAMC3][VRUEMJ9] Restore to Stock

docchaos

Member
Aug 25, 2008
44
5
0
Again a warning, be careful you may brick, explode your phone, etc. I removed the MD5 extension from the file, and used the pit file, and it returned me to stock with no issues. I make no guarantees this will work, but it worked for me. I tried to flash the file with ODIN with the MD5 file extension, but it locked up and failed. Changed it to just the TAR extension and it worked fine. Again, buyer beware.
 

imnuts

Inactive Recognized Developer
Jul 27, 2007
3,808
3,174
113
West Chester
www.imnuts.org
Again a warning, be careful you may brick, explode your phone, etc. I removed the MD5 extension from the file, and used the pit file, and it returned me to stock with no issues. I make no guarantees this will work, but it worked for me. I tried to flash the file with ODIN with the MD5 file extension, but it locked up and failed. Changed it to just the TAR extension and it worked fine. Again, buyer beware.
DO NOT DO THIS. If it fails the MD5 check, you have a bad download. If the bad portion of the download is in sboot.bin, your phone is a paperweight. If you keep getting bad downloads, use a different browser or internet connection. Downloading via your phone is also likely a bad idea as it is more likely to not download properly.
 

soba49

Senior Member
Nov 6, 2010
303
34
0
boston, ma
Now that Adam's new jailbreak is favoring heimdall for all platforms, it's likely there will be a lot of people with heimdall configured but not Odin, even on Windows.

Could you please provide heimdall instructions for this image. I've done a lot of the reading, I'm mostly looking for confirmation in case I made any mistakes.

Please include 2 and 3.
1. The official md5 for the stock.tar.md5 files themselves*
Example, I got MD5 (CI605_I605VRLJB_I605VRALJB_CL414933_HWID04_HW-Rev0406_low_ship_user.tar.md5) = f5a374385da4151ab756c361efe5a278

2. A command line for extracting the file
Example, tar -xvf stock.tar.md5 seemed to extract correctly. Couldn't find any mention of people having issues with the last file extracted being corrupt or anything like that.

3. A command line for flashing its contents with heimdall
heimdall flash --verbose --primary-boot boot.img --cache cache.img --hidden hidden.img --modem modem.bin --param param.bin --recovery recovery.img --secondary-boot sboot.bin --factoryfs system.img --11 tombstones.img --81 tz.img

Is --11 "TOMBSTONES" synonymous with --dbdata, and --81 "TZSW" synonymous with --kernel? Is there any reason to include --pit and --repartition?

I looked at my PIT file, which you can extract from your phone in download mode:
Code:
heimdall download-pit --output note2.pit
heimdall print-pit note2.pit > note2_pitprint.txt
here's a shorter version of that command.

heimdall flash --verbose --80 sboot.bin --81 tz.img --7 param.bin --8 boot.img --9 recovery.img --10 modem.bin --11 tombstones.img --12 cache.img --13 system.img --14 hidden.img


If you're looking for other identifiers, either look at your own PIT above, or here's the output from mine today.

*: I know this is redundant since it includes its own checksum, but cutting off the tail file and comparing the md5s is a little awkward, and mysteriously heimdall has never added a feature to do this easily

PS> If anyone is looking for PIT files here are 2. One I downloaded from XDA some time ago, and Another that I just copied off of my phone (running Beans ROM) today. For reasons unknown to me they're slightly different, but agree so far as the partitions in this stock ROM are concerned.


---------- Post added at 12:54 PM ---------- Previous post was at 12:04 PM ----------

how do I check the md5 sum on this kind of file? just perplexed lol
All I found about how to check a tar.md5 file is here. This provides a script to do it, your mileage may vary...

Because of the way tar files are made, there's apparently empty space at the end of the file. The file is made by making the archive, then concatenating the output of md5sum onto the tail of that file.

So basically it's as onerous as you'd expect it to be. You either undo the process, or you look at it like it's 2 separate files:
1.You figure out the length of the file, wc -c stock.tar.md5
a. you write down the length, 1653944426 in my case
b. output was 1653944426 stock.tar.md5

2. Then look at the last few characters to find that md5 output using tail, and count them, tail -c 256 stock.tar.md5
a. you count the number of letters in this output, for me it was 106 (I counted by copying and pasting into an echo command and piping that through wc)
b. output was c5167c5413b6c8cea609db49a5896f34 CI605_I605VRLJB_I605VRALJB_CL414933_HWID04_HW-Rev0406_low_ship_user.tar
c. in one line, using wc, tail, and perl, tail -c 256 stock.tar.md5 | perl -pi -e 's/\x00//g' | wc -c will give you 106 directly​
3. Then you pipe all but the end of the archive through md5, and compare the number to the on you found in 2. (head -c ### stock.tar.md5 | md5 )
a. To compute ###, you subtract the number you found from 2. from the number you found in 1: 1653944426 - 106 = 1653944320.
b. output is c5167c5413b6c8cea609db49a5896f34, a match
c. NOTE: if you don't get the right value for ### the MD5 WILL NOT MATCH​

The two md5sums match for me. Woohoo. This is why the guy who answered posted a script. It's simple to do, but tedious.
 
Last edited:

soba49

Senior Member
Nov 6, 2010
303
34
0
boston, ma
Checking the MD5 without Odin

I decided it's better to just have a tool for checking the MD5s in filename.tar.md5

Here's one in written in Python, without any requirements, for head, tail, wc, or any md5sum tools. It's actually my very first Python script.

Code:
#!/usr/bin/python

#Copyright 2013 Ainsley McCall V0.11
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.


import hashlib	#for md5 library
import sys	#for single character output

tar_md5_file = "stock.tar.md5"
CHUNKSIZE    = 2**20 #1,048,576


if(len(sys.argv) > 1):
	tar_md5_file = sys.argv[1]
else:
	print "usage: "+sys.argv[0]+" <file.tar.md5>"
	sys.exit(1)

try:
	f = open(tar_md5_file, "rb")
except IOError:
	print "File " + tar_md5_file + " was not found!"
	sys.exit(1)
else:
	print "Analyzing File..."


def file_length(fname):
	f = open(fname, "r")
	f.seek(0,2)
	val = f.tell()
	f.close()
	return val
def tar_length(fname):
	f = open(fname, "rb")
	offset = 0
	try:
	    f.seek(-256,2);
	    offset = f.tell();
	    null_byte = chr(0) 
	    byteblock = f.read(256) 
	    for i in range(255,0,-1):
	   	b = byteblock[i]
		if(b == null_byte):
			if(i == 255):
				offset = -1
				break
			i += 1 # set to beginning of tail
			offset += i
			break;
	finally:
    		f.close()
		if offset == -1:
			print "Error!  No MD5 tail at end of file!"
			sys.exit(1)
		return offset 		

def do_md5(fname, flength):
	m = hashlib.md5()
	try:
		CS = min(flength, CHUNKSIZE)
		i=0
		counter = max(int(flength / CHUNKSIZE / 50),1)
    		f = open(fname, "rb")
    		while flength > 0:
        		byteblock = f.read(CS)
			flength -= CS
			m.update(byteblock)
			i+=1
			if(flength < CS):
				CS = flength
			if(i % counter == 0):
				sys.stdout.write(".")
				sys.stdout.flush()
	finally:
    		f.close()
	return m.hexdigest()
def do_tail(fname,tlength):
	with open(fname, "r") as f:
		f.seek(tlength,0)
		var = f.read()
		f.close()
		for s1 in (var.split()):
			if len(s1) == 32:
				return (s1)
		return var.split()[0]

fname = tar_md5_file
tlength =  tar_length( fname)
flength =  file_length(fname)

#import commands
#var1 = commands.getstatusoutput('tail -c ' + str(flength-tlength) + " " + tar_md5_file)
#s1 = ((var1[1]).split() )[0]

print "Tar is "+str(tlength)+" bytes long.  Tail is "+str(flength-tlength) +" bytes long"
s1 = do_tail(fname, tlength)
print "Calculating MD5"
s2 = do_md5(fname, tlength)

print "Done!"

if( s1 == s2 ):
   print "Tail ("+s1+") = MD5 (" + s2 + ") OK!"  
else: 
   print "Tail ("+s1+") != MD5 (" + s2 + ") FAIL!"  

sys.exit(0)
 
Last edited:

Longwayii

Member
Oct 1, 2010
35
0
0
can somebody help!!! i have odin and all necessary files but odin is not detected my note 2 crazy this is that my laptop is detected. how can that be and any thoughts on what i can do? i was on ota update verison and tried to boot to recovery and didnt know bootloader wasnt unlocked. so phone says unathorized software on phone return device to verizon. im getting deseparte enough to do just that lol
 

imnuts

Inactive Recognized Developer
Jul 27, 2007
3,808
3,174
113
West Chester
www.imnuts.org
can somebody help!!! i have odin and all necessary files but odin is not detected my note 2 crazy this is that my laptop is detected. how can that be and any thoughts on what i can do? i was on ota update verison and tried to boot to recovery and didnt know bootloader wasnt unlocked. so phone says unathorized software on phone return device to verizon. im getting deseparte enough to do just that lol
Did you install drivers?
 

Longwayii

Member
Oct 1, 2010
35
0
0
yes drivers are installed and phone is in download mode but it never shows up in odin with a id #

---------- Post added at 04:18 AM ---------- Previous post was at 04:14 AM ----------

the drivers needed is samsung note 2 usb drivers correct? does my phone suppose to show up as adb device?
 

Longwayii

Member
Oct 1, 2010
35
0
0
Its just says samsung android device connected. Doesnt ask for anything else and odin doesnt detect it. Can I download bootstrap.exc on my laptop? My phone only goes in download mode nothing else

Sent from my SCH-I605 using xda premium
 

denpad2010

Senior Member
Jun 2, 2010
885
32
58
SC
isaw in other tread i need pit file but here i dont see anybody talking about pit file,only odin package nthat i need put in pda field,so do or dont need a pit file??? thanks
 

soba49

Senior Member
Nov 6, 2010
303
34
0
boston, ma
isaw in other tread i need pit file but here i dont see anybody talking about pit file,only odin package nthat i need put in pda field,so do or dont need a pit file??? thanks
Unless you installed a non-stock ROM, vanilla, etc, you probably don't _need_ to repartition with A PIT file. However, chances are if you're looking to go to stock, you'll want to ensure your partition table is stock also. (I thought mine was untouched then realized the exploit I used to put in TWRP modified it).


Anyway, sch-i605-16gb.pit,
http://db.tt/30lrz5Lo
 
Last edited:

denpad2010

Senior Member
Jun 2, 2010
885
32
58
SC
Unless you installed anon stock ROM, vanilla, etc, you probably don't _need_ to repartition with A PIT file. However, chances are if you're looking to go to stock, you'll want to ensure your partition table is stock also. (I thought mine was untouched then realized the exploit I used to put in TWRP modified it).


Anyway, sch-i605-16gb.pit,
http://db.tt/30lrz5Lo
Is running jellybeans build 13 can you tell me if I need the pit file, or I can use the file either way... Thanks

Sent from my SCH-I605 using xda premium
 

soba49

Senior Member
Nov 6, 2010
303
34
0
boston, ma
Is running jellybeans build 13 can you tell me if I need the pit file, or I can use the file either way... Thanks

Sent from my SCH-I605 using xda premium
I'm also running beans 13.

If you use the PIT file: You'll be fully back to stock. You'll be able to freely accept OTA updates, send your phone to the manufacturer, whatever.

If you don't use the PIT file: The Odin will still work, and your phone will be 99.9% stock, with a slight deviation in the partition table: you'll have an extra entry for partition ID 82 that points to the same offset and block count as partition ID 80. It'll still work fine for running CASUAL, installing other ROMs, etc. and will act exactly like a fully stock phone.

In the context of using this Odin image to restore to root, I really can't think of a good reason to not use the PIT file as well. I suppose if you were tinkering with the file, and trying to flash without overwriting your data, or more generally if you had modified your system to use custom partitions and wanted to otherwise preserve that data, then you'd use a different PIT or none at all --- but in that scenario you'd know exactly what you were doing and why.

So in short, yeah, generally speaking it probably won't matter either way.

If you're sending your phone out as stock, use the PIT file, it won't hurt anything.
If you are keeping your phone, modifying it soon anyway, or have some reason to care otherwise, don't sweat it, and don't use a PIT.
 
  • Like
Reactions: denpad2010

denpad2010

Senior Member
Jun 2, 2010
885
32
58
SC
I'm also running beans 13.

If you use the PIT file: You'll be fully back to stock. You'll be able to freely accept OTA updates, send your phone to the manufacturer, whatever.

If you don't use the PIT file: The Odin will still work, and your phone will be 99.9% stock, with a slight deviation in the partition table: you'll have an extra entry for partition ID 82 that points to the same offset and block count as partition ID 80. It'll still work fine for running CASUAL, installing other ROMs, etc. and will act exactly like a fully stock phone.

In the context of using this Odin image to restore to root, I really can't think of a good reason to not use the PIT file as well. I suppose if you were tinkering with the file, and trying to flash without overwriting your data, or more generally if you had modified your system to use custom partitions and wanted to otherwise preserve that data, then you'd use a different PIT or none at all --- but in that scenario you'd know exactly what you were doing and why.

So in short, yeah, generally speaking it probably won't matter either way.

If you're sending your phone out as stock, use the PIT file, it won't hurt anything.
If you are keeping your phone, modifying it soon anyway, or have some reason to care otherwise, don't sweat it, and don't use a PIT.
Last question to be clear, which version should I d/l cause in another post I read since this phone is running latest OTA I should use alternative version

Sent from my SCH-I605 using xda premium