- About Kitsune Denshi
- Components
- Electric Items
- Equipment
- Hacks!
- Projects
This is an old revision of the document!
The 4145A boots from a 5.25“ floppy disk, which is also used to hold user data. The format of the disk is sufficiently unusual (or rather, antique) that modern PCs will likely struggle to read the disks. However, due to the age of the original disk (mine is from 1989) and the fact that without it, the 4145A is nothing more than a very effective door stop, I was really keen to read the disk and come up with a method of duplicating it.
If you have a computer that supports the following format, you should not have any trouble reading or writing the 4145A's disk:
In that case, you can just copy disks as you please and keep your 4145A alive forever - at least until the drive gives up the ghost.
The floppy controller inside the 4145A is a Fujitsu MB8866, which is thankfully placed on a separate board together with the HP-IB controller and is connected to the main CPU through a parallel data bus. This means that both the disk drive and the controller board can be removed from the 4145A and easily interfaced to something else in isolation. In my case, I decided to interface the controller to an mbed, which in hindsight may not have been the best choice: Some of the bus IO functions are surprisingly slow for a 96MHz ARM Cortex-M3, and it was just barely fast enough to interface to the controller. What a sad sign of the times.
Unfortunately, the datasheet for the MB8866 is rather sparse, and it definitely didn't contain enough information to successfully interface to it. However, a lot of the floppy controllers from that time are largely compatible - they share a similar interface, commands and internal state machines. I was very lucky to come across an excellent datasheet / app note for a TI TMS279X (which itself is a somewhat compatible copy of a WD FD179X), which allowed me to successfully talk to the MB8866. There are significant differences in the external and internal circuitry of these devices (e.g. internal vs. external VCO capacitors), but since I am using the HP 4145A's controller board all of this has been taken care of. The only differences I did need to care about are some minor ones in some control bits.
The figure below illustrated how the floppy controller board (“A9 board”, as per the service manual) is connected to the mbed. I used a 74LVC245 as a level shifter on the data bus to do a tidy job for once. Level shifting isn't needed on any other signals because the MB8866 is happy with 3.3V logic levels at its inputs and its only other two outputs to the mbed are open collector, which are pulled up to 3.3V.
Interfacing to the mbed.
The following table shows the connection of all the signals. As you can also see in the figure below, all connections to ICs are made using small probe hooks - by far the most convenient solution in my opinion. However, all signals are also available on the card edge connector.
Note that you need to supply an external 4MHz clock to the A9 board, as well as a 5V power supply. Do not use the mbed's VBUS for this purpose, as the board will draw >700mA. Besides, you will need an external 5V and 12V power supply anyway for the floppy drive.
Connection on A9 board | Name on A9 board | Connection on mbed | Name on mbed | Function |
---|---|---|---|---|
U2-4 | FDSEL | p21 | fd_sel | Activates floppy drive |
U16-4 | B4MHz | Signal generator 4MHz 0-5V | Clock for MB8866 | |
U5-10 | nFDCMR | p23 | n_reset | Resets the MB8866 |
U5-9 | nPRGRST | |||
U3[7..14] | IOD[0..7] | p[13..20] | data_bus | Data bus (connected through '245) |
U6-13 | BBA2 | p24 | n_cs | MB8866 Chip Select |
U6-12 | nFDDCS | |||
U11-2 | B02TTL | p25 | rw_en | Enables nWE or nEE on the MB8866 |
U11-3 | R/nW | p26 | rw | high = read, low = write |
U3[5..6] | BBA[0..1] | p[27..28] | address_bus | Address “bus” |
U11-5 | nHP-IB | VOUT (3.3V) | HP-IB controller Chip Select | |
U3-38 | (DRQ) | p29 | drq | Data request in read/write operations |
U3-39 | (INTRQ) | p30 | intrq | Interrupt request (operation complete) |
Test point 1 | GND | GND | ||
Test point 4 | +5V | NC | 5V power supply for A9 board | |
Test point 5 | +12V | NC | 12V power supply for A9 board (not needed |
A9 board connected to mbed.
The firmware on the mbed is rather simple. It connects to a PC through the USB UART, from which it takes commands and to which it returns data. Its functions are:
On the PC, there is a collection of very hacky scripts that talk to the mbed and perform various tasks.
This is very useful to establish the exact format used on the disk. By looking at the raw track information, the exact gap sizes, sync bytes, and sector header and size can be determined.
./diskread.py > original_disk_tracks.txt
This gets all the data (as seen by the processor) from the disk. Since the controller also checks the CRCs of the sectors, reading out the data this way almost guarantees a good (or at least known bad) disk image.
./diskread_sectors.py > original_disk_sectors.txt
The raw track information read out earlier cannot simply be written back to make a copy of a disk for two reasons: First, only data written in one go after a sync byte is guaranteed to be valid. This means that as the whole track is read, there is some uncertainty and wrong data in the gaps between sectors. Second, in write track mode, the controller uses certain data bytes as special commands to write address marks or CRCs (e.g. instructing the controller to write 0xF7 will actually write two bytes of CRC to the disk).
Therefore, a special disk image must be created first which contains all of these control characters in the right places, and does not contain any data that could be interpreted by the controller as control characters.
./make_image.py > blank_disk.txt
This will write the previously generated blank image to the disk (a new one, hopefully!), which generates the sector structure on the disk and hence effectively formats the disk:
./diskwrite.py < blank_disk.txt
Now that the disk is properly formatted, the previously read data can be written back to the disk, sector-by-sector.
./diskwrite_sectors.py < original_disk_sectors.txt
The new disk now contains a faithful copy of the original, and certainly my 4145A didn't mind booting off it.
The drive used in the 4145A doesn't seem to want to write to HD disks. Which isn't entirely surprising, because they have slightly different magnetic properties. So make sure you use a double density (DD) disk with the 4145A's drive. Of course, it would be perfectly feasible to hook up a HD drive to the controller card, write a HD disk through the MB8866 and then put the HD drive into the 4145A instead of the original one.