SD Card - boot sector

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

Reply to
Peter Sommerfeld
Loading thread data ...

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

Reply to
larwe

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

Reply to
psommerfeld

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.

formatting link

Reply to
larwe

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 snipped-for-privacy@storagecraft.com

formatting link

Reply to
Maxim S. Shatskih

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
maxim@storagecraft.com
http://www.storagecraft.com
Reply to
Maxim S. Shatskih

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

Reply to
Ross Marchant

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.

Reply to
larwe

That's an amazingly broad generalization, broad to the point of being dangerously wrong. It depends entirely on the size of the card - because it's determined by the reported CHS geometry of the card, presumably for legacy FDISK reasons. The LBR is generally _one track_ away from the MBR.

For the specific sizes of SD card you've used in recent times, maybe spt was always 63.

The OP's post clearly shows that your generalization isn't even true for the cards he happens to have lying about.

Reply to
larwe

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 bs=512 count=100

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.

Reply to
larwe

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]

Reply to
Beverly Howard [Ms-MVP/MobileDev]

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

Reply to
Ross Marchant

What about USB and Firewire disks?

Paul

Reply to
Paul Black

They're not "removable".

-- Grant Edwards grante Yow! Hmmm... a CRIPPLED at ACCOUNTANT with a FALAFEL visi.com sandwich is HIT by a TROLLEY-CAR...

Reply to
Grant Edwards

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).

Reply to
larwe

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!
                               visi.com
Reply to
Grant Edwards

Exactly. Saw this personally on Iomega ZipDrive.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com
Reply to
Maxim S. Shatskih

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

Reply to
psommerfeld

First - CHS geometry on a flash card if a fake.

Second - CHS geometry on post-1995 hard disks is a fake too.

Third - in Windows, if the disk is not registered in BIOS, then Windows assumes S=63 and H=255, with a cylinder of 8MB. This is hard-coded to Windows Disk.sys driver.

Fourth - if the hard disk is registered in BIOS as LBA, then again S=63 and H=255.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com
Reply to
Maxim S. Shatskih

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.

Reply to
larwe

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.