LinuxCNC on Rpi4 / Rpi3 / DietPi
- garlicbread
- Offline
- New Member
Less
More
- Posts: 15
- Thank you received: 12
05 May 2023 21:38 #270755
by garlicbread
LinuxCNC on Rpi4 / Rpi3 / DietPi was created by garlicbread
Hi All,
I've recently been experimenting trying to get LinuxCNC running on a RPI4 / RPI3
Using DietPi as a basis, I figured I'd list some of the details here I've been using for setup that might be useful
Although so far I've only managed to build the userspace side for 32bit and not 64bit for some reason It's basically raspian but with most of the default stuff not installed, so sort of a strimmed down version.
Although I've found it's main advantage over dietpi is if you install something via the dietpi-software menu
It will also handle all the configuration / setup, so I can just tick a box for xfce / xrdp
and instantly have a desktop I can remote to from a laptop without faffing with config files
I've recently been experimenting trying to get LinuxCNC running on a RPI4 / RPI3
Using DietPi as a basis, I figured I'd list some of the details here I've been using for setup that might be useful
Although so far I've only managed to build the userspace side for 32bit and not 64bit for some reason It's basically raspian but with most of the default stuff not installed, so sort of a strimmed down version.
Although I've found it's main advantage over dietpi is if you install something via the dietpi-software menu
It will also handle all the configuration / setup, so I can just tick a box for xfce / xrdp
and instantly have a desktop I can remote to from a laptop without faffing with config files
- BCM2710 = 64bit OS version
- BCM2709 = 32bit OS version
Please Log in or Create an account to join the conversation.
- garlicbread
- Offline
- New Member
Less
More
- Posts: 15
- Thank you received: 12
05 May 2023 21:48 #270757
by garlicbread
Replied by garlicbread on topic LinuxCNC on Rpi4 / Rpi3 / DietPi
For the realtime kernel
Ideally you don't want to be building the kernel sources on a SD card
so personally I tend to keep /boot on the sd card but move everything else across to a USB Hard Disk
I won't bother to go into details on how to do that here unless someone asks.
raspian recently merged 6.1.27 into they're 6.1 branch
github.com/raspberrypi/linux/tree/83cf6b...b7fef70b1a7c9539b0b9
using this in combination with this patch
mirrors.edge.kernel.org/pub/linux/kernel...-6.1.26-rt8.patch.xz
this seems to work ok for a realtime rpi kernel, at least for the Pi4
Install some dependencies
Download Linux Sources
Patch Sources
Set the default config for the rpi
In this example I'm using a subdirectory of /boot/rt/
this way we're free to switch back to the original kernel if needed
To boot to the new kernel
Edit the /boot/config.txt file.
Add os_prefix=/rt/ to the top, this will select the files under /boot/rt where the new kernel will be located
If anything goes wrong then just put the sd card in a usb adapter and comment out that line to switch back to the old kernel
If using a Pi3 I'd suggest sticking to 32bit
Also there seems to be some issues with it's USB Controller and Realtime
forums.raspberrypi.com/viewtopic.php?t=159170
One workaround for this is to add dwc_otg.fiq_enable=0 dwc_otg.fiq_fsm_enable=0 to the end of cmdline.txt
Which I think makes it more stable but I'm not entirely sure if it's fully stable
as I was still seeing some messages related to mmc1 under dmesg with network traffic
The Pi4 by comparison seems a lot more stable
I've not got an orangePi 5 to test but they're official kernels seems to be older at around version 5.4.65
with some branches going up to 5.18.
I think Armbian may have patches for a later kernel for the rock chipset.
This probably also applies to a lot of the other rpi alternatives since a lot of those also use the same rock chipset
Pi4's are starting to make they're way back onto Amazon now but they are a bit expensive still
Ideally you don't want to be building the kernel sources on a SD card
so personally I tend to keep /boot on the sd card but move everything else across to a USB Hard Disk
I won't bother to go into details on how to do that here unless someone asks.
raspian recently merged 6.1.27 into they're 6.1 branch
github.com/raspberrypi/linux/tree/83cf6b...b7fef70b1a7c9539b0b9
using this in combination with this patch
mirrors.edge.kernel.org/pub/linux/kernel...-6.1.26-rt8.patch.xz
this seems to work ok for a realtime rpi kernel, at least for the Pi4
Install some dependencies
sudo apt install git bc bison flex libssl-dev make gcc raspberrypi-kernel-headers libc6-dev
sudo apt install patch xz-utils libncurses-dev
Download Linux Sources
cd /usr/src/
wget https://github.com/raspberrypi/linux/archive/refs/heads/rpi-6.1.y.tar.gz
tar -xvf rpi-6.1.y.tar.gz
mv linux-rpi-6.1.y linux-6.1.27-linuxcnc-rt
Patch Sources
wget https://mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/6.1/patch-6.1.26-rt8.patch.xz
cd linux-6.1.27-linuxcnc-rt
xzcat ../patch-6.1.26-rt8.patch.xz | patch -p1
Set the default config for the rpi
# 64bit Rpi4 / Rpi3
KERNEL=kernel8
make bcm2711_defconfig
# 32Bit Rpi3
KERNEL=kernel7
make bcm2709_defconfig
# 32Bit Rpi4
KERNEL=kernel7l
make bcm2711_defconfig
- Run make menuconfig
- under General -> Preemption Model, switch this to real-time
- Edit .config and add something to the end of `CONFIG_LOCALVERSION` to make it unique
- such as "-linuxcnc-rt"
In this example I'm using a subdirectory of /boot/rt/
this way we're free to switch back to the original kernel if needed
# For 64bit
make -j4 Image.gz modules dtbs
make modules_install
mkdir -p /boot/rt/overlays/
cp arch/arm64/boot/dts/broadcom/*.dtb /boot/rt/
cp arch/arm64/boot/dts/overlays/*.dtb* /boot/rt/overlays/
cp arch/arm64/boot/dts/overlays/README /boot/rt/overlays/
cp arch/arm64/boot/Image.gz /boot/rt/$KERNEL.img
# For 32bit
make -j4 zImage modules dtbs
make modules_install
mkdir -p /boot/rt/overlays/
cp arch/arm/boot/dts/*.dtb /boot/rt/
cp arch/arm/boot/dts/overlays/*.dtb* /boot/rt/overlays/
cp arch/arm/boot/dts/overlays/README /boot/rt/overlays/
cp arch/arm/boot/zImage /boot/rt/$KERNEL.img
To boot to the new kernel
Edit the /boot/config.txt file.
Add os_prefix=/rt/ to the top, this will select the files under /boot/rt where the new kernel will be located
If anything goes wrong then just put the sd card in a usb adapter and comment out that line to switch back to the old kernel
If using a Pi3 I'd suggest sticking to 32bit
Also there seems to be some issues with it's USB Controller and Realtime
forums.raspberrypi.com/viewtopic.php?t=159170
One workaround for this is to add dwc_otg.fiq_enable=0 dwc_otg.fiq_fsm_enable=0 to the end of cmdline.txt
Which I think makes it more stable but I'm not entirely sure if it's fully stable
as I was still seeing some messages related to mmc1 under dmesg with network traffic
The Pi4 by comparison seems a lot more stable
I've not got an orangePi 5 to test but they're official kernels seems to be older at around version 5.4.65
with some branches going up to 5.18.
I think Armbian may have patches for a later kernel for the rock chipset.
This probably also applies to a lot of the other rpi alternatives since a lot of those also use the same rock chipset
Pi4's are starting to make they're way back onto Amazon now but they are a bit expensive still
Please Log in or Create an account to join the conversation.
- garlicbread
- Offline
- New Member
Less
More
- Posts: 15
- Thank you received: 12
05 May 2023 21:51 #270758
by garlicbread
Replied by garlicbread on topic LinuxCNC on Rpi4 / Rpi3 / DietPi
For the userspace tools this is what I've been using so far based on
gnipsel.com/linuxcnc/debian-11-emc.html
Install some dependencies since dietpi doesn't include a lot of things by default
Download sources
Build Sources
Install the deb files
I've been having some issues building for 64bit
So still looking into that
DietPi is currently on Debian 11 Bullseye, so one thing I might try is version 12 Bookworm
since there is a way to enable that
dietpi.com/blog/?p=2809
gnipsel.com/linuxcnc/debian-11-emc.html
Install some dependencies since dietpi doesn't include a lot of things by default
apt install build-essential devscripts gdebi debhelper dh-python libudev-dev autoconf automake bwidget \
intltool libboost-python-dev libepoxy-dev libgl1-mesa-dev libglu1-mesa-dev libgtk2.0-dev libgtk-3-dev libmodbus-dev \
libeditreadline-dev libxmu-dev netcat po4a python3-dev python3-tk python3-xlib tcl8.6-dev tclx tk8.6-dev yapps2 \
asciidoc dblatex docbook-xsl dvipng groff imagemagick inkscape python3-lxml source-highlight w3c-linkchecker xsltproc \
texlive-extra-utils texlive-font-utils texlive-fonts-recommended texlive-lang-cyrillic \
texlive-lang-french texlive-lang-german texlive-lang-polish texlive-lang-spanish texlive-xetex \
texlive-latex-recommended asciidoc-dblatex texlive-lang-european \
desktop-file-utils libusb-1.0-0-dev fonts-dejavu graphviz gdebi
apt update
apt upgrade
apt dist-upgrade
apt autoremove
Download sources
mkdir ~/linuxcnc-build
cd ~/linuxcnc-build
git clone https://github.com/LinuxCNC/linuxcnc.git build
cd build
git checkout 2.9
Build Sources
# Had some issues without no-docs specified
debian/configure no-docs
# Check for anything missing we still need to install as a depend
dpkg-checkbuilddeps
# Build the deb
debuild -uc -us
Install the deb files
cd ..
# 32bit
gdebi linuxcnc-uspace_2.9.0~pre1_armhf.deb linuxcnc-uspace-dev_2.9.0~pre1_armhf.deb linuxcnc-uspace-dbgsym_2.9.0~pre1_armhf.deb
I've been having some issues building for 64bit
make: *** [debian/rules:38: binary] Error 25
dpkg-buildpackage: error: debian/rules binary subprocess returned exit status 2
debuild: fatal error at line 1182:
dpkg-buildpackage -us -uc -ui failed
So still looking into that
DietPi is currently on Debian 11 Bullseye, so one thing I might try is version 12 Bookworm
since there is a way to enable that
dietpi.com/blog/?p=2809
Please Log in or Create an account to join the conversation.
- tommylight
- Away
- Moderator
Less
More
- Posts: 19188
- Thank you received: 6432
06 May 2023 08:59 #270776
by tommylight
Replied by tommylight on topic LinuxCNC on Rpi4 / Rpi3 / DietPi
You should try BookWorm as i am pretty sure it has armf packages already, so all you would need after installing Debian is:
sudo apt install linuxcnc-uspace
This should also install RT kernel.
sudo apt install linuxcnc-uspace
This should also install RT kernel.
Please Log in or Create an account to join the conversation.
06 May 2023 10:58 - 06 May 2023 10:59 #270785
by rodw
docs.google.com/document/d/1S0K-UBlXnsYC...b_0/edit?usp=sharing
Replied by rodw on topic LinuxCNC on Rpi4 / Rpi3 / DietPi
Actually, Debian offer Raspberry Specific images. I have installed Bookworm and Bullsey on the Raspberry. It only gets you to a terminal prompt but it's easy to install a graphical environment from there. I compiled some notes you may like to follow.You should try BookWorm as i am pretty sure it has armf packages already, so all you would need after installing Debian is:
sudo apt install linuxcnc-uspace
This should also install RT kernel.
docs.google.com/document/d/1S0K-UBlXnsYC...b_0/edit?usp=sharing
Last edit: 06 May 2023 10:59 by rodw.
Please Log in or Create an account to join the conversation.
- garlicbread
- Offline
- New Member
Less
More
- Posts: 15
- Thank you received: 12
07 May 2023 00:01 #270836
by garlicbread
Replied by garlicbread on topic LinuxCNC on Rpi4 / Rpi3 / DietPi
I recently switched to bookworm
dietpi.com/blog/?p=2809and I was supprised to find there was packages for arm64, I kinda assumed it would be 32bit only
I also managed to build from source based on the the date time of the pre-built package
My reason for using dietpi over raw debian or raspian is just because it automates away the setting up of wifi / rdp / remote desktop and network shares
also it auto strims out a lot of the cruft not actually needed as a starting point
Its something I could setup manually, but it's generally just a hassle when messing with config files when it could all be done via a menu
dietpi.com/blog/?p=2809
sudo bash -c "$(curl -sSf 'https://raw.githubusercontent.com/MichaIng/DietPi/master/.meta/dietpi-bookworm-upgrade')"
apt install linuxcnc-uspace
I also managed to build from source based on the the date time of the pre-built package
git clone https://github.com/LinuxCNC/linuxcnc.git build
cd build
git checkout 017e4928b91e0f7e94fbf49fd11fe8b1d8515d94
cd src
./autogen.sh
./configure --with-realtime=uspace --enable-non-distributable=yes
make
make setuid
My reason for using dietpi over raw debian or raspian is just because it automates away the setting up of wifi / rdp / remote desktop and network shares
also it auto strims out a lot of the cruft not actually needed as a starting point
Its something I could setup manually, but it's generally just a hassle when messing with config files when it could all be done via a menu
The following user(s) said Thank You: rodw
Please Log in or Create an account to join the conversation.
- garlicbread
- Offline
- New Member
Less
More
- Posts: 15
- Thank you received: 12
07 May 2023 22:22 #270895
by garlicbread
Replied by garlicbread on topic LinuxCNC on Rpi4 / Rpi3 / DietPi
So I recently switched from 6.1 to 6.3
the performance seemed better also I encountered a random glitch with the harddisk after about an hour or so with 6.1 where it'd break the system
6.3 seems to have an odd glitch with the wifi rarely which prevents it recieving connections but not that often, and it can be fixed by restarting the wifi
performance still isn't great however but not terrible I think
interestingly enough running glxgears seems to have little impact
This is with "processor.max_cstate=1 isolcpus=2,3" in cmdline.txt
and dtparam=audio=off in config.txt
and the latest linuxcnc master (which I've figued how to build now)
Going to see if I can get the 5.10 series kernels to work to see how they compare
as the other Pi4 thread shows them as getting much better results
the performance seemed better also I encountered a random glitch with the harddisk after about an hour or so with 6.1 where it'd break the system
6.3 seems to have an odd glitch with the wifi rarely which prevents it recieving connections but not that often, and it can be fixed by restarting the wifi
performance still isn't great however but not terrible I think
interestingly enough running glxgears seems to have little impact
This is with "processor.max_cstate=1 isolcpus=2,3" in cmdline.txt
and dtparam=audio=off in config.txt
and the latest linuxcnc master (which I've figued how to build now)
Going to see if I can get the 5.10 series kernels to work to see how they compare
as the other Pi4 thread shows them as getting much better results
Attachments:
Please Log in or Create an account to join the conversation.
- garlicbread
- Offline
- New Member
Less
More
- Posts: 15
- Thank you received: 12
08 May 2023 23:03 #270968
by garlicbread
Replied by garlicbread on topic LinuxCNC on Rpi4 / Rpi3 / DietPi
One of the things I've been trying out is the linuxcnc rpi4 default image.
Just as a benchmark to see what latency I could get with that. Performance wise it's older but much better, but it gives me an idea for what to aim for with something more recent.
Although I did notice it won't work on a pi4 that's had it's eeprom updated recently if that pi has had a more recent os installed onto it and that os has updated the eeprom.
It's an easy fix though, just a case of copying / pasting the "start*", "fixup*", "bootcode.bin" files across from a more recent os into the boot partition in the image. I've created a patched image here with those changes.
lfs.hecatron.com/linuxcnc/linuxcnc-2.8.1-pi4-fwpatched.7z
Although trying to upgrade it with "apt upgrade" will break it as the upgrade process tries to update the firmware files but fails halfway through and just removes them instead from /boot/ making the system unbootable (also it breaks wifi for some reason)
Just as a benchmark to see what latency I could get with that. Performance wise it's older but much better, but it gives me an idea for what to aim for with something more recent.
Although I did notice it won't work on a pi4 that's had it's eeprom updated recently if that pi has had a more recent os installed onto it and that os has updated the eeprom.
It's an easy fix though, just a case of copying / pasting the "start*", "fixup*", "bootcode.bin" files across from a more recent os into the boot partition in the image. I've created a patched image here with those changes.
lfs.hecatron.com/linuxcnc/linuxcnc-2.8.1-pi4-fwpatched.7z
Although trying to upgrade it with "apt upgrade" will break it as the upgrade process tries to update the firmware files but fails halfway through and just removes them instead from /boot/ making the system unbootable (also it breaks wifi for some reason)
Please Log in or Create an account to join the conversation.
- garlicbread
- Offline
- New Member
Less
More
- Posts: 15
- Thank you received: 12
16 May 2023 11:52 #271450
by garlicbread
Replied by garlicbread on topic LinuxCNC on Rpi4 / Rpi3 / DietPi
Just a quick update after a great deal of faffing I discovered the one thing that makes a huge difference isWhich is basically the 3D Accleration
From a before
To an after
I've also managed to get 5.4 working since I've seen that in other threads and wanted to see it's performance by comparison
I've also managed to hoard a large list of possible kernel options and optimisations which I need to trawl through
I've also written up a load of notes which I'll post a link to once I'm done.
Next its a case of going through each kernel config option / userspace script / boot command line option / kernel 6.3
I was trying that before but not getting consistent results until turning that video setting on doooh
dtoverlay=vc4-fkms-v3d-pi4
From a before
To an after
I've also managed to get 5.4 working since I've seen that in other threads and wanted to see it's performance by comparison
I've also managed to hoard a large list of possible kernel options and optimisations which I need to trawl through
I've also written up a load of notes which I'll post a link to once I'm done.
Next its a case of going through each kernel config option / userspace script / boot command line option / kernel 6.3
I was trying that before but not getting consistent results until turning that video setting on doooh
Attachments:
Please Log in or Create an account to join the conversation.
16 May 2023 12:15 #271454
by rodw
Replied by rodw on topic LinuxCNC on Rpi4 / Rpi3 / DietPi
Is that set in command.txt?
We've been working on Bookworm and the Pi today to build solid documentation for the Linuxcnc V 2.9 release
We've been working on Bookworm and the Pi today to build solid documentation for the Linuxcnc V 2.9 release
Please Log in or Create an account to join the conversation.
Time to create page: 0.332 seconds