SD Card - boot sector

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Hi guys,

I am finding that reading the raw data off an SD in my embedded, that
the boot sector is not actually at address 0, but differs from card to
card (ie. my 64 MB has the boot sector at 4E00, and my 128 MB at C600).

Everything else before this is read as 0's.

I am not using any of the secure stuff on the card, just plain-old SPI.
I verifed I am reading the exact values vs. WinHex on a PC and card
reader.

Can anyone provide insight into this? Is there some non-readable secure
stuff on SD cards before the boot sector? Any ideas where I get more
info on this? (I have tons of info on the FAT field descriptions, etc
already).

Thanks!

-- Pete


Re: SD Card - boot sector
Quoted text here. Click to load it

What boot sector are you talking about - the DOS boot sector (first
sector of the FAT volume) or the MBR?


Re: SD Card - boot sector
It's the one where the 1st byte is EB and offset 3 in the sector has
the string "MSDOS5.0" on my FAT32-formatted card. I apolozige for not
knowing the correct term, but it must be the DOS boot sector?

-- Pete


Re: SD Card - boot sector

Quoted text here. Click to load it

That's the LBR. Removable flash media are formatted as hard disks. They
have an MBR (partition table) at sector 0. If you formatted the card on
Windows the MBR is probably set up so that the first partition is at
cylinder 0 head 1 sector 1 (i.e. you lose the first track on the disk).

Look at my DOSFS code for information on the MBR format and C code to
work out the start of the partition. http://www.zws.com/products/dosfs /


Re: SD Card - boot sector
Quoted text here. Click to load it

Usually. This depends upon its controller firmware, whether it reports itself
as removable media or not.

If not - then it will have MBR, and will have the "hard disk" icon in Windows.

If yes - it will have no MBR (boot sector at sector 0) and will have the
"diskette drive" icon in Windows.

Windows does not support MBR and partitions on removable media, but requires
the partition table (MBR, GPT or Dynamic Disk) on a non-removable media.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
We've slightly trimmed the long signature. Click to see the full one.
Re: SD Card - boot sector
Quoted text here. Click to load it

Sometimes removeable media come with the MBR / partition table and so
formatting will retain will retain the MBR. However if the disk is
subsequently damaged then windows will totally reformat the disk, with no
MBR and the dos boot sector as sector 0. It is worthwhile checking for both
instances. I do this by checking if the first byte of sector 0 is 0xEB.

Ross



Re: SD Card - boot sector


Quoted text here. Click to load it

What kind of interface were you using to access the drive?

I just did the following: On a linux box:

dd if=/dev/zero of=/dev/sda bs51%2 count10%0

then using the inbuilt O2Micro SD reader slot in my laptop, reformatted
the card in Windows. The resulting card had an MBR with one partition
(not marked active).

So I don't think it's as consistent as this.


Re: SD Card - boot sector
While I can't speak to the structure of the card itself, it's been my
observation that the card is only part of the equation... the reader
plays a bigger part with respect to "booting" devices and it's ability
to do so is dependant on both the computer's ability to boot from the
connection method and that computer's current bios configuration has to
be set to allow such a boot.

Of about half a dozen different usb card readers, I have two that show
up as usb boot devices on my system's boot selector menu and I have only
two computers out of about seven which offer the capability to boot from
usb devices... for example, my Sony Vaio Picturebook will boot via usb,
but it will only recognize one specific usb floppy drive as a valid boot
device.

With those two bootable SD readers, I can then use different boot
configurations stored on different SD cards to boot the pc.

Tip... disconnect all usb devices except a card reader and follow your
box's alternate boot steps... if the reader is bootable, it will show in
the boot device menu under an interesting variety of device names.

Beverly Howard [MS MVP-Mobile Devices]



Re: SD Card - boot sector
Quoted text here. Click to load it

Belkin card reader.

I think it may have been when the MBR was damaged windows reformatted it
this way. Sorry for any confusion or generalisations, it might only be my
box that was playing up.

Ross



Re: SD Card - boot sector
Quoted text here. Click to load it

Exactly. Saw this personally on Iomega ZipDrive.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
We've slightly trimmed the long signature. Click to see the full one.
Re: SD Card - boot sector


Quoted text here. Click to load it

In a practical sense: all embedded systems that I have seen (cameras,
mainly) that use removable media will format it as a hard disk. I
suspect that most media playback devices would not recognize a "big
floppy" flash disk. Some flash media specifications explicitly require
an MBR (SSFDC comes to mind).

All the USB adapters I've used - which is many different types - cause
Windows to format cards with an MBR. As a matter of interest, the units
I have also report as removable to Windows.

It's safe to say that anybody who doesn't format flash media with an
MBR is being a maverick.


Re: SD Card - boot sector
Quoted text here. Click to load it

Yes, looked at Disk driver source - Windows supports MBR on removable media,
but uses only the very first valid partition off it.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
We've slightly trimmed the long signature. Click to see the full one.
Re: SD Card - boot sector
Quoted text here. Click to load it

What about USB and Firewire disks?

Paul

Re: SD Card - boot sector
Quoted text here. Click to load it

They're not "removable".

--
Grant Edwards                   grante             Yow!  Hmmm... a CRIPPLED
                                  at               ACCOUNTANT with a FALAFEL
We've slightly trimmed the long signature. Click to see the full one.
Re: SD Card - boot sector


Quoted text here. Click to load it

Depends on the disk. What about ZIP disks?

My cheapo USB-to-laptop-drive adapters mount as a removable drive (they
show the "socketed drive" icon and have an Eject option on the context
menu).


Re: SD Card - boot sector
Quoted text here. Click to load it

Right.  For some reason I thought we were talking about
USB and Firewire hard-drives.  Other types of USB mass-storage
show up as removable (Zip disks, CF readers, etc.).

--
Grant Edwards                   grante             Yow!  MERYL STREEP is my
                                  at               obstetrician!
We've slightly trimmed the long signature. Click to see the full one.
Re: SD Card - boot sector
Quoted text here. Click to load it

First, I was mistaken. MBR is supported on removable media. But only 1
partition is used on it. Look at Disk driver source from the DDK (if you have
one).

Second, do not mix removable _media_ and removable _device_. USB and 1394 disks
are fixed-media removable devices. Iomega ZIP USB is a removable media (special
diskettes) removable device.

Most USB flash drives are emulating the removable media - the USB diskette
drive with the diskette glued to it forever. But some old USB flash drives
emulate the real USB-attached hard disk.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
We've slightly trimmed the long signature. Click to see the full one.
Re: SD Card - boot sector
Quoted text here. Click to load it

Ok, so does it make sense that the MBR, (ie. everything leading up to
the LBR), is all 0's on my SD cards? The were formatted as FAT32 under
Win XP. Shouldn't the MBR contain some non-0 data?

-- Pete


Re: SD Card - boot sector
Quoted text here. Click to load it

It doesn't match with what I tried when I tested it (see rest of this
thread) but others report the same behavior you mentioned.

What I got was a populated partition table with an AA55 boot signature
at the end (in the first sector).


Oh! One thing I forgot - Some USB card-reader devices don't give you
physical sector access to the disk; they appear, for want of a better
phrase, on int 24h/int 25h only - not on int 13h. On these devices, you
can't get at the MBR - all you see is the logical volume.

I don't know if they still make readers with this oddity.


Re: SD Card - boot sector
    The card can have the MBR partition table. In this case, the boot sector is
usually sector 63.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
We've slightly trimmed the long signature. Click to see the full one.

Site Timeline