fdrawcmd(1)
π fdrawcmd π
welcome to the fdrawcmd(1) page bestie, straight outta the General Commands Manual β¨ this is the tool that lets you slide into the floppy disk controller's DMs with zero filter, and honestly? iconic behavior.
π NAME π
fdrawcmd β send raw commands to the floppy disk controller
like, raw raw. no wrapper, no vibes-based abstraction, just you and the silicon π
π¨ NOTE π¨
okay bestie before we go any further, you gotta know something about this manpage itself: it has been automatically generated from fdutils's texinfo documentation. and the process is only approximative π β some items, such as cross-references, footnotes and indices, are lost in that translation. and it's not just that: only the items specific to each command got translated, and the general information about fdutils got dropped in the manpage version. so the author strongly advises you to use the original texinfo doc. periodt.
here's how to get the good versions:
- To generate a printable copy from the texinfo doc, run the following commands:
./configure; make dvi; dvips fdutils.dvi
- To generate a HTML copy, run:
./configure; make html
a pre-made HTML can be found at: http://www.tux.org/pub/knaff/fdutils
- To generate an info copy (browsable using emacs' info mode), run:
./configure; make info
the texinfo doc looks most pretty when printed or as HTML π indeed, in the info version certain examples are difficult to read due to the quoting conventions used in info. so yeah. printed or HTML. those are the vibes.
π¦ DESCRIPTION π¦
okay so here's the whole shape of it:
fdrawcmd [drive=drive] [rate=rate]
[length=length] [repeat=repeat]
[cylinder=physical-cyl] command [parameters ...] [mode]
fdrawcmd is used to send raw commands to the floppy disk controller, after having selected a given drive. you must have write permission to the selected drive. no permission, no party π
when writing to a disk, data is read from stdin; when reading, data is printed to stdout. and the gossip? the diagnostic messages, the return values from the controller, and the value of the disk change line after the command all get printed to stderr π¬
β¨ OPTIONS β¨
first up, the glow-up rule for numbers: all numbers may be given in octal (0211), decimal (137), or hexadecimal (0x89). pick your fighter π
drive=driveβ Selects the drive. the default is drive 0 (/dev/fd0).rate=rateβ Selects the data transfer rate. Use0for high density disks,1for double density 5 1/4 disks (or 2 Mbps tapes, if the appropriate rate table is selected), and2for double density 3 1/2 disks.length=lengthβ Describes the length of the transferred data for commands reading from and writing to the disk. The default is to continue until end of file.repeat=countβ Repeat the command count times. heads up though: this only works correctly for commands which don't do any data transfer.cylinder=countβ Seek to the given cylinder before executing the command.commandβ The name of the command to send. command may be a spelled out name (likereadorwrite), or a number representing the command's floppy disk controller opcode. a named command has already a mode associated with it, whereas for a number the mode parameter should be described using the mode option.parametersβ The parameters for the command (optional, not all commands need parameters).modeβ Various flags or'ed together describing the properties of the command.
π COMMANDS π
lowkey a disclaimer first: the description of the various floppy commands given in this manpage is very sketchy. for more details get the 82078 spec sheet which can be found at:
http://www-techdoc.intel.com/docs/periph/fd_contr/datasheets/
look for the chapter COMMAND SET/DESCRIPTIONS. older FDCs only support a subset of the commands described therein, but the syntax for the commands that do exist is the same. so don't come for me about the sketchiness, go read the spec sheet π«Ά
πΈ Commands available on all FDCs
read drvsel cyl head sect szcod spt rw-gap szcod2β Readslengthbytes of data from the disk.drvselis the drive selector: bit 0 and 1 describe the drive, and bit 2 describes the head. the remaining parameters give the cylinder, the head (yes, again π), the sector, the size of the sector (128 * 2 ^ szcod), the sectors per track (sptβ this is used to switch to the second head when the first side has been read), and the size of the read-write gap.szcod2should be0xff.readreturnsST0 ST1 ST2andcyl head sect szcodof the next sector to be read; see/usr/include/linux/fdreg.h.
N.B. Certain newer floppy disk controllers are buggy, and do not correctly recognize the end of transfer when operating in virtual DMA mode. For these, you need to setsptto the id of the last sector to be read (for example, if you intend to read sectors 2, 3, 4, setsptto 4, even if the disk has more sectors), and set theno-mtflag.
write drvsel cyl head sect szcod spt rw-gap szcod2β Analogous toread.sense drvselβ Returns the third status byte (ST3).recalibrate drvselβ Recalibrates the drive and returnsST0 ST1.seek drvsel cylβ Moves the head tocyland returnsST0 ST1.specify drvsel spec1 spec2β Specify various parameters to the drive.format drvsel szcod sect-per-track fmt-gap fmt-fillβ Formats the cylinder. the new sectors are filled withfmt-fill. the header information comes from the input, which is made up ofcyl head sect szcodquadruples. theszcodparameter from the command line is used to describe the actual size of the sectors, and theszcodfrom the input is used to write into the header. however β and this is the spicy part π₯ β the first write to these sectors will use the header information, and might overwrite the following sectors if theszcodparameter from the command line was too small.readid drvselβ reads the first sector header that comes and returnsST0 ST1 ST2andcyl head sect szcodof the encountered header.
π Commands available on 82072 and later
dumpregsβ Prints the contents of the FDC's registers, if supported.
π§ Commands available on 82072A and later
configure conf1 conf2 conf3β Configures FIFO operation.
β Commands available on 82077 and later
versionβ Echoes0x90if the FDC is more recent than 82072A, and0x80otherwise.perpendicular rateβ Sets the perpendicular mode. Use0for normal,2for 500kb/s perpendicular, and3for 1 Mb/s perpendicular.seek_out drvsel nβ does a relative seek ofncylinders towards cylinder 0.seek_in drvsel nβ does a relative seek ofncylinders away from cylinder 0.
π Commands available on 82077AA and later
lockβ Locks the FIFO configuration, so that it survives a FDC software reset.unlockβ Unlock the FIFO configuration.
π₯ Commands available on 82078
partidβ echoes a byte describing the type of the FDC in the 3 high bits, and the stepping in the three low bits.powerdown powerconfβ configures automatic power down of the FDC. the old configuration is echoed.option isoβ enables/disables ISO formats. odd values ofisoenable these formats, whereas even values disable them. ISO formats don't have index headers, and thus allow one to fit slightly more data on a disk. (slightly more data?? slay π )saveβ prints out 16 internal registers of the FDC.restore r1 r2 r3 ... r16β restores the 16 internal registers of the FDC.format_n_write drvsel szcod sect-per-track fmt-gap fmt-fillβ formats the cylinder and writes initial data to it. the input data is made up of a sequence of headers (4 bytes) and data:header1 data1 header2 data2 ... headern datandrivespec dspec1 dspec2 ... specn terminatorβ chooses rate tables for various drives. eachdspecbyte describes one drive. bits 0 and 1 say which drive is described. bits 2 and 3 describe the rate table. only tables 0 and 2 are interesting. both tables only differ in the meaning of rate 1. for table 0 (the default) rate 0 is 300 kb/s (used for 5 1/4 DD disks), whereas for table 1 it is 2 Mbps (used for fast floppy tape drives). bit 4 is the precompensation table select bit. it should be set to 0. bit 5-7 should be zero as well. the terminator byte ends thedrivespeccommand. it is either0xc0or0x80. if it is0xc0, no result phase follows; if it is0x80, the current data rate table configuration for the four drives is echoed.
π MODES π
the mode option is only needed when you describe the command as a numerical value. some mode names are also valid command names. they are considered as command name if the command name has not yet been given, and as mode name otherwise. iykyk β¨
- If you give a command name followed by explicit modes, both the implicit flags of the command name, and the explicit modes are or'ed together.
- If on the other hand you give a command name preceded by explicit modes, only the explicit modes are or'ed together.
and now, the modes themselves:
readβ Read data from disk using DMA.writeβ Write data to the disk.intrβ Wait for an interrupt.spinβ wait for the disk to spin up.diskβ Aborts the operation if no disk is in the drive. this only works if you also chose a physical cylinder to seek to.no-motorβ Don't switch on the drive motor while issuing the command.no-motor-afterβ Switch off the motor immediately after the command returns.fmβ Uses the FM version of theread,readid,writeandformatcommands.no-mtβ Do not use MT (multitrack) mode for theread,readidandwritecommands. this is needed on certain broken FDC's which don't recognize end of transfer when running in nodma mode. in order to use these safely, setno-mt, and chose the id of the last sector to be read assect-per-track.
one more thing bestie:fdrawcmdopens the device node with theNDELAYflag. this means that the driver should not try to autodetect the disk type (it might not be formatted), and that it should not reset the FDC. if a reset was needed, the command simply fails. if that happens, executefloppycontrol --resetnow 0, and try again. you got this π«Ά
π SEE ALSO π
Fdutils' texinfo doc
okay that's the whole page bestie, and this one's a fdutils-5.6 classic from 27Jan21 β go forth and talk to your floppy controller, it's giving main character energy ππ¦π
π¦ where this page comes from
- debian bookworm: fdutils 5.6-4 Β· GPL-2.0-or-later
- debian trixie: fdutils 5.6-4+b1 Β· GPL-2.0-or-later
- ubuntu jammy: fdutils 5.6-2 Β· GPL-2.0-or-later
- ubuntu noble: fdutils 5.6-4 Β· GPL-2.0-or-later
- ubuntu questing: fdutils 5.6-5
- ubuntu resolute: fdutils 5.6-5build1 Β· GPL-2.0-or-later
- ubuntu stonking: fdutils 5.6-5build1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms