
Auger v2.0 Board Setup
J. Kelley, j.kelley@astro.ru.nl

Introduction
------------

This document describes how to set up an Auger v2.0 digitizer.  On
delivery, the kernel and filesystem on the PC card need to be updated,
which is the first step.  Next, the network settings have to be updated.
The DAQ software must be loaded onto the flash filesystem.  Finally, the
GPS receiver must be put into UTC mode.

Physical Setup
--------------

First, the board must be connected to the host computer used for
programming.  Currently, this is "merum."  The following physical
connections to the digitizer should be in place:

1. 12V to power pigtail (from a power supply capable of 1A).  

2. Ethernet cable to LAN hub or to host PC Ethernet port.  This subnet is
192.168.61.x, with the default IP address of the host as 192.168.61.161.
This can be changed in the setup scripts.

3. Serial connections to board.  This consists of:

   a. Ribbon cable to header P12 on the board.  Careful of the pin
   alignment (the arrow on the connector lines up with pin 1 on the
   header).  

   b. Ribbon cable to "AUGINT" serial interface board.  

   c. Serial cable (DB9, crossover / null modem) from CON1 on interface board to
   serial port on PC.  The software assumes this is /dev/ttyS0.  
  
   d. For GPS receiver configuration: USB cable from CON3 on interface
   board to USB port on PC.  The software assumes this is /dev/ttyUSB0
   (serial USB).   

4. (Optional) GPS antenna to GPS input (TNC).

Host Software Setup
-------------------

These instructions describe how to set up the host PC to communicate with
the digitizer.  We assume the use of a Linux machine, but the installation
scripts will also work on a Mac (see Appendix A).

1. A serial terminal program, such as "minicom", must be installed on the
host PC.  A normal user should have read/write access to the serial port,
/dev/ttyS0.  The serial settings are 38400-8N1-no flow control.  This is
already set up on merum.

If minicom is not set up, here's how to install and set up on an Ubuntu
machine: 

   % aptitude install minicom

Then run minicom:

   % minicom

'CTRL-A O' will bring up the settings screen.  Then choose "Serial port
setup", change the serial settings to "38400 8N1", and make sure all flow
control is OFF.  Choose "Modem and dialing", and delete the init string and
reset string.  Then choose "Save setup as dfl [default]".  Quit minicom
with 'CTRL-A X'.

On my Ubuntu system, normal users already had permissions to read and write
/dev/ttyS0.  If this is not the case, to make it so that non-root users can
access the serial port, you may need to add the user to the "dialout" group
(on Ubuntu, anyway). 

   % addgroup <user> dialout

If this still doesn't work, you may need to add a udev entry.  Or just run
as root.  

You can test that the serial connection is working correctly by starting
minicom again, upon which you should see a login prompt from the digitizer.
If you reset the digitizer with the reset button or power-cycle it, you
should see the bootloader sequence (u-Boot).  

2. A TFTP server should be running (or set up to run by inetd on an
incoming connection on port 69.  Again, this is already running on merum.  

If a TFTP daemon is not running, to install on an Ubuntu machine:

   % aptitude install xinetd tftpd

Create a file called /etc/xinetd.d/tftp containing the following xinetd
entry:

service tftp
{
        disable = no
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = nobody
        only_from               = localhost 192.168.61.0/24
        server                  = /usr/sbin/in.tftpd
        server_args             = -s /tftpboot
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}

Create the server directory:

    % mkdir /tftpboot

Restart xinetd:

    % /etc/init.d/xinetd restart

3. A DHCP server must be running for certain versions of the board-loading procedure below.  This should be serving IP address on the 192.168.61.xxx subnet.  

4. Install the "expect" scripting program if it is not already installed:

   % aptitude install expect
   % rehash

5. Check out the "digitizer" project from SVN (currently the SVN
server is running on merum and is only accessible on the Radboud LAN, but
hopefully this will change).  This contains the scripts and binaries
necessary to flash the board.  Alternatively, download a snapshot <here>.  

Loading the Board Software
--------------------------

1. Copy the kernel image ("zImage*.dat") and filesystem image
("voipacfs*.bin") that you wish to use from the binaries/ directory in the
digitizer project to /tftpboot on the host PC, renaming them to
"zImage.dat" and "voipacfs.bin".  

You can skip this if the appropriate images are already in
/tftpboot, of course.
   
*****

The procedure to load the file system depends on the type of flash on the Voipac card you have.  See the README_loadfs documents for more information.  

2a. [NOR flash, OBSOLETE] Change into the scripts directory, run the loadfs script, and follow
   the instructions: 

   % cd scripts
   % ./loadfs <SERIAL #>

This takes approximately 10 minutes.  If the load succeeds, you will see
the message "Reboot into Linux succesful!"  If it hangs, something has gone
wrong. 

2b. [NOR flash, CURRENT] See the README_loadfs_nor.txt document.

2c. [NAND flash] Change into the scripts directory, run the loadfs_nand script, and follow the instructions:

    % cd scripts
    % ./loadfs_nand <SERIAL #>

*****

3. Run the script to update the network settings.

   % ./fix_network <SERIAL #>

Note that this reads the PC card MAC address from a text file in the same
directory.  This file must be updated for new boards as they arrive, or if
PC cards are moved around.

At this stage, ssh into the board should work (as root only).  

4. Run the script to load the DAQ setup (FPGA design, Linux drivers, and
   DAQ software) onto the board:

   % ./setup_daq <SERIAL #> <STATION ID>

The "station ID" really only matters for the MAXIMA setup.

At this point, the DAQ user is set up and the DAQ software is installed
onto the board.  After setup_daq reboots, you should see the FPGA 1-second
lights blinking, indicating that the firmware has loaded.

If the GPS receiver is to be configured and the USB cable is attached:

5. Run the script to switch the GPS into UTC time:

   % cd ..; gpscom/gpscom -r 7 -d 4 -u 1 -f
   <exit with CTRL-C>

The GPS antenna does not need to be connected to run this script.

Appendix A
----------

The digitizer software can also be run from a Mac.  In this case, a
USB-to-serial converter, such as the Keyspan USA-19HS, must be used for the
physical serial connection.  Once this in place, the following can be used
for serial communcation and TFTP support.

Note: some of the required software may be part of the Mac Developer
Toolkit, but this can be downloaded from Apple for free.  

1. Connect the digitizer to both the USB-to-serial converter and the Ethernet
port.  

2. In System Preferences -> Network, set the Mac's IP address on the
Ethernet interface to match the server IP in the scripts.  Currently, this
is 192.168.61.161.

3. The highly useful 'screen' program can be used for serial communication.
Without changing any scripts, one can use this to mimic 'minicom' by adding
a script somewhere in your PATH called 'minicom', consisting of this alias:

    #!/usr/bin/screen -U /dev/tty.KeySerial1 38400

Read up on 'screen' if you are not familiar with the escape commands to
manipulate terminals within the program.  

4. A TFTP daemon is also already installed on the Mac.  It can be started
from a Terminal session with 

  % sudo launchctl load -w /System/Library/LaunchDaemons/tftp.plist

and stopped with

  % sudo launchctl unload -w /System/Library/LaunchDaemons/tftp.plist

By default, the tftp directory is in /private/tftpboot.  I changed the
permissions on this directory to 777.  

5. The dhcp server is somewhat more annoying.  I had to download the dhcpd source from ISC and compile it.  I then created a dhcpd.conf file containing:

## /etc/dhcpd.conf file
subnet 192.168.61.0 netmask 255.255.255.0 {
    range 192.168.61.150 192.168.61.200;
    default-lease-time 300000;
    max-lease-time 350000;
    option routers 192.168.61.161;              
}

Then create a fake leases file:

  % sudo touch /var/db/dhcpd.leases

Finally, one can launch the dhcp server with

  % sudo ./server/dhcpd -f -d -cf dhcpd.conf en0

6. The 'expect' program is already installed.  

With these adaptations, the digitizer software can be loaded with the existing scripts with no modification.  The only problem is that by mimicking "minicom" with the "screen" script, you may have to kill the screen process manually after the expect script exits.


