Page 1 of 1
Floppy disk write problem
Posted: Mon Jun 21, 2010 11:58 am
by ehenkes
Our FDD driver reads perfect, but at writing we get a "double" at 9 sectors higher (killing the root dir etc.). How can I avoid this failure?
http://prettyos.svn.sourceforge.net/vie ... athrev=538 <--- whole flpydsk.c
http://codepad.org/pEVo6eoE <--- transfer source code
Every advice would be highly appreciated.
Re: Floppy disk write problem
Posted: Mon Jun 21, 2010 12:21 pm
by Combuster
9 sectors happens to be the distance between FAT1 and FAT2, are you accidentally writing (something other than the FAT) twice?
Re: Floppy disk write problem
Posted: Mon Jun 21, 2010 12:55 pm
by ehenkes
are you accidentally writing (something other than the FAT) twice?
No, I do not. This was funny:
Code: Select all
if (forceWrite) // write the current FAT sector to the partition "volume"
{
uint32_t i, sectorFAT;
//======================= HOTFIX =============================ehenkes=============//
if (volume->type == FAT12)
{
volume->fatcopy = 1;
}
//======================= HOTFIX =============================ehenkes=============//
for (i=0, sectorFAT=globalLastFATSectorRead; i<volume->fatcopy; i++, sectorFAT+=volume->fatsize)
{
if (singleSectorWrite(sectorFAT, globalBufferFATSector, volume) != CE_GOOD)
{
return ClusterFailValue;
}
}
Needless to say, volume->fatcopy == 2 for a floppy disk volume. But in this case the root dir was killed by the "+9" twin. Hence, I reduced to fatcopy = 1 that means the FAT2 is written, when the FAT 1 get its data.
But with significantly higher sectors than 1 and 10 it does not work this way. No idea why. The 9 need not to be stable, depends on the position in the track, as far as I remember. Alternative is to read a track, manipulate it in the memory and write it back in whole tracks. But it must be possible to write individual sectors w/o shooting like a MP!
Re: Floppy disk write problem
Posted: Mon Jun 21, 2010 4:56 pm
by ehenkes
I found it by comparison with týndur:
The FDC_CMD_EXT_MULTITRACK is to much, if you want to write single sectors
týndur uses 0x0 as the last byte to send,, whereas I use 0xFF. Any comments?