May 24, 2022

My first day with the David Gesswein MFM emulator

This is a very nice piece of work. It can be used in two ways. One is to capture data from an existing MFM drive. The other is to emulate (i.e. replace) an MFM drive in an old system.

My interest is solely for its capture and analysis capability, but its emulation capabilities are worth commenting on in passing. With one of these you can keep a disk image as a disk file. These old drives were 10, 20, or 40 megabytes commonly. This is a fairly trivial file size on a modern disk. Being able to keep different disk images, swap them around, even send them to collaborators is a unique ability.

The emulator is based on the BBB (Beaglebone Black) and uses one of the PRU on the BBB to capture the raw MFM bit stream. It can use a BBG (green) as well as a BBB (black).

My friend AJ loaned me one of his that was temporarily collecting dust. Let's see if we can get it set up and reading data from a disk.

Set up my BBB

I take my unit "G" out of the drawer. A note in the box says that I flashed it with a Debian Console image in 2016. It has apparently been sitting in the drawer (for 6 years) ever since, as my interest has wandered to other projects.

David's instructions say to put his prebuilt image onto an SD card and then use it to reflash the BBB. Let us see if we can manage that. We will need a power supply, serial cable, and blank SD card. His prebuild image is 143M in size and downloads in the time it takes to type this sentence.

I find a new micro-SD card, put it into my card reader and plug it in. Linux sets it up as /dev/sdg (be careful to get this right, as copying the BBB to the wrong device can nuke your linux desktop!). Now I do:

unxz BBB-mfm-emu_v2.39.img.xz
su
dd bs=64M if=BBB-mfm-emu_v2.39.img of=/dev/sdg
exit
xz BBB-mfm-emu_v2.39.img
Now, I plug the SD card into the BBB, connect my usb to serial gadget to the console. Fire up picocom at 115200 baud and hook up a 5v/2a power dingus. It dives right in and starts flashing. The four blue LED next to the network connector are running back and forth the whole time and there are plenty of messages on the serial console.
A condensed selection follow:
##enable BBB: eMMC Flasher:
#cmdline=init=/opt/scripts/tools/eMMC/init-eMMC-flasher-v3.sh
100000+0 records in
100000+0 records out
51200000 bytes (51 MB) copied, 3.07247 s, 16.7 MB/s
Syncing: /dev/mmcblk1 complete
-----------------------------
.......
.......
eMMC has been flashed: please wait for device to power down.
.......
.......
INIT: version 2.88 booting
DHCPREQUEST on eth0 to 255.255.255.255 port 67
DHCPREQUEST on eth0 to 255.255.255.255 port 67
No DHCPOFFERS received.
Trying recorded lease 192.168.2.133
PING 192.168.2.10 (192.168.2.10) 56(84) bytes of data.

default username:password is [debian:temppwd]

The IP Address for eth0 is: 192.168.2.136
The IP Address for usb0 is: 192.168.7.2
[  261.934644] Disabling non-boot CPUs ...
[  261.939272] System halted.
It all takes less than 5 minutes. Near the end all 4 blue LED are on solid, then finally the lights all go out and it is done.

I remove the SD card, connect a network cable, and power cycle the unit. I see the usual semi-random activity on the LED, and finally on the console, I see:

default username:password is [debian:temppwd]

The IP Address for eth0 is: 192.168.2.136
The IP Address for usb0 is: 192.168.7.2
beaglebone login:
I thought that the 192.168.2.x address business was going to be a headache, but that apparently is just misleading. Typing ifconfig -a shows the IP to be 192.168.0.126 on my local network. This is in my DHCP range. I set up an alias "mfm" in my /etc/hosts and:
ssh debian@mfm
su
It won't let me do "su" over an ssh connection, but it is OK from the serial console. So let me set some passwords for tom and root. I will leave debian alone.
su
useradd tom
mkdir /home/tom
cd /home
chown tom:tom tom
passwd tom
passwd
sync
halt
Halt gives me a kernel panic, but I am quite used to seeing that on BBB, and what can you do about it anyhow, it is somebody elses problem.

Now the BBB gets mated to the Gesswein board. No way to hook up a serial console now! Also careful reading of David's instructions state:

Don't use the barrel jack when the MFM board is installed if the DC/DC converter U12 is also installed on the MFM board.
That is interesting and not what I would have expected. Apparently the BBB will get powered from the Gesswein board via the power on the molex connector. A little DC/DC board is indeed installed on the Gesswein board AJ loaned me. Good thing I didn't rush along and try to power it from the barrel jack. I can put that power supply away.

I hook up a network cable and power via the usual drive molex and away we go again. I ssh in, the date looks correct.

I am trying to follow the test instructions and I am told to try a powerfail script. After a bit of searching, I find it at /root/powerfail.

su
cd /root/powerfail
./powerfail --debug --powercmd true --threshold 0
Unable to open A/D device /sys/bus/iio/devices/iio:device0/in_voltage0_raw:
  No such file or directory
echo cape-bone-iio > /sys/devices/bone_capemgr.*/slots
./powerfail --debug --powercmd true --threshold 0
Average 12.41V max 12.42V min 12.41V
poweroff -f
It just powers down once and for all, which is OK by me. My ssh connection is dead, but the big red light on the emulator is on forever thanks to the big capacitors. For my purposes, I don't think it matters if it works or not and I move along.

Try the ST225 drive I recently bought at a "surplus store"

This turns out to be a dead end, so just skip to the next section.

I drag out an ST225 drive I bought at a surplus store for just this purpose and the cables I intend to use. I use some paint thinner to clean sticky tape residue off my cables and I am ready to go. Now some questions.

I don't quickly find answers to this, so I am watching the "Adrian's basement" video.

Apparently J3 and J4 are the connectors I want for reading. I find a 34 pin cable without a twist, so I can eliminate that question. My 20 pin cable has a hole obstructed by a plastic key, so I will need to extract that somehow to plug it into the emulator. This turns out to be an easy 10 second operation with a pin probe and I am now all cabled up.

I verify that the write enable jumper P1 is removed. He also recommends powering up the drive after the BBB is booted and the script "setup_mfm_read" has been run. This won't be easy with the drive and the emulator powered from the same supply.

I apply power. No smoke or fire. The disk sounds as such a disk usually does and the BBB boots up powered from the emulator.

ssh mfm
su -
cd mfm
./mfm_read
Unable to open pin 61, did you run the setup script?
Nope, I didn't. I get the feeling there must be some documentation somewhere I missed out on. (And there is, see "example usage" below).
root@beaglebone:~/mfm# ./setup_mfm_read
Rev B Board
oot@beaglebone:~/mfm# ./mfm_read
Board revision A detected
Drive must be between 1 and 4
I create a bash script to hold the long command line and call it "zrun". I put this inside:
#!/bin/bash
./mfm_read --drive 1 --analyze --emulation_file ../emu1 --extracted_data_file ../stdata
Then I type:
root@beaglebone:~/mfm# ./zrun
Board revision A detected
Found drive at select 2
Drive RPM 3599.9
Primary transition period 140 ns, should be around 200
Primary transition period 140 ns, should be around 200
Retrying on cylinder 0 head 1
Primary transition period 140 ns, should be around 200
Unable to determine drive format
Well, we learned the drive is jumpered for drive select 2 anyway.

Ah -- there is a link "example usage" which turns out to be the gold mine about how to actually use the board:

The ST225 has 615 cylinders, 4 heads (2 disks), 17 sectors per track. Precomp at 300. 512 bytes per sector. Landing zone at 670.

So, away we go using the second method as per the documentation I found. It goes fast reporting cylinders on multiples of 5.

./mfm_read --emulation_file ../emu1 --cylinders 615 --heads 4 --drive 2
Board revision A detected
Track read time in ms min 21.254209 max 3576.761833 avg 41.245358
For fun, I run this a second time, but let it put data in a file "emu2". When this finishes, I see:
ls -l
-rw-r--r-- 1 root   root   51286213 May 23 22:56 emu1
Heck with this drive, let's get brave and try the Callan drive which is what I am really interested in. (It looks like this ST225 may have been wiped clean, i.e deformatted -- maybe)

Let's try the Callan drive

root@beaglebone: ./mfm_read --analyze --emulation_file ../callan_emu1 --extracted_data_file ../callan_data1

Board revision A detected
Found drive at select 1
Drive RPM 3604.0
Matches count 34 for controller WD_1006
Header CRC: Polynomial 0x1021 length 16 initial value 0xffff
Sector length 512
Data CRC: Polynomial 0x140a0445 length 32 initial value 0xffffffff
Selected head 8 found 0, last good head found 7
Read errors trying to determine sector numbering, results may be in error
Number of heads 8 number of sectors 17 first sector 0
Interleave (not checked): 0 9 1 10 2 11 3 12 4 13 5 14 6 15 7 16 8
Drive supports buffered seeks (ST412)
Found cylinder 0 expected 256
Found cylinder 1 expected 257
Stopping end of disk search due to mismatching cylinder count
Number of cylinders 256, 17.8 MB

Command line to read disk:
--format WD_1006 --sectors 17,0 --heads 8 --cylinders 256 --header_crc 0xffff,0x1021,16,0 --data_crc  0xffffffff,0x140a0445,32,6 --sector_length 512 --retries 50,4 --drive 1
Expected sector size 512 header says 256 cyl 0 head 0 sector 0
Expected sector size 512 header says 256 cyl 0 head 0 sector 6
Expected sector size 512 header says 256 cyl 0 head 0 sector 12
Expected sector size 512 header says 256 cyl 0 head 0 sector 1
Expected sector size 512 header says 256 cyl 0 head 0 sector 7
Expected sector size 512 header says 256 cyl 0 head 0 sector 13
Expected sector size 512 header says 256 cyl 0 head 0 sector 2
Expected sector size 512 header says 256 cyl 0 head 0 sector 8
Expected sector size 512 header says 256 cyl 0 head 0 sector 14
....
Expected sector size 512 header says 256 cyl 255 head 7 sector 8
Found cyl 0 to 255, head 0 to 7, sector 0 to 16
Expected 34816 sectors got 34814 good sectors, 0 bad header, 2 bad data
0 sectors marked bad or spare
1 sectors corrected with ECC. Max bits in burst corrected 1
Track read time in ms min 29.197292 max 3488.321875 avg 42.575290
The disk is in fact a Rodime 204 with 4 physical disks (hence 8 heads), formatted with 256 byte sectors (32 per track), and it has 320 cylinders.

Next I did this:

./mfm_read --transitions_file ../callan_raw1 --drive 1 --heads 8 --cylinders 320
./mfm_read --transitions_file ../callan_raw2 --drive 1 --heads 8 --cylinders 320
These ran fine with no errors reported.
Feedback? Questions? Drop me a line!

Tom's Computer Info / [email protected]