|
| 1 | +RTEMS - Deploying an Example IOC |
| 2 | +================================ |
| 3 | + |
| 4 | +The previous tutorials walked through how to create a generic linux soft |
| 5 | +IOC and how to deploy an IOC instance using that generic IOC. |
| 6 | + |
| 7 | +epics-containers also supports RTEMS 5 running on MVVME5500. We will |
| 8 | +now will look at the differences for this architecture. Further |
| 9 | +architectures will be supported in future. |
| 10 | + |
| 11 | +Each beamline or accelerator domain will require a server for |
| 12 | +serving the IOC binaries and instance files to the RTEMS devices. This |
| 13 | +needs to be set up for your test beamline before proceeding, |
| 14 | +see `rtems_setup`. |
| 15 | + |
| 16 | +Once you have the file server set up, deploying an IOC instance that uses |
| 17 | +an RTEMS Generic IOC is very similar to `deploy_example`. |
| 18 | + |
| 19 | +We will be adding |
| 20 | +a new IOC instance to the ``bl01t`` beamline that we created in the previous |
| 21 | +tutorials. You will need to have worked through the previous tutorials in |
| 22 | +order to complete this one. |
| 23 | + |
| 24 | +Preparing the RTEMS Boot loader |
| 25 | +------------------------------- |
| 26 | + |
| 27 | +To try this tutorial you will need a VME crate with an MVVME5500 processor card |
| 28 | +installed. You will also need access to the serial console over ethernet |
| 29 | +using a terminal server or similar. |
| 30 | + |
| 31 | +.. note:: |
| 32 | + |
| 33 | + **DLS Users** for details of setting up RTEMS on your VME crates see |
| 34 | + this `internal link <https://confluence.diamond.ac.uk/pages/viewpage.action?spaceKey=CNTRLS&title=RTEMS>`_ |
| 35 | + |
| 36 | + The following crate is already running RTEMS and can be used for this |
| 37 | + tutorial, but check with the accelerator controls team before using it: |
| 38 | + |
| 39 | + :console: ts0001 7007 |
| 40 | + :crate monitor: ts0001 7008 |
| 41 | + |
| 42 | + It is likely already set up as per the example below. |
| 43 | + |
| 44 | +Use telnet to connect to the console of your target IOC. e.g. |
| 45 | +``telnet ts0001 7007``. We want to get to the MOTLoad prompt which should look |
| 46 | +like ``MVME5500>``. If you see an IOC Shell prompt instead hit ``Ctrl-D`` to |
| 47 | +exit and then ``Esc`` when you see |
| 48 | +``Boot Script - Press <ESC> to Bypass, <SPC> to Continue`` |
| 49 | + |
| 50 | +Now you want to set the boot script to load the IOC binary from the network via |
| 51 | +TFTP and mount the instance files from the network via NFS. The command |
| 52 | +``gevShow`` will show you the current state of the global environment variables. |
| 53 | +e.g. |
| 54 | + |
| 55 | +.. code-block:: |
| 56 | +
|
| 57 | + MVME5500> gevShow |
| 58 | + mot-/dev/enet0-cipa=172.23.250.15 |
| 59 | + mot-/dev/enet0-snma=255.255.240.0 |
| 60 | + mot-/dev/enet0-gipa=172.23.240.254 |
| 61 | + mot-boot-device=/dev/em1 |
| 62 | + rtems-client-name=bl01t-ea-ioc-02 |
| 63 | + epics-script=172.23.168.203:/iocs:bl01t/bl01t-ea-ioc-02/config/st.cmd |
| 64 | + mot-script-boot |
| 65 | + dla=malloc 0x230000 |
| 66 | + tftpGet -d/dev/enet1 -fbl01t/bl01t-ea-ioc-02/bin/RTEMS-beatnik/ioc.boot -m255.255.240.0 -g172.23.240.254 -s172.23.168.203 -c172.23.250.15 -adla |
| 67 | + go -a0095F000 |
| 68 | +
|
| 69 | + Total Number of GE Variables =7, Bytes Utilized =427, Bytes Free =3165 |
| 70 | +
|
| 71 | +Now use ``gevEdit`` to change the global variables to the values you need. |
| 72 | +For this tutorial we will create an IOC called bl01t-ea-ioc-02 and for the |
| 73 | +example we assume the file server is on 172.23.168.203. For the details of |
| 74 | +setting up these parameters see your site documentation but the important |
| 75 | +values to change for this tutorial IOC would be: |
| 76 | + |
| 77 | +:rtems-client-name: bl01t-ea-ioc-02 |
| 78 | +:epics-script: 172.23.168.203:/iocs:bl01t/bl01t-ea-ioc-02/config/st.cmd |
| 79 | +:mot-script-boot (2nd line): tftpGet -d/dev/enet1 -fbl01t/bl01t-ea-ioc-02/bin/RTEMS-beatnik/ioc.boot -m255.255.240.0 -g172.23.240.254 -s172.23.168.203 -c172.23.250.15 -adla |
| 80 | + |
| 81 | +Now your ``gevShow`` should look similar to the example above. |
| 82 | + |
| 83 | +Meaning of the parameters: |
| 84 | + |
| 85 | +:rtems-client-name: a name for the IOC crate |
| 86 | +:epics-script: an NFS address for the IOC's root folder |
| 87 | +:mot-script-boot: a TFTP address for the IOC's binary boot file |
| 88 | + |
| 89 | +Note that the IP parameters to the tftpGet command are respectively: |
| 90 | +net mask, gateway, server address, client address. |
| 91 | + |
| 92 | + |
| 93 | +Creating an RTEMS IOC Instance |
| 94 | +------------------------------ |
| 95 | + |
| 96 | +We will be adding a new IOC instance to the ``bl01t`` beamline that we created in |
| 97 | +:doc:`create_beamline`. The first step is to make a copy of our existing IOC instance |
| 98 | +and make some modifications to it. We will call this new IOC instance |
| 99 | +``bl01t-ea-ioc-02``. |
| 100 | + |
| 101 | +.. code-block:: bash |
| 102 | +
|
| 103 | + cd bl01t |
| 104 | + cp -r iocs/bl01t-ea-ioc-01 iocs/bl01t-ea-ioc-02 |
| 105 | + # don't need this file for the new IOC |
| 106 | + rm iocs/bl01t-ea-ioc-02/config/extra.db |
| 107 | +
|
| 108 | +We are going to make a very basic IOC with some hand coded database with |
| 109 | +a couple of simple records. Therefore the generic IOC that we use can just |
| 110 | +be ioc-template. |
| 111 | + |
| 112 | +Generic IOCs have multiple targets, they always have a |
| 113 | +``developer`` target which is used for building and debugging the generic IOC and |
| 114 | +a ``runtime`` target which is lightweight and usually used when running the IOC |
| 115 | +in the cluster. The matrix of targets also includes an architecture dimension, |
| 116 | +at present the ioc-template supports two architectures, ``linux`` and |
| 117 | +``rtems``, thus there are 4 targets in total as follows: |
| 118 | + |
| 119 | +- ghcr.io/epics-containers/ioc-template-linux-runtime |
| 120 | +- ghcr.io/epics-containers/ioc-template-linux-developer |
| 121 | +- ghcr.io/epics-containers/ioc-template-rtems-runtime |
| 122 | +- ghcr.io/epics-containers/ioc-template-rtems-developer |
| 123 | + |
| 124 | +We want to run the RTEMS runtime target on the cluster so this will appear |
| 125 | +at the top of the ``values.yaml`` file. In addition there are a number of |
| 126 | +environment variables required for the RTEMS target that we also specify in |
| 127 | +``values.yaml``. |
| 128 | +Edit the file |
| 129 | +``iocs/bl01t-ea-ioc-02/values.yaml`` to look like this: |
| 130 | + |
| 131 | +.. code-block:: yaml |
| 132 | +
|
| 133 | +If you are not at DLS you will need to change the above to match the |
| 134 | +parameters of your RTEMS IOC. The environment variables are: |
| 135 | + |
| 136 | +:K8S_IOC_ADDRESS: The IP address of the IOC (mot-/dev/enet0-cipa above) |
| 137 | +:RTEMS_VME_CONSOLE_ADDR: Address of terminal server for console access |
| 138 | +:RTEMS_VME_CONSOLE_PORT: Port of terminal server for console access |
| 139 | +:RTEMS_VME_AUTO_REBOOT: true to reboot the hard IOC when the IOC container changes |
| 140 | +:RTEMS_VME_AUTO_PAUSE: true to pause/unpause when the IOC container stops/starts |
| 141 | + |
| 142 | +Edit the file ``iocs/bl01t-ea-ioc-02/Chart.yaml`` and change the 1st 4 lines |
| 143 | +to represent this new IOC (the rest of the file is boilerplate): |
| 144 | + |
| 145 | +.. code-block:: yaml |
| 146 | +
|
| 147 | + apiVersion: v2 |
| 148 | + name: bl01t-ea-ioc-02 |
| 149 | + description: | |
| 150 | + example RTEMS IOC for bl01t |
| 151 | +
|
| 152 | +For configuration we will create a simple database with a few of records and |
| 153 | +a basic startup script. Add the following files to the |
| 154 | +``iocs/bl01t-ea-ioc-02/config`` directory. |
| 155 | + |
| 156 | +.. code-block:: :caption: bl01t-ea-ioc-02.db |
| 157 | + |
| 158 | + record(calc, "bl01t-ea-ioc-02:SUM") { |
| 159 | + field(DESC, "Sum A and B") |
| 160 | + field(CALC, "A+B") |
| 161 | + field(SCAN, ".1 second") |
| 162 | + field(INPA, "bl01t-ea-ioc-02:A") |
| 163 | + field(INPB, "bl01t-ea-ioc-02:B") |
| 164 | + } |
| 165 | + |
| 166 | + record(ao, "bl01t-ea-ioc-02:A") { |
| 167 | + field(DESC, "A voltage") |
| 168 | + field(EGU, "Volts") |
| 169 | + field(VAL, "0.0") |
| 170 | + } |
| 171 | + |
| 172 | + record(ao, "bl01t-ea-ioc-02:B") { |
| 173 | + field(DESC, "B voltage") |
| 174 | + field(EGU, "Volts") |
| 175 | + field(VAL, "0.0") |
| 176 | + } |
| 177 | + |
| 178 | +.. code-block:: :caption: st.cmd |
| 179 | + |
| 180 | + # RTEMS Test IOC bl01t-ea-ioc-02 |
| 181 | + |
| 182 | + dbLoadDatabase "/iocs/bl01t/bl01t-ea-ioc-02/dbd/ioc.dbd" |
| 183 | + ioc_registerRecordDeviceDriver(pdbbase) |
| 184 | + |
| 185 | + # db files from the support modules are all held in this folder |
| 186 | + epicsEnvSet(EPICS_DB_INCLUDE_PATH, "/iocs/bl01t/bl01t-ea-ioc-02/support/db") |
| 187 | + |
| 188 | + # load our hand crafted database |
| 189 | + dbLoadRecords("/iocs/bl01t/bl01t-ea-ioc-02/config/bl01t-ea-ioc-02.db") |
| 190 | + # also make Database records for DEVIOCSTATS |
| 191 | + dbLoadRecords(iocAdminSoft.db, "IOC=bl01t-ea-ioc-02") |
| 192 | + dbLoadRecords(iocAdminScanMon.db, "IOC=bl01t-ea-ioc-02") |
| 193 | + |
| 194 | + iocInit |
| 195 | + |
| 196 | +You now have a new helm chart in iocs/bl01t-ea-ioc-02 that describes an IOC |
| 197 | +instance for your RTEMS device. Recall that this is not literally where the IOC |
| 198 | +runs, it deploys a kubernetes pod that manages the RTEMS IOC. It does contain |
| 199 | +the IOC's configuration and the IOC's binary code, which it will copy to the |
| 200 | +file-server on startup. |
| 201 | + |
| 202 | +You are now ready to deploy the IOC instance to the cluster and test it out. |
| 203 | + |
| 204 | + |
| 205 | +Deploying an RTEMS IOC Instance |
| 206 | +------------------------------- |
| 207 | + |
| 208 | +TODO: |
| 209 | + |
| 210 | +Once you have the correct configuration in your RTEMS boot-loader and you have |
| 211 | +deployed the kubernetes IOC instance, you can restart the IOC with |
| 212 | +the ``reset`` command. This will cause it to reboot and it should pick |
| 213 | +up your binary from the network and start the IOC. You should see the |
| 214 | +iocShell fire up and run |
0 commit comments