Discussion in "8051 Discussion Forum" started by    Help    Dec 8, 2008.
Fri Jan 16 2009, 01:12 am
#51
Well when you format the card, only the file entries in root entry get deleted. all data on disk remain as it is. thus why data recovery softwares retrieve data to easily.

here is Something from Prjc.net website

the end-of-file number is actually anything equal to or greater than 0xFFFFFFF8, but in practive 0xFFFFFFFF is always written.

Fri Jan 16 2009, 10:15 pm
#52



Ya, you are rite. After modified the .txt file the old data still there and the new data will write to new sector.

So, what's the next step we going to do?
Sun Jan 18 2009, 04:02 pm
#53
read the MBR, find the location of first fat, and then go to sector where root is located. user the HxD software to do this. after getting into root, translate it to get info on directory entry.

this will be just a simulation of what exactly you're going to do in your hardware code. simulation is just to verify if method is fine you know what i mean.
Sun Jan 18 2009, 10:08 pm
#54
Dear Fren,





read the MBR, find the location of first fat,


May i know start from which byte is the location of first fat? I have read the PJRC but still not understand.

then go to sector where root is located. user the HxD software to do this. after getting into root,


Do you mean HxD have tool to seach the root?
Tue Jan 20 2009, 03:00 am
#55
in MBR, read the partition 1 table, there you will get info from where the LBA (first sector of partion starts)


Partition Table


FAT Volume ID

in FAT volume ID you will get everything you're looking for
Tue Jan 20 2009, 08:40 pm
#56
Dear Fren,

I still don't know how to read the Patition Table and Fat Volume ID. How to read the data actually?

Thank you,
Tue Jan 20 2009, 10:06 pm
#57
I think what Ajay is trying to say is this:

1. Read Sector 0 (512 bytes). Within this data you will find the address of the LBA, which is the first sector of the first partition.
2. Once you have this address, read that sector (512 bytes). Within this data you will find every thing you are looking for, like the bytes per sector, total sectors, number of clusters, etc, etc...

A good reference for what is contained within Sector 0, along with where the LBA address is located, can be found here:

http://en.wikipedia.org/wiki/Master_Boot_Record

Referring to the first table on the right (Structure of a Master Boot Record), you will see the address for the "Table of primary partitions", which is located at 0x1BE. Now look below this at the table "Layout of one 16-byte partition record", and you can see that the LBA address has an 0x08 byte offset in the first partition record. The address to read the LBA sector from is therefore 0X1BE + 0X08, or 0X1C6 - Notice also that this address is a 4 byte value, so actually you will build the address from the values at 0X1C6, 0X1C7, 0X1C8, and 0X1C9, like this:

LBA_StartAddress= (ULONG)(DiskBuffer[0x01C6]) +
((ULONG)(DiskBuffer[0x01C7])<<8) +
((ULONG)(DiskBuffer[0x01C8])<<16) +
((ULONG)(DiskBuffer[0x01C9])<<24);

Once you have this address, go and read the sector starting there and you will find what you are looking for...

-dave
 ajay_bhargav like this.
Tue Jan 20 2009, 10:12 pm
#58
One more thing:

Once you read the first sector of the FAT (the LBA address above), a good description of what's stored in there can be found here:

http://en.wikipedia.org/wiki/Fat16

At the bottom, under "Boot Sector"
Wed Jan 21 2009, 07:51 am
#59
Dear DavesGarage,

Thank for your reply. Your explaination is quite clearly but before go farther i would like to clarify the LBA data.

I have created a .txt file with "Testing...Hello" text in SD card. At the Sector-0 0x1BE to 0x1FD address the data is empty but the text is store at Sector-155 0x13600.




Why the LBA data is empty? Is it i miss understand some where?

Thank you,.


[ Edited Wed Jan 21 2009, 07:54 am ]
Wed Jan 21 2009, 10:58 am
#60
Actually, the LBA data is not empty - it points to address 0x00000000

If you read the definition of the Master Boot Record at:

http://en.wikipedia.org/wiki/Master_boot_record

The first part says:

The MBR may be used for one or more of the following:

* Holding a disk's primary partition table.[2]
* Bootstrapping operating systems, after the computer's BIOS passes execution to machine code instructions contained within the MBR.
* Uniquely identifying individual disk media, with a 32-bit disk signature; even though it may never be used by the machine the disk is running on.[3][4][5][6]


The footnote [2] at the bottom says:

^ In cases where the disk has a BIOS overlay or Boot manager installed, the partition table may be moved to some other physical location on the drive; e.g., a BIOS overlay often places a copy of the original MBR contents in the second sector ("Sector 1") then hides itself from any subsequently booted OS or application, so the MBR copy in Sector 1 is treated as if it were still residing in the first sector.

Your particular card doesn't relocate the FAT to a different sector...it's in the very first sector.

Notice the spaces starting at address 0x03? These are the OEM Name (padded with spaces) described in the boot sector table at:

http://en.wikipedia.org/wiki/Fat16

And notice the values at 0x0B and 0x0C? They are 0x00 and 0x02. When you arrange them as little-endian, they make 0x200, which is 512 - the size of the sector...

You are not missing anything, you already have it... :-)

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Jamiegob
Sun May 05 2024, 10:11 am
Gregoryjed
Sun May 05 2024, 10:02 am
Mariocax
Sun May 05 2024, 08:51 am
WilliamErync
Sun May 05 2024, 02:35 am
Danielnof
Sat May 04 2024, 11:12 pm
oriminna
Sat May 04 2024, 08:28 pm
scaneraNom
Sat May 04 2024, 02:21 am
gtaletrzua
Fri May 03 2024, 10:55 am