SD Card - Sector 0

Status
Not open for further replies.

UTMonkey

Member
Dear All,

I have a SPI+18F2550+SDCard project written in C18 and I am having a problem reading sector 0 of my SD Card.

After the usual CMD0 (returns 1) and CMD1 (returns 0) I issue a CMD17.

At first, a look at the buffer (attached) looks as if it has done nothing, but at the end of the buffer the last two hex values are 0x55AA.

I understand that those bytes reside at the end of the MBR which is at Sector 0.

So it (sort of) works, but when I fire up Winhex to look at Sector 0 there is slightly more data (non zero) on the sector.

So it looks like my CMD17 isnt retrieving the data correctly, I have been able to issue SEND_CID and SEND_CSD commands with no trouble.

Any ideas? I am happy to submit my source, I just wanted to see if there was something obvious you guys thought I was missing?

Kind Regards

Mark
 

Attachments

  • Output.TXT
    27.1 KB · Views: 316
  • output.jpg
    160.2 KB · Views: 391
Last edited:
At first, a look at the buffer (attached) looks as if it has done nothing, but at the end of the buffer the last two hex values are 0x55AA.

I understand that those bytes reside at the end of the MBR which is at Sector 0.
That looks pretty normal for an unformatted card/disk. Format it and it will have a proper partition table at the bottom.
 
Hi Futz,

Thats the problem, thats the image after formatting - take a look at the screen shot.

Regards

Mark
 
Thats the problem, thats the image after formatting - take a look at the screen shot.
Your output format is bogus. The offsets on the left should be in hex, just like the sector byte values. Displaying that in decimal forces me to use a calculator for everything. Horrible!

Anyhoo, your first partition entry should start at $1be (446). It's not there. Stick that card in your camera and format it. What did you use to format it before?

How big a card is it?

EDIT: Just found this:
Often USB flash disks do not have a partition table, and are basically a "super-floppy"
It may be that your camera or whatever you used to format the card is one of those bogus things. Format it with something that does it correctly, with a proper partition table. My Canon camera does it right. What are you using?

I'm just guessing, of course.
 
Last edited:
Hi Futz,

The textfile is in 3 columns the first column is in hex (beginning at 0x100 so you need to subtract) then you get the decimal column.

I used XP to format the drive and it is 1GB.

I am sort of confused as i was expecting to see the same values in the text file that are present in the screen shot.

Thanks for looking.

Mark

p.s. using the information you supplied - $2be (remember the 0x100 offset) does have some data in it, see below.

2BE [446] 0x00
2BF [447] 0x03
2C0 [448] 0x3D
2C1 [449] 0x00
2C2 [450] 0x06
2C3 [451] 0x0D
2C4 [452] 0xED
2C5 [453] 0xDB
2C6 [454] 0xF9

Is this useful(?)
 
Last edited:
The textfile is in 3 columns the first column is in hex (beginning at 0x100 so you need to subtract) then you get the decimal column.
Understood.

I used XP to format the drive and it is 1GB.
Can you format it with something else besides Microsh** software? Just in case?

I am sort of confused as i was expecting to see the same values in the text file that are present in the screen shot.
Huh? You're confused?! I'm lost! Why wouldn't they be the same? The screen shot looks like a normal unformatted MBR, though probably previously used. But the text values make more sense.

That looks pretty correct. That's not all of it, but that first part looks right. Why doesn't your screen shot match? Maybe you're looking at a different drive?

EDIT: If you don't already have it, go **broken link removed** for good info.
 
Last edited:
D'oh, Silly me!

Actually Winhex was looking at the logical drives sector 0 and not the physical drives sector 0.

Thanks for taking the time.

All the best
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…