Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Sector 0 in a Compactflash

Status
Not open for further replies.

Tulkas

Member level 4
Joined
May 30, 2002
Messages
70
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Activity points
646
dump sector compact flash

How can i access to this sector directly with a microcontroller. I have to start reading sectors (hidden sectors) until i find it, but this is an ugly method. Fat spec. says the first sector is sector 0, but really the first sectors are hidden sectors (in some CF) and then i can't access to sector 0.

Thanks. Sorry for my English.
 

compact flash mbr

The first sector (the one you get with C,H,S=0,0,1 or LBA=0) is the Master Boot Record, which contains the Master Partition Table.

From this table you get information on how the disk is partitioned. A FAT formatted partition will count sectors relative to the start of the partition, not from the start of the disk.

There are loads of places on the net to find more information about this.

For example see http://www.maverick-os.dk/FileSystemFormats/Standard_DiskFormat.html.

Hope this helps a bit.
 

mbr not in sector 0 in sd cards

The boot sector is always placed in the first sector of the partition. So, you will have to offset all sector calculations from the beginning of the partition.
I found this site very useful when I started with fat16 development, except mine was on an MMC. Hope it helps you.
**broken link removed**
 
  • Like
Reactions: js

    js

    Points: 2
    Helpful Answer Positive Rating
mbr compact flash

Ok, thanks. I want to read boot sector to get information about sectors per cluster, total sectors, etc, etc. But sometimes this sector is in LBA=32 or LBA = 64, etc, because there are hidden sectors, boot sector not always is in LBA=0, i need to know where it is. Until now i am reading first byte of all sectors from 0, when this byte is 0xEB then i am reading boot sector, and for access to the rest sectors i have to add this offset.
 

how to access different sectors in compact flash

These are the addresses I probed on my MMC card. Fits perfectly with the specifications for a freshly formatted MMC card. Maybe you've got the addresses wrong. Note that the following applies for FAT16

Partition Entries (Absolute byte addresses):-
Code:
#DEFINE	PARTITION1	0x01BE
#DEFINE	PARTITION2	0x01CE
#DEFINE	PARTITION3	0x01DE
#DEFINE	PARTITION4	0x01EE

Start of Partition:-
PartitionStart=((First Sector Relative Position)+1)*(No of bytes per sector)

Address of BPB:-
- Same as PartitionStart (ie sector zero)

Address of FAT table:-
FATStart=PartitionStart+(BPB_RsvdSecCnt)*(No of bytes per sector)

Address of Root Directory:-
RootDirStart=FATStart+(BPB_FATSz16)*(No of bytes per sector)*(BPB_NumFATs)

Address of first data sector:-
DataStart=RootDirStart+(BPB_RootEntCnt)*32
 

compact flash sector zero description

Tulkas said:
Ok, thanks. I want to read boot sector to get information about sectors per cluster, total sectors, etc, etc. But sometimes this sector is in LBA=32 or LBA = 64, etc, because there are hidden sectors, boot sector not always is in LBA=0, i need to know where it is. Until now i am reading first byte of all sectors from 0, when this byte is 0xEB then i am reading boot sector, and for access to the rest sectors i have to add this offset.

I think you are confusing the Master Boot Record and the Boot Sector.

You find the master boot record at LBA=0, from there you can find the partion start addresses. And there you find your Boot Sector.

Just read the official Microsoft documentation carefully:

**broken link removed**
 

compact flash sector zero

Ok, oK, but Master Boot Record not always is in LBA = 0. i have some CF and i have to read the MBR with an offset, 32, 63, etc, etc. I don`'t understand nothing.
 

reading sector 0 c++

Then can you post a sector dump from LBA=0 (for say the first 128 sectors)? Are you accessing the card in True IDE mode?
 

reading sector 0 sd card c++

I'm accessing the card in true ide mode. The dump of LBA = 0 is the file LBA0 and the dump of LBA = 32 (where i read the MBR) is LBA32.
 

boot sector jump code 0xeb

I see. It looks like the card is formatted like a diskette (not uncommon amongst removable disks), which means there is no Master Boot Record.

Sector 0 is the Volume Boot Record, since there is only one partition.

As I see it (for your first sector):

00h - jump code (EB 3C) + NOP (90)
0Bh - bytes per sector (WORD) = 512
0Dh - sectors per cluster (BYTE) = 4
0Eh - reserved sectors (WORD) = 1
10h - copies of FAT (BYTE) = 2
11h - max Root Dir entries (WORD) = 512
13h - numbers of sectors for partition < 32 MB (WORD) = 62,560 (=32,030,720 bytes on card)
15h - media discriptor (BYTE) = F8 (hard disk)
16h - sectors per FAT (WORD) = 61
1Ch - hidden sectors in partition (DWORD) = 32
20h - numbers of sectors for partition >= 32 MB (DWORD) = 0
26h - Extedned Signature (BYTE) = 29h
2Bh - Volume Name (11 bytes) = NO NAME
36h - FAT name (8 bytes) = FAT16
1FEh - Executable Marker = 55AA

So reserved sectors + hidden sectors = 33, that means the first FAT should be at sector 33. After the 2 FATs you should find the first directory entry.

Can you confirm this?
 

view mbr compact flash hex program

ok, first fat is at sector 33. But my question is, how can i know how many hidden sectors there is in the CF. If MBR is located in LBA=0 is very easy, but in all my cards MBR is in others sectors. My method is search for 'jump code' at start of each sectors from LBA = 0, but i don't think that a software which reads CF do it like me.

I hope that my question is understood.

Thanks.
 

mbr cf sector 0

If it is a card readable by Windows, there should be a Master/Volume Boot Record at the first sector.

When you have cards with a structure unlike this, please post a sector dump here, I'm curious. :)
 

cf bpb sector 0

**broken link removed**

- FlashFile A File System Library & Communications Protocol For Atmel AVR Microcontrollers and Secure Digital & Multimedia Cards or Compact Flash Cards
 

read sector 0 from cf

goshka said:
h**p://www.prllc.com/products/FlashFileCF.zip

- FlashFile A File System Library & Communications Protocol For Atmel AVR Microcontrollers and Secure Digital & Multimedia Cards or Compact Flash Cards

:? Ehm, yes, a password protected ZIP file?
 

windows format compact flash at 63 sectors track

you must buy this library to get the password
 

lba sector 0

Yes.
**broken link removed**
 

format sector 0 compact flash

free:
**broken link removed**
 

compact flash sector 0

**broken link removed**
 

64 compact flash boot record

Somebody can post a sector dump (LBA=0) of a CF card??.

Thanks.
 

sectors compact flash

CF sector0 format is similar hdd sector0 format accurately.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top