--- /dev/null
+\section{Configuration}
+
+% \subsection{Running TRB3}
+
+The TRB software allows you to run several TRBnets for different TRB3 at the
+same machine at the same time. Each TRB has its own identifier. Your system
+should have working DHPC and DNS servers.
+
+\subsection{Preparing DHCP}
+
+The DHCP is used to assign IP address to each TRB3. You must know MAC address of
+TRB3 in order to configure DHPC server.
+
+
+\begin{warning} Running DHPC server in your institution network may run you into
+troubles with your network administrator. If you are not sure, contact him
+first. It is safer to run you TRB3 system on separated local network. Ask you
+computer administrator (AYA) for details.
+\end{warning}
+
+Commands in this part you must execute as a superuser.
+
+In order to get MAC address of the TRB3 you can ask someone or check by
+yourself. When TRB3 is starting up it sends request to the network to DHCP
+servers. Check your system logs to see this requests. Here is example
+
+\begin{lstlisting}[label=dhcp-request,caption=Sample of DHCP request]
+ # you must run following command as a root
+$ watch tail /var/log/messages # it may be different for your system, AYA
+ # now restart your TRB3 and watch incoming messages, you should see something like this
+Nov 29 10:55:18 localhost dhcpd: DHCPDISCOVER from 02:00:be:d9:21:90 via eth0
+ # if there is another DHCP in the network then you will see its answer
+Nov 29 10:55:18 localhost dhcpd: DHCPOFFER on 10.155.59.130 to 02:00:be:d9:21:90 via eth0
+Nov 29 10:55:18 localhost dhcpd: DHCPREQUEST for 10.155.59.130 (10.155.59.47) from 02:00:be:d9:21:90 via eth0
+Nov 29 10:55:18 localhost dhcpd: DHCPACK on 10.155.59.130 to 02:00:be:d9:21:90 via eth0
+\end{lstlisting}
+
+The MAC address of TRB3 is \verb+02:00:be:d9:21:90+ and DHCP assigned the IP
+address \verb+10.155.59.130+ (this IP will be different for your network).
+
+We need to know the network address and network mask. For example we take local
+separated network with address \verb+10.0.0.0+ and mask \verb+255.255.255.0+.
+Your computer (server) is \verb+10.0.00.1+. We assign address \verb+10.0.0.33+
+to TRB3 with serial number (S/N) 033. Your TRB will have different number, it is
+good practice to keep IP address the same like serial number, it is easier to
+find them later.
+
+Now we can configure the DHCP. Open file \verb+/etc/dhcp/dhcpd.conf+ with your
+favourite editor and put
+\begin{lstlisting}[label=dhcp-config,caption=/etc/dhcp/dhcpd.conf]
+non_authoritative;
+
+shared-network YourNetworkName {
+ default-lease-time 43200;
+ max-lease-time 86400;
+ allow unknown-clients;
+ allow bootp;
+
+ option subnet-mask 255.255.255.0;
+
+ option domain-name "mylovelytrb3.hades.net";
+ option domain-name-servers 10.0.0.1;
+
+ option ip-forwarding false;
+
+ use-host-decl-names on;
+
+subnet 10.0.0.0 netmask 255.255.255.0 {
+# Optionally here you can set default gateway for routing.
+# option routers 10.0.0.0;
+
+ group {
+ host trb033 {
+ hardware ethernet 02:00:be:d9:21:90;
+ fixed-address 10.0.0.33;
+ }
+ }
+}
+\end{lstlisting}
+
+Now we can start your DHCP server. How to do this ask AYA (it is different
+for different LINUX distributions). You should also configure your RPCBIND (it
+has nothing to do with HADES RPC) to run with option \verb+i+ $\to$ AYA.
+
+Now you can restart your TRB3 and watch again log of your system, you should get
+following output
+\begin{lstlisting}[label=,caption=Sample of DHCP request]
+Nov 29 10:55:18 localhost dhcpd: DHCPDISCOVER from 02:00:be:d9:21:90 via eth0
+Nov 29 10:55:18 localhost dhcpd: DHCPOFFER on 10.0.0.33 to 02:00:be:d9:21:90 via eth0
+Nov 29 10:55:18 localhost dhcpd: DHCPREQUEST for 10.0.0.33 (10.0.0.1) from 02:00:be:d9:21:90 via eth0
+Nov 29 10:55:18 localhost dhcpd: DHCPACK on 10.0.0.33 to 02:00:be:d9:21:90 via eth0
+\end{lstlisting}
+This means that DHCP works fine. If you have more TRB3s then you need to add
+more \verb+host+ sections inside subnet's group.
+
+\subsection{Preparing DNS}
+If you are using only one computer then you don't need to run DNS server, your
+local one is enough. As a superuser edit file \verb+/etc/hosts+ and add this
+line
+\begin{lstlisting}[label=,caption=/etc/hosts]
+10.0.0.33 trb033
+\end{lstlisting}
+If you have more TRB3s add them there also.
+
+Now you can test your DNS with ping. You should get something like this.
+
+\begin{lstlisting}[label=,caption=Example of ping results on working TRB3]
+$ ping trb033 -c 3
+PING trb033 (10.0.0.33) 56(84) bytes of data.
+64 bytes from trb033 (10.0.0.33): icmp_req=1 ttl=255 time=0.077 ms
+64 bytes from trb033 (10.0.0.33): icmp_req=2 ttl=255 time=0.058 ms
+64 bytes from trb033 (10.0.0.33): icmp_req=3 ttl=255 time=0.053 ms
+
+--- trb033 ping statistics ---
+3 packets transmitted, 3 received, 0% packet loss, time 1999ms
+rtt min/avg/max/mdev = 0.053/0.062/0.077/0.013 ms
+\end{lstlisting}
+
+\subsection{Starting TRBnet}
+
+Each TRB3 can be controlled with \verb+trbcmd+ command over then TRBnet. Each
+TRBnet is assigned to TRB3 and when communicating to TRB3 you must inform
+\verb+trbcmd+ which TRBnet you want to use. The TRBnet id is the number from
+range $0\ldots255$ (0 is default). In following we will run the TRB3 with serial
+number (S/N) = 33 on TRBnet with id = 1;
+
+There are several commands and variables which you must know:
+\begin{description}
+ \item[TRB3\_SERVER] This variable keeps the DNS name of the TRB for which we run
+the TRBnet. Must be set before starting TRBnet.
+ \item[trbnetd -i $<id>$] This command starts the TRBnet for the TRB3 defined in
+\verb+TRB3_SERVER+. The \verb+id+ is the id for TRBnet.
+ \item[DAQOPSERVER] This variable keeps the server and TRBnet id for running trb
+commands (see \verb+trbnetd+ command).
+ \item[trbcmd] The basic command to manage all TRBnet.
+\end{description}
+
+Here is example how to start TRBnet and get IDs of all FPGAs on the TRB3
+\begin{lstlisting}[label=,caption=Testing TRBnet for multi TRB3 system]
+$ TRB3_SERVER=trb033 trbnetd -i 1
+$ DAQOPSERVER=localhost:1 trbcmd i 0xffff
+0xf3c0 0x7c0000039021d928 0x05
+0xf306 0x9e00000390195f28 0x00
+0xf306 0x5100000390195528 0x01
+0xf306 0xfc00000390225628 0x02
+0xf306 0xb600000390225b28 0x03
+\end{lstlisting}
+
+If we have several TRB3 and we don't know which TRBnets are assigned to them, we
+can easily find them with following commands
+
+\begin{lstlisting}[label=,caption=Identifying of TRBnet daemons]
+$ ps ax | grep trbnetd
+ 2556 ? S 1:15 trbnetd -i 33
+21818 pts/21 S+ 0:00 /bin/grep trbnetd
+$ cat /proc/$(pgrep -f "trbnetd -i 33")/environ | strings | grep TRB3
+TRB3_SERVER=trb033
+\end{lstlisting}
+
+If you are using only one TRB3 then you can also export variables globally
+\begin{lstlisting}[label=,caption=Recommended way to run TRBnet for single TRB3 system]
+$ export TRB3_SERVER=trb033
+$ trbnetd -i 1
+$ export DAQOPSERVER=localhost:1
+$ trbcmd i 0xffff
+0xf3c0 0x7c0000039021d928 0x05
+0xf306 0x9e00000390195f28 0x00
+0xf306 0x5100000390195528 0x01
+0xf306 0xfc00000390225628 0x02
+0xf306 0xb600000390225b28 0x03
+\end{lstlisting}
+In future we assume that we have only one TRB3 and these variables are exported.
+You can add this exports to your \verb+~/trb3/setenv.sh+ file.
+
+As you can see the FPGA addresses (first column) are not configured yet in your
+system. The middle columns is the unique ID of the FPGA (temp sensor), the last
+column is the FPGA number (0x05 is the central FPGA). To set proper addresses
+execute following command
+\begin{lstlisting}[label=,caption=Updating addresses and serial numbers]
+$ ~/trbsoft/trb3/merge_serial_address.pl ~/trb3/base/serials_trb3.db ~/trb3/base/addresses_trb3.db > /dev/null
+\end{lstlisting}
+It will load proper configuration to your TRB3. After this we can check whether our changes made expected result.
+\begin{lstlisting}[label=,caption=Results of addresses changes]
+$ trbcmd i 0xffff
+0x8000 0x7c0000039021d928 0x05
+0x1000 0x9e00000390195f28 0x00
+0x1001 0x5100000390195528 0x01
+0x1002 0xfc00000390225628 0x02
+0x1003 0xb600000390225b28 0x03
+\end{lstlisting}
+
+The files \verb+serials_trb3.db+ and \verb+addresses_trb3.db+ are the global
+databases of the all TRB3 produced ever for HADES. If you must assign new
+addresses to your TRB3 setup, you should open file
+\verb+~/trb3/base/addresses_trb3.db+. In column \verb+S/N+ you should find your
+TRB3 number and then change TRBnet addresses to proper one (if you don't know
+$\to$ AMT).
+
+After this your changes should be saved, for this commit changes to the
+repository (requires password).
+\begin{lstlisting}[label=,caption=Commiting changes to repository]
+$ cvs commit -m "Description of your changes" addresses_trb3.db
+\end{lstlisting}
+\begin{warning}
+Be sure that everything is OK, your changes may break system of all
+other users of the TRB3.
+\end{warning}
+As the last you should rerun merging of the addresses and serials.
+
+\subsection{CTS monitor configuration}
+
+In order to inform CTS server which endpoint hosts the CTS, you must or edit
+config file (is recommended if you do not change it to often), or give it as a
+command line parameter for the server. For the first one edit the file
+\verb+~/trbsoft/trb3/cts/CtsConfig.pm+ and change the return value from the getDefaultEndpoint function.
+
+\begin{lstlisting}[label=ctssfg,caption=\$\{HOME\}/trbsoft/trb3/cts/CtsConfig.pm]
+package CtsConfig;
+
+#default cts endpoint. can be overriden by a command line parameter
+sub getDefaultEndpoint {
+ return 0x8000;
+}
+
+1;
+\end{lstlisting}
+
+
+\subsection{DAQ configuration}
+
+You must configure your TRB3 which is the IP address of the Event Builder. This
+you can set in proper registers of the central FPGA of
+the TRB3. For this in the file \verb+configure_trb3.sh+ find line starting with
+\verb+#mac address of the EB+, in register \verb+0x8100+ write lower four bytes
+of the MAC and \verb+0x8101+ two upper bytes, for example for MAC
+\verb+00:11:22:33:44:55:66+ configuration look following
+
+\begin{lstlisting}[label=,caption=Settings Event Builder address for TRB3]
+#mac address of the EB
+#ebhost 00:11:22:33:44:55
+trbcmd w 0x8000 0x8100 0x22334455 # lower bytes
+trbcmd w 0x8000 0x8101 0x0011 # upper bytes
+\end{lstlisting}
+
+{\color{red}\fbox{
+TODO: how to get this script?
+}}
\ No newline at end of file
--- /dev/null
+\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
+\usepackage{color}
+
+% \usepackage{minted}
+% \usemintedstyle{console}
+
+\usepackage{listings}
+
+\newenvironment{warning}
+{\begin{center}
+ \begin{minipage}[]{0.1\textwidth}
+ \centering
+ \includegraphics[width=0.8\textwidth]{trb3qs_img/dialog-warning}
+ \tiny\textbf{WARNING}
+ \end{minipage}
+\begin{minipage}[]{0.85\textwidth}}
+{\end{minipage}
+ \end{center}}
+
+\usepackage{listings}
+% \usepackage{courier}
+% \usepackage{beramono}
+
+ \lstset{
+ basicstyle=\ttfamily, % Standardschrift
+% numbers=left, % Ort der Zeilennummern
+ numberstyle=\tiny, % Stil der Zeilennummern
+ stepnumber=2, % Abstand zwischen den Zeilennummern
+ numbersep=5pt, % Abstand der Nummern zum Text
+ tabsize=2, % Groesse von Tabs
+ extendedchars=true, %
+ breaklines=true, % Zeilen werden Umgebrochen
+ keywordstyle=\color{red},
+ frame=rb,
+ columns=fullflexible,
+ % keywordstyle=[1]\textbf, % Stil der Keywords
+ % keywordstyle=[2]\textbf, %
+ % keywordstyle=[3]\textbf, %
+ % keywordstyle=[4]\textbf, \sqrt{\sqrt{}} %
+ stringstyle=\color{white}\ttfamily, % Farbe der String
+ showspaces=false, % Leerzeichen anzeigen ?
+ showtabs=false, % Tabs anzeigen ?
+ xleftmargin=10pt,
+ framexleftmargin=17pt,
+ framexrightmargin=5pt,
+ framexbottommargin=4pt,
+% backgroundcolor=\color{lightgray},
+ showstringspaces=false % Leerzeichen in Strings anzeigen ?
+ }
+ \lstloadlanguages{% Check Dokumentation for further languages ...
+ %[Visual]Basic
+ %Pascal
+ %C
+ %C++
+ %XML
+ %HTML
+% Java
+ }
+ %\DeclareCaptionFont{blue}{\color{blue}}
+
+ %\captionsetup[lstlisting]{singlelinecheck=false, labelfont={blue}, textfont={blue}}
+ \usepackage{caption}
+\DeclareCaptionFont{white}{\color{white}}
+\DeclareCaptionFormat{listing}{\colorbox[rgb]{0.8, 0.8, 0.8}{\parbox{\textwidth}{\hspace{15pt}#1#2#3}}}
+\captionsetup[lstlisting]{format=listing,singlelinecheck=false, margin=0pt, font={tt}}
+
+% \lstinputlisting[label=samplecode,caption=A sample]{sourceCode/HelloWorld.java}
\ No newline at end of file
--- /dev/null
+\section{Software installation}
+
+For convenience I start each code line with prompt (\verb+$+). If the command
+(in brown) is too long for one line, then its continuity starts with intendation in the
+next line. Lines starting with \verb+#+ are comments (in green).
+
+% \subsection{Preparation}
+
+The software is keep in CVS repository in GSI. You must fetch a few mandatory
+directories. This repository is closed and requires password. If you don't know it,
+contact with Michael Traxler (Ask Michael Traxler$\to$ AMT).
+
+\begin{lstlisting}[label=,caption=Downloading the tools repositories]
+$ cd ~
+$ cvs -d :ext:hadaq@lxi001.gsi.de:/misc/hadesprojects/daq/cvsroot co trbsoft
+$ cvs -d :ext:hadaq@lxi001.gsi.de:/misc/hadesprojects/daq/cvsroot co trb3/base
+$ cvs -d :ext:hadaq@lxi001.gsi.de:/misc/hadesprojects/daq/cvsroot co trb3/README
+\end{lstlisting}
+% $ cvs -d :ext:hadaq@lxi001.gsi.de:/misc/hadesprojects/daq/cvsroot co hadaq
+
+
+\begin{lstlisting}[label=,caption=Preparation of TRB3 tools]
+$ cd ~/trbsoft/trbnettools
+$ cat HOWTO_COMPILE.TXT # now you can see all posible ways to compile software
+ # we compile for TRB3
+$ make distclean
+$ make TRB3=1
+$ make TRB3=1 install # if you get error here due to no permissions
+ # run it as a root
+$ sudo make TRB3=1 install # if it doesn't work,
+ # contact your computer administrator for help
+ # now export your binaries to PATH
+$ export PATH=${HOME}/trbsoft/trbnettools/binlocal:${PATH}
+ # to make life easier add this line above to your profile to to env script
+\end{lstlisting}
+% $ ln -s ~/trbsoft/trbnettools/binlocal/trbnetd ~/trbsoft/trbnettools/bin
+
+To prepare Event Builder you must fetch three directories from CVS, add
+execution permissions to configure scripts, run thm with proper parameters and
+compile and install libraries and binaries. On the end do not forget to export
+your new locations to \verb+$PATH+. The full procedure is shown in following
+snippet.
+
+% \begin{verbatim}
+\begin{lstlisting}[label=,caption=Preparation of Event Builder]
+# mkdir ~/trbsoft/src
+$ cd ~/trbsoft/src
+$ cvs -d :ext:hadaq@lxi001.gsi.de:/misc/hadesprojects/daq/cvsroot co allParam hadaq compat
+$ chmod +x {allParam,compat,hadaq}/configure
+$ for ddd in allParam compat hadaq; do cd ~/trbsoft/src/${ddd}; CPPFLAGS="-I${HOME}/daqsoftware/include" LDFLAGS="-L${HOME}/daqsoftware/lib" ./configure --prefix=${HOME}/daqsoftware; make all install || break; done
+$ export PATH=${HOME}/daqsoftware/bin:${PATH}
+# this export salso can be add to profile or init script
+\end{lstlisting}
+% \end{verbatim}
+
+If you get error
+\verb+evtbuild.c:46:38: fatal error: rawapin.h: No such file or directory+ then
+edit file \verb+evtbuild.c+, comment out \verb+#define RFIO+ and repeat last
+command (the \verb+for+ loop).
+
+On the it is recommended to create init script
+\begin{lstlisting}[label=setenv,caption=\$\{HOME\}/trb3/setenv.sh]
+#!/bin/bash
+export PATH="${HOME}/daqsoftware/bin:${HOME}/trbsoft/trbnettools/binlocal:${PATH}"
+\end{lstlisting}
+This script should be run with command \verb+. ~/trb3/setenv.sh+ in each new terminal
+supposed to work for TRB3.
\ No newline at end of file