This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: IDE + fatfs issues


Hey All

I'm revisiting my attempt to read a CompactFlash card using IDE/fatfs, and am still looking at these same issues...

David Brennan wrote:
I have a couple of questions about the implementation "rules" that are
checked on both IDE and fatfs "devices".

IDE:
On or about line 372 of ide_disk.c within function ide_disk_init()
after identifying the disk, the "Type" is verified:
if (((ide_idData->general_conf>>8)&0x1f)!=2) {
diag_printf("IDE device %d:%d is not a hard disk!\n",
info->port, info->chan);
return false;
}
Looking at ATA specs, even going back a few years, it appears that the bits used to make this test are considered "retired". Therefore this test appears to be invalid and should be removed.

fatfs:
On or about line 1885 of fatfs_supp.c within function fatfs_init()
after reading the boot record, a number of fields are validated:
    // Check some known boot record values
    if (0x29 != boot_rec.ext_sig       ||
        0x55 != boot_rec.exe_marker[0] ||
        0xAA != boot_rec.exe_marker[1])
        return EINVAL;

I believe the first test is not always valid. On my Compact Flash
card, formatted with FreeDOS v0.9 beta, this field is 0x00. According
to Microsoft's documentation for fatfs, Windows NT requires this to be
either 0x28 or 0x29. I found other documentation that states that if
it is 0x29, then the next 3 fields are valid, but 0x00 was also valid.
As a temporary fix, I just hacked out the first check. I can submit a
"true" patch for this if requested. But I thought I would look for
some opinions first.
To me it appears that the code is reading the disk's MBR and *not* the FAT boot sector of the first partition. For a hard drive, doesn't the code need to read the first sector of the drive (the MBR), parse the partition table contained therein, then read in the sector indicated by the partition table? Or am I reading this wrong?

- Frank

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]