building linuxcnc-dev on ubuntu 16.04 preempt-rt kernel

More
03 Nov 2017 16:52 - 11 Apr 2018 22:09 #101272 by thang
thang created the topic: building linuxcnc-dev on ubuntu 16.04 preempt-rt kernel
This tutorial about how to install linuxcnc-dev on ubuntu 16.04 and preempt-rt kernel. It includes 3 steps:
step1: install preempt-rt kernel
step2: install linuxcnc-dev
step3: fix latency

Step 1: install preempt-rt
+ install some require packages
sudo apt-get install git
sudo apt-get install libssl-dev ( for compile preempt-rt kernel)
sudo apt-get install dpkg-dev
sudo apt-get install libncurses5-dev ( for menuconfig)
+ download kernel and patch
mkdir kernel
cd kernel
wget www.kernel.org/pub/linux/kernel/projects...4.9.47-rt37.patch.gz ( download patch)
(Edit apugh 11/4/18 This link does not work, try looking here for a newer patch: mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/4.9/ )
wget www.kernel.org/pub/linux/kernel/v4.x/linux-4.9.47.tar.gz (download kernel)
tar -xzvf linux-4.9.47.tar.gz
+ patch kernel
cd linux-4.9.47
gzip -cd ../patch-4.9.47-rt37.patch.gz | patch -p1 --verbose
+ config kernel
make menuconfig
+ The menuconfig appear
select Processor type and features-->Preemption Model---> Fully Preemptible Kernel (RT)-->back to top menu
select Power management and ACPI option ---> disable susspend to RAM, Hybernation and CPU frequency scaling --> back to top menu
select Memory Debugging --> Check for stack overflows ( already deselect so dont select this -just check)
save and exit
+ compile kernel
make -j4 ( if you have a cpu quad core)
sudo make modules_install -j4
sudo make install -j4
+ now, check new kernel
cd /boot
ls
you will see somethings like initrd.img-4.9.47-rt37, vmlinuz-4.9.47-rt37, and config-4.9.47-rt37
sudo update-grub
+ reboot ---> select advanced oftion--> select new kernel --> check kernel by : uname -r

Step2: building linuxcnc-dev
+ download linuxcnc-dev
git clone git://github.com/linuxcnc/linuxcnc.git linuxcnc-dev
git checkout 2.7 ( no necessary if u want to use master version)
+ install require packages
Go to system settings --> software & update --> tick Source code
sudo apt-get update
cd linuxcnc-dev/debian
./configure uspace noauto
cd ..
dpkg-checkbuilddeps
+ now install required packages showed after command dpkg-checkbuilddeps then comeback to dir linuxcnc-dev/src
cd src
./autogen.sh ( if this command show error i think u need: sudo apt-get install autoconf )
./configure --with-realtime=uspace
make clear
make -j4
sudo make setuid
+ config RIP
cd ..
source ../scripts/rip-environment

Step 3: reduce latency
+ after you installed linuxcnc-dev, it's time to do first test with latency-test
+ if your latency spike up to 100-300ums or more after some seconds so i think u need fix smi. You can follow this link to fix it by rtai_smi.ko: wiki.linuxcnc.org/cgi-bin/wiki.pl?FixingSMIIssues . If it doesn't work, let try fix it by smictl that is described at the end of page. Here is detail how to fix smi by smictl:
sudo apt-get install git-core
git clone git://git.kiszka.org/smictrl.git && cd smictrl
git clone git://github.com/zultron/smictrl-deb.git debian
sudo apt-get install libpci-dev
sudo dpkg-buildpackage -uc –us
sudo dpkg -i ../smictrl_*.deb
sudo smictrl
sudo smictrl -s 0 ( run this command every after restart pc)
I got this solution from:
www.10k3d.com/2015/06/my-journey-into-wo...nc-machining_22.html
+ Now let try run latency-test again and hope it works
+ If your latency test still high a bit and you are using a CPU multicores then u can reduce latency by disable multicore very simple by:
sudo nano /etc/default/grub
add line GRUB_CMDLINE_LINUX_DEFAULT="isolcpus = 1" if you have duo core ( there are somethings else in " " just dont remove them), isolcpus = 1,2,3 if you have quad core cpu (1,2,3 mean core1,core2 and core3, cant disable core0)
sudo update-grub
reboot
Here is my result:
Attachments:
Last Edit: 11 Apr 2018 22:09 by andypugh.
The following user(s) said Thank You: k-1, tivoi, ozzyrob
More
03 Nov 2017 17:23 #101280 by andypugh
andypugh replied the topic: building linuxcnc-dev on ubuntu 16.04 preempt-rt kernel
Latency is excellent, no need to do any further tuning.
More
03 Nov 2017 21:34 - 03 Nov 2017 22:49 #101293 by ozzyrob
ozzyrob replied the topic: building linuxcnc-dev on ubuntu 16.04 preempt-rt kernel
Great work.....just the link to your simctrl solution is not working in your post.......the link below does work and I'm guessing this is the one you were referring to.

www.10k3d.com/2015/06/my-journey-into-wo...nc-machining_22.html

And the rt patch link

www.kernel.org/pub/linux/kernel/projects...4.9.47-rt37.patch.gz

Once again great job
Last Edit: 03 Nov 2017 22:49 by ozzyrob.
The following user(s) said Thank You: thang
More
04 Nov 2017 01:09 #101300 by thang
thang replied the topic: building linuxcnc-dev on ubuntu 16.04 preempt-rt kernel
thank you, i edited
More
04 Nov 2017 04:51 #101302 by ozzyrob
ozzyrob replied the topic: building linuxcnc-dev on ubuntu 16.04 preempt-rt kernel
Just thinking out aloud...............
rtai_smi.ko and the other rati modules are not built during config --with-realtime=uspace, (and only whilst using rtai) that's right yeah ?

The latest kernel rtai-5.0.1 will support is 4.4.43, correct ?
More
06 Feb 2018 08:07 #105480 by thang
thang replied the topic: building linuxcnc-dev on ubuntu 16.04 preempt-rt kernel
After using smictrl, i have a problem that my pc often cant turn off after use command "smictrl -s 0", does anyone get this problem too and have experience to fix it
More
12 Feb 2018 10:32 - 12 Feb 2018 12:59 #105785 by Bello
Bello replied the topic: building linuxcnc-dev on ubuntu 16.04 preempt-rt kernel
Hi,
I'm trying to follow the steps to install linuxcnc on my ubuntu 16 but the packets you mentioned in the stepsd aren't exists yet.
I'm trying with linux-4.9.76.tar.gz
Last Edit: 12 Feb 2018 12:59 by Bello.
More
09 Apr 2018 22:37 #108682 by dbanks
dbanks replied the topic: building linuxcnc-dev on ubuntu 16.04 preempt-rt kernel
Can anybody validate this tutorial? I've been having a ton of trouble with the other ways I've tried. Has anyone had luck with this one in specific? Thanks in advance.
More
09 Apr 2018 23:34 #108683 by andypugh
andypugh replied the topic: building linuxcnc-dev on ubuntu 16.04 preempt-rt kernel

dbanks wrote: Can anybody validate this tutorial? I've been having a ton of trouble with the other ways I've tried. Has anyone had luck with this one in specific? Thanks in advance.


Is here a particular reason that you don't want to use one of the LiveDVD installs? Or is that one of the ways that you have had trouble with?
More
09 Apr 2018 23:36 #108684 by dbanks
dbanks replied the topic: building linuxcnc-dev on ubuntu 16.04 preempt-rt kernel
I've tried writing to a drive from terminal, from rufus/unetbootin, etc. Once it's been loaded with a bootable iso it disappears from the boot menu. No matter which way I've done it. The one time it didn't disappear, setting it did nothing anyway. Which method are you specifically referring to?
Time to create page: 0.109 seconds
Powered by Kunena Forum