• Updated 2023-07-12: Hello, Guest! Welcome back, and be sure to check out this follow-up post about our outage a week or so ago.

TashTwenty: Single-Chip DCD (Hard Disk 20) Interface

tashtari

PIC Whisperer
As I mentioned earlier, the DCD protocol was designed with the capability to daisy chain together a theoretically-infinite number of DCDs, with Mac pulsing the PH3 line to advance to the next one. I at first didn't think that the PIC would be fast enough to respond to this, but I measured on the scope and apparently those pulses are pretty leisurely-paced, about 5 us wide and 24 us apart. What I do wonder, though, is whether one of the faster macs that supported the HD20 (Classic II, LC, IIsi, IIci, some others, maybe more with the ROMinator SIMM) would go too fast for the firmware to detect. I don't have the means to test this right now, I only have a 512ke and a Classic and they're both members of the 8 MHz club...
 

tashtari

PIC Whisperer
Could this theoretically convert a standard floppy drive into an "HD20," to enable floppy daisy chaining?
The only thing that might make it possible is some of the bits (Ejectable and Disk_In_Place) in the Controller Status block. I haven't tested this, so I'm just conjecturing here, but it might be that DCD was designed to be able to support not only hard drives but superfloppy-like removable media. If that does work and it's possible for DCDs to be ejected and inserted while the machine is running, then the sky's the limit. One could, in theory, make a device with firmware to interface with a floppy drive and make it appear as a block device accessible via a DCD interface - and it could be a high-density floppy drive, too, or a Zip drive or whatever. With the proper circuitry, this hypothetical device could have a daisy-chained port on the back that could accept another DCD (which could itself have a port to continue the chain) or a regular floppy drive (which would be the end of the chain.)

That said, it's well outside the scope of this project. =) Controlling a floppy drive would require a beefier microcontroller than the PIC16F1825 I'm using, for one thing. Although, if I get around to making an alternative version of the firmware that uses SPI to interface with another device, that device could do whatever it likes, including interfacing with a floppy drive, but I don't want to over-promise...
 

NJRoadfan

Well-known member
Still trying to figure out if DCD or SmartPort (same thing, but for the Apple II) came out first. I'm thinking DCD as SmartPort was expanded to cover character devices like RTCs in the protocol. Both are an example of "operator overloading" the IWM to support devices well beyond a floppy drive.
 

tashtari

PIC Whisperer
If that does work and it's possible for DCDs to be ejected and inserted
Update: It is possible to eject a DCD that has the ejectable flag set, but it comes right back immediately, and there doesn't appear to be a command being sent that could mean "eject media" or anything similar. The only thing I wonder about as I look at the trace is that sometimes the byte after the command byte in the Controller Status command is 0x00 and sometimes it's 0x01. I don't know what the significance of this is. It'd be a weird way to ask the drive to eject, but that doesn't rule it out. If there's an answer to this question, it probably lies in the depths of the driver code. BMOW posted a decompiler listing with some comments, though damned if I can make much sense of it. Anyone care to dig in?

Still trying to figure out if DCD or SmartPort (same thing, but for the Apple II) came out first. I'm thinking DCD as SmartPort was expanded to cover character devices like RTCs in the protocol.
Someone pointed out on the IRC channel that at the time, the Macintosh and Apple II team saw one another as enemies, so it's quite possible that both protocols were developed with no knowledge at all of the other...
 

NJRoadfan

Well-known member
What's sad is that its the same damn thing, just different dialect :p A shame because Apple was just getting big into "family peripherals" that worked on both the Macintosh and Apple II lines. Imagine being able to buy a HD20 and have it work both on your Mac512k and Apple IIc out of the box!
 

tashtari

PIC Whisperer
New feature! Taking advantage of the one remaining GPIO pin I hadn't used and the daisy-chain feature I've been talking about, it is now possible to connect more DCDs (or a floppy drive) downstream from TashTwenty. Tested with the Floppy Emu since I don't confide that any of my real floppy drives are working right now...
 

tashtari

PIC Whisperer
The boards are here, and boy are they ever thin. OSHPark's normal service results in 1.4mm-thick boards, which is just slightly too much to sandwich between the solder cups of the "DB"-19 connector, so I opted for their 0.9mm service, and the difference is palpable. Next time I may have to order from someplace that does a 1.2mm board or so. But 0.9mm does fit. More updates soon, I have some firmware work to do first...
 

tashtari

PIC Whisperer
Finally did a firmware task that I've been meaning to do for a while now... I implemented MBR, otherwise known as a sane user interface for this chip. All you have to do is create an MBR partition table on your card with one or more (primary) partitions with type ID 0x20 and TashTwenty will turn those partitions into drives of the appropriate size on your mac. Simple! You can even have other partitions of other types on the same card, it'll just ignore them.

Still need to figure out a good way to let the user customize the drive icon, though, because who wouldn't want a custom drive icon?

I'll hopefully assemble a board tomorrow and have pictures.
 

NJRoadfan

Well-known member
Would these partitions be directly mountable on an older OS X machine if you used Apple's official 0xAF MBR ID? I've never had HFS partitions on a MBR drive before, but Apple must have used them at one point, maybe in OS X Server 1.0.
 

tashtari

PIC Whisperer
Would these partitions be directly mountable on an older OS X machine if you used Apple's official 0xAF MBR ID?
That's a really good question... I had figured that the MBR partitions, since each represents a disk, could potentially contain partition tables of their own, but it looks like I might be wrong about that. The first sector of one of my 0x20-type partitions starts with the signature "LK" for the boot block (if it's bootable) and the third with "BD" for an HFS volume, same as the .dsk files I use with emulators, so they might be in effect identical to 0xAF partitions. It makes sense that Apple never intended the HD20 to be partitioned (why would you need to?) and Wikipedia says that Apple Partition Map was introduced with the Macintosh II, so maybe before that, hard drives were just single partitions.

I'd try it myself, but I don't own any post-68040 macs. If does work, though, I'm happy to change the magic number the firmware uses.

(Also curious, the Plus predates the II, so if Wikipedia is correct, was there a time when a SCSI hard drive would not have been expected to have a partition table?)
 

ktkm

Well-known member
Nice! I’d love to get my hands on one, and perhaps print a cover that conforms to the other connectors?
 

tashtari

PIC Whisperer
Would these partitions be directly mountable on an older OS X machine if you used Apple's official 0xAF MBR ID?
Yes, they would, as it turns out! I've changed the firmware to look for 0xAF partitions instead of 0x20, now I can practically call this a card reader for classic macs (without hotplugging, of course.) Thanks to @jessenator for helping me with this.

Nice! I’d love to get my hands on one, and perhaps print a cover that conforms to the other connectors?
A case would be cool! I've uploaded my board (Eagle CAD .brd file) on Github for anyone to fab if they wish. It'd be nice to be able to make kits available but right now the project isn't mature enough. My board is pretty amateurish anyway, @demik is working on a nicer one...
 

demik

Well-known member
My board is pretty amateurish anyway, @demik is working on a nicer one...

Your board is pretty cool for something attached to the DB connector. I've seen commercial stuff much worse, with everything glued and stuffed into a DB housing.

So I'm working on a two parts implementation of TashTwenty (Ala Floppy Emu) that will use a small internal case. The design will be open source and use through hole components.

Unfortunately with components shortage & other delay, I'm not sure the final release of the board will be finished this year.

If you are in a hurry, I suggest using @tashtari design for now. If you want to switch to my design afterwards, you can always reuse the DB19, SD card and the PIC.
 

tashtari

PIC Whisperer
Latest additions to the firmware include the use of multiblock reads from the card (for speed), support for cards up to 2 TB in size, and using part of the "manufacturer reserved" area of the status block to give a count of errors and unknown commands. At this point, I can't think of anything else to do with the firmware, feature-wise. Unless (until) bugs are found, I might be done. \o/ I made a release on GitHub with a binary in case anyone wants to build one of these and doesn't feel like getting MPLAB set up.
 
Top