Skip to content

Instantly share code, notes, and snippets.

@piratecarrot
Last active February 25, 2026 10:42
Show Gist options
  • Select an option

  • Save piratecarrot/70d237a53e7de3ca24d0306e6e467fd4 to your computer and use it in GitHub Desktop.

Select an option

Save piratecarrot/70d237a53e7de3ca24d0306e6e467fd4 to your computer and use it in GitHub Desktop.
Beckhoff TwinCAT RTLinux

Install Beckhoff TwinCAT on Debian Trixie

These instructions were created based on this github repository. Instead of fetching their stuff, I https://github.com/Beckhoff/TC_XAR_Container_Sample/tree/main

Step 1

Install Debian Trixie (13)

Step 2

Run the attached script to set things up

Step 3

Execute this command. I tried in LXC on ProxMox and am not getting the main command to run. I have tried setting the -f parameter to 0x4, 0x5, 0x6 which give errors.

/usr/bin/TcSystemServiceUm -f 0x7 -i "${AMS_NETID}" -p /var/run/TcSystemServiceUm.pid

Todo

  1. Obviously, get it working
  2. See if we have to use Beckhoff's Debian sources. It is slow.
#!/usr/bin/env bash
EMAIL=my-email@email.com
PASSWORD=my-password
# Update the package lists and install necessary packages
apt update \
&& apt-get install --yes --no-install-recommends \
curl \
ca-certificates
# Rename the default apt sources list to avoid conflicts with Beckhoff's apt repository
mv /etc/apt/sources.list.d/debian.sources /etc/apt/sources.list.d/debian.sources.bak
# Create login credentials for Beckhoff's apt repository
tee /etc/apt/auth.conf.d/bhf.conf > /dev/null <<EOF
machine deb.beckhoff.com login ${EMAIL} password ${PASSWORD}
machine deb-mirror.beckhoff.com login ${EMAIL} password ${PASSWORD}
EOF
# Get the apt sources for Beckhoff's apt repository (deb822 format)
tee /etc/apt/sources.list.d/debian-beckhoff.sources > /dev/null <<'EOF'
Types: deb
URIs: https://deb-mirror.beckhoff.com/debian
Suites: trixie
Components: main
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
Types: deb
URIs: https://deb-mirror.beckhoff.com/debian-security
Suites: trixie-security
Components: main
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
EOF
tee /etc/apt/sources.list.d/bhf.sources > /dev/null <<'EOF'
Types: deb
URIs: https://deb.beckhoff.com/debian
Suites: trixie-stable
Components: main
Signed-By: /usr/share/keyrings/bhf.asc
EOF
# Get the GPG key for Beckhoff's apt repository
curl --fail --netrc-file "/etc/apt/auth.conf.d/bhf.conf" \
-o /usr/share/keyrings/bhf.asc \
https://deb.beckhoff.com/repo.pub
apt install --yes tc31-xar-um
# --- TwinCAT 3 configuration ---
TC3_DIR=/etc/TwinCAT/3.1
# Static routes: ADS-over-MQTT via local mosquitto broker
mkdir -p "${TC3_DIR}/Target"
tee "${TC3_DIR}/Target/StaticRoutes.xml" > /dev/null <<'EOF'
<?xml version="1.0" encoding="utf-8"?>
<TcConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://www.beckhoff.com/schemas/2015/12/TcConfig">
<RemoteConnections>
<Mqtt>
<Address Port="1883">mosquitto</Address>
<Topic>AdsOverMqtt</Topic>
</Mqtt>
</RemoteConnections>
</TcConfig>
EOF
# Startup state: set TwinCAT to boot directly into RUN mode (0x05)
mkdir -p "${TC3_DIR}/Target/RegFiles"
tee "${TC3_DIR}/Target/RegFiles/SysStartupState.reg" > /dev/null <<'EOF'
Windows Registry Editor Version 5.00
; SysStartupState defines the TwinCAT System Service Startup State
; RUN = "SysStartupState"=dword:00000005
; CONFIG = "SysStartupState"=dword:0000000f
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Beckhoff\TwinCAT3\System]
"SysStartupState"=dword:00000005
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment