User Tools

Site Tools


projects:hp_4145a_virtual_floppy

HP 4145A Virtual Floppy Drive

I had a co-worker ask if I could copy an old floppy disk. This disk was an old 5.25“ one… I was told it was for an HP 4145A Semiconductor Parameter Analyzer. I said sure, why not… This is where the fun started…

I didn't have the source floppy disk, yet, so I started with some research. I came across this site.

HP 4145A Semiconductor Parameter Analyzer (This site is also the reason I chose DocuWiki, and why I'm posting my work). I'll let you read their site, and try not to copy too much of their stuff. I'll focus on my main findings.

In short, the source floppy is:

  • 5.25” floppy diskette - 90KB…
  • Single Sided, Single Density, FM recording (Typical 360K DOS is MFM)
  • 40 tracks, 9 sectors per track, 256 byte sector size
  • A 360KB from back-in-the-day will work as a destination! 1.2MB will not…

Ok, fine, dandy. Kitsune told us that. This is where I started.

IBM PC

I was looking to quickly copy this disk on a standard IBM-clone PC (naïve). I have a 1.2MB / 360KB drives on hand, and based on Kitsune's work, it looked like a Shugart standard drive (unlike Apple stuff). So, I looked up PC floppy controller information.

In short, the PC floppy controller does support FM mode, which is the Single Density format (MFM being double density). Excellent! Maybe DOS's DEBUG could read the tracks?

I tried, and no.. It seems BIOS functions just want to use default parameters for floppy drives. For a 360KB disk, 512 bytes / sector and MFM. It actually goes further than that! You can format a floppy as single sided. How does DOS know? In early testing, I wiped out Track 0, Head 0, Sector 1 (one based…), and DOS couldn't read the floppy anymore. It seems DOS really want to read the floppy parameters from the BPB (BIOS Parameter Block). Anyways, BIOS INT 0x13 doesn't have parameters for data format (FM/MFM). Problems…

So, with 82077 hardware willing, but BIOS support lacking, what is a person who said they could copy the floppy to do? Dig deeper…

82077

I began with some simple 82077 programming.

First off, programming the FDC is a PITA in PIO mode… I figured DMA and interrupts would be harder in the short term, so I did PIO.

I started by making functions to read and write bytes to the Data Register. You can't just pour bytes into it, so you have to watch the Main Status Register, and lock-step the process. Basically, a function where you pass a command array, and a “packet” length. A way to read command's Result Phase is also needed. You can lock-step it, and detect when all bytes have been read. This was another PITA, but, once it was all working, things were good.

Oh, before I forget, don't practice on you HP 4145A floppy disk. Unobtanium…

Ok, boiler plate code done, I wrote a function to do READ ID, which tells the FDC to report back the first valid Address Mark it comes across, and the number of bytes in the sector. This simple command can tell if parameters are set correctly in the FDC, and that code for writing commands and reading results are valid.

For me, here is what I found to work.

  • The FM/MFM / F bit needs to be 0, to signify FM / Single Density
  • GAP = 26 (base 10) for FM mode and 9 sectors per track. This was GAP1 from Kitsune. Using a standard gap of 0x2a (base 16) caused multiple revolutions to read each sector.
  • GAP = 50 (base 10) for formatting the track. Roughly twice the read GAP.. No documentation, but I forgot how I came to it..
  • Set Configuration Control Register = 2 for 300RPM 360KB floppy drive. Set =1 for 360RPM 1.2MB floppy drive. This is the bitrate. I think 250kbps vs 300kbps…
  • When working with a 360KB 40-Track floppy in a 1.2MB drive, you have to multiply the Track# by 2, because 1.2MB drives have 80 tracks.. This is not automatic. I don't recommend writing a 90KB (360KB) disk on a 1.2MB drive, as the track width isn't right. Reading the disk on a HP 4145A (or any 360KB drive) may not work.

Ok, once the simple command was working, I moved on to Recalibrate, Seek, and Read commands. I only did the single track commands, as I didn't want more complexity.

Like I said, practice on another floppy. I practiced on a DOS formatted 360KB disk with some data on it. I wrote a program to step through all 40 tracks, and each head, reading a track at a time. I sent all this data to a file. I did this a few times, and checked MD5 checksums to validate what I was doing. I also opened the image in WinImage. All was good!

Ok, now we change our settings for FM mode, and read the 90KB HP 4145A disk. Do it a few times. Make sure each reading is the same. Now backup that file. Make it read-only. Cherish it. It is now a copy of the disk you cannot obtain. Go check E-bay. Testers without a floppy are significantly lower cost… But you already knew this, and that is probably why you are here. You know, that glimmer of hope…

So, we now have to write that data to a new floppy disk. The problem is that we can't just write a 360KB floppy and call it good. Remember DOS has 512 byte sectors. We need 256 byte sectors. So, we have to issue a Format command, with FM mode bit=0. Then we write packets for each sector's parameters. Track #, Head # (always 0 since we are single sided), Sector #, and the number of bytes in the sector. You send that packet 9 times, updating the sector # each time. This brings up an interesting side thought… What about the other side? You could just leave whatever was there, without the top tracks, or, write some hidden info that nobody will likely ever read (up to you). Once the track is formatted, you can issue a Write command (per sector, or 9 sectors at once), you know, to save stepping time.

Once you've written it, go and read it, and checksum it. It had better match. If not, you need to look into that..

Horary! You now have a duplicate of your HP 4145A's life blood. Go write a blog and celebrate your success. After all, you've saved the world, right??? Right?

Gotek / FlashFloppy Emulation

Ah, sadly, as an Engineer, you are never satisfied. You have a copy of your precious, but what if, you know, the unthinkable happens… Your floppy drive goes the way of the 360KB floppy disk… I know, I know, shh, don't talk so loud. It's a standard floppy drive, so you can get another. Yeah… Check E-Bay… Those can cost more than a tester… So, we need another solution. Stick with me here, this gets weirder…

Lets look at a Gotek SFR1M44-U100 3.5 Inch 1.44MB USB SSD Floppy Drive Emulator. You can get them on E-Bay, Amazon, etc, for $20-$40. You just need to make sure it looks like this one. There are reasons why (below).

As this drive comes, it won't help us. These things come setup for very specific floppy formats. 1.44MB, 720KB, etc. They also require specially formatted USB sticks. For the problem they are solving (who has reliable 1.44MB media anymore?), they are great.

But, we need 90KB floppies…

So, we will look at FlashFloppy . Sure, there is HxC, and again, they also solve a problem, but for those of us in the USA, they are harder to get, and they are $90+.. If you do get an HxC, which is documented to work, you are pretty much done (except for converting your floppy image). The HxC is ready to go pretty much out of the box. For me, why go simple when you can go convoluted?! Right?

Ok, back to FlashFloppy. FlashFloppy was written to run on the Gotek drive (remember, look for the one pictured above, but there are ways to use others). FlashFloppy is like HxC, in that they emulate the electrical signals coming from a floppy drive. For now, I'll leave it as a home work task of flashing a Gotek with FlashFloppy. They tell you how to do it. I don't need to re-write those instructions and waste those bytes. Remember when 90KB or storage was $$$?

Ok, once you have FlashFloppy up and running, we can place a FAT32 formatted thumb drive with the proper config files to tell FF (FlashFloppy) what kind of drive to emulate, and how. Really, we just tell it Heads=1, Sectors=9, Tracks=40, BPS=256, and FM format. Simple! I'll even give you a ZIP with those config files! Ain't I super? Anyways, once those are there, you just name your 90KB image file in a special way, and FF will emulate your disk!

projects/hp_4145a_virtual_floppy.txt · Last modified: 2019/09/13 15:25 by srbios

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki