CODESYS Control
Made for netPI, the Raspberry Pi 3B Architecture based industrial suited Open Edge Connectivity Ecosystem
Secured netPI Docker
netPI features a restricted Docker protecting the system software's integrity by maximum. The restrictions are
- privileged mode is not automatically adding all host devices
/dev/
to a container - volume bind mounts to rootfs is not supported
- the devices
/dev
,/dev/mem
,/dev/sd*
,/dev/dm*
,/dev/mapper
,/dev/mmcblk*
cannot be added to a container
Container features
The image provided hereunder deploys a container with a basic setup of Linux tools, utilities and default user needed for a flawless installation of the CODESYS Control for Raspberry Pi (SL and MC SL) packages with the Windows® based CODESYS Development System V3(free).
Base of this image builds debian with enabled SSH and created default user 'pi'(sudo). This setup is equivalent to a stripped down Raspbian OS with least capabilities.
Once the container is deployed it needs an upgrade with the following packages you can download from the CODESYS store
- CODESYS Control for Raspberry Pi SL or CODESYS Control for Raspberry Pi MC SL
- CODESYS Edge Gateway (needed since version V3.5.15.x)
Container licensing
If not licensed the "CODESYS Control for Raspberry Pi" SoftPLC runtime operates 1 hour and then stops. A Licensing is needed to make it run an unlimited time.
A license purchase follows an email with a ticket number (e.g A78HY-TBVMD-8SVC7-P8BHX-4LED6) granting you the license. The Tools->License Manager
in the CODESYS Development System (internet needed) transforms the ticket number in a deployed license. The ticket number can be used only one time and gets invalid during the licensing procedure.
It is possible to deploy a license to either a CODESYS Runtime Key (USB dongle) or to a software container.
IMPORTANT NOTE: A software container needs special care since the license is stored on the device itself in the Docker container. If this container is lost or destroyed by any reason or is deleted your license copy is gone forever!!!. This is why a license backup is obligatory in this case.
To backup the license file "3SLicenseInfo.tar" follow this FAQ information. To restore the license file "3SLicenseInfo.tar" follow this FAQ information.
Container setup
Host network
The container needs to run in host
network mode.
Using this mode makes port mapping unnecessary since all the used container ports (like 22) are exposed to the host automatically.
Privileged mode
The privileged mode option needs to be activated to lift the standard Docker enforced container limitations. With this setting the container and the applications inside are the getting (almost) all capabilities as if running on the Host directly
Host devices
The CODESYS runtime perfoms a license versus serial number check across the device VideoCore GPU when started. To grant access to the GPU chip the /dev/vcio
host device is mandatory to add to the container.
In case a CODESYS Runtime Key Dongle is used for licensing the host device /dev/hidraw0
needs to be added to the container.
On netPI RTE 3 target only (optional):
The container configures the two RJ45 Industrial Ethernet ports (RTE) as standard LAN interface (single MAC address, but switched) named cifx0
automatically if the following devices found added to the container
- host device
/dev/spidev0.0
granting access to the network controller netX driving the RTE ports - host device
/dev/net/tun
granting access to network interface registering logic
Environment variables (optional)
On netPI RTE 3 target only (optional):
The configuration of the LAN interface cifx0
is done with the following variables
- IP_ADDRESS with a value in the format
x.x.x.x
e.g. 192.168.0.1 configures the interface IP address. A valuedhcp
instead enables the dhcp mode and the interface waits to receive its IP address through a DCHP server. - SUBNET_MASK with a value in the format
x.x.x.x
e.g. 255.255.255.0 configures the interface subnet mask. Not necessary to configure in dhcp mode. - GATEWAY with a value in the format
x.x.x.x
e.g. 192.168.0.10 configures the interface gateway address. A gateway is optional. Not necessary to configure in dhcp mode.
Container deployment
STEP 1. Open netPI's website in your browser (https).
STEP 2. Click the Docker tile to open the Portainer.io Docker management user interface.
STEP 3. Enter the following parameters under Containers > + Add Container
Parameter | Value | Remark |
---|---|---|
Image | hilschernetpi/netpi-codesys-basis | |
Network > Network | host | |
Restart policy | always | |
Runtime > Devices > +add device | Host path /dev/vcio -> Container path /dev/vcio | |
Runtime > Devices > +add device | Host path /dev/hidraw0 -> Container path /dev/hidraw0 | for CODESYS Runtime Key Dongle |
Runtime > Devices > +add device | Host path /dev/spidev0.0 -> Container path /dev/spidev0.0 | for cifx0 LAN |
Runtime > Devices > +add device | Host path /dev/net/tun -> Container path /dev/net/tun | for cifx0 LAN |
Runtime > Env | name IP_ADDRESS -> value e.g.192.168.0.1 or dhcp | for cifx0 LAN |
Runtime > Env | name SUBNET_MASK -> value e.g.255.255.255.0 | for cifx0 LAN, no need for dhcp |
Runtime > Env | name GATEWAY -> value e.g.192.168.0.10 | optional for cifx0 LAN, no need for dhcp |
Runtime > Privileged mode | On |
STEP 4. Press the button Actions > Start/Deploy container
Pulling the image may take a while (5-10mins). Sometimes it may take too long and a time out is indicated. In this case repeat STEP 4.
Container access
A fresh container can immediately be upgraded with your downloaded packages from the CODESYS store. Here is how to proceed
STEP 1: Upgrade your CODESYS development system first with support for Raspberry Pi/Linux compatible platforms using the function Tools->Package Manager->Install
. Choose your packages "CODESYS Control for Raspberry Pi 3.5.xx.xx.package" and "CODESYS Edge Gateway for Linux 3.5.x.x.package" and click Install
.
STEP 2: Restart the development system to activate the installed packages extending the top menu bar Tools
by two new functions.
STEP 3: Use the new function Tools->Update Raspberry Pi
to deploy your "CODESYS Control for Raspberry Pi" package to the container. Enter the user pi
and the password raspberry
as Login credentials
. Enter your netPI's IP address in Select target->IP address
, choose the version under Package
you want to install and press Install
. The installation may take up to 1 minute. Choose Standard
or Multicore
runtime mode during installation.
STEP 4: Use the new function Tools->Update Edge Gateway
to deploy your "CODESYS Edge Gateway for Linux" package to the container. Enter the user pi
and the password raspberry
as Login credentials
. Enter your netPI's IP address in Select target->IP address
, choose the version V3.5.x.x.(armhf)
under Package
you want to install and press Install
. The installation may take up to 1 minute. The container is now well prepared and ready to receive a project.
STEP 5: Create a CODESYS new project. Choose Standard Project
and as Device
"CODESYS Control for Raspberry Pi xx" and then ok
. After project creation double click the topmost Device(CODESYS Control for Raspberry Pi)
in the project tree.
STEP 6: Setup a communication from the CODESYS development system to the container Edge Gateway. Use the function Gateway->Add New Gateway
in the dialog Device
. As gateway IP-address
use the netPI IP address at port 1217 and click ok
. Use the option Device->Scan Network...
option and click the found device found. e.g. NTB827EBEA02D0 [0000.0539] and ok
.
Container test
The container has been successfully tested against the CODESYS Development System V3 in the version V3.5.15.10 and the CODESYS Control for Raspberry Pi SL and CODESYS Control for Raspberry Pi MC SL both in the version V3.5.15.10
Container automated build
The project complies with the scripting based Dockerfile method to build the image output file. Using this method is a precondition for an automated web based build process on DockerHub platform.
DockerHub web platform is x86 CPU based, but an ARM CPU coded output file is needed for Raspberry systems. This is why the Dockerfile includes the balena.io steps.