AVR based SCSI RAM disk


Because I am a SCSI fan, I want to have a SCSI controller to play with ...

The goal of this project was a universal SCSI controller (not a hostadapter) consisting of standard parts. It should be modular, SCSI3 (ANSI X3.301:1997) compliant and SE/HVD/LVD compatible with corresponding PHYs. I have chosen a RAM disk as logical unit to focus development on the SCSI controller not to media access and/or OS drivers (RAM is easier to control than other media and any OS already have drivers for Type 0 "direct access" devices).

The SCSI controller developed with this project I have used for my SCSI PCMCIA drive.


At the beginning I cannot get my hands on that nice SN75LVDM977 LVD/SE multimode tranceivers from Texas Instruments so the prototype have a SE PHY using bipolar TTL technology (robust, cheap and available). Four 30Pin DRAM modules I found in my equipment become the media. Two AVR microcontrollers do the work (one for the parallel SCSI interface, the other for the target and logical unit functions). The result was the working prototype in 3.5" floppy drive formfactor shown below:

RAM disk picture
RAM disk prototype hardware V1.0 patched to V1.0.1 (click to enlarge)

I have designed the PCB with Eagle V4.09 for GNU/Linux from Cadsoft Computer GmbH. Two prototypes of the PCB were manufactured by Beta Layout GmbH for me. Because of some design flaws that firmware development have revealed, I have to patch several things (the red wires in the picture) resulting in Hardware V1.0.1:

Top placeplan
Hardware V1.0.1 placeplan (click to enlarge)

The schematic and layout data can be downloaded here:

I claim only the right of being the originator of the schematic and layout, feel free to use it for everything you want. Some libraries are modified versions and originally created by Cadsoft. You can use the modified libraries for any purpose (the terms of Cadsoft apply if I overlooked something and this is not allowed).


The "PIA" and "Target" modules requires firmware to work. I have developed the firmware on a GNU/Linux host, it should be possible to build it with the shipped Makefiles on any UNIX host if the following tools are available:

Source code and images for Flash-EPROM and EEPROM are included in the packages.

Note: PIA and target firmware with equal major numbers are compatible.

PIA (Parallel Interface Agent) firmware

The PIA firmware is relatively small (about 3KiByte) and written in assembler. The PIA controls the SCSI bus by implementing the SPI (SCSI Parallel Interface) and provides a SDS (Service Delivery Subsystem) as descibed in the SAM document to the Target module.
PIA firmware is available under BSD license:

Target firmware

The Target firmware is written in C and about 24KiByte in size. With enabled debug system the size increases to about 55KiByte (mainly due to string constants and inlining). The Target module implements a logical unit of Type 0 "direct access" that should comply to the SPC and SBC documents (and the handling of INQUIRY and REQUEST SENSE commands for nonexisting LUNs).
The logical unit uses four standard 30Pin memory modules with asynchronous DRAM as media and map it to logical blocks of 512Byte size.
Target firmware is available under GNU general public license:

The target firmare contains a debug system that can print messages via the AVRs USART to a terminal. A level converter like MAX232 must be connected to CON30. The debug messages for different modules can be separately enabled and disabled (the module is printed in brackets).
The Adaptec AHA-2940 device scan issues a SCSI bus reset and executes an INQUIRY command. This is logged like this:

SCSI RAM-disk debug system

Hardware: V1.0.1, Firmware: V0.0 (Build: 2005-07-17 21:10:39 UTC)

Init target:
Activate UNIT ATTENTION condition
Enable interrupts ... OK
Enable DRAM refresh ... OK
Init DRAM ... OK

Target POST:
SRAM test ... OK
DRAM size ... 4MiByte
DRAM test ... OK
POST complete

Init PIA:
Read our SCSI ID from jumper block ... 6
Configure PIA for target mode ...
PIA has enabled the SCSI interface

Boot complete

Starting taskrouter
[Task router] Prepare for next task
[Task router] Idle
[Task router] An initiator selects us
[Task router] Connected to initiator with SCSI ID 7
[Task router] I_T nexus established
[Task router] ATTENTION condition detected
[Task router] Receive message from initiator
[Task router] Message: C0
[Task router] IDENTIFY message received
[Task router] LUN 0 selected
[Task router] I_T_L nexus established
[Task router] ATTENTION condition detected
[Task router] Receive message from initiator
[Task router] Message: 01 03 01
[Task router] Unknown message received
[Task router] Send MESSAGE REJECT message
[Task router] Receive command from initiator
[Task router] Check for reservation conflict
[LUN 0 Taskmanager] Check for reservation
[Task router] Create task for LUN 0
[LUN 0 Taskmanager] Create task
[LUN 0 Deviceserver] Execute task
[LUN 0 Deviceserver] CDB: 12 00 00 00 20 00
[LUN 0 Deviceserver] Command: INQUIRY
[LUN 0 Deviceserver] Command successfully completed
[Task router] Success, report status GOOD
[Task router] Send TASK COMPLETE message
[Task router] Release SCSI bus
[Task router] Prepare for next task
[Task router] Idle

The messages logged for a Linux boot that leads to this:

(scsi0) Adaptec AHA-294X SCSI host adapter found at PCI 2/0
(scsi0) Narrow Channel, SCSI ID=7, 16/255 SCBs
(scsi0) Downloading sequencer code... 406 instructions downloaded
scsi0 : Adaptec AHA274x/284x/294x (EISA/VLB/PCI-Fast SCSI) 5.1.17/3.2.4
       [Adaptec AHA-294X SCSI host adapter]
scsi : 1 host.
(scsi0:0:0:0) Synchronous at 5.0 Mbyte/sec, offset 8.
  Vendor: QUANTUM   Model: MAVERICK 540S     Rev: 0901
  Type:   Direct-Access                      ANSI SCSI revision: 02
Detected scsi disk sda at scsi0, channel 0, id 0, lun 0
  Vendor: TOSHIBA   Model: CD-ROM XM-3301TA  Rev: 2411
  Type:   CD-ROM                             ANSI SCSI revision: 02
  Vendor: Selfmade  Model: RAM-Disk          Rev: V1.0
  Type:   Direct-Access                      ANSI SCSI revision: 03
Detected scsi disk sdb at scsi0, channel 0, id 6, lun 0
scsi : detected 2 SCSI disks total.
SCSI device sda: hdwr sector= 512 bytes. Sectors= 1057758 [516 MB] [0.5 GB]
SCSI device sdb: hdwr sector= 512 bytes. Sectors= 8192 [4 MB] [0.0 GB]
Partition check:
 sda: sda1 sda2
 sdb: unknown partition table

can be found here: Debug messages for Linux boot [ASCII]


Browser        IDFC        Last update: 2010-09-16        michael.baeuerle@gmx.net