Altera_Forum
Honored Contributor
21 years agoReading the first sector of a CF card
I'm trying to read the first sector of a compact flash card. This is the boot sector and bpb of a fat filesystem. This sector has a lot of information about how the filesystem is(number of sectors, bytes per sector, sector per cluster, etc). The problem is that i cant read it. I can read the second sector. I'm using the compact flash component from this forum and the source code with modifications. This is the code for the test application:
/* This testapplication shall read the bpb*/
# include "system.h"# include "ideutils.h"# include <stdio.h>
int main(void)
{
char *egenstr = "0 0 0";
if (IDE_initialize()) {//We can do some after this
readCHS(egenstr); //trying to read first sector..
}
else
{
printf("Cannot initialize IDE device.\r");
}
IDE_deinitialize();
printf("\rgoodbye\r\r4");
return 0;
} And this is the output: wrote and verified 10 values successfully.
Identify Device:
serial number: 001705A0603R4656
firmware revision: Vdg 1.23
model number: SanDisk SDCFB-32
LBA mode supported
PIO mode supported: 4
device parameters:
# logical cylinders: 490
# logical heads: 4
# logical sectors/track: 32
LBA capacity = 62720 sectors
successfully wrote default parameters to IDE drive.
readCHS: cylinder: 0; head; 0; sector: 0
CHS = (0, 0, 0); numSectors: 1
timeout awaiting DRQ=1
error register: 0x10
timeout awaiting DRQ in readSectorsCHS()
DRQ not set in status reg in readSectorsCHS()
readCHS() failed.
goodbye I've tried to increase the awaitDRQ time, but it's no use. Is it possible that this card isn't formatted properly? (It's not the one that came with the Nios Development kit.) Thanks for any help. -Ole Kristian Tørresen