konosubakonoakua / blog

https://konosubakonoakua.github.io/blog/
MIT License
0 stars 0 forks source link

[sw][epics] epics installation #116

Open konosubakonoakua opened 1 week ago

konosubakonoakua commented 1 week ago

Epics Base

Dependencies

sudo apt install build-essential libreadline-dev  perl tcl tk

Make Directories

sudo mkdir -p /epics
sudo chown $USER:$USER /epics
ln -s /epics $HOME/EPICS
cd /epics

Clone Repo

wget https://epics-controls.org/download/base/base-7.0.8.1.tar.gz
tar -xvf base-7.0.8.1.tar.gz
cd base-7.0.8.1

Or,

git clone --recursive -b 7.0 https://git.launchpad.net/epics-base base-7.0
cd base-7.0

Or,

# my fork
git clone --recursive -b 7.0 https://github.com/konosubakonoakua/epics-base base-7.0
cd base-7.0

Make

make -j8

If failed, and need to rebuild

make distclean
git reset --hard
git clean -fd

Setup Env (Optional)

cat >> ~/.bashrc << 'EOF'

export EPICS_BASE=/epics/3.15/base
export EPICS_HOST_ARCH=$(${EPICS_BASE}/startup/EpicsHostArch)
export PATH=${EPICS_BASE}/bin/${EPICS_HOST_ARCH}:$PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${EPICS_BASE}/lib/${EPICS_HOST_ARCH}

EOF

Test

which softIoc
softIoc

Test softIoc app

mkdir -p $HOME/EPICS/TEST/testIoc
cd $HOME/EPICS/TEST/testIoc
makeBaseApp.pl -t example testIoc
makeBaseApp.pl -i -t example testIoc
make
cd iocBoot/ioctestIoc
./st.cmd
konosubakonoakua commented 1 week ago

Download synApps

Consider using assemble_synApps.sh

First check the latest version: https://github.com/EPICS-synApps/support/releases/latest For now, it's R6-3

export _SYNAPPS_VERSION=R6-3
export _SYNAPPS_FILENAME=synApps_6_3
export _SYNAPPS=/epics/$_SYNAPPS_FILENAME
cd ~/Downloads
wget https://github.com/EPICS-synApps/support/releases/download/$_SYNAPPS_VERSION/$_SYNAPPS_FILENAME.tar.gz
if [ $? -eq 0 ]; then
  tar -xzf $_SYNAPPS_FILENAME.tar.gz -C /epics/
  rm $_SYNAPPS_FILENAME.tar.gz
  cd /epics
fi

Copy desired modules

export _EPICS_VERSION=3.15
export _EPICS_BASE = /epics/$_EPICS_VERSION/base
export _EPICS_SUPPORT=/epics/$_EPICS_VERSION/support
mkdir -p $_EPICS_SUPPORT
cd /epics/$_EPICS_SUPPORT
cp -r $_SYNAPPS/support/StreamDevice* .
cp -r $_SYNAPPS/support/asyn* .
cp -r $_SYNAPPS/support/calc* .
cp -r $_SYNAPPS/support/sscan* .
cp -r $_SYNAPPS/support/sequencer-mirror* .

Modify support modules (not tested yet)

cd $_EPICS_SUPPORT
export REPO_SEQUENCER_MIRROR=$(find $_EPICS_SUPPORT -maxdepth 1 -type d -name "*sequencer-mirror*" -exec basename {} \;)
export REPO_SSCAN=$(find $_EPICS_SUPPORT -maxdepth 1 -type d -name "*sscan*" -exec basename {} \;)
export REPO_CALC=$(find $_EPICS_SUPPORT -maxdepth 1 -type d -name "*calc*" -exec basename {} \;)
export REPO_ASYN=$(find $_EPICS_SUPPORT -maxdepth 1 -type d -name "*asyn*" -exec basename {} \;)
export REPO_STREAMDEVICE=$(find $_EPICS_SUPPORT -maxdepth 1 -type d -name "*StreamDevice*" -exec basename {} \;)

StreamDevice

echo > ${REPO_STREAMDEVICE}/configure/RELEASE.local << EOF
SUPPORT=${_EPICS_SUPPORT}
ASYN=\$(SUPPORT)/${REPO_ASYN}
CALC=\$(SUPPORT)/${REPO_CALC}
PCRE=
EPICS_BASE=${_EPICS_BASE}
EOF
rm -f ${REPO_STREAMDEVICE}/GNUmakefile

Asyn

echo > ${REPO_ASYN}/configure/RELEASE.local << EOF
SUPPORT=${_EPICS_SUPPORT}
SNCSEQ=\$(SUPPORT)/${REPO_SEQUENCER_MIRROR}
CALC=\$(SUPPORT)/${REPO_CALC}
SSCAN=\$(SUPPORT)/${REPO_SSCAN}
EPICS_BASE=${_EPICS_BASE}
EOF
echo > ${REPO_ASYN}/configure/CONFIG_SITE.local << EOF
TIRPC=YES
EOF

CALC

echo > ${REPO_CALC}/configure/RELEASE.local << EOF
SUPPORT=${_EPICS_SUPPORT}
SSCAN=\$(SUPPORT)/${REPO_SSCAN}
SNCSEQ=\$(SUPPORT)/${REPO_SEQUENCER_MIRROR}
CALC=\$(SUPPORT)/${REPO_CALC}
EPICS_BASE=${_EPICS_BASE}
EOF

SSCAN

echo > ${REPO_SSCAN}/configure/RELEASE.local << EOF
SUPPORT=${_EPICS_SUPPORT}
SNCSEQ=\$(SUPPORT)/${REPO_SEQUENCER_MIRROR}
EPICS_BASE=${_EPICS_BASE}
EOF

SEQUENCER_MIRROR

echo > ${REPO_SEQUENCER_MIRROR}/configure/RELEASE.local << EOF
EPICS_BASE=${_EPICS_BASE}
EOF

Compilation order (EPICS_BASE must have been compiled)

cd ${REPO_SEQUENCER_MIRROR} && make distclean && make -j4
cd ${REPO_SSCAN} && make distclean && make -j4
cd ${REPO_CALC} && make distclean && make -j4
cd ${REPO_ASYN} && make distclean && make -j4
cd ${REPO_STREAMDEVICE} && make distclean && make -j4
konosubakonoakua commented 4 days ago
If you only want to try Asyn & StreamDevice ## Asyn Make dir ```bash cd ${EPICS_BASE} mkdir -p support cd support ``` Clone ```bash git clone https://github.com/epics-modules/asyn.git cd asyn/configure ``` Modify Use these command for dry-run, only checking ```bash sed -n "s|EPICS_BASE=.*|EPICS_BASE=${EPICS_BASE}|p" RELEASE sed -n "s|SUPPORT=.*|SUPPORT=${EPICS_BASE}/support|p" RELEASE sed -n "s|# TIRPC=YES|TIRPC=YES|p" CONFIG_SITE ``` Really modify ```bash sed -i "s|EPICS_BASE=.*|EPICS_BASE=${EPICS_BASE}|" RELEASE sed -i "s|SUPPORT=.*|SUPPORT=${EPICS_BASE}/support|" RELEASE sed -i "s|# TIRPC=YES|TIRPC=YES|" CONFIG_SITE ``` Make it ```bash make -j8 ``` ## StreamDevice Make dir ```bash mkdir -p ${EPICS_BASE}/support ``` Clone ```bash cd ${EPICS_BASE}/support git clone https://github.com/paulscherrerinstitute/StreamDevice.git cd StreamDevice/ rm GNUmakefile ``` Modify Use these command for dry-run, only checking ```bash sed -n "s|EPICS_BASE=.*|EPICS_BASE=${EPICS_BASE}|p" RELEASE sed -n "s|ASYN=.*|ASYN=\$(SUPPORT)/asyn|p" RELEASE sed -n "/CALC=.*/s|^|# |p" RELEASE sed -n "/PCRE=.*/s|^|# |p" RELEASE ``` Really modify We don't have CALC & PCRE support installed now, so disable them. ```bash sed -i "s|EPICS_BASE=.*|EPICS_BASE=${EPICS_BASE}|" RELEASE sed -i "s|ASYN=.*|ASYN=\$(SUPPORT)/asyn|" RELEASE sed -i "/CALC=.*/s|^|# |" RELEASE sed -i "/PCRE=.*/s|^|# |" RELEASE ``` Make it ```bash make -j8 ``` If we want to use CALC, then I recommend installing synApps.
konosubakonoakua commented 4 days ago

cross-compile (gcc-arm-linux-gnueabi)

Install compiler for zynq cortex-a9

sudo apt install gcc-arm-linux-gnueabi g++-arm-linux-gnueabi

Install qemu-user-static (for running arm executables)

sudo apt install qemu-user-static

Install dependencies

export EPICS_TOOLS_ARM_PKGS=/epics/tools/arm/pkgs
mkdir -p $EPICS_TOOLS_ARM_PKGS

Install readline

cd $EPICS_TOOLS_ARM_PKGS
wget https://mirrors.ustc.edu.cn/gnu/readline/readline-8.2.tar.gz
tar -xvf readline-8.2.tar.gz
cd $EPICS_TOOLS_ARM_PKGS/readline-8.2
CC=arm-linux-gnueabi-gcc ./configure --host=arm-linux-gnueabi --prefix=/usr/arm-linux-gnueabi
make -j4
sudo make install

Install ncurses

cd $EPICS_TOOLS_ARM_PKGS
wget https://mirrors.ustc.edu.cn/gnu/ncurses/ncurses-6.5.tar.gz
tar -xvf ncurses-6.5.tar.gz
cd $EPICS_TOOLS_ARM_PKGS/ncurses-6.5
# NOTE: Beginning with ncurses 6.5 option `--enable-widec` is enabled by default; Older versions disable it by default.
CC=arm-linux-gnueabi-gcc ./configure --host=arm-linux-gnueabi --prefix=/usr/arm-linux-gnueabi --with-normal --with-shared --with-strip-program=arm-linux-gnueabi-strip  --disable-widec --without-tests --enable-pc-files --with-pkg-config --with-pkg-config-libdir=libdir
make -j4
sudo make install

Compile epics-base

Modify compiler & libraries options

export EPICS_BASE=/epics/3.15/base
export EPICS_BASE=/epics/7/base
cd $EPICS_BASE
Use patches
git apply << 'EOF'
diff --git a/configure/os/CONFIG_SITE.Common.linux-arm b/configure/os/CONFIG_SITE.Common.linux-arm
index 8f5fb8c82..613652c1e 100644
--- a/configure/os/CONFIG_SITE.Common.linux-arm
+++ b/configure/os/CONFIG_SITE.Common.linux-arm
@@ -26,7 +26,7 @@ COMMANDLINE_LIBRARY = $(strip $(if $(wildcard \
 # from the top of the Base tree after changing this setting.

 # Needs -lncurses:
-#COMMANDLINE_LIBRARY = READLINE_NCURSES
+COMMANDLINE_LIBRARY = READLINE_NCURSES

 # Needs -lcurses:
 #COMMANDLINE_LIBRARY = READLINE_CURSES
diff --git a/configure/os/CONFIG_SITE.linux-x86.linux-arm b/configure/os/CONFIG_SITE.linux-x86.linux-arm
index a1edb423d..46ee8629c 100644
--- a/configure/os/CONFIG_SITE.linux-x86.linux-arm
+++ b/configure/os/CONFIG_SITE.linux-x86.linux-arm
@@ -4,11 +4,11 @@
 #-------------------------------------------------------

 # Set GNU crosscompiler target name
-GNU_TARGET = arm-xilinx-linux-gnueabi
+GNU_TARGET = arm-linux-gnueabi

 # Set GNU tools install path
 # Examples are installations at the APS:
-GNU_DIR = /usr/local/vw/zynq-2011.09
+GNU_DIR = /usr
 #GNU_DIR = /usr/local/Xilinx/SDK/2016.3/gnu/arm/lin
 #GNU_DIR = /APSshare/XilinxSDK/2015.4/gnu/arm/lin

@@ -25,6 +25,7 @@ GNU_DIR = /usr/local/vw/zynq-2011.09

 # To use libreadline, point this to its install prefix
 #READLINE_DIR = $(GNU_DIR)
+READLINE_DIR = /usr/arm-linux-gnueabi
 #READLINE_DIR = /tools/cross/linux-x86.linux-arm/readline
 # See CONFIG_SITE.Common.linux-arm for other COMMANDLINE_LIBRARY values
 #COMMANDLINE_LIBRARY = READLINE
EOF
Or just use sed
sed -i 's/#COMMANDLINE_LIBRARY = READLINE_NCURSES/COMMANDLINE_LIBRARY = READLINE_NCURSES/' configure/os/CONFIG_SITE.Common.linux-arm
sed -i 's/GNU_TARGET = arm-xilinx-linux-gnueabi/GNU_TARGET = arm-linux-gnueabi/' configure/os/CONFIG_SITE.linux-x86.linux-arm
sed -i 's/GNU_DIR = \/usr\/local\/vw\/zynq-2011.09/GNU_DIR = \/usr/' configure/os/CONFIG_SITE.linux-x86.linux-arm
sed -i 's/#READLINE_DIR = $(GNU_DIR)/READLINE_DIR = \/usr\/arm-linux-gnueabi/' configure/os/CONFIG_SITE.linux-x86.linux-arm
create CONFIG_SITE.local
echo "CROSS_COMPILER_TARGET_ARCHS=linux-arm" > $EPICS_BASE/configure/os/CONFIG_SITE.local
konosubakonoakua commented 4 days ago

cross-compile softIoc

tbd

konosubakonoakua commented 1 day ago

Multiple Soft IOCs on one host (same subnet)

[!TIP] automatically create/delete an iptables rule that replaces the destination address of all incoming CA UDP traffic on each interface with the broadcast address of that interface.

Drop/link the following script into /etc/network/if-up.d/ and /etc/network/if-down.d/. If your system does not have the ip command, consider updating it (or install package iproute2 from backports).

channel-access-reach-multiple-soft-iocs-linux

#!/bin/sh -e
# Called when an interface goes up / down

# Author: Ralph Lange <Ralph.Lange@gmx.de>

# Make any incoming Channel Access name resolution queries go to the broadcast address
# (to hit all IOCs on this host)

# Change this if you run CA on a non-standard port
PORT=5064

[ "$METHOD" != "none" ] || exit 0
[ "$IFACE" != "lo" ] || exit 0

line=`ip addr show $IFACE`
addr=`echo $line | grep -Po 'inet \K[\d.]+'`
bcast=`echo $line | grep -Po 'brd \K[\d.]+'`
[ -z "$addr" -o -z "$bcast" ] && return 1

if [ "$MODE" = "start" ]
then
    iptables -t nat -A PREROUTING -d $addr -p udp --dport $PORT -j DNAT --to-destination $bcast
elif [ "$MODE" = "stop" ]
then
    iptables -t nat -D PREROUTING -d $addr -p udp --dport $PORT -j DNAT --to-destination $bcast
fi

exit 0

[!CAUTION] Note: This will not work for clients on the same host. (Adding that feature makes things a lot more complicated, and I like things to be simple.)

If you need connections between IOCs on one host, I would suggest adding the broadcast address of the loopback interface (usually 127.255.255.255) to each IOC’s EPICS_CA_ADDR_LIST setting.

export EPICS_CA_ADDR_LIST=127.255.255.255
export EPICS_PVA_ADDR_LIST=127.0.0.1
export EPICS_CA_AUTO_ADDR_LIST=no
export EPICS_PVA_AUTO_ADDR_LIST=no

Multiple IOCs on the same computer but on a different subnet

[!TIP] Refer to:

konosubakonoakua commented 21 hours ago

References