EPICS for the Bewildered



Installing the EPICS Server (under vxWorks)

Now we have to get EPICS running on our idling VME crate running VxWorks. This means we need to compile EPICS for the controller card running in the VME crate.

The compilation process is mildly tricky if you've never cross-compiled code. There are no compilers designed to run under vxWorks, so your host system needs to compile the code into a binary the controller-card can run.

If you're running Windoze or Sun on your host system, all you need is the Tornado distribution (which contains the Tornado Interactive Development Enviroment) and it should work out-of-the-box. Needless to say, I'm a linux geek, so things are a bit tougher.

We'll need a cross-compiler for linux. This compiler, of course, depends on the definitions in the Tornado distribution.

Compiling the Cross-Compiler

Read the README file and you should do fine, although I needed to tweak the mkCrossGCC (thanks, Andrew) file because libiberty was not getting compiled. It might be helpful to add the line
WIND_BASE=/opt/tornadoXXX
(or whereever you've placed the Tornado distribution) to the mkCrossGCC file. The first pass (./mkCrossGCC CPU=<cpu>) will build the
$CROSS_BASE/obj-<cpu>
$WIND_BASE/host/x86-linux/<cpu>-wrs-vxworks/sys-include
directories. The second pass (./mkCrossGCC CPU=<cpu> build) will create the bin, include, install-tools, and lib directories under the Tornado distribution. and all the compiler tools needed in the cross-compiler distribution.

Compiling EPICS

At this point, we need to tell the EPICS distribution how to cross-compile code for our VME crate.

=3.14.8.2

  • Edit $EPICS_BASE/configure/os/CONFIG_SITE.Common.vxWorksCommon
  • Edit $EPICS_BASE/configure/CONFIG_SITE

    =3.14

    =3.13

    Change cwd to $EPICS_BASE and type "make." It is now time for your third cup of coffee.
    The biniaries will be found under $EPICS_BASE/bin/$CROSS_COMPILER_TARGET_ARCHS

    Installing EPICS on the IOC

    = EPICS 3.13

    Now we have to get the VME crate to run the code we compiled. First, we'll attempt to load the EPICS core. The iocCore program provides basic database processing routines and includes the channel access, dbServer, and time-handling programs.

    Assuming that the host you compiled the EPICS code on is the same as the host acting as the harddrive for the IOC, try typing these two lines at the vxWorks prompt:

    cd "/opt/epics/base/bin/ppc604/"  (or wherever your EPICS distribution is)
    ld < iocCore
    

    NB: If you are running on a power-pc chip and EPICS 3.13.x (as we are) it is highly possible that you will see the error

    Relocation value does not fit in 24 bits

    when you try and load iocCore. To quote from the EPICS website:

    "The PowerPC relative branch instruction is limited to jumps between +/- 32MB of the current instruction (24 bits = +/- 4M instructions, 4 bytes per instruction = +/- 32MB). Unfortunately the vxWorks kernel gets put into the bottom end of RAM, but it loads all application code at the top end. If the two are separated by more than 32MB (should you have 64MB or more on board) then when it tries to load the application code those calls that use these relative branch instructions to vxWorks routines can't be resolved within 24 bits, and the loader prints the message you're seeing."

    There are three fixes for this problem.


    When specifying your CROSS_COMPILER_TARGET_ARCHS, pick the vxWorks "long" option. That effectively does the second fix.


    The second fix recommends adding a compiler flag -mlongcall.


    Mark Rivers suggests a third fix: Simply occupy enough upper memory to force all loaded code to stay within the lower 32MB. This is done by starting the st.cmd file with
    mem = malloc(extra*1024*1024)
    (where the integer "extra" is the difference between the memory on your card and 32MB [in mebibytes]) and then calling
    free(mem)
    at the end.

    We have a 128MB card, so extra=128-32

    If this works, then we can test it. How? Try this set of commands:

    mem = malloc(96*1024*1024)           #We need this
    cd "/opt/epics/base/bin/ppc604"      #Or wherever your compiled iocCore lives
    ld < iocCore
    free(mem)
    coreRelease
    
    And you should get:
    ############################################################################
    ###  @(#)EPICS IOC CORE built on Feb 20 2004
    ###  @(#)Version R3.13.7 $2002/07/25 17:27:00$
    ############################################################################
    value = 0 = 0x0
    
    or something like it.

    = EPICS 3.14

    Things are quite a bit different under 3.14. So far the way I've tested an EPICS installation is to follow chapter 2, "Getting Started" in the EPICS: IOC Application Developer's Guide Simply follow the formula:

    1. Create a directory for the example application. I use $EPICS/base/testApp.
    2. Change CWD to this directory and create the example application with the following two commands:
      $EPICS/base/bin/linux-x86/makeBaseApp.pl -t example myexample
      $EPICS/base/bin/linux-x86/makeBaseApp.pl -i -t example myexample
    3. Type "make"
    4. Either change your startup script to point to $EPICS/testApp/iocBoot/iocmyexample/st.cmd or type the following commands into your ioc command line:
      ioc> cd "$EPICS/testAppiocBoot/iocmyexample"
      ioc> < st.cmd
    You should get the following banner:

    iocInit()
    Starting iocInit
    ############################################################################
    ### EPICS IOC CORE built on Sep 2 2005
    ### EPICS R3.14.7 $R3-14-7$ $2004/12/06 22:31:52$
    ############################################################################
    iocInit: All initialization complete
    value = 0 = 0x0
    Do a "dbl" and see what PVs you have avaliable.

    CONGRATULATIONS! You have a working server! Now you just have to put some databases on it....


    (Configuring the IOC) <-BACK | NEXT-> (Getting EPICS to Do Stuff)