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-includedirectories. 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.
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) coreReleaseAnd you should get:
############################################################################ ### @(#)EPICS IOC CORE built on Feb 20 2004 ### @(#)Version R3.13.7 $2002/07/25 17:27:00$ ############################################################################ value = 0 = 0x0or something like it.
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:
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....