Skip to content

Instantly share code, notes, and snippets.

@wisedier
Last active November 3, 2019 16:15
Show Gist options
  • Save wisedier/866edef97cf99ac2b564902f6fb5ff5f to your computer and use it in GitHub Desktop.
Save wisedier/866edef97cf99ac2b564902f6fb5ff5f to your computer and use it in GitHub Desktop.
Installing OpenSCADA with latest version of dependencies

OpenSCADA Installation

OpenSCADA is platform which supports high fidelity emulation of IEC 6111-3 compliant PLCs and SCADA protocols. You can check details at OpenSCADA documentation.

Environment

  • Ubuntu 18.04.3 LTS (x86_64)

Install required packages

  • Install APT packages

    sudo apt update
    sudo apt install -y build-essential python3 python3-pip python3-tk \
      openjdk-8-jdk pkg-config zip unzip g++ zlib1g-dev libssl-dev \
      automake checkinstall libncurses5 libncurses5-dev git
  • Install Bazel builder

    wget https://github.com/bazelbuild/bazel/releases/download/1.1.0/bazel-1.1.0-installer-linux-x86_64.sh
    chmod +x bazel-1.1.0-installer-linux-x86_64.sh
    ./bazel-1.1.0-installer-linux-x86_64.sh --prefix=$HOME/.local
    echo "export PATH=\$PATH:\$HOME/.local/bin" >> ~/.bashrc
    source ~/.bashrc
  • Install Python packages

    pip3 install virtualenv virtualenvwrapper
    cat << EOF >> ~/.bashrc
    WORKON_HOME=$HOME/.virtualenvs
    VIRTUALENVWRAPPER_PYTHON=$(which python3)
    VIRTUALENVWRAPPER_VIRTUALENV=$HOME/.local/bin/virtualenv
    source $HOME/.local/bin/virtualenvwrapper.sh
    EOF
    source ~/.bashrc
    mkvirtualenv oscada
    pip install grpcio grpcio-tools numpy opencv-python
  • Install OpenSCADA and Kronos (Virtualization) repositories

    git clone https://github.com/Vignesh2208/Kronos.git
    git clone https://github.com/Vignesh2208/OpenSCADA.git

    Details Installation instruction for Kronos is at Kronos Documentation. You shoud hold Shift button while booting to choose 4.4.5-ins-VT kernel in advanced Ubuntu boot mode after building and loading Kronos kernel.

    If you met code model kernel does not support PIC mode error while compiling, you should apply the below patch. The error can be occurred when you use high version of GCC to compile relatively lower version of kernel.

    diff --git a/Makefile b/Makefile
    index dda982c..f96b174 100644
    --- a/Makefile
    +++ b/Makefile
    @@ -608,6 +608,12 @@ endif # $(dot-config)
    # Defaults to vmlinux, but the arch makefile usually adds further targets
    all: vmlinux
    
    +# force no-pie for distro compilers that enable pie by default
    +KBUILD_CFLAGS += $(call cc-option, -fno-pie)
    +KBUILD_CFLAGS += $(call cc-option, -no-pie)
    +KBUILD_AFLAGS += $(call cc-option, -fno-pie)
    +KBUILD_CPPFLAGS += $(call cc-option, -fno-pie)
    +
    # The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default
    # values of the respective KBUILD_* variables
    ARCH_CPPFLAGS :=

    Save the diff as pie.patch, apply it and compile again.

    patch -p1 < pie.patch
  • Test kronos_functions

    Load Kronos kernel module and you should test it is loaded and installed without an error.

    >>> import kronos_functions
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ImportError: No module named kronos_functions

    If you get the above error, check there exists the package in disk-packages directory of global python or oscada virtualenv. In my case, the pacakge was installed in /usr/local/lib/python3.x/dist-packages so I copied it to site-pacakges directory of my virtual environment like the below.

    cp /usr/local/lib/python3.7/dist-packages/kronos_functions* ~/.virtualenvs/oscada/lib/python3.7/site-packages/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment