• Hello MLAers! We've re-enabled auto-approval for accounts. If you are still waiting on account approval, please check this thread for more information.

HD20 Schematics required

BTW, just one thing I want to clarify a bit when I toss an idea/technical guess into this thread... if I fail to throw a "kudos" for the work you've done so far or come across as a bit "critical" it's just me being me. (Which is usually "busy and not having a whole lot of time to compose my thoughts".) You deserve a lot of credit for taking this project this far... *much* further than usually seems to happen with these "wouldn't it be cool if someone made a device to do X for my old Mac, like other people have made to do X for their (insert other obsolete system here) machines?" threads. If I suggest that you do something differently from how you're doing it you can usually take it as an honest attempt to be helpful rather than simply being contrary or critical.

So, with that out of the way: I can certainly see the value in your suggestion of logging conversations with the HD-20 without necessarily understanding them so you can perform experiments like playing back what appears to be the initialization acknowledgement to see if it tricks the Mac into thinking an HD-20 is attached when one isn't. That said, I still think it might be of great value to downplay the HD-20 *temporarily* and concentrate on nailing down what it takes to make your microcontroller fully conversant with "IWM-speak". I'm a big believer in looking for opportunities to break big projects into smaller modules that can be tackled individually, and with the documentation you have on hand perfecting your IWM signal processing before continuing seems like the lowest-hanging fruit. And again, based on the documentation you have on hand probably the best way to do *that* would be to concentrate on what the IWM was designed to do, which is speak to a floppy drive.

There are certain fundamentals about the HD-20 that we just don't know... one of the biggest holes in our knowledge is we have no idea how seeking/sector addressing is performed with the device. Does the Mac know about the low-level geometry of the drive and use the control lines to send track stepping and head selection commands, or is the HD-20 treated as a linear block of sectors and addressing is entirely encoded inside GCR-encoded bytes sent via the IWM shift register? We could probably make some educated guesses about this by blindly watching conversation logs and watching how often the control lines change when doing a bulk data transfer, but we won't really learn anything about the actual syntax. (Particularly if it *does* use GCR-encoded control bytes extensively.) We *know* based on the documentation how the floppy drive should react when its control lines are toggled and also know it doesn't accept any high-level commands from the IWM's serial shift register so the task of separating wheat (data) from the chaff (synchronization bits and filesystem headers) will be *much* easier because there won't be any unknown needles (HD-20 control bytes) mixed in to confuse you.

This seems to me a somewhat logical order of operations:

1: Wire up your snoop cable to an external floppy drive. Log control line transitions and the IWM serial bits while performing some known tasks. (Mounting/unmounting disks, reading a sector, writing a sector, formatting, etc.)

2: Based on your logs and the IWM documentation, teach your microcontroller how to understand GCR to the point that you can write a known value to the disk and have the microcontroller able to grab the sector as its written and unpack it to its original form.

3: If you have enough memory/your microcontroller is capable enough, set it up so it can fully emulate an external drive. (This could actually be a two-step implementation. Step 1 would be "emulating the raw bits", in which your microcontroller fully decodes control signals but writes the GCR bytes in raw form to its flash device, which means that emulating an 800k floppy would probably take about 1MB of flash. Step 2 would be real-time encoding/decoding of the GCR signals and mapping them to an emulator-style disk image on a FAT formatted flash drive. This might require a fairly powerful microcontroller.) Note that if you get this working you'll have a marketable device already. Many people have wanted a flash replacement for the Mac floppy drive.

4. If you really want to make sure you got everything right, reverse it. Hook a Mac floppy drive up to your microcontroller and see if you can read disks produced by a Mac and write images out to real disks that a Mac can read. This proves that not only have you mastered *speaking* to an IWM, you can fully emulate/replace one as well.

5. *Then* you'll be fully equipped to tackle the project of cracking the protocol spoken by the HD-20. Put your now very highly educated IWM protocol analyzer/emulator back inline with the HD-20 and not only watch the signals, but watch the *bytes inside the signals*. You'll be in a much better position to understand what you see.

But again, take this totally with a grain of salt. If you think you're up to skipping steps 1-4, well, you might manage it. I do again think it's worth noting that the product of step #3 is already something people want, so even if you fail to ever crack the HD-20 you've already won if you get that far.

 
IN THEORY

A device could be created that emulates an HD-20 AND an external floppy drive with an HD-20 startup disk image in it, allowing a Mac 512 to boot completely from the device.

That sounds pretty cool to me.

 
yessir.

If you wanted to be REALLY slick, once you get the device running, you could use a USB or SD card based flash device, store diskcopy 4.2 or diskcopy 6 IMG files on the device. Then the device would read/write the IMG files as if they were the floppy itself.

Then you can pick which file you want to open up as a "floppy" or "hardfile" and it mounts. hehe. heck you could even write a lightweight app to signal the device to list the number of image files, which image files, and pick which one you want to mount as a floppy.

Im sure DiskCopy images are in a totally different format than RAW floppy data but hey, thats what microcontroller RAM is for. the RAM is used as the I/O for raw floppy data. once you eject the disk from the finder, the MCU picks up the eject command and then writes the RAW data in RAM as an updated DC4.2 or DC6 IMG file. Simple. Not so simple for an HD20 volume, but heck you can use a HFV file for that. hehehehehehe

possibilities are endless.

 
IN THEORY
A device could be created that emulates an HD-20 AND an external floppy drive with an HD-20 startup disk image in it, allowing a Mac 512 to boot completely from the device.

That sounds pretty cool to me.
Bingo. Once you get your "floppy emulator" to work completely it's almost certainly just a case of elaborating the software to make it emulate an HD-20... or, like you suggest, emulate both an HD-20 and a floppy drive at the same time. There appears to be sufficient documentation for the floppy controller in the Mac available to write a rudimentary volume management program that could run on the Mac itself and signal the through the IWM when a user might want to switch disk images assigned to the various devices if you really wanted to get fancy. (Or you could do it with an LCD and a few switches on the device itself, or... whatever floats your boat, really.)

Im sure DiskCopy images are in a totally different format than RAW floppy data but hey, thats what microcontroller RAM is for. the RAM is used as the I/O for raw floppy data. once you eject the disk from the finder, the MCU picks up the eject command and then writes the RAW data in RAM as an updated DC4.2 or DC6 IMG file. Simple. Not so simple for an HD20 volume, but heck you can use a HFV file for that. hehehehehehe.
Actually, I'm fairly certain (uncompressed) DiskCopy images are essentially the same as HFV files other than they have some header information attached. (You can write 1.44 MB floppy disks from DiskCopy images on Windows or Linux machines as if it were a raw .dsk file just by specifying that rawrite or dd skip some number of bytes at the beginning. If that's the case assuming your microcontroller program is already sophisticated enough to deal with images stored on a DOS filesystem supporting DiskCopy images wouldn't really be any harder than "normal" disk images as you might use in vMac or BasiliskII.)

Of course the Rev. 0.1 floppy emulator would probably just emulate the mechanics of a floppy drive and store GCR-encoded bytes in a completely raw form. Refinement and ease of use comes later. ;^)

Anyway... I do wish I were better at reading assembly language. It would be nice to figure out whether the Mac uses the same GCR encoding loop that it does when writing floppy sectors when it prepares a chunk of data to transfer to the HD-20. I'm basically wondering if it's *possible* that when talking to the HD-20 it's able to "break the rules" of the IWM and use it as a straight UART without the overhead of GCR encoding. My reading of the IWM documentation suggests that wouldn't really work because the clock synchronization would fail after too many consecutive zeros. (IE, if you sent it "10001011 it would raise an error *and stop reading* after the third zero and not bother reading the rest of the bits into its buffer, thus not allowing you to ignore the error and assume the data byte was ok regardless.) One thing to look for in the Z8 code would be a loop that does GCR packing/unpacking. I've had this nagging thought that one of these two things might be true:

A: It's possible, if dangerous, to bend the rules of the IWM, and send straight unencoded data over it somehow.

B: Is it possible that GCR-encoded data from the Mac destined for the hard drive is never actually decoded by the Z8 and is instead just written to it as GCR? The drive has an RLL encoder on it which means that the GCR encoding would be redundant and waste space, but... it seems like a possibility.

I imagine B: is probably more likely than A: if it turns out that the Z8 doesn't encode/decode GCR. Of course, I'm probably just overthinking it. The Z8 is a pretty fast chip, it shouldn't slow things down much to have it decode GCR into a sector buffer.

 
Those are interesting things to think about and to keep in mind as I poke around.

Today, I adjusted my setup so that it actually spits out binary data and the time since the last data was recorded. Looking at this after a short while, I realized that I am missing many of the impulses in the serial data. I'll have to devise a way to pick up on impulses better.

I am no longer certain that they are 0.5µS long. Tracing through my program, it actually takes me about that long to gather a sample right now. :(

Interrupts can catch impulses, but that makes the program much less efficient. I'm trying to think of a hardware solution, maybe using T flip-flops. That could get messy really fast.

 
There is a problem with the state diagram I posted. I thought that the 74109 was negative-edge triggered for some reason, in fact it is positive edge triggered. So the inverting gates going into the clock inputs make it act like it's negative edge triggered.

Glancing at it, this changes any (1,x,x) into a (0,x,x) and (x,x,1) into (x,x,0). I'm not 100% sure what else it affects.

 
I put T-flip-flops in with the read and write lines, unfortunately I'm STILL getting impulse signals through the flip-flop.

So the signal must be noisy and triggering the flip flop multiple times per impulse unless I wired something wrong. (I'm using a 74LS109 with J = 1, /K = 0, /Set = 1, /Reset = 1, original signal fed to clock, output signal taken from Q.) So what I most likely need is a very specialized low-pass filter (MAYBE that would work) or a schmitt trigger between the Mac stuff and the T-Flip-Flop. I don't have any schmitt trigger chips on hand unfortunately.

BAH.

This will allow me to record the serial data better once I get it figured out though.

Also, from what I've seen, at least during early stages of startup, the serial speed seems closer to 450bps than 500bps.

 
I am no longer certain that they are 0.5µS long. Tracing through my program, it actually takes me about that long to gather a sample right now. :(
The IWM documentation sounds like the pulse itself is indeed a lot shorter than the 2 microsecond pulse window. (The chip data suggests that /RDDATA works with pulses in the 300ns-width ballpark.) I'm not surprised you're missing some.

Also, from what I've seen, at least during early stages of startup, the serial speed seems closer to 450bps than 500bps.
A little math based on the size of the sectors, sectors per track and rotational speed of the 400/800k floppy drive indicates that the Macintosh floppy drive writes *bytes* to the floppy drive sectors at about 322,000 bits per second. This is *not* counting the overhead from GCR and other synchronization bits. Add that in and the bit rate is going to be about 450,000-500,000 bps. This jives roughly with the IWM documentation's statement that the "fast mode" uses 2µ second "bit cells", but... keep in mind the timings are going to be slightly "off" on the Mac, because it seems to me that the documentation was written assuming an even 7 or 8Mhz clock. The Mac derives the IWM's clock from that single 15.6Mhz oscillator that's divided up for everything in the system so I'd expect that the timing would be a little slower than 500kbp... I guess by about 3%, that assuming they're using the bit-cell divider settings for an 8Mhz clock. (If they were treating 15.6/2 as a 7Mhz clock it would of course be substantially faster than 500kps.)

Of course, that's not the 10% difference you're seeing, so... it could just be you're "slipping time" as you miss pulses. (Being enough out of sync could also make the signal look "noisy" as you see two pulses within a single "listening window"... assuming I vaguely understand how you have this wired up, which I may not.)

If you have an oscilloscope lying around that can handle 1Mhz-ish signals it would probably be useful to snoop with that and get an idea of how wide the pulses actually are.

 
I tried with my scope, but unfortunately, the Mac boots in literally 5 seconds and it can't sync onto anything. I can't do a freeze screen with this scope. It does have some very nice time/frequency/amplitude measurement features though.

I'm not sure what's up with the flip flop. Maybe the pulses are too fast for it or something. I'll have to think about that for a while and browse the datasheet.

 
My microcontroller has 8 bits of input compare that I may be able to use for this. Basically, it automatically flags and stores timing data of rising edges. This happens in parallel with execution, so no time is wasted operating the system. I'm not sure if that will help but it's good to keep in mind. It could most definitely pick up all impulses, but it buffers only ONE, so I have to grab and store that information before the next impulse.

 
heres an idea. Pull out the 15mhz clock from the mac and use that as a reference clock?? Everything else runs off of this clock, So can your microcontroller?

would keep instruction for instruction timing accurate, and machine cycles synced. Then creating a timer interrupt for the bit timing window would be MUCH easier.

 
I tried with my scope, but unfortunately, the Mac boots in literally 5 seconds and it can't sync onto anything. I can't do a freeze screen with this scope. It does have some very nice time/frequency/amplitude measurement features though.
Doh, you're right. I hadn't thought about how "intermittent" the IWM data would be. Without a good memory scope you're sort of stuck. (I suppose in theory you could write a little assembly-language program that would put the IWM into a continuous write loop, basically telling it to write a never-ending sector to a disk in an external floppy drive. That would let you scope it, I guess, but I'll admit it's a tall order.)

Exactly what are you running in the way of a microcontroller, out of curiosity? The only one I have any experience with is the Propeller. I have a vague idea how I'd try to take a crack at synchronization code with that, but it sort of depends on the Propeller's unique ability to run multiple tasks in parallel.

 
68HC12. (9S12DP256 @ 24MHz) "Dragon12 Plus USB". I've had a couple of Dragons and they've become nostalgic, much in the same sense as our beloved Macs.

Although it's old tech and expensive, it's amazing for assembly programming. I love the instruction set. It also has countless ports and subsystems. Unfortunately it has only like 2k of RAM I can use. Apparently it's expandable but that takes up some ports and potentially slows things down.

I'm in the process of moving so this project may experience a lack of activity. But I'm notorious for coming back to projects. I do not forget or give up on these things. I don't think anyone here expects an immediate solution from me, it's more about the ride than the destination with these things. Think about how much we have and will learn.

The actual result will be like, oh wow, a Mac 512k boots off of this circuit board that has 5 zillion gigabytes of storage. Cool, yes, but nothing compared to ripping into and figuring out this awesome Woz stuff.

 
I read a scan of the HD20 manual recently and I came across something interesting. It suggested you could use two HD20's linked together. Makes sense, since the HD20 has it's own floppy controller which allows a 800K external drive to be attached on the end. So, in theory, you could add more than two HD20's linked to each other. Any one ever had 2 or more working together? Any idea on the limit of HD20's you could have attached?

 
Yup. This is pretty common knowledge. As I posted above, it has been reported as many as 4 to 6 have been daisy chained at one time.

 
Wonder if there is a theoretical limit. Wasn't SCSI limited to 7? Would be interesting if the HD20 could go more than SCSI! :lol:

 
It was probably limited by the ability of the Mac to handle the directoriy index. Remember, for all practical purposes, the Mac thought the HD 20 was a huge floppy disk. I shudder to think of it manipulating a 120MB floppy disk. How slow would that be!?

 
It was probably limited by the ability of the Mac to handle the directoriy index...
The problem with huge directory indexes (IE, the entire directory hierarchy with its "fake" folder system had to fit in RAM) was confined to MFS disks. Hypothetically there wouldn't be any problem with making a large HFS-formatted HD-20-style disks other than the overall low performance of the interface. (Although so far as that goes... I've never used an HD-20 but I doubt it was much slower than a ZIP drive, and that's a 100MB volume.) So far as it relates to the project to re-create the HD-20 if it's found that the HD-20 has a mechanism to report its size to the host Macintosh rather than the OS being hard-coded to treat it as "20MB" then it may be "trivial" to make a larger version.

As for those reports of people using more than two HD-20s I'd be curious to see a reliable citation. We've seen on this board people confusing the HD-20 with the HD-20SC, and obviously there would be no problem daisy-chaining six HD-20SCs together.

 
Are you thinking the OS or ROM/driver limits the Mac to having only two HD20's? Otherwise, if each HD20 has it's own Woz floppy controller (unlike the external 800 drive), shouldn't the number be unlimited theoretically?

 
Back
Top