# Presentation: 423196

## DEBUGGING EPICS  APPLICATIONS

**Bob Dalesio and Rozelle Wright**

- February 10, 1997

## Outline

- References
- Booting a VME Crate - vxWorks and EPICS
- Debugging Hardware Failures
- Debugging Database Problems
- Debugging Client Connections to the Database
- Developing and Debugging new code under vxWorks

## DEBUGGING REFERENCES

**EPICS Documentation on WWW at APS**
- http://epics.aps.anl.gov/asd/controls
- Applications Developer's Guide
- Particularly -- Chapter 2. -- IOC Test Facilities
- Record Reference Manual
**  ****VxWorks Programmer's Manual**
- Particularly
- Chapter 2 -- Getting Started
- Chapter 12 -- Debugging
- Chapter 11 -- The Shell

## Boot Parameters

- mv167> bootChange
- '.' = clear field;  '-' = go to previous field;  ^D = quit
- boot device          : ei
- processor number     : 0
- host name            : leia
- file name            : ~wright/vx/v51.epics/config/mv167/vxWorks
- inet on ethernet (e) : 189.165.32.83:ffffff00
- inet on backplane (b):
- host inet (h)        : 189.165.32.26
- gateway inet (g)     :
- user (u)             : vx
- ftp password (pw) (blank = use rsh): xxxxxxx
- flags (f)            : 0x29
- target name (tn)     : vxmv156733a
- startup script (s)   : ~wright/camac_demo/camac/startup.mv167
- other (o)            :

## Booting vxWorks

**Boot Parameters Used for Booting vxWorks**
- boot device          : ei
- host name            : leia
- file name            : ~wright/vx/v51.epics/config/mv167/vxWorks
- host inet (h)        : 189.165.32.26
- user (u)             : vx
- ftp password (pw) (blank = use rsh): xxxxxxx
**Successful Boot of vxWorks - from Serial Port**
- Attaching network interface ei0... done.
- Attaching network interface lo0... done.
- Loading... 362104 + 102960 + 26566
- Start at 0x1000
- Attaching network interface ei0... done.
- Attaching network interface lo0... done.
- Loading symbol table from leia:~wright/vx/v51.epics/config/mv167/vxWorks
- ...done

## Booting vxWorks

**Unsuccessful Boot of vxWorks - from Serial Port**
- Attaching network interface ei0... done.                       :ei0 is correct ethernet driver
- Attaching network interface lo0... done.
- Loading...
- Error loading file: errno = 0xd.
- Can't load boot file!!
**Possible Reasons**
- Verify boot parameters are OK
- Network is down, a bad cable connection or has an improper termination
- vxWorks does not exist at the specified filename in the boot parameters
- vx account or password not setup on the specified host
- file protections on the specified filename are not correct

## Booting EPICS

**After Successful Boot of vxWorks - from Serial Port**
- runs this:   startup script (s)   : ~wright/camac_demo/camac/startup.mv167
**Successful Boot**
- done
- Executing startup script ~wright/camac_demo/camac/startup.mv167
- (will execute each command in the startup script)

## Booting EPICS

**Verify Successful Boot by telnet'ing to IOC and typing:  i**
- NAME        ENTRY       TID    PRI   STATUS      PC       SP     ERRNO  DELAY
- ---------- ------------ -------- --- ---------- -------- -------- ------- -
- *timeStamp  _gts_select    2b9570  32 PEND           a2a0   2b9414       0     0
- *callback   _callbackTas   2bd2cc  40 PEND           a2a0   2bd284       0     0
- *scanEvent  30da20         299184  41 PEND           a2a0   29913c       0     0
- *gpibLink   2c99b2         2bb5e4  47 PEND           a2a0   2bb590       0     0
- *scanPeriod 30d676         29ba44  53 DELAY         46772   29b9f8       0     4
- *CA client  _camsgtask     2ad814 180 PEND           a2a0   2ad71c       0     0
- *CA repeater_ca_repeater   38439c 181 PEND           a2a0   384250       0     0
- *CA TCP     _req_server    2b5a28 181 PEND           a2a0   2b598c       0     0
- *CA event   _event_task    27f7c0 181 PEND           a2a0   27f778       0     0
- *CA event   _event_task    33ce64 181 PEND           a2a0   33ce1c       0     0
- *CA UDP     _cast_server   2b44b0 182 PEND           a2a0   2b4384       0     0
- *CA online  _rsrv_online   2b2f24 183 DELAY         46772   2b2e88       0   283
- *taskwd     31a368         2c4500 200 DELAY         46772   2c444c       0   241
- value = 0 = 0x0
-    * - EPICS tasks

## Booting EPICS

**Unsuccessful Boot of EPICS**
- telnet to IOC successfully verifies that vxWorks booted
- observe the execution of the startup script
- rename the startup file
- reboot the IOC
- telnet into the IOC
- invoke the startup script manually using the '<' redirection character
- for example:< ~wright/camac_demo/camac/startup.mv167
**Common Errors**
- missing record or device support
- recSup.ascii or devSup.ascii lists support that is not in the object file being loaded
- undefined symbol
- you added code that references external symbols that were not loaded first

## Hardware Interfaces in the IOC

**Detecting Errors**
- dbior - command that calls the report function of every driver
- *Note: most drivers have reports - some do not!
- dbpr "database record name" - report all of the fields of a database record if the SEVR field is Invalid and the STAT field is either READ/WRITE then there is a failure returning from the device/driver support
**Common Source of Errors**
- address jumpers on the card not correct - check manual and module_types.c
- for interrupt devices:
- the backplane jumpers need to be correct from CPU to this module
- the interrupt vector needs to be unique - use the veclist diagnostic to list all vectors
- verify that the device and driver support were loaded (see booting EPICS)

## Database Logic in the IOC

**Detecting Errors**
- dbpr "database record name" - report all of the fields of a database record if the SEVR field is Invalid and the STAT field is UDF the record was never processed
- Use the database debugger to step through the database execution see chapter 2 of the Application Developer's Guide
- Set the TPRO field of a database record - this will cause all records processed as part of  this chain to print their name to stdout
- Use the dbt command to determine the execution time of a particular database chain
**Common Source of Errors**
- address fields are incorrect
- forward links do not pass data
- scan mechanisms are wrong
- passive records are processed too frequently  (improper use of Process Passive)

## Connections to the Database

**Detecting Errors**
- Standard channel access clients give an indication when they are not able to connect
- Applications must do the same: sequences, tcl/TK  ........
- Use cau or probe to check out the channel access connection
**Common Source of Errors**
- The process variable name is incorrect - use dbgrep to verify the name is in the IOC
- Broadcast address on the IOC and workstation must match    bootChange to see the boot parameters where the IOC sets the net mask    ifconfig -a  to see the netmask on the Unix workstation
- The IOC is using 100% of the CPU - telnet to the IOC and use the spy command
- Verify client connection - telnet to the IOC and use the client_stat command

## Plots, Sliders, Bars Not Working

**Common Source of Errors**
- HOPR and LOPR are not set in the database or the display list
- The value is outside the specified display range - either HOPR/LOPR or in display
- Value is outside the control range in the database - see DRVH and DRVL fields

## Debugging New Code in the IOC

**New Subroutines / tasks in vxWorks**
- Verify it loads successfully - linking is done at load time
- vxWorks treats all global symbols as commands available from the shell:
- telnet to the ioc
- set a breakpoint on your new routine
- spawn the routine using the sp command
- step through the routine and verify that it works before integrating it
- use global symbols to peek/poke or turn on/off debug statements
**New drivers in vxWorks**
- Use the m command to peek/poke memory locations to verify new hardware
- Put in good diagnostic routines that dump all available registers (this is for dbior later)
- Put in test codes to exercise, calibrate or reinitial the hardware