# Presentation: 497484

##     EPICS/RTEMS at NSLS

**    ****EPICS/RTEMS at NSLS**

- S. Kate Feng
- EPICS Meeting at DLS, UK
- June 19, 2003

-  1

## Projects that use EPICS  at NSLS

**DUV-FEL accelerator (only one beamline)**
- I began to implement EPICS/VxWorks in 2000
- 400 nm SASE achieved in February, 2002
- 266 nm HGHG achieved in October, 2002
- Currently in operation for users
**NSLS beamlines (currently > 10)**
- Peter Siddons and Ivan So began to implement EPICS/VxWorks in 2000
- Peter Siddons proposed to use RTEMS for beamline applications

-  2

## EPICS/RTEMS  at NSLS

**I began the project in October, 2002**
**Development platform is Linux RedHat 7.3**
**EPICS 3.14  IOC test platform is RTEMS**
**Evaluated cexp vs. esh for RTEMS dynamic loading**
- cexp is ideal for run-time dynamic loading plus other nice features
- esh would be a good debugging tool (e.g. breakpoint and single step) if it is fully developed as promised.  All the run-time modules to be loaded have to be pre-mounted into the IMFS file system via a makefile before running

-  3

## Sample features as of June 10, 2003

| Run-time dynamic loader |   100 % | Pre-mounted files only |
| --- | --- | --- |
| Invoking func() to skip function registration | yes | yes |
| Disassembler | yes | yes |
| Symbol Table lookup | yes | yes |
| Telnetd, scripts and reentrant | yes | no |
| Data Type | All types except short | Only integer and float |
| Memory dump for a region | no | yes |
| Single step | no | Promised, not done |
| Break point | no | Promised, not done |
| Thread control | no | yes |

| Sample features as of 6/10/03 | cexp | esh |
| --- | --- | --- |

-  4

## RTEMS IOC configuration at NSLS

**RTEMS IOC configuration**
- CPU:  MVME2306
- RTEMS : gcc-3.2.2, newlib-1.11.0, rtems-4.6.0pre3
- RTEMS image download:  bootp/tftp
- Shell:  rtems-cexp for dynamic loading (T.S., SSRL)
- Remote login:  telnetd  (Till Straumann, SSRL, SLAC)
- Portability:  RTEMS devLib.c (T.S., SSRL), epics threads, epicsMutex, and so on (Eric Norum, APS)
- EPICS 3.14.0beta2 (Marty Kraimer, APS, and Jeff Hill LANL)

-  5

## EPICS 3.14 OSI for the DUV-FEL project    

**Radiation monitor IOC (**needed for operation**)**
- Tested on the RTEMS and Tornado2.02 platform
- Used epicsTime thread instead of routines from drvTS.c
- drvXVme293.c:  driver for the MVME293 counter
- devWFXvme293.c:  radiation counts at various locations
- devWF30secTotal.c:  average radiation dose every 30 seconds at various locations
- devWFHourTotal.c:  total radiation dose hourly at various locations
- devWFWorkdayTotal.c:  total radiation dose during an eight-hour workday at various locations

-  6

## EPICS/RTEMS for NSLS beamlines

**Added OSI over the beamline device/driver routines from the R3.13.x release and tested successfully on the RTEMS platform for the bitIO, scaler and OMS58 motor controller**
- stdApp (50%)
- motorApp
**Collaborating with Mark River, Time Mooney and others  from APS to install and test the up-to-date beamline device/driver routines**

-  7

## What did I modify in EPICS 3.14?

**I modified the registerRecordDeviceDriver.pl file so that I could continue the scheme of dynamic loading to load the Record/Device/Driver for stdApp and motorApp in the startup script**
**Instead of registerRecordDeviceDriver(pdbase) for both the stdApp and motorApp,  I used:**
**std_registerRecordDeviceDriver(pdbase)**
**motor_registerRecordDeviceDriver(pdbase)**

-  8

## Excerpt of the RTEMS startup script 

- cexpModuleLoad("std.obj")
- cexpModuleLoad("motor.obj“)
- vmeUniverseInit()
- devAvme9440Config(1,0x8000,0x80)
- VSCSetup(1, 0x20000000, 200)
- oms58Setup(1, 8, 0xa000, 190, 7,0.2)
- dbLoadDatabase("../dbd/std.dbd")
**std_registerRecordDeviceDriver(pdbbase)**
- dbLoadDatabase("../dbd/motor.dbd")
**motor_registerRecordDeviceDriver(pdbbase)**
- dbLoadRecords("../db/Acromag_16IO.db","P=Kate:,A=B1")
- dbLoadRecords("../db/Jscaler.db","P=Kate:,S=scaler1,C=0")
- dbLoadTemplate("../db/motor.substitutions")
- dbLoadRecords("../db/scanParms.db","P=Kate:,Q=m10,SCANREC=$(P)scan1,POS=$(Q).VAL,RDBK=$(Q).RBV")
- iocInit()

**Excerpt of the RTEMS startup script**** **

-   9

## Next step

**To install and test RTEMS – NFS (Till Straumann, SSRL) so that we can use EPICS save_restore (Tim Mooney, APS)**
**To find a different VME/CPU board to run RTEMS in the event that Motorola discontinues the MVME230x board**

-   10

## RTEMS-specific issues that I encountered 

**      ****Most of the RTEMS-specific issues are transparent over the EPICS OSI.  The RTEMS-specific issues I dealt with were very minor. For example :**
**Use strtok instead of strtok_r for strict ANSI C**
**I/O Ops.:  in_8(), in_be16(), ....out_be32() for PPC**
**The NTP client for RTEMS reads only the GMT time.  An easy workaround is  to change the value of rtems_bsdnet_timeoffset in the osdTime.cpp file to offset the local time.**

-   11

## Summary

**While RTEMS is lacking in source level debugging tools, the existing EPICS OSI/RTEMS/CEXP packages are sufficient for us to port the IOC applications to RTEMS.**
**As of today, RTEMS meets the requirements of our real-time IOC applications.  The challenge to its wider use lies in its limited range of BSP’s.**

-   12