An AT&T 3B2/400 Emulator

3b2-emulator-screenshot.png

Introduction

The AT&T 3B2/400 was a small, multi-user UNIX computer developed by AT&T in 1985. It was part of the larger 3B family of UNIX computers based on the Western Electric WE32000 and WE32100 series of CPUs and peripherals. What makes the 3B2 historically interesting was its use as the primary porting platform for AT&T UNIX System V Release 3.

This emulator is part of the SIMH simulation framework, and emulates a standard desktop 3B2/400 with the following devices:

  • 1MB, 2MB, or 4MB of system memory
  • One 720KB floppy diskette
  • One or two 30MB, 72MB, 135MB, or 161MB MFM hard disk drives.
  • One 23MB QIC Cartridge Tape (CTC)
  • Up to twelve 4-port serial cards for remote terminals (PORTS)

Since internals documentation for the 3B2 series are not readily available, the emulator was made possible through a reverse-engineering effort, studying the System V Release 3 source code, and lots of caffeine.

Changelog

  • 2018-07-13: Several timing and terminal fixes from upstream SIMH.
  • 2018-05-22: Fix for critical floppy timing issue.
  • 2018-05-21: Support for CIO ("Common IO") expansion cards. PORTS and CTC cards are now supported. PORTS cards each provide 4 serial lines, and up to 4 PORTS cards are supported. CTC cards provide a 23MB Cipher "FloppyTape" tape backup solution. One CTC card is supported.
  • 2018-04-11: Major fix to DMA and CONTTY serial support.
  • 2017-12-27: HD135 and HD161 are now both recognized names for the Maxtor XT1190 disk drive.
  • 2017-12-27: Fix for CPU traps. The UNIX debugger sdb should now work correctly under System V Release 3.
  • 2017-12-17: Minor compiler warning fix.
  • 2017-12-16: Fixed a FIFO overflow bug in the CONTTY device.
  • 2017-12-15: Critical MMU bugfix.
  • 2017-12-13: Improved support for multiple hard disk drives, as well as adding support for additional hard disk geometries.
  • 2017-12-09: Added support for the secondary on-board serial terminal (CONTTY).

Binary Download

Latest Build: Friday, 13 July 2018

File Size Description SHA1 Checksum
3b2 740 KB macOS 10.13.5 Executable a04ca38fcda91d36b7001de0900e6ad214ba87ea
3b2 955 KB GNU/Linux x86-64 Executable b391acfb765b51b3ac2cb1946f2bf73c231a50c4
3B2.exe 660 KB Windows XP/7/10 32-bit Executable ebd560a6a325ed92d2d3864f3eb0b32763dd316b

Compiling from Source on GNU/Linux or MacOS X

The SIMH source repository is here: https://github.com/simh/simh

If you would like to build the emulator on GNU/Linux yourself:

  • Clone the SIMH repository listed above
  • cd into the simh directory
  • Type make 3b2

The binary will be built into the ./BIN/ directory.

Usage

The 3B2 emulator is part of SIMH, the Computer History Simulation Project. Full documentation for the SIMH platform is availble here:

A complete description of SIMH would be much too long for this document, but in brief, it is a platform for writing and hosting computer simulators. SIMH implements a great number of simulators, of which the 3B2/400 is only one.

Below is a "Getting Started" guide to help ease you into the world of SIMH in general, and using the 3B2/400 specifically.

Getting Started

The 3b2 binary (or 3B2.exe under Windows) is a standalone application. On Linux, all you need to do is CD into the directory where you've downloaded 3b2, and type:

$ ./3b2

On Windows, open the cmd.exe shell, CD into the directory where you've downloaded 3B2.exe, and type:

C:\some\directory> 3B2

In either case, you will be greeted with an interactive SIMH shell where you can type commands. It looks like this:

AT&T 3B2 Model 400 simulator V4.0-0 Current        git commit id: 392b8f26
sim>

To quit at any time, just type quit and press the Enter key.

Example Startup File

Any command that you can type to the SIMH sim> prompt can be stored in a startup file, and thiks is generally the easiest way to do things. For example, you may create a file named boot.ini, and enter the following commands:

set cpu 4M
set cpu idle

set id0 HD161
attach id0 hard_disk.img

attach if floppy_disk.img

attach nvram nvram.bin
attach tod tod.bin

attach contty 8000

set ctc enabled

set ports enabled
set ports lines=16
attach ports 9000

When you start the 3B2 simulator, you can pass the name of this file to the program as an argument, for example under Linux

./3b2 boot.ini

And under Windows

C:\some\directory> 3B2 boot.ini

This will launch the simulator and run all the commands in the file.

We'll look at all of the options specified in this example file in greater detail below

Simulator Options

CPU Memory

set cpu 4M

This line sets the available system memory to 4MB, which is the maximum amount that a 3B2/400 could address. Other options are 1M and 2M.

IDLE support

set cpu idle

This enables CPU idle support. Idle support lets the emulator use less host CPU. If this line were not present, the emulator would use 100% of one host CPU core.

Hard Disk Type

set id0 HD161

This command tells the emulator what type of hard disk is attached. id0 is the first emulated hard disk drive (id stands for "Internal Disk"). A second hard disk may optionally be attached as id1.

HD161 tells the emulator that the hard disk is a Maxtor XT1190 161MB MFM hard disk.

Other options include HD30 for a 30MB hard disk, and HD72 for a 72MB hard disk.

Unless otherwise specified, HD72 is the default, because a 72MB hard disk was the largest that AT&T originally shipped with the 3B2/400.

Hard Disk Image

attach id0 hard_disk.img

This line attaches the disk id0 to a virtual hard disk file named hard_disk.img, creating the file if it doesn't exist.

Note that the 3B2/400 expects hard disks to be low-level formatted before they can be used. That is addressed later in this document.

Floppy Disk Image

attach if floppy_disk.img

This line, similar to the line above, attaches a virtual floppy disk image to the floppy drive. (if for "Internal Floppy")

The 3B2/400 floppy disk uses double sided 80-track diskettes with 9 tracks per sector and 512 bytes per track, for a total disk size of 720KB.

NVRAM and Time-of-Day Clock

attach nvram nvram.bin
attach tod tod.bin

These two lines create files to store the state of NVRAM (Non-Volatile RAM) and the Time-of-Day Clock. When these devices are attached, the 3B2/400 emulator will remember important settings and the current time of day between boots.

CONTTY Serial Port

attach contty 8000

All 3B2/400s have two serial ports on the system board: One for the console terminal, labled CONSOLE, and one for a second serial connection, labeled CONTTY. This command enables the secondary serial port and attaches it to Telnet port 9000. You can then use a Telnet client to connect to the host that the emulator is running on on port 8000, and you will be connected to the virtual CONTTY serial line.

CTC Tape Drive

set ctc enabled
attach ctc tape.img

This enables the Cartridge Tape Controller (CTC) card. This is a 23 MB Cipher "FloppyTape" QIC tape device present on 3B2/400 computers. The virtual tape drive may be connected to a file with the command attach ctc <filename>

PORTS Serial Ports

set ports enabled
set ports lines=16
attach ports 9000

The PORTS card is an optional expansion card for the 3B2/400. Each PORTS card supports 4 serial terminals, and up to 4 PORTS cards may be installed in a 3B2/400.

These commands enabled PORTS support, sets the number of simulated terminal lines to 16 (4 cards), and listens for connections on port 9000.

Booting The 3B2/400

To boot the simulated 3B2/400, type:

sim> boot

You may see several different messages.

First Time Booting

If you have never booted the 3B2/400 before, or if you have deleted the nvram.bin NVRAM file, you will see the message

FW ERROR 1-01: NVRAM SANITY FAILURE
               DEFAULT VALUES ASSUMED
               IF REPEATED, CHECK THE BATTERY

This is normal. Once the 3B2/400 has booted at least one time, and stored its settings into NVRAM, this message should not be repeated.

Disk Not Formatted Yet

If the hard disk image you've attached id0 to has not been formatted yet, or if no disk image is attached, you will see the following message.

FW ERROR 1-02: DISK SANITY FAILURE
               EXECUTION HALTED

Once the disk image has been formatted, or if you use a pre-built image from below, you should no longer see this message.

System Failure Prompt

If either of the above messages appear, or if UNIX has not yet been installed, you will see the following message

SYSTEM FAILURE: CONSULT YOUR SYSTEM ADMINISTRATION UTILITIES GUIDE

IMPORTANT: The SYSTEM FAILURE line is actually an invisible password prompt!

Type the default system maintenance password, which is mcp, and press Enter to continue.

Booting UNIX

Once you've entered the mcp password, you should see the message

Enter name of program to execute [ ]:

Simply type unix and press Enter.

Finally, you will be asked which device to boot from.

	Possible load devices are:

Option Number    Slot     Name
---------------------------------------
       0          0     FD5
       1          0     HD161-B

Enter Load Device Option Number [1 (HD161-B)]:

Enter 0 to boot from the floppy disk, or 1 to boot from the hard disk.

Automatic Boot

Once UNIX has been installed to the hard disk, the system always boots automatically from the first hard disk.

Exiting the Emulator

To stop SIMH at any time, type the control sequence Control-E. This will return you to the SIMH prompt (sim>), where you can type quit.

Prebuilt Hard Disk Images

To make getting started as painless as possible, I have prepared several hard disk images with AT&T System V Release 3.2 UNIX pre-installed.

All hard-disk images are of type HD161, to give you maximum free space.

There is also a pre-generated NVRAM image that you can use, if you wish. NVRAM is "Non-Volatile RAM", and stores parts of the system configuration between boots.

Image Compressed Size Description
hd161.img.gz 7.5 MB Full Install [1]
hd161_blank.img.gz 164 KB Blank Disk [2]
  1. The "Full Install" hard disk was installed from the full set of all 26 floppy disks making up a standard System V Release 3.2 distribution, plus the following extras:
    • Set default terminal type to VT100
    • C-Kermit 5A(189) installed as /usr/bin/kermit
    • GNU Bison 1.25 installed under /usr/gnu
    • GNU gzip 1.2.4 insatlled under /usr/gnu
    • GNU tar 1.09 installed under /usr/gnu
  2. The "Blank Disk" image is a blank 161 MB hard disk, useful for doing a fresh install, or for adding a second hard disk drive to your installation.

Transferring Data Between the Emulator and a Host

One interesting challenge is, "How do we share data between the host system and the emulated 3B2?"

There are three options available for this, ranging from simplest to hardest.

C-Kermit

C-Kermit is a very simple program that transfers data over serial lines. It's very easy to use. The main downside is that transfers are very slow. They're limited to the speed of the emulated serial port, which is 9,600 baud by default, and cannot go above 115,200 bps.

Caveat: On the emulated 3B2, the size of file you can transfer is limited by the ulimit setting, and by default cannot be more than 1MB in size. You may increase the ulimit to overcome this limitation.

To use Kermit, you will need two pieces of software:

  1. Kermit for your host operating system
  2. C-Kermit for the 3B2 (below).

Kermit 95 for Windows is available here: http://www.kermitproject.org/k95.html

C-Kermit for Linux is available through most distribution's package managers.

C-Kermit for the 3B2 is available here, on a diskette image:

Image Size Description
cku189.img 720 KB C-Kermit 5A(189) compiled for SVR3.2 on the 3B2/400

Installing Kermit on the Emulator

NOTE: You can skip this step if you have used the pre-built hard disk image from above, because it already includes C-Kermit 5A(189) pre-installed.

To install C-Kermit, first attach the floppy image to the simulator with the following command:

sim> ATTACH IF ck189.img

Then, in SVR3 UNIX, mount the floppy:

# mount /dev/diskette /install
# cp /install/kermit /usr/bin/kermit

Finally, unmount the floppy image

# umount /dev/diskette

Copying Data from the Host Computer to the 3B2

  1. Enable the CONTTY or a PORTS device on the 3B2. For example, to listen for connections on port 8888, you would add this to your startup file:

    ATTACH CONTTY 8888
    
    or
    
    ENABLE PORTS
    SET PORTS LINES=8
    ATTACH PORTS 8888
    
  2. Start Kermit on your host system.
  3. From C-Kermit on your host system, use the following command to connect to the CONTTY device:

    C-Kermit> TELNET /NOWAIT 127.0.0.1 8888
    

    Be sure to replace the IP address and port with the appropriate values.

  4. When Kermit has connected to the CONTTY device, press Enter a few times until you see a login prompt. Log in as your standard user on the 3B2.
  5. Now, on the 3B2, run C-Kermit, and type:

    C-Kermit> RECEIVE
    

    followed by the control sequence to bring you back to the host Kermit interface:

    <Control>-\ c
    

    (that’s the Control key plus backslash (\), followed by the “c” key)

  6. You should now be back in the host Kermit session. Type:

    C-Kermit> SEND <filename>
    

Your file should transfer to the 3B2 at about 1200 bytes per second. Not blazingly fast, but tolerable.

Copying Data from the 3B2 to the Host Computer

This is really just the reverse procedure. You do exactly the same things, except on the 3B2 C-Kermit session, you type:

C-Kermit> SEND <filename>

And on the Host Kermit session, you type:

C-Kermit> RECEIVE

Using a CTC Tape Image

TODO: This section is coming soon!

Using a Hard Disk image

This method is really a tremendous hack, but it's probably the fastest way to transfer very large that are too big to fit onto a CTC tape image.

The basic idea is to write a CPIO archive to a specific location on a blank hard disk image under Linux, and then, in SVR3, to read the CPIO archive out of the raw disk device.

On the Linux Host

  1. Prepare a blank hard disk image with a valid low level format, partition table, and VTOC. If you need a pre-built image, one is available below. Download the file hd72_xfer.img.gz and uncompress it.
  2. Prepare a cpio archive of the files you wish to transfer to the emulated 3B2. In Linux, you must remember to pass the --format odc flag to build a compatible cpio archive, e.g.:

    $ ls * | cpio -ov --format odc > example.cpio
    
  3. Use dd to write the archive into the blank hard disk image. By passing the seek=810 flag, we skip into an unused area of the disk.

    $ dd if=example.cpio of=hd72_xfer.img bs=512 seek=810 conv=notrunc
    
  4. Finally, attach the disk image under SIMH (you must do this when the 3B2 is powered down!)

    sim> set id1 hd72
    sim> attach id1 hd72_xfer.img
    

On the Simulated 3B2

Now we reverse the process on the 3B2 by using dd and cpio to read from the raw emulated disk.

# dd if=/dev/rSA/disk2 skip=648 bs=512 | cpio -idv

(Note that we skip 648 blocks instead of 810. That is intentional, because the first cylinder is not mapped to the /dev/rSA/disk2 device.)

Using UNIX SVR3

If your only experience with UNIX-like systems is through modern Linux, you should be aware of a few things.

First, SVR3 is not loaded with fancy utilities like Linux. The base 3B2 installation doesn’t even come with man pages.

Second, you don't (by default) get a backspace character. That’s not a problem with the emulator, that’s really how SVR3.2 works. If you want to delete a character, you have to type the pound / hash symbol (#). And if you want to delete the whole line and start again, you have to press the at symbol (@).

Control Character Setup

You can change these default terminal control characters to something more familiar with the stty utility.

stty intr "^C"
stty erase "^?"
stty kill "^U"

Some terminal emulators send CTRL-H to delete a character. On such a terminal, you can use:

stty erase "^H"

To check the current values:

stty -a

Terminal Setup

If you want to use the vi editor in visual mode, you will need to define your TERM environment variable to something that SVR3.2 recognizes. It’s generally safe to set this to vt100.

TERM=vt100
export TERM

You can put this into your .profile file to set it automatically each time you log in.

Shutting Down

Don't forget to shut down cleanly by typing:

# shutdown -i0 -g0 -y

Installing SVR3.2 From Scratch

Preparing a Hard Disk Image

If you're feeling particularly adventurous, you can create a new blank hard drive image and low-level format it using the IDTOOLS floppy, then proceed to install SVR3.2 from scratch.

The IDTOOLS floppy image is here:

Image Size Description
idtools.img 720 KB Integrated Disk Utils and DGMON Diagnostic Monitor

Instead of attaching the pre-installed hard drive image from above, just attach a new file. A blank hard drive image will be created by SIMH.

Then, boot off of the idtools.img floppy.

sim> attach id0 new_blank_hd.img
sim> attach if0 idtools.img
sim> attach nvram nvram.bin
sim> boot cpu

At the "System Failure" prompt, enter the password mcp and press enter.

Then at the Enter name of program to execute [ ]: prompt, enter idtools, and select the floppy drive.

Once idtools is running, you'll see the following menu:

---------------------   IDTOOLS   ---------------------

   Floppy diskette formatter - type formflop
         Hard disk formatter - type formhard
            Hard disk verify - type verify
Disk to disk copy high speed - type ddhs
 Disk to disk copy by sector - type dd
          Disk <--> mem copy - type d-m
        Defect table builder - type defect
          Write sanity track - type fixdisk
        Change boot defaults - type chgboot
                        Quit - type q

Command?

Type formhard, then select disk 0.

You'll needc to know the parameters of the hard disk to format it. The following emulated hard disks are supported. Note: All disks are 18 Sectors per Track, and 512 Bytes per Sector.

SIMH Description ID Cyl Tracks/Cyl
HD30 CDC Wren 94155-36 3 697 5
HD72 CDC Wren II 94156-86 5 925 9
HD72C Fujitsu M2243AS 8 754 11
HD161 Maxtor XT1190 11 1224 15
         

Below is an example session with responses for formatting a 161MB (HD161) disk. Enter the correct responses for whichever type of disk you are formatting.

Current config table values:
           Drive Id:    2 - ? 11
   Number cylinders:  306 - ? 1224
    Number tracks/cyl:  4 - ? 15
 Number sectors/track: 18 - ? 18
Number bytes/sector:  512 - ? 512

You can really just skip all the annoying bad block stuff. You'll have to press Enter a lot.

Finally, select:

Format entire disk - type 1

The disk image will be low-level formatted and verified, and a sanity track will be written.

Installing the Operating System from Floppy Disk

I will largely leave this as an exercise for the reader. The basic procedure is to boot unix from the first floppy disk, and then follow the prompts to install the Essential Utilities floppy disks 1 – 6. After the Essential Utilities are installed, you can reboot off the hard disk id0 and proceed to install additional products with the sysadm softwaremgmt command.

All of the SVR3.2 floppy images can be found here.

https://static.loomcom.com/3b2/software/