LinuxCNC / linuxcnc

LinuxCNC controls CNC machines. It can drive milling machines, lathes, 3d printers, laser cutters, plasma cutters, robot arms, hexapods, and more.
http://linuxcnc.org/
GNU General Public License v2.0
1.74k stars 1.14k forks source link

debian/configure: Re-add support for RTAI #2052

Open NTULINUX opened 1 year ago

NTULINUX commented 1 year ago

With Bullseye RTAI kernels available (4.19.257) 6f285604ac1a1b58b2d65d5904ffec3998a833ef should be at least partially reverted.

petterreinholdtsen commented 1 year ago

[NTU]

With Bullseye RTAI kernels available (4.19.257) 6f285604ac1a1b58b2d65d5904ffec3998a833ef should be at least partially reverted.

Perhaps you can identify which parts should be reverted and create a pull request to reintroduce updated RTAI support?

-- Happy hacking Petter Reinholdtsen

andrewheeler82 commented 1 year ago

I don't know if I understand this correctly, but officially there is no RTAI kernel from the Debian developers. The kernel 4.19.257 is from their development. That's why I think this change https://github.com/LinuxCNC/linuxcnc/commit/6f285604ac1a1b58b2d65d5904ffec3998a833ef was made. But I'm happy to be enlightened because I personally prefer RTAI.

NTULINUX commented 1 year ago

I don't know if I understand this correctly, but officially there is no RTAI kernel from the Debian developers. The kernel 4.19.257 is from their development. That's why I think this change 6f28560 was made. But I'm happy to be enlightened because I personally prefer RTAI.

There has never been an RTAI kernel from the Debian developers, however the ability to build LinuxCNC Debian packages with RTAI support has been an option for as long as I remember up until that commit. LinuxCNC would host their own RTAI kernel packages in their repository with corresponding LinuxCNC packages as well. The ability to switch between PREEMPT_RT and RTAI installations should and has been available for quite some time all using the package manager thanks to the LinuxCNC repository.

It looks like the previously hosted RTAI Debian packages in the LinuxCNC repository have been deleted. LinuxCNC hosted RTAI kernels, the modules package and LinuxCNC for Buster and Stretch however I can't find them anymore:

https://linuxcnc.org/dists/stretch/

https://linuxcnc.org/dists/buster/

andrewheeler82 commented 1 year ago

many thanks for the information. My last RTAI kernel was Debian 7 32-bit.

NTULINUX commented 1 year ago

Ah, I found them!

https://www.linuxcnc.org/dists/buster/base/binary-amd64/

I was looking in 2.8-rt instead of base.

andrewheeler82 commented 1 year ago

Ok 👍🏻 nice.

NTULINUX commented 1 year ago

Need help:

From 9b840b0c01f49022379a46e29a9a86e9d0f54062 Mon Sep 17 00:00:00 2001
From: Alec Ari <neotheuser@ymail.com>
Date: Sun, 9 Oct 2022 00:14:04 -0500
Subject: BROKEN: Revert "debian/configure: Drop outdated support for rtai and
 xenomai"

BROKEN
This reverts commit 6f285604ac1a1b58b2d65d5904ffec3998a833ef.
BROKEN

Signed-off-by: Alec Ari <neotheuser@ymail.com>
---
 debian/configure                     | 144 +++++++++++++++++++++++----
 debian/linuxcnc-uspace-rtai.files.in |   1 +
 2 files changed, 123 insertions(+), 22 deletions(-)
 create mode 100644 debian/linuxcnc-uspace-rtai.files.in

diff --git a/debian/configure b/debian/configure
index f5a9683549..1973b1cf0e 100755
--- a/debian/configure
+++ b/debian/configure
@@ -18,7 +18,22 @@ usage () {
 $P: Set up debian/ files to build for a particular kernel

 Usage:
-  $P [no-docs]
+    $P uspace [noauto | rtai | rtai=packagename] ...
+        Build for a userspace realtime systems or simulator
+
+    $P sim
+        Deprecated synonym for '$P uspace'
+
+    $P [kernel-version]
+        Build for the installed RTAI realtime kernel specified by
+        [kernel-version], for example "3.4.9-rtai-686-pae"
+
+    $P -r
+        Build for the currently running kernel for RTAI realtime only
+
+    $P -a
+        If the currently running kernel has realtime extensions, use it.
+        Otherwise use any available realtime kernel it can find.

   Extra options:
     no-docs
@@ -28,15 +43,48 @@ EOF

 cd "${0%/*}"

-if [ "$1" == "-h" -o "$1" == "-help" -o "$1" == "--help" ]; then
+if [ $# -eq 0 -o "$1" == "-h" -o "$1" == "-help" -o "$1" == "--help" ]; then
     usage
+    if [ $# -ne 1 ]; then
+        exit 1
+    fi
     exit 0
 fi

+if [ $1 = "-r" ]; then
+    set -- `uname -r`
+elif [ $1 = "-a" ]; then
+    KERNEL="$(uname -r)"
+    if [ ! -d "/usr/realtime-$KERNEL" ]; then
+        KERNEL=$(ls -1d /usr/realtime-* 2> /dev/null | cut -d - -f 2- | head -1)
+        if [ -z "$KERNEL" ]; then
+            echo "no realtime kernels found!"
+            exit 1
+        fi
+    fi
+    set -- $KERNEL
+fi
+
+TARGET=$1; shift
+
+# for example: "3.16.0-9"
+KERNEL_VERSION_ABI=${TARGET%-rtai-*}
+
+MODULE_PATH=usr/realtime-$TARGET/modules/linuxcnc
+MODULE_EXT=.ko
+KERNEL_DEPENDS="linux-image-$TARGET,rtai-modules-$TARGET|rtai-modules-$KERNEL_VERSION_ABI"
+KERNEL_HEADERS=linux-headers-$TARGET
+EXTRA_FILES=
 EXTRA_BUILD=
+KERNEL_VERSION=$TARGET
+DRIVERS=drivers.files.in
+PYTHON_VERSION=$(python3 -c 'import sys; print (sys.version[:3])')
 PYTHON_VERSION_NEXT=$(python3 -c 'import sys; print (sys.version[:2] + str(1+int(sys.version[2])))')
 LIBREADLINE_DEV="libreadline-gplv2-dev | libreadline-dev"

+BUILD_RTAI=false
+BUILD_AUTO=true
+
 ENABLE_BUILD_DOCUMENTATION=--enable-build-documentation=pdf

 # Specialize these based on DISTRIB_NAME as needed
@@ -44,11 +92,21 @@ ENABLE_BUILD_DOCUMENTATION=--enable-build-documentation=pdf
 # the whole point is to allow a range of kernels to work, and we don't know
 # of any common thing that all such kernels would provide.

+# rtai-modules typically doesn't properly declare the architectures where
+# it works, so hardcode it...
+RTAI_DEV="$(apt-cache search -n rtai-modules | head -1 | awk '{print $1}')"
+RTAI_ARCHITECTURE="i386 amd64"
+if [ ! -z "$RTAI_DEV" ]; then
+    RTAI_DEV="$RTAI_DEV [i386], $RTAI_DEV [amd64]"
+fi
+
 while test $# -ne 0; do
     case "$1" in
-    sim|uspace|noauto) echo "$1 is accepted for compatibility, but ignored";;
+    noauto) BUILD_AUTO=false ;;
+    rtai) BUILD_RTAI=true ;;
+    rtai=*) BUILD_RTAI=true; RTAI_DEV=${1#rtai=} ;;
     no-docs) unset ENABLE_BUILD_DOCUMENTATION ;;
-    *) echo 1>&2 "Unknown option: $1"; exit 99 ;;
+    *) echo 1>&2 "Unknown feature: $1"; exit 99 ;;
     esac
     shift
 done
@@ -104,8 +162,15 @@ case $DISTRIB_NAME in
         DEBHELPER="debhelper-compat (= 13)"
         ;;
     Ubuntu-20.*)
+        DOC_DEPENDS="$DOC_DEPENDS, asciidoc-dblatex"
+        YAPPS_RUNTIME="yapps2"
         ;;
     Debian-10|Debian-10.*|Raspbian-10|Raspbian-10.*)
+        DOC_DEPENDS="$DOC_DEPENDS, asciidoc-dblatex"
+        PYTHON_GST=python-gst-1.0,gstreamer1.0-plugins-base
+        EXTRA_BUILD=python-yapps
+        YAPPS_RUNTIME="python-yapps"
+        STANDARDS_VERSION="3.9.8"
         ;;
     *)
         echo "unknown distribution: $DISTRIB_NAME"
@@ -114,23 +179,45 @@ case $DISTRIB_NAME in
         ;;
 esac

-TARGET=uspace
+TARGET_EXTRA=
 MAIN_PACKAGE_NAME=linuxcnc
 OTHER_MAIN_PACKAGE_NAME=linuxcnc-uspace
 EXTRA_RECOMMENDS=hostmot2-firmware-all
-MODULE_PATH=usr/lib/linuxcnc/modules
-MODULE_EXT=.so
-KERNEL_DEPENDS=libudev-dev,iptables
-KERNEL_DEPENDS_BUILD=libudev-dev
-KERNEL_HEADERS=
-KERNEL_VERSION=uspace
-MODUTILS_DEPENDS=
-DISTRIB_NAME=uspace-$DISTRIB_NAME
-MAIN_PACKAGE_NAME=linuxcnc-uspace
-OTHER_MAIN_PACKAGE_NAME=linuxcnc
-
-EXTRA_RECOMMENDS="$EXTRA_RECOMMENDS, linux-image-rt-amd64 [linux-amd64], linux-image-rt-686-pae [linux-i386]"
-CONFIGURE_REALTIME_ARG=--with-realtime=uspace
+case $TARGET in
+    uspace|sim)
+        if $BUILD_AUTO; then
+            if test ! -z "$RTAI_DEV"; then
+                BUILD_RTAI=true
+            fi
+        fi
+
+        if $BUILD_RTAI; then
+            EXTRA_BUILD="$EXTRA_BUILD,$RTAI_DEV"
+            TARGET_EXTRA="$TARGET_EXTRA+rtai"
+        fi
+
+   TARGET=uspace
+        MODULE_PATH=usr/lib/linuxcnc/modules
+   MODULE_EXT=.so
+   KERNEL_DEPENDS=libudev-dev,iptables
+   KERNEL_HEADERS=
+   KERNEL_VERSION=uspace
+        MODUTILS_DEPENDS=
+   DRIVERS=
+        EXTRA_FILES="usr/bin/rtapi_app"
+   DISTRIB_NAME=uspace-$DISTRIB_NAME
+   MAIN_PACKAGE_NAME=linuxcnc-uspace
+        OTHER_MAIN_PACKAGE_NAME=linuxcnc
+
+        EXTRA_RECOMMENDS="$EXTRA_RECOMMENDS, linux-image-rt-amd64 [linux-amd64]"
+        CONFIGURE_REALTIME_ARG=--with-realtime=uspace
+    ;;
+    4.19.*-rtai-*)
+        CONFIGURE_REALTIME_ARG=--with-realtime=/usr/realtime-$KERNEL_VERSION
+    ;;
+    *)
+   echo "your kernel '$TARGET' is not known. There might be needed dependencies which won't get set automatically."
+esac

 subst () {
 sed \
@@ -160,7 +247,6 @@ sed \
     -e "s#@TARGET@#$TARGET#g" \
     -e "s#@CONFIGURE_REALTIME_ARG@#$CONFIGURE_REALTIME_ARG#g" \
     -e "s#@TCLTK_VERSION@#$TCLTK_VERSION#g" \
-    -e "s#@XENOMAI_ARCHITECTURE@#$XENOMAI_ARCHITECTURE#g" \
     -e "s|@YAPPS_RUNTIME@|$YAPPS_RUNTIME|g" \
     -e "s#@ENABLE_BUILD_DOCUMENTATION@#$ENABLE_BUILD_DOCUMENTATION#g" \
     -e '/^\s*,\s*$/d' \
@@ -175,11 +261,25 @@ fi

 subst control.top.in > control

+if [ "$TARGET" == "uspace" ]; then
+    if $BUILD_RTAI; then
+        echo >> control
+        subst control.uspace-rtai.in >> control
+        subst linuxcnc-uspace-rtai.files.in > linuxcnc-uspace-rtai.files
+    fi
+fi
+
 echo >> control
 subst control.main-pkg.in >> control

-subst linuxcnc.install.in > ${MAIN_PACKAGE_NAME}.install
-subst linuxcnc.lintian-overrides.in > ${MAIN_PACKAGE_NAME}.lintian-overrides
+if [ "$TARGET" == "uspace" ]; then
+    cp linuxcnc-dev.files.in linuxcnc-uspace-dev.files
+else
+    cp linuxcnc-dev.files.in linuxcnc-dev.files
+    echo "$MODULE_PATH/Module.symvers" >> linuxcnc-dev.files
+fi
+
+subst rules.in > rules; chmod +x rules

 subst rules.in > rules
 chmod +x rules
@@ -190,4 +290,4 @@ fi

 rm -f ../build-stamp
-echo "successfully configured for '$DISTRIB_NAME'.."
+echo "successfully configured for '$DISTRIB_NAME'-'$TARGET$TARGET_EXTRA'.."
diff --git a/debian/linuxcnc-uspace-rtai.files.in b/debian/linuxcnc-uspace-rtai.files.in
new file mode 100644
index 0000000000..0b05b4f794
--- /dev/null
+++ b/debian/linuxcnc-uspace-rtai.files.in
@@ -0,0 +1 @@
+/usr/lib/libuspace-rtai.so.0
-- 
2.30.2
andypugh commented 1 year ago

What help do you need?

NTULINUX commented 1 year ago

I'm having trouble adding back in RTAI support. If you apply that patch, can you let me know at least how close I am and any pointers? I also don't know what the syntax is to call the debian configure script to build RTAI.

I think we have done away with linuxcnc-dev.files.in linuxcnc-uspace-dev.files ? Not sure but it says:

No such file: linuxcnc-dev.files.in

andypugh commented 1 year ago

To configure for RTAI if you are booted into the RTAI kernel then it is

./debian/configure -r

I might find time to try your patch, but I am hardly even keeping up with personal emails at the moment.

petterreinholdtsen commented 1 year ago

[Andy Pugh]

To configure for RTAI if you are booted into the RTAI kernel then it is

./debian/configure -r

I might find time to try your patch, but I am hardly even keeping up with personal emails at the moment.

Can it only be built after booting into a RTAI kernel? If it can be build by just installing some build dependency, we could get away with adjusting .github/workflows/ci.yml to install this extra dependency from somewhere (like we do with po4a) and then build the RTAI kernel. I assume it can not be tested, but we could test the build that way.

-- Happy hacking Petter Reinholdtsen

andypugh commented 1 year ago

I haven't tried, but my feeling is that it needs the kernel headers at the very least.

NTULINUX commented 1 year ago

Yes, you need the headers. -r looks like it uses uname -r so you'd need to use the $P [kernel-version] one.

petterreinholdtsen commented 1 year ago

[NTU]

Yes, you need the headers. -r looks like it uses uname -r so you'd need to use the $P [kernel-version] one.

Can you tell exactly which package is needed, and how you call d/configure and src/configure? It would make it more obvious how to adjust the github CI setup.

-- Happy hacking Petter Reinholdtsen

silopolis commented 1 year ago

Le mer. 16 nov. 2022 à 02:03, andypugh @.***> a écrit :

I haven't tried, but my feeling is that it needs the kernel headers at the very least.

I think Seb said it needs to load and unload kernel modules too, at least for testing, in the release manager/builbot thread

petterreinholdtsen commented 1 year ago

[Jérémie Tarot]

I think Seb said it needs to load and unload kernel modules too, at least for testing, in the release manager/builbot thread

I think we all agree that testing is out of scope for a github build of RTAI. My goal is to get the build going to detect when the code is not building.

-- Happy hacking Petter Reinholdtsen

silopolis commented 1 year ago

Le mer. 16 nov. 2022 à 12:24, petterreinholdtsen @.***> a écrit :

[Jérémie Tarot]

I think Seb said it needs to load and unload kernel modules too, at least for testing, in the release manager/builbot thread

I think we all agree that testing is out of scope for a github build of RTAI. My goal is to get the build going to detect when the code is not building.

oh ok 🖐

NTULINUX commented 1 year ago

If the build system issued runtests then it could make sure RTAI is working ok.

NTULINUX commented 2 weeks ago

I was able to build LinuxCNC RTAI debian packages with my branch here:

https://github.com/NTULINUX/linuxcnc-rtai/tree/ntulinux/2.9-rtai

Took @andypugh 's andypugh/2.9-rtai branch and rebased it on top of the latest checkout of the 2.9 branch and it built. I wasn't able to test RTAI itself though because it panics on this laptop that I'm temporarily using.