CODESYS on Raspberry Pi, start to finish

How to install and setup CODESYS soft PLC on the Raspberry Pi single-board computer.



Prepare Raspberry Pi

Flash SD

Flash a 32bit raspi OS (lite is ok, but stick to 32, do not use 64bit !!! )… 32bit OS is a requirements for the Control Raspberry MC SL

Enable SSH

enable SSH as usual with the .ssh file in the boot partition

Configure network

  • set a static IP like for the RPi and use a LAN cable to connect the dev PC (stay away from wifi and DHCP for now… to be investigated later)
# add the following / uncomment 
# sudo nano /etc/dhcpcd.conf

interface wlan0 (or eth0 or whatever)
static domain_name_servers=
static ip_address=

Bug / Fix

SSH to the RPi and modify the /boot/config.txt as follows (


failing to do so will trigger a bug where the RTE does not detect the OS as 32bit even though it is …..

[ERROR] Architecture seems to be arm64. CODESYS Control for Raspberry Pi SL is only available on the 32-bit kernel for Raspberry Pi!

RESTART raspberry??


CODESYS IDE requires a Windows machine to run.

  • installed (note that first it adds the CODESYS Installer and then use it for all the other packages)
  • with the IDE in place, via the Installer add the CODESYS Control for Raspberry MC SL

Configure PC network

make sure the ethernet port on the dev PC is configured to be some or similar on the same subnet of the rpi (get to the dialog box shown below… changing to Manual IP from elsewhere might not work properly)

Alt text

Flash RTE

flash the 4.8.0 RTE… select multicore

then try to scan to find it

Alt text

for now the authentication by the user is mandatory so setup admin/admin credential for privileged user

(TODO consider disabling it


then go on with the login….(it asks twice)

Alt text


Alt text

then go on and login

Alt text

and again with app compiled and deployed

Alt text


TODO: describe the many levels of codesys authentications…

SSH Autentication

Setting up SSH keys for CODESYS development will save the coder from manually login each time he needs to deploy an artifact (i.e. connect to the Raspberry Pi);product=CODESYS_Control_for_Raspberry_Pi_SL;version=


Start generate the ssh key on the dev pc (either win or linux)… the use the following to set them as authorized keys on the server

# -i specifies the (public) key you want to push to the server (remote), the rest is the
# usual login to the your remoter 
ssh-copy-id -i ~/.ssh/ pi@

ssh keys are added on the server to the same .ssh/authorize_keys file

  • update (or uncomment lines) the sshd config file to allow for auth key access (and optionally disable completely the ssh access with password)… ref to with some additions
PermitRootLogin no
PasswordAuthentication no # yes, if you want allow "ssh" pwd access (local pwd is always possible)
PubkeyAuthentication yes    
AuthorizedKeysFile .ssh/authorized_keys
ChallengeResponseAuthentication no
UsePAM no

restart the service after the changes

sudo systemctl reload sshd

Autorestart via cronjob

Without a valid license, the CODESYS RTE will run for 2 hours then stop. Assuming the application and/or process you’re running is not impacted by it (e.g., simple mockups and lab setups) a cron job can be configured to periodically restart the CODESYS service (below we do it every hour). Cron job is active immediately, with no need to restart cron. Note that we use sudo to edit the root cron table, and not the user cron table.

sudo crontab -e
*/60 * * * * /usr/sbin/service codesyscontrol restart

To check the job runs correctly use top to check the PID of the codesysruntime.service is changed every hour.

TODOs and Further development

Few ideas I’d like to experiment with in the future are:



Here’s a list of some of the references used throughout this project: