Documentation:Users:Linux CAMAC - MdsWiki
Navigation
Personal tools

From MdsWiki

Jump to: navigation, search

Linux CAMAC hardware configuration

The following CAMAC interfaces are supported on MDSplus

  • Jorway 411S SCSI Serial Highway
  • Kinetic Systems 2145 SCSI Serial Highway
  • Jorway 73A SCSI Crate Controller

The MDSplus support for these devices uses the generic SCSI driver provided with Linux. Standard kernels such as RedHat are generally configured with everything you need to use the MDSplus CAMAC support. If you build your own Linux kernel you should configure it with the "Legacy /proc/scsi File System" and the sg (generic SCSI) driver.

Linux CAMAC software configuration

First you have to define the location where you will keep track of your module definitions. You do this by defining the environment variable: CTS_DB_DIR which should point to a directory which will contain the tables which identify the CAMAC crates and modules attached to your system. This is often stored in /etc/cts and the environment variable can be defined in /etc/mdsplus.conf using the following line in /etc/mdsplus.conf

CTS_DB_DIR /etc/cts

Create this directory and assign file protection to grant write access to users that you want to be able to change the CAMAC module assignments.

Next you need to create a startup file so things will get loaded properly when the system boots. You should be able to put the following into a file called /etc/rc.d/init.d/camac.

Notes:

  • Adjust the CTS_DB_DIR environment variable if you use a different directory location.
  • Change the /sbin/modprobe line to reflect the driver needed for your SCSI card (or remove it entirely if the driver is loaded automatically before CAMAC is started).
#! /bin/bash
#
# camac Bring up/down camac
#
# chkconfig: 2345 99 99
# description: Run mdscts autoconfig and mdscts set */on at boot time
#
# probe: false
#
# See how we were called.
case "$1" in
  start)
#
# If your J411S is on a SCSI card using a kernel module,
#  you can load it here with /sbin/modprobe.
# (E.g., the DEC KZPAA card uses the "sym53c8xx" module.) 
# If it is built into the kernel you should comment out
#  the /sbin/modprobe command
#
       /sbin/modprobe aic7xxx
#
        export LD_LIBRARY_PATH=/usr/local/mdsplus/lib:$LD_LIBRARY_PATH
#
# CTS_DB_DIR should be defined in /etc/mdsplus.conf,
#  *OR* you can un-comment the next line
#
#        export CTS_DB_DIR=/etc/cts
#
# If you have the SCSI generic driver built in, comment out
#  the following "if" block
#
        if ! /sbin/lsmod | /bin/grep "^sg" > /dev/null
        then
          /sbin/insmod sg
        fi
#
# Test for the CTS database directory; if necessary
#  create it and populate it with the db files
#
        if ! test -d $CTS_DB_DIR
        then
          mkdir $CTS_DB_DIR
        fi
        if [ ! -r $CTS_DB_DIR/buffer.db ]
        then 
           echo " " > $CTS_DB_DIR/buffer.db
        fi
        if [ ! -r $CTS_DB_DIR/crate.db ]
        then 
           echo " " > $CTS_DB_DIR/crate.db
        fi
        if [ ! -r $CTS_DB_DIR/cts.db ]
        then 
           echo " " > $CTS_DB_DIR/cts.db
        fi
#
# Set the permissions to all having r/w access
#  *OR* consider using access control lists (ACLs)
#
        chmod a+rw $CTS_DB_DIR
        chmod a+rw $CTS_DB_DIR/*.db
#
# You may need to do the following line only once
#
        chmod a+rw /dev/sg*
#
# Set up the crates in crate.db
#
        /usr/local/mdsplus/bin/mdscts autoconfig
#
# Turn all crates online
#
        /usr/local/mdsplus/bin/mdscts set/on/quiet
        ;;
  stop)
        ;;
  *)
        echo $"Usage: $0 {start|stop}"
        exit 1
esac
exit 0

Next enable the camac script at startup using the following command:

$ chkconfig --add camac

Next manually invoke the startup script to load the sg driver and create the db files:

$ /etc/rc.d/init.d/camac start

Important: Most "standard" MDSplus installs assume that one will be using remote CAMAC commands. If you have the Jorway 411S on the host, you need to have libCamShr.so point to the proper library files.

If you see libCamShr.so listing like this (containing links to libRemCamShr.*):

$ ls -l /usr/local/mdsplus/lib/libCamShr*
lrwxrwxrwx 1 root root     15 Jan 10 15:51 /usr/local/mdsplus/lib/libCamShr.so -> libRemCamShr.so
lrwxrwxrwx 1 root root     16 Jan 10 15:51 /usr/local/mdsplus/lib/libCamShr.so.1 -> libCamShr.so.1.8
-rwxr-xr-x 1 root root 151405 Jan 10 15:51 /usr/local/mdsplus/lib/libCamShr.so.1.8

You need to delete the soft link to libRemCamShr.so (be careful) and make a new one to the local CAMAC library:

$ cd /usr/local/mdsplus/lib
$ sudo rm -i libCamShr.so

Do NOT delete libCamShr.so.1.8 !!

Make the new soft link (libCamShr.so.1.8 is the real library file),

$ sudo ln -s libCamShr.so.1 libCamShr.so

Next use mdscts to assign crates and modules:

$ mdscts
CTS> addcrate GKainn: ! where a=scsi bus (i.e. A,B,C or D), 
     i=scsi id of the j411s, nn=crate number
CTS> assign GKainn:Nmm cts-name[/comment="This is a comment"]
CTS> set */on
CTS> SHOW *
CTS> SHOW/CRATE

That should basically be it. Once you define names for your CAMAC modules you should be able to use mdsccl to try talking to your CAMAC modules.

NOTE: Initialization Issues with CTS DB Files

The three "db" files in /etc/cts:

$ ls /etc/cts
buffer.db  crate.db  cts.db

seem to initially need a blank line in them (viz. they can't be empty files) to avoid mdscts errors such as:

CTS> sh /cr
mdsdcl: --> failed on line 'sh /cr'
CTS> sh *  
mdsdcl: --> failed on line 'sh *'

Place a blank line in each of them to start. (They are initially created by the touch command in the /etc/rc.d/init.d/camac script.)

Also, the mdscts command "sh /cr" shows blanks until CAMAC devices are added:

$ mdscts
CTS> sh /cr
 CRATE   ONL LAM PRV ENH
=======  === === === ===
=======  === === === ===
CTS> addcrate gka501:
CTS> set /on
CTS> sh /cr
 CRATE   ONL LAM PRV ENH
=======  === === === ===
=======  === === === ===
CTS> ass           
_Physical name:: gka501:n2
_Logical name:: hit_dg11_a
CTS> sh *
  #  Logical Name                     Physical   Comment
==== ================================ ========== ========================================1
  1: HIT_DG11_A                       GKA501:N2                                          <
==== ================================ ========== ========================================
CTS> sh /cr
 CRATE   ONL LAM PRV ENH
=======  === === === ===
GKA501:   *   .   .   *
=======  === === === ===

It seems to work OK after this initialization.