[comp.sys.atari.st] hard disk article

toml@xrxns.UUCP (02/11/87)

after receiving numerous queries about my paper on a "roll-your-own" hard
disk system for the atari st, most of them encouraging me to post it, i have
decided to do so.  i hope that this doesn't offend the net powers-that-be,
but it's only a measly 20 Kbytes.  it is in plaintext form, so that the
news software can efficiently make use of compress(1).
the graphics referenced in the document are available in two forms:
on paper, for the price of a SASE (22 cents in US, 44 cents foreign),
or electronically as Interpress masters (requires NS Print Services 10).
drop me a mail note if you want to try Interpress.
the document attached is "as-submitted" to ST Applications magazine.  
it is my understanding that it will appear in the march issue, though 
what form it may be edited into i cannot say.
i will be happy to correspond with anyone having questions or problems.

tom love
xerox egp/edds
leesburg, virginia
UUCP: {various & seismo} !rochester!rocksanne!xrxns!toml
XNS Internet:  tom love:lsbg-egp/cad:xerox
ph: 703-777-8000 x5185

-------------------------------- cut here -------------------------------

A Hacker's Hard Disk for the Atari ST

Tom Love

(c) Copyright 1987, John Thomas Love, Rt. 2, Box 277, Sterling, VA
22170 USA.  (703)430-2853

All rights reserved.  Reproduction of this document for profit or other
business purposes by any means is prohibited without written permission
from the author.  Permission for not-for-profit electronic distribution
of this document is granted providing this copyright notice appears in
its entirety.  Copies of the graphics referenced in this article are
available from the author at the above address for the cost of return
postage.

Atari, TOS, and Atari ST are trademarks of Atari Corp.  Unix is a
registered trademark of AT&T Bell Laboratories.  IBM, IBM PC/XT, and
IBM PC/AT are registered trademarks of International Business Machines
Corp.  GEM is a trademark of Digital Research Inc.  Supra is a
trademark of somebody...

This article exists in draft form, as submitted for publication in 
the March '87 issue of "ST Applications" magazine.  ST Applications 
has been published monthly since September 1985.  It provides a nice 
mix of technical articles, programming projects, MIDI, news and 
rumors, and software reviews.  Support disks are available.  
Subscriptions are $32.50/yr without the disk, $92.50/yr with the 
disk.  Single issues are $4.50 each, $12.00 with the disk.  
The editor is William Petry.  Their address is:  ST Applications,
P.O. Box 980, Forestville, CA, 95436 USA.  Please mention my name
and this article if you contact them.



1. Introduction

Back in the old days, when the "home computer" was only beginning to
become a reality, the typical computer hobbyist was generally at least
as adept at soldering patch wires onto his machine's circuit boards as
he was at patching bugs in his code.  Since those days personal
computing systems have greatly matured, so that most users spend their
time using commercial software or perhaps writing programs of their own
- but rarely are they actually involved in any sort of hardware
hacking.

This article describes the adventures of a relatively hardware-naive
user (me) in attempting to assemble a usable hard disk system for an
Atari 1040ST using essentially off-the-shelf hardware.  The primary
goal here is to provide the reader with the sort of documentation I
could have used as I muddled through this project.  Thus this is not a
product review (though no doubt comments of a less than objective
nature may sneak in at times);  nor is this a "circuit cellar" sort of
a project (I never had to use a soldering iron once!).  Instead, this a
project report, with an emphasis on "how-to" for those considering the
same undertaking.  But first, some background, to explain the rationale
for this project.

The need for a hard disk on my 1040 became obvious very shortly after I
brought the system home.  I program industrial-strength Unix systems
during the day, and am spoiled by the typically huge amounts of online
storage available.  While I have no doubt that serious software
development is possible on floppy-based ST systems, it is not for me.
However, the going price for a "turnkey" twenty megabyte hard disk
system for the ST is still in excess of $600.  This is not only
expensive, but provides no reasonable option for upgrading disk storage
capacity in the future.  Luckily I learned of an alternative approach
which solves both problems.  This approach employs an industry standard
hard disk, controller, and power supply, and a custom board which
converts the ST hard disk interface to the interface standard
understood by the controller.  This custom adaptor board was developed
and is sold by Berkeley Microsystems of Oakland, CA., hereafter
referred to as "Berkeley".

Since I knew that I could borrow an unused hard disk and power supply
from work, the cost of the system immediately became attractive - about
$255 for the necessary interface hardware.  And expandability with the
Berkeley approach is better than with the Supra or Atari hard disks, as
the adaptor/controller pair is capable of supporting two separate hard
disks simultaneously.  The clincher, for me, was the inclusion of a
battery backed system clock on the adaptor board, providing the same
capabilities as cartridge based clocks which sell for about $50.  The
only obstacle, as I was informed by Chris Rhodin of Berkeley:  no
documentation (though he says they will be shipping documentation with
their board kits soon).  This important consideration notwithstanding,
I decided to go for it.

2. System Hardware

The package I received from Berkeley contained an Adaptek SCSI (Small
Computer Systems Interface) disk controller board, the Berkeley
DMA-to-SCSI adaptor board, four cables, and a microfloppy containing
the installation and driver software.  Just as promised, there wasn't a
scrap of documentation in the box or on the disk.  Berkeley left it to
me to acquire my own hard disk and power supply.  Fig. 1 diagrams the
components of the system and how they interconnect logically.

The purpose of the SCSI controller board is twofold.  It communicates
with the disk drive itself, sending out commands to read and write
data, and receiving the results of those commands;  and it communicates
with the outside world, receiving similar commands and sending back
data and status.  The controller effectively serves as a protocol
converter between the industry standard SCSI protocol and the
ST506/ST412 protocol understood by the disk drive.

In many computer systems the "outside world" which drives the disk
controller is the system CPU and operating system, often communicating
directly on the system bus.  In the case of the Atari ST, however, no
direct mechanism is provided to interface a disk controller to the CPU,
so the CPU communicates with the hard disk by the only reasonably
speedy interface provided, the DMA (Direct Memory Access) interface.
This external 19 pin interface permits 8-bit parallel communication
with the system data bus at rates up to 1 megabyte per second.  The
intermediary between the DMA interface and the SCSI controller is
Berkeley Microsystems' SCSI adaptor board.  This adaptor board is
responsible for converting between the DMA protocol spoken by the Atari
and the SCSI protocol understood by the disk controller.

The disk drive need meet only one requirement:  it must be ST506/ST412
compatible.  This covers just about all fixed disks manufactured for
personal computers since the early Eighties, including drives for the
IBM PC/XT and PC/AT and compatibles.  Capacities of available drives
typically range from 10 megabytes to 86 megabytes;  note however that
constraints imposed by TOS limit usable capacity of a single drive to
64 megabytes.  New 20 megabyte drives (e.g. the Seagate ST225)  are
typically available for somewhere around $280 without a controller (be
sure you do not pay for a controller board, since most are for PCs and
are useless to an Atari owner).  Alternatively, good deals may be found
in new and used hard drives at computer swap meets, in user group
magazines, and by word of mouth.  Expect to pay on the order of $10 per
megabyte for used hardware.  The disk I am using is a Quantum 540 which
provides 34 megabytes of storage after formatting.

Acquisition of a power supply is a similar problem.  New power supplies
for PCs are available from discount houses for $50 to $75, depending on
power output rating.  Alternatively, scrounging might net you just what
you need for twenty dollars or less.  If buying a PC-type power supply,
plan on buying one with a minimum of of 65 watts output for a single
hard drive system or 135 watts for a double drive system.  If you're
scrounging, keep in mind that you need +5 volt and +12 volt output,
with 3 to 5 amps each for a single drive system and 6 to 10 amps each
for a double drive system.  Different hard drives have different power
requirements, so if possible consult the drive's technical reference
manual for peak power draw.  It is a good idea to put an AC line filter
on the 110V input to the power supply, and a line switch on the input
is highly recommended for turning the disk system on and off.  The
power is distributed to each of the boards and to each disk drive by
means of four wires and a standard keyed AMP "Mate-N-Lok" connector,
identical to that used by conventional floppy drives and available at
any electronics supply house (AMP part number 1-408424-0).  Most PC
power supplies come with harnesses and connectors ready-made.

Finally, the cables.  Berkeley can provide cables for a single drive
system for a minimal cost.  Their cable kit includes the 19 wire cable
between the DMA port and their adaptor board;  a short flat 50 wire
ribbon cable to connect the Berkeley adaptor to the Adaptek
controller;  and two flat ribbon cables to connect the controller to
the hard drive, a 20 wire data cable and a 34 wire control cable.  If a
second hard drive is used a third connector should be crimped onto the
middle of the control cable, and second data cable is necessary.  If
you have access to facilities for manufacturing your own cables you
might be well advised to, since the cables provided by Berkeley are
painfully short.  My installation uses the cables provided by Berkeley,
though, so it is possible.

3. Hardware Assembly

Before beginning assembly we need to consider how this package is to be
enclosed, if at all.  Things to think about are RF emissions, heat
dissipation, isolation from external disturbances, and general
tidiness.  The boards and drive do not seem to emit any noticable RF
(radio frequency) noise, so unless you live in a neighborhood of ham
radio fanatics you probably do not need to go to the trouble or expense
of a metal enclosure.  My setup seemed to run a little warm at first,
but since my power supply happens to have a built-in fan I just
rearranged things so that the power supply cools the other components.
If necessary, a muffin fan can be added to the setup for about $10.

I opted for the "cheap-is-beautiful" approach, sandwiching the two
boards between two 6" by 8" pieces of 1/4" plywood, holding the whole
thing together with four 4" long #6 machine screws and spacing each
layer by about 3/4 of an inch with nuts and small pieces of
non-conductive plastic tubing.  The hard drive sits on top of the whole
sandwich.  Crude but simple.  It is also possible to screw the boards
directly to the bottom of the hard drive, or use commercially available
mounting rails.

My assembly method was largely dictated by the short cables provided by
Berkeley.  After playing with the connectors it became apparent that
there was only one way things would fit together.  Figure 2 graphically
illustrates this connectivity;  the following paragraphs provide a more
detailed explanation.

Begin with the assumption that the circuitry attached to your hard
drive is the on the bottom.  The disk controller board goes directly
underneath the hard drive, with the components facing down and the 50
pin header (the two rows of pins sticking straight out from the board)
and LED toward the front.  Under the controller goes the Berkeley
adaptor board, with its components also facing down and its 50 pin
header toward the front.  The 19 wire DMA cable connects to the header
on the back side of the Berkeley adaptor board, with the cable directed
away from the board.  Next the 50 wire ribbon cable connects the 50 pin
headers on the front of both boards.  Proper orientation is important.
This is achieved by plugging the cable into the Adaptek so it that it
extends away from the board (toward the front), then bending it down
and flipping the connector around so that it meets the Berkeley adaptor
board's header.

Next, the disk drive is connected to the controller by the 20 wire data
cable and the 34 wire control cable.  These cables attach to the disk
drive by means of edge connectors;  on the disk controller the control
cable attaches with an edge connector while the data cable(s) attach to
the header(s) at the rear of the board.  The header near the side of
the board is used for drive zero (the designation for the drive in a
single-drive system, or the first drive in a two-drive system);  the
header in the middle of the back of the controller is used for drive
one in a two-drive system.  The control cable attaches directly without
any twists.  The data cable is attached to the disk with the cable
directed downward, and is turned under to fasten to the appropriate
header on the bottom of the controller.  Note that none of the ribbon
cables used require any twists in them.

One further consideration:  hard drives typically have a jumper on the
bottom labelled "DS".  This is the "drive select" jumper which provides
each disk with an identity, whether drive zero, drive one, or greater.
On a single drive system the DS jumper should be set to 0;  on a double
drive system one disk should be set to DS0 and the other to DS1.

Finally, power connectors need to be supplied to each of the boards and
the disk drive.  The standard connector keying makes this
straightforward.  Now comes the test of nerve:  plug it into the wall
and turn it on (for safety's sake while disconnected from the ST's DMA
port).  If everything was put together properly the LEDs on the disk
controller and drive will begin blinking and you will hear the
unmistakeable sound of the hard drive beginning to spin and coming up
to speed.  If these things do not happen all I can suggest is re-reading
everything above and trying again before calling Berkeley.

4. Software Installation and Configuration

In order to make the disk usable to the ST it must be properly
installed and formatted.  Begin this procedure by turning everything
off, connecting the DMA cable to the back of the ST, turning on the
hard drive, and then after it is spun up turning on the ST.  Insert the
floppy supplied by Berkeley into drive A and open it up.

The AUTO folder on the Berkeley disk contains two programs, install.prg
and setclk.prg.  These should both copied into the AUTO folder on your
boot floppy.  Install.prg handles boot-time installation of the hard
disk, and setclk.prg automatically notifies GEM of the date and time
stored in the clock on the adaptor board.  The battery-backed clock
needs to be set once at installation time.  This is done by setting the
date and time correctly in the GEM Control Panel and then running the
program initclk.prg in the root directory of the Berkeley floppy.  This
program only need be run again when the hardware clock needs to be
reset, for example when changing to daylight savings time, leap year,
or if the battery wears out.

Next open up the AHDI folder on the diskette.  This contains two
programs of interest, hdx.prg and ship.prg, and an important data file
called wincap.  Hdx is the hard disk installer program, and ship is
used for parking the disk's heads before transportation.  The wincap
file needs to be examined to ensure that it contains data relevant to
your brand and model of disk drive, including the name, the number of
heads, the number of cylinders, write precompensation, reduced write
current, default partition, and other obscure things.  Wincap entries
for a number of the more standard drives are already in place.  If your
drive is not one of the ones already installed you will need to refer
to a technical reference manual for your drive, Chris at Berkeley
Microsystems, or both in order to get a usable entry.  A text editor
such as micro-emacs is necessary to modify the wincap file.

Next run the program hdx.prg.  This is a GEM application which is used
to format, partition, zero, and mark bad blocks on the disk.  Each
operation is available under the "DISK" pulldown menu.  The format
operation should be performed first, so pull down and activate
"format".  You must verify that you want to format, then select the
physical unit.  This will be drive 0.  Next you must pick the drive
type from a menu which is generated based on the wincap file.  Finally,
you must verify one more time that you want to format (an operation
which destroys all data on the disk), and formatting will begin.

The next step is to partition.  Again you must verify that you wish to
partition and name the physical unit, then you are presented with a
panel of logical unit names (C: through P:) with sizes associated with
each partition.  A partition, or logical unit, may be no larger than 16
megabytes.  You may divide up your disk as you like;  mine is cut into
14, 10, and 10 megabytes for C: through E: respectively.  If you have a
favorite ramdisk which is hardcoded to be device C: (or something else)
you may wish to partition around it.

Next each partition must be zeroed.  Invoke the "zero" step once for
each partition, specifying which partition each time.  And last invoke
the "markbad" step once for each partition.  This scans through each
partition identifying and mapping out unreliable blocks;  it takes
longer than any of the other steps.  When all this is done, exit hdx by
pulling down the FILE menu and activating "quit".

The last step is to establish an icon for each partition by selecting
an existing disk icon and choosing "install disk drive" from the
OPTIONS menu, filling out the drive identifier and icon label fields,
and clicking on "install".  This should be done once for each partition
built in the hdx partition step.  When this is done, save your desktop
to your boot floppy and try powering everything down and cold booting.
If the installation went properly, your desktop will show an icon
for each partition.  Select each icon one at a time and "show info" to
verify that the correct amount of bytes available is displayed.  If all
this appears right, consider yourself the owner of a hard disk system.

5. Use

Use of a hard disk in the TOS environment is not much different than
use of floppy disks, except of course that the hard disk is much
bigger, faster, and does not require any of that obnoxious disk
swapping.  At this time a boot floppy containing your AUTO folder,
desktop.inf, and any desired desk accessories is still necessary;  both
Atari and Berkeley Microsystems are working on reliable methods for
booting directly from the hard disk.

When turning on your system you should turn on your power supply first,
powering up the boards and disk.  Turn on the monitor while waiting for
the the disk to spin up.  After about five or ten seconds, when the
disk is spun up and its LED stops blinking, then turn on the ST.  In
powering down, reverse the order:  ST off first, disk last.  Note that
cycling power on the disk while the system is up causes a system
reset.

Installing a hard disk may solve many problems, but it invariably
introduces one rather unpleasant one:  backing up your files.  I am
unaware of any reasonably priced tape backup mechanism currently or
soon available for the ST.  This leaves the floppy as the only viable
medium.  There are a variety of commercial and public domain packages
available to make the procedure easier and faster than simply copying.

One issue which has not been received much press but is very important
to all ST users is what has come to be known as the "forty folder
limit".  Due to a bug in GEMDOS's limited resource manager, the TOS
file system can get a case of amnesia if more than forty folders exist
on the set of installed partitions (including the floppy).  The problem
does not occur every time, but if it does, the loss of information on
your hard disk may be total.  Therefore until a fix is published by
Atari you should keep a close watch on the number of folders you create
on your filesystem.

6. Evaluation, Conclusions, and Recommendations

If you have read through all of the above installation instructions you
may have come to the conclusion that all this is a lot of trouble;  if
so, you're not far wrong.  However, for some people this "hacker's"
hard disk makes more sense than the expensive turnkey systems.  These
people would be those with inexpensive access to any of the components
of the system;  those with limited budgets who want to start out small
(say with a cheap 10 meg disk) and later expand;  those with very large
storage needs such as BBS sysops, programmers, and businesses;  and
those who just like to tinker with hardware.  I would specifically not
recommend this system to those meek people who are obsessed with
warranties or have a deathly fear of electricity.

My system has operated reliably since I put it on line several weeks
ago.  While I cannot provide any quantitative data as to performance or
contrast my system with an Atari or Supra hard disk, loading software
is significantly, perhaps five to eight times, faster than loading from
floppy.  Overall it has greatly improved the utility of my system and
at an exceptionally low cost.

Postscript:  The address for Berkeley Microsystems is:  1107 El Centro
Ave., Oakland, CA USA 94602, phone (415)530-3436.

The price for the two-board set is still $250 but will be going up, so
contact Berkeley Microsystems to verify price information before
ordering.  Berkeley will be shipping an installation manual with their 
boards soon.