Floppy disk write problem

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
ehenkes
Member
Member
Posts: 124
Joined: Mon Mar 23, 2009 3:15 am
Location: Germany
Contact:

Floppy disk write problem

Post 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.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Floppy disk write problem

Post by Combuster »

9 sectors happens to be the distance between FAT1 and FAT2, are you accidentally writing (something other than the FAT) twice?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
ehenkes
Member
Member
Posts: 124
Joined: Mon Mar 23, 2009 3:15 am
Location: Germany
Contact:

Re: Floppy disk write problem

Post 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. :mrgreen:

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!
User avatar
ehenkes
Member
Member
Posts: 124
Joined: Mon Mar 23, 2009 3:15 am
Location: Germany
Contact:

Re: Floppy disk write problem

Post 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 :mrgreen:

týndur uses 0x0 as the last byte to send,, whereas I use 0xFF. Any comments?
Post Reply