Troubleshooting
In this section, I'll describe some tips and tricks I learned along the way and provide a few outside-the-box debugging methods I came up with to understand what was happening.
Hardware Tips and Tricks
- Do not power the floppy drive from a GPIO pin! You will fry your microcontroller.
- The bottom 16 pins are for
LOGIC GROUND
not motor ground. - You only need 1 of the bottom 16 pins to be connected, but some of them are not hooked up internally!
- The
READ DATA
pin might need an external pull-up resistor. - You shouldn't have to hook up the 12v pin for a 3.5" floppy drive. Leave that one disconnected.
- Try a different microcontroller. You need at least 16MHz and at that low speed you're gonna have to hit up assembly, probably.
Software Tips and Tricks
- The user space data is not filled with 0x00, as one might think. It's typically filled with
0xF6
. - When performing a write operation, you might need to skip the first pulse you prepared because that initial bit is already accounted for automatically from the barrier code.
- Consider using assembly if you are having timing issues.
- The track can be misaligned, even if you did everything right. Verify you are on the right physical track/cylinder before read/write operations.
- Write unit tests for your MFM encoding functions!
- You need to pull
DRIVE SELECT
pinLOW
before doing anything. Even the Write Protect pin will be unresponsive until this happens. - Keep track of the motor state with a variable so it doesn't get reinitialized frequently. You don't actually want the motor-on routine to happen frequently since it takes 500ms+.
- When performing a write, pre-compute the pulses. Trying to calculate them in realtime will likely mess up your timing.
Debugging
It can be a little tricky to debug some things. Here are a few strategies I came up with.
- To verify your ability to READ data, parse the Sector Metadata. It's present in all (non-corrupt) floppies. If you can read that, you're doing pretty well!
- To verify your ability to WRITE data, consider committing a pattern like
0x13, 0x37
and then read it back. - Do not be afraid to write unit tests for core logic. Especiallly the encoding/decoding bits.
- Write a function to count the number of pulses (S, M, L) in one revolution and then emit that over serial. This will tell you if the timing is right. You should have a healthy amount of all 3 but more short pulses if it's a fresh disk.