5,599,033 Members 31,596 Now Online
XDA Developers Android and Mobile Development Forum

[TOOL] MTD-Utils

Tip us?
 
_n0p_
Old
(Last edited by _n0p_; 24th September 2012 at 02:44 PM.) Reason: My first tests
#1  
_n0p_'s Avatar
Senior Member - OP
Thanks Meter 1821
Posts: 2,556
Join Date: Apr 2009
Location: Kiev
Prompt [TOOL] MTD-Utils

Here, i've quickly compiled three MTD utils ( git://git.infradead.org/mtd-utils.git ):
nanddump, nandwrite, flash_erase
So far tested nanddump - works , i was wandering what's inside
--
mtd3: 00040000 00020000 "LogFilter"
mtd4: 00300000 00020000 "oem_log"
--
Nothing interesting, actually.
--
nandwrite should enable you to write boot, recovery, system and firstboot right from android system (i don't think that it's good idea, but anyway).
--
Readme:
MTD-Utils 1.5
Please use with extreme caution!
--
Streak 5, dump example for recovery:
./nanddump /dev/mtd/mtd1 -f /sdcard/mtd1
--
Our layout:
cat /proc/mtd
dev: size erasesize name
mtd0: 00500000 00020000 "boot"
mtd1: 00600000 00020000 "recovery"
mtd2: 00600000 00020000 "recovery_bak"
mtd3: 00040000 00020000 "LogFilter"
mtd4: 00300000 00020000 "oem_log"
mtd5: 00100000 00020000 "splash"
mtd6: 10400000 00020000 "system"
mtd7: 08c00000 00020000 "userdata"
--
Have fun,
Sergei (_n0p_)

(tools attached)

--
I was able to switch recovery on the fly, having /sdcard/CWM.img (CWM port by TheManii) and /sdcard/SM.img (Old and trusty StreakMod):

/system/xbin/flash_erase /dev/mtd/mtd1 0 0
/system/xbin/nandwrite /dev/mtd/mtd1 /sdcard/CWM.img
Reboot, checked if works - it does

Back to StreakMod:
/system/xbin/flash_erase /dev/mtd/mtd1 0 0
/system/xbin/nandwrite /dev/mtd/mtd1 /sdcard/SM.img
Attached Files
File Type: zip mtd-utils.zip - [Click for QR Code] (308.4 KB, 1327 views)
The Following 13 Users Say Thank You to _n0p_ For This Useful Post: [ Click to Expand ]
 
_n0p_
Old
#2  
_n0p_'s Avatar
Senior Member - OP
Thanks Meter 1821
Posts: 2,556
Join Date: Apr 2009
Location: Kiev
Changelog:
Added flash_erase
The Following 2 Users Say Thank You to _n0p_ For This Useful Post: [ Click to Expand ]
 
citric_acid
Old
#3  
Member
Thanks Meter 6
Posts: 60
Join Date: Sep 2012
can you please guide how to flash this
should i flash this in streakmod recovery and will it wipe my current streakmod with cwm recovery ?
 
_n0p_
Old
#4  
_n0p_'s Avatar
Senior Member - OP
Thanks Meter 1821
Posts: 2,556
Join Date: Apr 2009
Location: Kiev
This zip pack should not be flashed.
This tools can operate on (at least) Streak NAND flash partitions, i.e. read, erase, write.
It contains three android binaries - you should extract them and place, preferably, into /system/xbin
Change permissions on al this files to 755 - like:
chmod 755 nanddump
Now, you should be able to flash boot(kernel) and recovery right from working Android system.
I've given an example in first post.
hunderteins, if you reading this - would you give mtd5 from your device?
I have it empty and wander what image format it should have.
The Following User Says Thank You to _n0p_ For This Useful Post: [ Click to Expand ]
 
_n0p_
Old
#5  
_n0p_'s Avatar
Senior Member - OP
Thanks Meter 1821
Posts: 2,556
Join Date: Apr 2009
Location: Kiev
Default Where is AMSS, DSP and stuff?

What do we have on NAND (my comments are in italic):

I/PrintK ( 1): <5>Creating 8 MTD partitions on "msm_nand":
54MB hole
I/PrintK ( 1): <5>0x000003600000-0x000003b00000 : "boot"
I/PrintK ( 1): <5>0x000003b00000-0x000004100000 : "recovery"
I/PrintK ( 1): <5>0x000004100000-0x000004700000 : "recovery_bak"
I/PrintK ( 1): <5>0x000004700000-0x000004740000 : "LogFilter"
I/PrintK ( 1): <5>0x000004740000-0x000004a40000 : "oem_log"
1MB hole
I/PrintK ( 1): <5>0x000004b40000-0x000004c40000 : "splash"
35MB hole
I/PrintK ( 1): <5>0x000007000000-0x000017400000 : "system"
I/PrintK ( 1): <5>0x000017400000-0x000030000000 : "userdata" (should be 0x000020000000)
W/PrintK ( 1): <4>mtd: partition "userdata" extends beyond the end of device "msm_nand" -- size truncated to 0x8c00000

According to this article:
http://forum.xda-developers.com/showthread.php?t=542688
this areas can be regained and hmmm, altered?
AMSS, DSP, service tag, provider lock and some other interesting stuff could be there!
The Following User Says Thank You to _n0p_ For This Useful Post: [ Click to Expand ]
 
hunderteins
Old
#6  
Senior Member
Thanks Meter 321
Posts: 167
Join Date: Sep 2009
Quote:
Originally Posted by _n0p_ View Post
hunderteins, if you reading this - would you give mtd5 from your device?
I have it empty and wander what image format it should have.
nice one. Thanks. But my mtd5 is 1048576 times 0xff.

What is the difference between

$ cat /dev/mtd/mtd5 > /sdcard/mtd5

and

$ nanddump /dev/mtd/mtd5 -f /sdcard/mtd5

?
The Following User Says Thank You to hunderteins For This Useful Post: [ Click to Expand ]
 
_n0p_
Old
#7  
_n0p_'s Avatar
Senior Member - OP
Thanks Meter 1821
Posts: 2,556
Join Date: Apr 2009
Location: Kiev
Quote:
Originally Posted by hunderteins View Post
nice one. Thanks. But my mtd5 is 1048576 times 0xff.

What is the difference between

$ cat /dev/mtd/mtd5 > /sdcard/mtd5

and

$ nanddump /dev/mtd/mtd5 -f /sdcard/mtd5

?
Well, it seems that nothing, but this makes me feel dumber than usual
I didn't try cat
 
TheManii
Old
#8  
Wiki Admin / Recognized Contributor
Thanks Meter 1433
Posts: 3,234
Join Date: Dec 2010

 
DONATE TO ME
flash_image should be the built in way of writing to mtd and raw emmc partitions, though we rarely ever discuss flash_image

try reading the raw nand at the beginning of it, thats where its stored on emmc devices, and there is unmapped space in the beginning
54mb should be approx enough shouldnt it? (not at pc to verify file sizes of the firmwares)

you could compare to the spro's map i guess, its an emmc device, but not a qisda one.
if i had the mapping for the "streak2 5" that would be the best to compare to, but i dont

is there any way to verify the mem locations are correct? i have the exact emmc layout for the s7/s10 because nvflash provides it if asked.
but there is no standardized tool for qualcomm chips, ill assume they're correct

also: at least on filesystems you should use dd and not cat for the fact that cat drops the final byte or something to that degree.
i dont recall if it applies to yaffs2 but it should for ext, it shouldnt matter for raw mtd partitions
XDA Wiki Moderator
Nexus 4: Stock KOT49H (4.4.2) 2013 N7: Stock KOT49H (4.4.2)
Touchpad: CM11 KOT49H (4.4.2) iTouch 5G: Stock 10B146 (6.1.2)
 
citric_acid
Old
#9  
Member
Thanks Meter 6
Posts: 60
Join Date: Sep 2012
hmmm iam still confused need to wait more to know this all
 
_n0p_
Old
#10  
_n0p_'s Avatar
Senior Member - OP
Thanks Meter 1821
Posts: 2,556
Join Date: Apr 2009
Location: Kiev
Quote:
Originally Posted by TheManii View Post
flash_image should be the built in way of writing to mtd and raw emmc partitions, though we rarely ever discuss flash_image
try reading the raw nand at the beginning of it, thats where its stored on emmc devices, and there is unmapped space in the beginning
54mb should be approx enough shouldnt it? (not at pc to verify file sizes of the firmwares)
You see, tools operate on logical partition level (i think flash_image is a userspace tool that uses mtd partitions, same as mtd-utils).
And kernel doesn't provide a raw device for NAND (i'd love to be wrong though).
I'll try tomorrow to supply kernel an MTD table via mtdparts parameter and check ow it goes.

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes