EPICS with RTEMS
RTEMS is a real-time operating system. Up to now there is support in EPICS up to RTEMS 4.11. Starting with RTEMS 5 ( not yet released ) it is possible to use the posix compatibility of RTEMS and to take over many EPICS libcom parts of the already existing linux-posix support.
This has been done successfully for the MVME6100/MVME5500 and MVME2100/MVME3100 platforms. To release it also in EPICS we are waiting for the official release of RTEMS 5.1(?).
We are currently working on an adaptation for the cheaper CPU VMEM2500 (QorIQ, multicore, P2020). We are also in the process of using the netbsd (libbsd).
1.) RTEMS preparation for MVME6100 (including network old version)
$ mkdir ${RTEMS_DIR}
$ cd ${RTEMS_DIR}
$ mkdir RTEMS_DEV; cd RTEMS_DEV
$ git clone git://git.rtems.org/rtems.git
$ git clone git://git.rtems.org/rtems-tools.git
$ git clone git://git.rtems.org/rtems-source-builder.git
$ cd rtems-tools
$ ./waf configure --prefix=${RTEMS_DIR}/RTEMS/rtems-5 build install
$ cd ../rtems-source-builder/rtems
$ ../source-builder/sb-set-builder --log log.txt --prefix=${RTEMS_DIR}/RTEMS/rtems-5 5/rtems-powerpc
[ takes more than 1 hr on PowerbookPro ]
add Path to e.g. .profile :
#RTEMS
echo " RTEMS 5 for beatnik"
export RTEMS_HOME=${HOME}/MVME6100/RTEMS/rtems-5
export PATH=${RTEMS_HOME}/bin:${PATH}
export RTEMS_MAKEFILE_PATH=${RTEMS_HOME}/powerpc-rtems5/beatnik
export RTEMS_SHARE_PATH=${RTEMS_HOME}/share/rtems5
logout/login
check:
$ powerpc-rtems5-g++ --version --verbose
$ cd ${RTEMS_DIR}/RTEMS_DEV/rtems
$ ../rtems-source-builder/source-builder/sb-bootstrap
Create build-dir for beatnik (MVME6100) and build it
$ cd ..; mkdir -p build/b-beatnik; cd build/b-beatnik/
$ ../../rtems/configure --enable-maintainer-mode --prefix=${RTEMS_DIR}/RTEMS/rtems-5 --target=powerpc-rtems5 --enable-rtemsbsp="beatnik" --enable-posix --enable-cxx --enable-networking
$ make all
$ make install
{ This version needs for VMEbus support Till Straumanns libbspExt.
$ cd ${RTEMS_DIR}/RTEMS_DEV
$ git clone https://github.com/epicsdeb/rtems-libbspext.git
$ cd rtems-libbspext
Changes to some files see: https://github.com/epicsdeb/rtems-libbspext/issues/3
$ make
$ make install
Installation EPICS. The version adapted for RTEMS5 (--enable-networking, bsdnet), not jet released.
export EPICS_DIR=/myHome/MVME6100/EPICS
$ mkdir ${EPICS_DIR}; cd ${EPICS_DIR}
$ git clone git@github.com:hjunkes/epicsBaseOwnPlayground.git
$ cd epicsBaseOwnPlayground
$ git checkout 7.0
$ git submodule update --init --recursive
[ add RTEMS-BASE to CONFIG_SITE.Common.RTEMS ]
$ vi configure/os/CONFIG_SITE.Common.RTEMS
[RTEMS-BASE in my installation == /Users/junkes/MVME6100/RTEMS]
change to
RTEMS_BASE = /Users/junkes/MVME6100/RTEMS/rtems-$(RTEMS_VERSION)
$ make
This should end up with these files
[epicsBaseOwnPlayground (7.0 *)]$ ls bin/RTEMS-beatnik/
caTestHarness dbTestHarness.boot libComTestHarness linkTestHarness.boot pvaTestHarness
pvdTestHarness.boot softIoc softIocPVA.boot
caTestHarness.boot filterTestHarness
libComTestHarness.boot pvDbTestHarness pvaTestHarness.boot recordTestHarness
softIoc.boot dbTestHarness filterTestHarness.boot linkTestHarness
pvDbTestHarness.boot pvdTestHarness recordTestHarness.boot softIocPVA
Now one can load the test programs to the target by
1.) copy e.g. libComTestHarness.boot to tftpserver:
$ scp bin/RTEMS-beatnik/libComTestHarness.boot root@epics:/srv/tftp
2.) connect to console e.g. via screen and reboot target
$ screen /dev/ttyUSB0 9600 Copyright(C)2008-2009,Emerson Network Power-Embedded Computing,Inc. All Rights Reserved Copyright Motorola Inc. 1999-2007, All Rights Reserved MOTLoad RTOS Version 2.0, PAL Version 2.3 RM01 Fri Jan 23 14:47:54 MST 2009 MPU-Type =MPC74x7 MPU-Int Clock Speed =1266MHz MPU-Ext Clock Speed =133MHz MPU-Int Cache(L2) Enabled, 512KB, L2CR =C0000000 MPU-Ext Cache(L3) Enabled, 2MB, 211MHz, L3CR =DC026300 PCI bus instance 0 =64 bit, 133 Mhz, PCI-X PCI bus instance 1 =64 bit, PCI Reset/Boot Vector =Flash1 Local Memory Found =20000000 (&536870912) User Download Buffer =006B7000:008B6FFF Boot Script - Press <ESC> to Bypass, <SPC> to Continue MVME6100> MVME6100> tftpGet -s141.14.128.9 -c141.14.128.12 -a04000000 -flibComTestHarness.boot Network Loading from: /dev/enet0 Loading File: libComTestHarness.boot Load Address: 04000000 Download Buffer Size = User Defined Client IP Address = 141.14.128.12 Server IP Address = 141.14.128.9 Gateway IP Address = 141.14.128.253 Subnet IP Address Mask = 255.255.255.0 Network File Load in Progress... Bytes Received =&2534352, Bytes Loaded =&2534352 Bytes/Second =&2534352, Elapsed Time =1 Second(s) MVME6100> netShut /dev/enet0 Disabled /dev/enet1 Disabled MVME6100> go -a04000000 ----------------------------------------- config addr is 0xf1000cf8 config data is 0xf1000cfc Welcome to RTEMS rtems-5.0.0 (PowerPC/Generic (classic FPU)/beatnik) CPU: MPC7457 Board Type: MVME6100-0163 (S/N E173D27) Bus Clock Freq: 133333333 Hz CPU Clock Freq: 1266666654 Hz Memory: 536870912 bytes ----------------------------------------- Now BSP_mem_size = 0x1fe00000 Configuration.work_space_size = 1f80bd0 Page table setup finished; will activate it NOW... Going to start PCI buses scanning and initialization Number of PCI buses found is : 3 MSR 0x2003032 Exit from bspstart unable to find the universe in pci config space Tundra Tsi148 PCI-VME bridge detected at 0x81100000, IRQ 84 Tsi148 Outbound Ports: Port VME-Addr Size PCI-Adrs Mode: 0: 0x20000000 0x0e000000 0x90000000 A32, SUP, D32, SCT 1: 0x00000000 0x00ff0000 0x9f000000 A24, SUP, D32, SCT 2: 0x00000000 0x00010000 0x9fff0000 A16, SUP, D32, SCT 7: 0x00000000 0x01000000 0x9e000000 CSR, SUP, D32, SCT Tsi148 Inbound Ports: Port VME-Addr Size PCI-Adrs Mode: 0: 0x90000000 0x1fe00000 0x00000000 A32, PGM, DAT, SUP, USR, MBLT, BLT vmeTsi148 IRQ manager: looking for registers on VME... Trying to find CSR on VME... vmeTsi148 - IRQ manager using VME CSR to flush FIFO Registering /dev/console as minor 0 (==/dev/ttyS0) Startup. ***** RTEMS Version: rtems-5.0.0 (PowerPC/Generic (classic FPU)/beatnik) ***** ***** Initializing network (network_task_priority = 196) ***** Link detected; attaching mve1 bootpc_init: using network interface 'mve1' bootpc hw address is ec:9e:cd:1a:12:3f My ip address is 141 .14 .128 .12 Domain Name Server is 141 .14 .128 .1 Hostname is gonzo Ignoring BOOTP/DHCP option code 28 Time Server is 141 .14 .142 .121 Domain name is rz-berlin.mpg.de Server name is 1001.1001@141.14.128.9:/export/epics Boot file is /export/epics/felsis3316/bin/RTEMS-beatnik/felsis3316.boot Command line is /export/epics/felsis3316/iocBoot/iocfelsis3316/st.cmd Subnet mask is 255 .255 .240 .0 Server ip address is 141 .14 .128 .1 Gateway ip address is 141 .14 .128 .128 Log server ip address is 141 .14 .128 .1 ***** Setting up file system ***** ***** Initializing NFS ***** check for time registered , C++ initialization ... ***** Preparing EPICS application ***** chdir("/") ***** Starting EPICS application ***** Backwards time errors prevented 0 times. Current Time Providers: "OS Clock", priority = 999 Current Time is 2019-09-25 09:01:47.237062. Event Time Providers: No Providers registered. ***** epicsThreadTest ***** 1..9 # System has 1 CPUs ok 1 - ncpus > 0 ok 2 - pget == pset ok 3 - thread.getPriority() == epicsThreadGetPriority(self) ok 4 - pget == pset ok 5 - thread.getPriority() == epicsThreadGetPriority(self) ok 6 - pget == pset ok 7 - thread.getPriority() == epicsThreadGetPriority(self) ok 8 - threadA epicsThreadIsOkToBlock() = 0 ok 9 - threadB epicsThreadIsOkToBlock() = 1 Results ======= Tests: 9 Passed: 9 = 100.00% ... # Task 2 cleaning up ok 7 - monRemove(thread='testTask2') # Task 1 cleaning up ok 8 - monRemove(thread='testTask1') Results ======= Tests: 8 Passed: 8 = 100.00% EPICS Test Harness Results ========================== All tests successful. Programs=38, Tests=2976, 320 wallclock secs ***** epicsExitTest ***** 1..15 ok 1 - Registered counter() EPICS Test Harness Results ========================== All tests successful. Programs=38, Tests=2976, 322 wallclock secs ok 2 - counter() called once ok 3 - unregistered counter() not called ok 4 - Registered mainExit() # threadA starting ok 5 - Registered atExit(0xf08b88) ok 6 - Registered atThreadExit(0xf08b88) # threadA waiting for atExit # threadB starting ok 7 - Registered atExit(0xf08bd8) ok 8 - Registered atThreadExit(0xf08bd8) # threadB waiting for atExit # Calling epicsExit ok 9 - threadB reached atExit ok 10 - threadB terminating ok 11 - threadB destroying pinfo ok 12 - threadA reached atExit ok 13 - threadA terminating ok 14 - threadA destroying pinfo ok 15 - Reached mainExit Results ======= Tests: 15 Passed: 15 = 100.00% fatal source: RTEMS_FATAL_SOURCE_EXIT bsp_fatal_extension(): RTEMS terminated -- no way back to MotLoad so I reset the card Printing a stack trace for your convenience :-) 0x01937824--> 0x01937820--> 0x00512644--> 0x00513168--> 0x00523164 0x00436728--> 0x01824600--> 0x01716164--> 0x00334956--> 0x00082916 0x00350024--> 0x00254916--> 0x00439336--> 0x00503848--> 0x00499524 0x00499348
There is a much cheaper CPU available MVME2500 with QorIQ (P2020) multicore.
Here we want to use the "true" libbsd network stuff.
That's what I'm fighting with now. If this works properly (incl. VMEbus support) I want to apply it to the MVME6100 as well.
$ mkdir ${RTEMS_DIR}
$ cd ${RTEMS_DIR}
$ mkdir RTEMS_DEV; cd RTEMS_DEV
$ git clone git://git.rtems.org/rtems.git
$ git clone git://git.rtems.org/rtems-tools.git
$ git clone git://git.rtems.org/rtems-source-builder.git
$ cd rtems-tools
$ ./waf configure --prefix=${RTEMS_DIR}/RTEMS/rtems-5 build install
$ cd ../rtems-source-builder/rtems
$ ../source-builder/sb-set-builder --log log.txt --prefix=${RTEMS_DIR}/RTEMS/rtems-5 5/rtems-powerpc
[ takes more than 1 hr on PowerbookPro ]
add Path to e.g. .profile :
#RTEMS
echo " RTEMS 5 for mvme2500 (qoriq_e500)"
export RTEMS_HOME=${HOME}/MVME2500/RTEMS/rtems-5
export PATH=${RTEMS_HOME}/bin:${PATH}
export RTEMS_MAKEFILE_PATH=${RTEMS_HOME}/powerpc-rtems5/qoriq_e500
export RTEMS_SHARE_PATH=${RTEMS_HOME}/share/rtems5
logout/login
check:
$ powerpc-rtems5-g++ --version --verbose
$ cd ${RTEMS_DIR}/RTEMS_DEV/rtems
$ ../rtems-source-builder/source-builder/sb-bootstrap
Create build-dir for qoriq_e500 (MVME2500) and build it
$ cd ..; mkdir -p build/b-qoriq_e500; cd build/b-qoriq_e500/
$ ../../rtems/configure --enable-maintainer-mode --prefix=/Users/junkes/MVME2500/RTEMS/rtems-5 --target=powerpc-rtems5 --enable-rtemsbsp=qoriq_e500 --enable-posix --enable-cxx --disable-networking
$ make all
$ make install
Install libbsd
$git clone git://git.rtems.org/rtems-libbsd.git
$ cd rtems-libbsd
$ git checkout --track origin/5-freebsd-12
$ git submodule init
$ git submodule update rtems_waf
Unfortunately there is also the problem with the libdebugger here. You have to patch it out:
diff --git a/libbsd.py b/libbsd.py
index 26515113..646414e6 100644
--- a/libbsd.py
+++ b/libbsd.py
@@ -5034,9 +5034,6 @@ class tests(builder.Module):
self.addTest(mm.generator['test']('termios06', ['test_main',
'../termios/test_termios_driver',
'../termios/test_termios_utilities']))
- self.addTest(mm.generator['test-if-header']('debugger01', 'rtems/rtems-debugger.h',
- ['test_main'], runTest = False, netTest = True,
- extraLibs = ['debugger']))
self.addTest(mm.generator['test']('crypto01', ['test_main']))
self.addTest(mm.generator['test']('ipsec01', ['test_main']))
self.addTest(mm.generator['test']('openssl01', ['test_main']))
$ ./waf
$ ./waf install
Now install EPICS
export EPICS_DIR=/myHome/MVME6100/EPICS
$ mkdir ${EPICS_DIR}; cd ${EPICS_DIR}
$ git clone git@github.com:hjunkes/epicsBaseOwnPlayground.git
$ cd epicsBaseOwnPlayground
$ git checkout 7.0
$ git submodule update --init --recursive
[ add RTEMS-BASE to CONFIG_SITE.Common.RTEMS ]
$ vi configure/os/CONFIG_SITE.Common.RTEMS
[RTEMS-BASE in my installation == /Users/junkes/MVME2500/RTEMS]
change to
RTEMS_BASE = /Users/junkes/MVME2500/RTEMS/rtems-$(RTEMS_VERSION)
Change CROSS_COMPIELR_TARGET in CONFIG_SITE to RTEMS-qoriq_e500
$ vi configure/CONFIG_SITE
$ make