How can I get "CODESYS control (Demo Mode)" running on a sensorEDGE FIELD (NFS-M8-QM-D2-N16/NFLD) device?

Q

How can I get "CODESYS control" running on a sensorEDGE FIELD (NFS-M8-QM-D2-N16/NFLD) device?

A

ATTENTION!

Currently, we have information indicating that licensing of CODESYS running in a container is not supported by the current version of CODESYS runtime.

General information

The CODESYS© SoftPLC runs on different kinds of devices and is compatible with different processor architectures.

On the official CODESYS store, the company CODESYS offers users links to precompiled runtimes and executables for different processor architectures that are ready-to-download and -use. Not only runtimes but extension packages are provided in the shop as well. With the correct links, they can also be downloaded electronically from an FTP server. To get CODESYS running on your device, you can build a container yourself and run it or deploy a pre-built container from a repository.

To build a container yourself you need to include the following packages from the CODESYS FTP server:

  1. CODESYS Control for Linux ARM SL package
  2. CODESYS Edge Gateway for Linux package

Building a container yourself

If you are familiar with building containers, you can easily build a container yourself in minutes on a device using a Dockerfile.

An example of a Dockerfile to build a container for ARM64 architecture based systems is shown below. The environment variables CDS_VERSION and EDGE_VERSION define the package versions loaded from the FTP server.

FROM arm64v8/debian:11.6
RUN apt-get update 
RUN apt-get install -y wget sudo unzip libusb-1.0-0-dev procps
ENV CDS_VERSION "4.11.0.0"
ENV EDGE_VERSION "4.11.0.0"
ENV URL "https://store-archive.codesys.com/ftp_download/3S/LinuxARM64/2302000039/$CDS_VERSION/CODESYS%20Control%20for%20Linux%20ARM64%20SL%20$CDS_VERSION.package"
ENV EDGE_URL "https://store-archive.codesys.com/ftp_download/3S/EdgeGatewayLinux/000120/$EDGE_VERSION/CODESYS%20Edge%20Gateway%20for%20Linux%20$EDGE_VERSION.package"
RUN wget --output-document=/tmp/codesys.package $URL && \
    unzip -p /tmp/codesys.package '*codemeter*.deb' > /tmp/codemeter.deb && dpkg -i /tmp/codemeter.deb && \
    unzip -p /tmp/codesys.package '*codesyscontrol*.deb' > /tmp/codesys.deb && dpkg -i /tmp/codesys.deb
RUN wget --output-document=/tmp/edge.package $EDGE_URL && \
    unzip -p /tmp/edge.package '*arm64.deb' > /tmp/edge.deb && dpkg -i /tmp/edge.deb
EXPOSE 11740 1217 11743 22352
ENTRYPOINT ["/bin/sh", "-c" , "/etc/init.d/codemeter start && /etc/init.d/codemeter-webadmin start && /etc/init.d/codesyscontrol start && /etc/init.d/codesysedge start  && tail -f /dev/null"]

On the device, create a file named "Dockerfile" with an editor such as "vi" first, using the following line:

vi Dockerfile

In the editor press the key "i" first to activate the "insert mode". Then copy and paste the Dockerfile lines above into the editor's empty text field. Initiate to save the file with the key [ESC] plus the key ":" and then use the keys "wq" + [ENTER] afterward for the write + quit command. Alternatively, just download the example file from here: Dockerfile and copy it to a folder on your device.

In the folder of the Dockerfile, use the docker build command to build the container:

docker build -t codesys_control_sl_linux .

Deploying the container

After the container has been built you can immediately deploy the container with

docker run -it -d --network=host -v=codesys_data:/var/opt/codesys --privileged --name=codesyscontrol codesys_control_sl_linux

It is important to run the container in the modes 'host' and 'privileged', since it needs access to host device specific system variables.

Containers on public repository

Pre-built (as described above) container images are made public on the Docker Hub container repository https://hub.docker.com/repository/docker/hilschernetiotedge/codesys_control_sl_linux ready for deployment.

Programming CODESYS control

Once the container is deployed, the CODESYS runtime can be programmed with the CODESYS development system V3 (for Windows). The progamming port 1217 (Edge gateway) is exposed.

Licensing information

Without a license the CODESYS runtime in the container runs for 2 hours only and then stops. It gives you enough time to test the runtime intensively. Else restart the container and continue testing.

Saving the license stored 

IMPORTANT NOTE! During the licensing procedure the license will be stored within the context of the container. If you stop and delete the container then your license is lost forever. So make sure you saved the license file through the CODESYS development system before or use the docker commit command to create a 1:1 container image backup copy of your currently running container inclusive the license.

See also...