This document describes the XRM configuration architecture, the single-template structure (XRM-BASE), and the deployment script deploy_XRM.sh.
The deploy_XRM.sh utility automates staging and remote deployment of custom system configurations and EPICS IOC parameters for D-TACQ ACQ400-series systems configured for the XRM subsystem.
All template files are consolidated into a single master template directory: XRM-BASE. When deploying, deploy_XRM.sh stages from this base and dynamically configures the requested XRM flavour.
Key responsibilities:
- Parameter Validation: Validates target hostname formats and verifies the requested flavour (
INST-A,INST-B,MAGPS,QPMS). - Offset Calculation: Dynamically computes secondary IOC hostname numbers using a
+500offset (e.g.,acq2206_100->acq2206_600). - Single Template Staging: Copies from
XRM-BASE/mnttoXRM_STAGINGand includes packages frompackageswhen present. - Dynamic Flavour Activation: Uncomments the appropriate
export XRM_MODEL="..."line inxrm_epics.sh, updatesXRM_PM, and configuressite-1-peers. - Variable Substitution: Replaces template placeholders (
ACQ400IOCnumandXRMIOCnum) with system-specific network names. - Traceability & Audit Logging: Prepends metadata headers to
rc.userrecording the deploying user, timestamp, Git commit SHA, and invocation incantation. - Remote Deployment Modes:
- Standard (
scp -r): Transfers the staged/mnt/localtree and any packages directly to the target unit via recursivescp. - Archive Mode (
ARCHIVE=1): Bundles the entire payload into a single compressed.tgzarchive, SCPs it to/tmpon the target, and extracts it directly into/mntvia SSH. Streamlines deployment and minimizes authentication prompts when SSH keys are not installed.
- Standard (
- Dry-Run Validation: Supports
DRYRUN=1mode to verify staging, archive generation, and variable substitution locally without touching hardware.
[DRYRUN=1] [ARCHIVE=1] [CLEAN=1] [SR=<sample_rate>] ./deploy_XRM.sh <hostname_string> <flavour_name> [ip_address]<hostname_string>: Target UUT hostname. Must end with an underscore followed by a number (e.g.,acq2206_100).<flavour_name>: One of the 4 supported XRM flavours:INST-AINST-BMAGPSQPMS
[ip_address]: (Optional) Target UUT IP address for network deployment when DNS resolution is unavailable. When omitted, deployment defaults to<hostname_string>.
DRYRUN=1: When set, completes all staging, archive generation, regex substitutions, and audit logging locally inXRM_STAGING, but skips SSH/SCP file transfers to the UUT.ARCHIVE=1: When set, packages the staged payload into<hostname>_payload.tgz, copies it via a singlescptransfer to/tmp/on the UUT, and decompresses it into/mntusingssh. Ideal for environments without SSH keys or for mass deployment.CLEAN=1: When set, reaches out to the target UUT right at the start of deployment, displays a warning with a 5-second countdown, and deletes the contents of/mnt/local(retaining the/caldirectory and/mnt/local/networkfile) as well as any packages containing*xrm*from/mnt/packages.SR=<sample_rate>: (Optional) Override default sample rate for the selected flavour.
The repository includes the packages/ directory and packages/pack_manifest. Binary .tgz package archives are excluded from Git version control.
Before deploying, populate the packages directory by downloading the archives specified in pack_manifest:
cd packages
wget -i pack_manifest
cd ..deploy_XRM.sh performs pre-flight package verification:
- Missing Packages: If any package listed in
pack_manifestis missing, deployment aborts with instructions to download it. - Stale Packages: If packages downloaded during previous commits are present in
packages/but no longer listed inpack_manifest, deployment aborts with instructions to remove the stale packages, preventing conflicting services from being installed on the UUT.
Dry Run Verification (Standard mode):
DRYRUN=1 ./deploy_XRM.sh acq2206_100 MAGPSDry Run Verification (Archive mode):
DRYRUN=1 ARCHIVE=1 ./deploy_XRM.sh acq2206_100 QPMSDry Run Verification with explicit IP address (No DNS):
DRYRUN=1 ./deploy_XRM.sh acq2206_100 MAGPS 192.168.0.100Live Deployment (Standard mode):
./deploy_XRM.sh acq2206_100 MAGPSLive Deployment (Archive mode - single SCP transfer):
ARCHIVE=1 ./deploy_XRM.sh acq2206_100 QPMSLive Deployment with explicit IP address (No DNS):
./deploy_XRM.sh acq2206_100 MAGPS 192.168.0.100 +--------------------------------+
| 1. Argument & Option Parsing | Validate arguments (UUT, flavour, optional IP), DRYRUN, CLEAN, ARCHIVE flags
+---------------+----------------+
|
+---------------v----------------+
| 2. Flavour Validation | Validate flavour matches one of INST-A, INST-B, MAGPS, QPMS
+---------------+----------------+
|
+---------------v----------------+
| 3. Package Verification | Verify manifest packages exist & detect stale packages
+---------------+----------------+
|
+---------------v----------------+
| 4. Hostname & Offset Math | Parse trailing number (e.g. 100), add +500 (e.g. 600)
+---------------+----------------+
|
+---------------v----------------+
| 5. Workspace Staging | Clean/recreate XRM_STAGING
+---------------+----------------+
|
+---------------v----------------+
| 6. Template & Package Copy | Copy XRM-BASE/mnt and packages/ to staging
+---------------+----------------+
|
+---------------v----------------+
| 7. Flavour & Var Substitution | Enable XRM_MODEL line, set XRM_PM, PEERS, ACQ400IOC, IOC_HOST
+---------------+----------------+
|
+---------------v----------------+
| 8. Audit Header Generation | Prepend Git SHA, user, timestamp, incantation to rc.user
+---------------+----------------+
|
+---------------v----------------+
| 9. Remote Deployment | Direct scp -r or compress -> scp -> ssh tar -xzf (to UUT_TARGET)
+--------------------------------+
-
Argument & Environment Flag Evaluation: Evaluates positional arguments (
<hostname_string>,<flavour_name>, optional[ip_address]) and environment flags (${DRYRUN},${ARCHIVE},${CLEAN},${SR}). ResolvesUUT_TARGETto[ip_address]if provided, otherwise defaulting to<hostname_string>. -
Flavour Parameter Mapping: Maps the command-line flavour argument to its model personality:
INST-A->MODEL_STR="XRM-INST-A",PEERS="1,2",XRM_PM=0INST-B->MODEL_STR="XRM-INST-B",PEERS="1,2",XRM_PM=0MAGPS->MODEL_STR="XRM-MagPS",PEERS="1",XRM_PM=1QPMS->MODEL_STR="XRM-QPMS",PEERS="1,2,3,4",XRM_PM=1
-
Package Verification: Reads
packages/pack_manifestto verify that all referenced.tgzarchives have been downloaded intopackages/, while also detecting any stale.tgzfiles downloaded during previous commits that are no longer inpack_manifest. If any package is missing or stale, displays warning banners identifying the files and aborts to prevent conflicting package installations. -
Hostname Offset Calculation: Matches
${HOSTNAME_ARG}against^([a-zA-Z0-9]+_)([0-9]+)$:- Adds offset:
NEW_NUM=$((OLD_NUM + 500)) - Sets
${NEW_VAR}(e.g.,acq2206_100->acq2206_600).
- Adds offset:
-
Staging Cleanup & Copy:
- Removes any existing
XRM_STAGINGand creates a fresh staging directory. - Copies
XRM-BASE/mntintoXRM_STAGING/. - Copies only validated
.tgzpackages frompack_manifestintoXRM_STAGING/mnt/packages/.
- Removes any existing
-
Template Configuration (
sed):- In
xrm_epics.sh: ReplacesACQ400IOCnumwith${HOSTNAME_ARG},XRMIOCnumwith${NEW_VAR}. - In
xrm_epics.sh: Uncomments and activatesexport XRM_MODEL="${MODEL_STR}". - In
xrm_epics.sh: Setsexport XRM_PM=${XRM_PM}. - In
site-1-peers: SetsPEERS=${PEERS}.
- In
-
Audit Metadata Injection: Injects deployment metadata into line 2 of
$STAGE_DIR/mnt/local/rc.user:# # created by deploy_XRM for uut:$uut xrm_var:$SOURCE_SUBFOLDER # by ${user} on $(date) # git $githash # incant $incant
-
UUT Transfer and Decompression:
- Archive Mode (
ARCHIVE=1):- Bundles
${STAGE_DIR}/mntinto a compressed archive:${STAGE_DIR}/${HOSTNAME_ARG}_payload.tgz. - Securely copies the single archive:
scp ${STAGE_DIR}/${ARCHIVE_NAME} root@${UUT_TARGET}:/tmp/. - Remotely extracts into
/mntand cleans up/tmp:ssh root@${UUT_TARGET} "tar -xzf /tmp/${ARCHIVE_NAME} -C /mnt && rm /tmp/${ARCHIVE_NAME}". - Single SCP transfer minimizes interactive authentication prompts when SSH keys are absent.
- Bundles
- Standard Mode (Default):
- Recursively copies directories via
scp -r ${STAGE_DIR}/mnt/local root@${UUT_TARGET}:/mnt/. - Recursively copies packages via
scp -r ${STAGE_DIR}/mnt/packages root@${UUT_TARGET}:/mnt/(if packages exist).
- Recursively copies directories via
- Dry-Run Mode (
DRYRUN=1):- Staging and archive compression are performed locally, while remote SCP and SSH commands are displayed and skipped.
- Archive Mode (
All template files are maintained under XRM-BASE/. The 4 supported operational flavours and their auto-configured parameters are:
| Flavour Name | XRM_MODEL String |
Sample Rate (Hz) | PEERS Sites |
XRM_PM |
NCHAN |
|---|---|---|---|---|---|
MAGPS |
XRM-MagPS |
100,000 (100 kHz) | 1 |
1 |
128 |
QPMS |
XRM-QPMS |
100,000 (100 kHz) | 1,2,3,4 |
1 |
128 |
INST-A |
XRM-INST-A |
4,000,000 (4 MHz) | 1,2 |
0 |
32 |
INST-B |
XRM-INST-B |
4,000,000 (4 MHz) | 1,2 |
0 |
32 |
Configuration files reside in XRM-BASE/mnt/local/:
The primary environment file loaded by the EPICS startup environment. It defines:
IOC_HOST: Secondary / XRM IOC identifier (assigned${NEW_VAR}/+500).ACQ400IOC: Primary hardware IOC identifier (assigned${HOSTNAME_ARG}).EPICS_CAS_INTF_ADDR_LIST/EPICS_PVAS_INTF_ADDR_LIST: Network interfaces for Channel Access and PVAccess servers (eth0:44000).EPICS_CA_ADDR_LIST/EPICS_PVA_ADDR_LIST: Broadcast and interface lists for clients.XRM_MODEL: Subsystem personality string (XRM-INST-A,XRM-INST-B,XRM-MagPS, orXRM-QPMS).XRM_PM: Process Management flag (1for MAGPS/QPMS,0for INST-A/B).XRM_INST1/XRM_INST2: Redis publisher strategy pipelines (STR,SPY).
Executed at the end of the Linux boot sequence. Dynamically reads XRM_MODEL to configure:
- Clock sample rate (
100000for MAGPS and QPMS,4000000for INST-A and INST-B). - Judgement mode setup and parameters.
- Cycle trigger direct from front panel and burst mode settings.
- Stream daemon configuration and White Rabbit clock phase adjustment.
Dynamically reads XRM_MODEL to configure:
run0aggregator site list (1,5,6for MAGPS;1,2,3,4for QPMS;1,2for INST-A;1,2,5for INST-B).- SPAD scratchpad timestamp settings.
- Channel count
NCHAN(128 for MAGPS/QPMS, 32 for INST-A/INST-B).
Dynamically reads XRM_MODEL to configure ACQ400_JUDGEMENT buffer lengths (4096 d0 for MAGPS/QPMS; 16384 d0 for INST-A/INST-B). Also sets system DMA buffer memory allocation (BLEN=4194304, NBUF=128) and fan speed.
Performs dynamic hardware mezzanine discovery across sites 1 through 6, applying calibration gain for acq428elf, voltage reference and gain for ao420fmc, dynamic CLKDIV for dio482elf_xrm, and White Rabbit TAI timestamp insertion into SPAD words.
Configures peer site aggregation across ADC mezzanines.
Configure Buffer-on-System streaming and White Rabbit timing calibration.
- All template configurations are stored under
XRM-BASE/. - Binary files (
.bin) and compressed packages (.tgz) are ignored by Git. XRM_STAGINGis ephemeral and cleared automatically on every deployment run.- Template files under
XRM-BASE/remain clean and version-controlled.