当前位置:   article > 正文

4.9.24+xenomai3.09-ubuntu18.04_xenomai安装 step

xenomai安装 step
  1. 相关网站website:
    wget https://www.kernel.org/pub/linux/kernel/
    wget https://xenomai.org/downloads/xenomai/stable/
    https://catkin-tools.readthedocs.io/en/latest/verbs/catkin_config.html
    https://rtt-lwr.readthedocs.io/en/latest/tutos/controller-tuto.html
  2. 参考教程course :
    https://gitlab.denx.de/Xenomai/xenomai/-/wikis/home
    https://gitlab.denx.de/Xenomai/xenomai/-/wikis/Installing_Xenomai_3
    https://rtt-lwr.readthedocs.io/en/latest/rtpc/xenomai3.html
    https://gitlab.denx.de/Xenomai/xenomai/-/wikis/Configuring_For_X86_Based_Dual_Kernels#user-content-optimized-cpu-and-platform-settings
    https://gitlab.denx.de/Xenomai/xenomai/-/wikis/Troubleshooting#user-content-kernel-issues-specific-to-the-xenomai-2-x-series
    https://gitlab.denx.de/Xenomai/xenomai/-/wikis/Porting_To_Xenomai_POSIX
    https://gitlab.denx.de/Xenomai/xenomai/-/wikis/Building_Applications_For_Xenomai_3
    http://www.cs.ru.nl/J.Hooman/DES/XenomaiExercises/
  3. 依赖包
    sudo apt-get install build-essential libncurses5-dev libelf-dev openssl libssl-dev libtool libltdl-dev git distcc
    sudo apt install xenomai-system-tools rt-tests build-essential libc-dev libc6-dev pkg-config ncurses-dev stress autoconf
    sudo apt-get install libeigen3-dev
    ps: install to /usr/include/eigen3/ and /usr/lib/cmake/eigen3
    ll /usr/lib/cmake/eigen3
    4.电脑配置(以j1900为例)
    iimt@iimt:~$ lscpu
    Architecture: x86_64
    CPU op-mode(s): 32-bit, 64-bit
    Byte Order: Little Endian
    CPU(s): 4
    On-line CPU(s) list: 0-3
    Thread(s) per core: 1
    Core(s) per socket: 4
    Socket(s): 1
    NUMA node(s): 1
    Vendor ID: GenuineIntel
    CPU family: 6
    Model: 55
    Model name: Intel® Celeron® CPU J1900 @ 1.99GHz
    Stepping: 8
    CPU MHz: 1999.200
    BogoMIPS: 3998.40
    Virtualization: VT-x
    L1d cache: 24K
    L1i cache: 32K
    L2 cache: 1024K
    NUMA node0 CPU(s): 0-3
    Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm sse4_1 sse4_2 movbe popcnt tsc_deadline_timer rdrand lahf_lm 3dnowprefetch epb tpr_shadow vnmi flexpriority ept vpid tsc_adjust smep erms dtherm arat
    所以,共有1cpu,2core,all of 4 logic cpu,支持tsc

cat /proc/cpuinfo | grep family
cpu family : 6
cpu family : 6
cpu family : 6
cpu family : 6
cpu family : 6
cpu family : 6
cpu family : 6
cpu family : 6
cpu family : 6
cpu family : 6
cpu family : 6
cpu family : 6
写在前面:
注意编译过程中的报错,以及不兼容状况

step1: Get the linux kernel
wget https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.9.24.tar.gz
tar xf linux-4.9.24.tar.gz

step2:Get Xenomai 3.0.9
wget https://xenomai.org/downloads/xenomai/stable/xenomai-3.0.9.tar.bz2
tar xf xenomai-3.0.9.tar.bz2

step3:Apply the Xenomai patch
cd linux-4.9.24
wget https://xenomai.org/downloads/ipipe/v4.x/x86/ipipe-core-4.9.24-x86-2.patch
…/xenomai-3.0.9/scripts/prepare-kernel.sh --arch=x86_64 --ipipe=ipipe-core-4.9.24-x86-2.patch

step4:Configure the kernel
cp kernel4.config linux-4.9.24#kernel4为自己在make menuconfig配置后保存而成,也可以不load,直接配置
Take the actual working config :

1 yes “” | make oldconfig
sudo apt install libncurses5-dev
make menuconfig
2 important!!!
load kernel4.config,add xenomai coalbalt config:
Xenomai/cobalt–>Drivers–>Real-time IPC drivers -->RTIPC protocol family(Enable)

Recommended options:

  • General setup
    –> Local version
  • append to kernel release: -xenomai-3.0.9
    –> Timers subsystem
    –> High Resolution Timer Support (Enable)
  • Xenomai/cobalt
    –> Sizes and static limits
    –> Number of registry slots (512 --> 4096)
    –> Size of system heap (Kb) (512 --> 4096)
    –> Size of private heap (Kb) (64 --> 256)
    –> Size of shared heap (Kb) (64 --> 256)
    –> Maximum number of POSIX timers per process (128 --> 512)
    –> Drivers
    –> RTnet
    –> RTnet, TCP/IP socket interface (Enable)
    –> Drivers
    –> New intel® PRO/1000 PCIe (Enable)
    –> Realtek 8169 (Enable)
    –> Loopback (Enable)
    –> Add-Ons
    –> Real-Time Capturing Support (Enable)
  • Power management and ACPI options
    –> CPU Frequency scaling
    –> CPU Frequency scaling (Disable)
    –> ACPI (Advanced Configuration and Power Interface) Support
    –> Processor (Disable)
    –> CPU Idle
    –> CPU idle PM support (Disable)
  • Pocessor type and features
    –> Enable maximum number of SMP processors and NUMA nodes (Disable)
    // Ref : http://xenomai.org/pipermail/xenomai/2017-September/037718.html
    –> Processor family
    –> Core 2/newer Xeon (if “cat /proc/cpuinfo | grep family” returns 6, set as Generic otherwise)
    // Xenomai will issue a warning about CONFIG_MIGRATION, disable those in this order
    –> Transparent Hugepage Support (Disable)
    –> Allow for memory compaction (Disable)
    –> Contiguous Memory Allocation (Disable)
    –> Allow for memory compaction
    –> Page Migration (Disable)
  • Device Drivers
    –> Staging drivers
    –> Unisys SPAR driver support
    –> Unisys visorbus driver (Disable)
    step5:Build the Real-Time kernel
    sudo apt install kernel-package
    CONCURRENCY_LEVEL= ( n p r o c ) m a k e − k p k g − − r o o t c m d f a k e r o o t − − i n i t r d k e r n e l i m a g e k e r n e l h e a d e r s s t e p 6 : C o m p i l e f a s t e r w i t h d i s t c c , 如 果 有 的 话 , 没 有 就 跳 过 这 一 步 M A K E F L A G S = " C C = / u s r / l i b / d i s t c c / g c c − 4.8 " m a k e − k p k g − j (nproc) make-kpkg --rootcmd fakeroot --initrd kernel_image kernel_headers step6:Compile faster with distcc,如果有的话,没有就跳过这一步 MAKEFLAGS="CC=/usr/lib/distcc/gcc-4.8" make-kpkg -j (nproc)makekpkgrootcmdfakerootinitrdkernelimagekernelheadersstep6:CompilefasterwithdistccMAKEFLAGS="CC=/usr/lib/distcc/gcc4.8"makekpkgj(distcc -j) --rootcmd fakeroot --initrd kernel_image kernel_headers
    step7:安装
    cd …
    sudo dpkg -i linux-headers-4.9.24-xenomai-3.0.9_4.9.24-xenomai-3.0.9-10.00.Custom_amd64.deb linux-image-4.9.24-xenomai-3.0.9_4.9.24-xenomai-3.0.9-10.00.Custom_amd64.deb

ps:
W: Possible missing firmware /lib/firmware/i915/kbl_guc_ver9_14.bin for module i915
W: Possible missing firmware /lib/firmware/i915/bxt_guc_ver8_7.bin for module i915

get into
https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/i915
download kbl_guc_ver9_14 and bxt_guc_ver8_7 ,put them into /lib/firmware/i915
sudo cp /home/iimt/RTlinux/bxt_guc_ver8_7.bin /lib/firmware/i915/
sudo cp /home/iimt/RTlinux/kbl_guc_ver9_14.bin /lib/firmware/i915/

step8:Allow non-root users
sudo addgroup xenomai --gid 1234
sudo addgroup root xenomai
sudo usermod -a -G xenomai $USER
step9:
Configure GRUB and reboot
sudo gedit /etc/default/grub
replace


GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=lsb_release -i -s 2> /dev/null || echo Debian
GRUB_CMDLINE_LINUX_DEFAULT=“quiet splash”
GRUB_CMDLINE_LINUX=""


to
GRUB_DEFAULT=“Advanced options for GNU/Linux>GNU/Linux, with Linux 4.9.24-xenomai-3.0.9”(注意,这里与grub界面一致)
#GRUB_DEFAULT=saved
#GRUB_SAVEDEFAULT=true
#Comment the following lines
#GRUB_HIDDEN_TIMEOUT=0
#GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=5
GRUB_CMDLINE_LINUX_DEFAULT=“quiet splash xenomai.allowed_group=1234”
GRUB_CMDLINE_LINUX=""

ps:
grep menuentry /boot/grub/grub.cfg
前缀带有menuentry都是GRUB_DEFAULT可以设置的启动项,
step10:
If you have an Intel HD Graphics integrated GPU (any type) :

GRUB_CMDLINE_LINUX_DEFAULT=“quiet splash i915.enable_rc6=0 i915.enable_dc=0 noapic xenomai.allowed_group=1234”
This removes powersavings from the graphics, that creates disturbing interruptions.

step11:
Update GRUB and reboot

sudo update-grub

ps:
iimt@iimt:~/RTlinux$ sudo update-grub
/usr/sbin/grub-mkconfig: 9: /etc/default/grub: Comment: not found
the file format is discrrect
sudo reboot

ps:
if you are ubuntu and windows double system,maybe erro
如果出现无法使用sudo update-grub,比如:/usr/sbin/grub-mkconfig 1 /etc/default/grub i# not found
解决方法:
sudo cp /usr/share/grub/default/grub /etc/default/grub
step12:
Installing Xenomai 3.0.5 User space libraries
enable xenomai test file
iimt@iimt:~$ sudo dpkg-reconfigure bash
1 First, make sure that you are running the cobalt kernel :
uname -a
Linux iimt 4.9.24-xenomai-3.0.5 #1 SMP Sun Apr 19 16:04:42 CST 2020 x86_64 x86_64 x86_64 GNU/Linux
iimt@iimt:~$ dmesg | grep Xenomai
[ 2.084619] [Xenomai] scheduling class idle registered.
[ 2.084620] [Xenomai] scheduling class rt registered.
[ 2.084647] [Xenomai] SMI-enabled chipset found, but SMI workaround disabled
[ 2.084691] I-pipe: head domain Xenomai registered.
[ 2.085941] [Xenomai] allowing access to group 1234
[ 2.086021] [Xenomai] Cobalt v3.0.9
2
cd xenomai-3.0.9
./configure --with-pic --with-core=cobalt --enable-smp --disable-tls --enable-dlopen-libs --disable-clock-monotonic-raw
make -jnproc
sudo make install
–disable-clock-monotonic-raw : http://xenomai.org/pipermail/xenomai/2017-September/037695.html

step13:防止gazebo编译问题的修复,适用于xenomai3.0.5
git clone https://git.xenomai.org/xenomai-3.git
iimt@iimt:~$ cd xenomai-3
root@iimt:/home/iimt/xenomai-3# ./scripts/bootstrap
root@iimt:/home/iimt/xenomai-3#./configure --with-pic --with-core=cobalt --enable-smp --disable-tls --enable-dlopen-libs
root@iimt:/home/iimt/xenomai-3#make -jnproc
root@iimt:/home/iimt/xenomai-3#sudo make install
step14:更新bash
echo ’

Xenomai

export XENOMAI_ROOT_DIR=/usr/xenomai
export XENOMAI_PATH=/usr/xenomai
export PATH= P A T H : PATH: PATH:XENOMAI_PATH/bin: X E N O M A I P A T H / s b i n e x p o r t P K G C O N F I G P A T H = XENOMAI_PATH/sbin export PKG_CONFIG_PATH= XENOMAIPATH/sbinexportPKGCONFIGPATH=PKG_CONFIG_PATH: X E N O M A I P A T H / l i b / p k g c o n f i g e x p o r t L D L I B R A R Y P A T H = XENOMAI_PATH/lib/pkgconfig export LD_LIBRARY_PATH= XENOMAIPATH/lib/pkgconfigexportLDLIBRARYPATH=LD_LIBRARY_PATH:$XENOMAI_PATH/lib
export OROCOS_TARGET=xenomai
’ >> ~/.xenomai_rc
echo ‘source ~/.xenomai_rc’ >> ~/.bashrc
source ~/.bashrc
step15:测试延时
进入下面的路径
root@iimt:cd /usr/xenomai/bin
root@iimt:/usr/xenomai/bin# ./latency
程序返回
== Sampling period: 100 us
== Test mode: periodic user-mode task
== All results in microseconds
warming up…
RTT| 00:00:01 (periodic user-mode task, 100 us period, priority 99)
RTH|----lat min|----lat avg|----lat max|-overrun|—msw|—lat best|–lat worst
RTD| 0.587| 1.288| 3.972| 0| 0| 0.587| 3.972
RTD| 0.070| 1.235| 4.716| 0| 0| 0.070| 4.716
RTD| 0.766| 1.304| 4.332| 0| 0| 0.070| 4.716
RTD| 0.513| 1.262| 3.682| 0| 0| 0.070| 4.716
RTD| 0.681| 1.193| 4.090| 0| 0| 0.070| 4.716
RTD| 0.308| 1.293| 5.854| 0| 0| 0.070| 5.854
RTD| 0.571| 1.286| 3.885| 0| 0| 0.070| 5.854
RTD| 0.655| 1.287| 4.149| 0| 0| 0.070| 5.854
RTD| 0.319| 1.309| 167.149| 1| 0| 0.070| 167.149
RTD| 0.678| 1.294| 4.759| 1| 0| 0.070| 167.149
RTD| 0.545| 1.420| 7.076| 1| 0| 0.070| 167.149
RTD| 0.329| 1.700| 8.384| 1| 0| 0.070| 167.149
RTD| 0.592| 1.673| 14.650| 1| 0| 0.070| 167.149
RTD| 0.676| 1.424| 9.247| 1| 0| 0.070| 167.149
RTD| 0.615| 1.541| 6.126| 1| 0| 0.070| 167.149
RTD| 0.687| 1.427| 7.313| 1| 0| 0.070| 167.149
RTD| 0.542| 1.459| 7.325| 1| 0| 0.070| 167.149
RTD| 0.361| 1.534| 13.339| 1| 0| 0.070| 167.149
RTD| 0.277| 1.879| 27.216| 1| 0| 0.070| 167.149
RTD| 0.372| 1.749| 10.360| 1| 0| 0.070| 167.149
RTD| 0.636| 1.360| 8.031| 1| 0| 0.070| 167.149
RTT| 00:00:22 (periodic user-mode task, 100 us period, priority 99)
RTH|----lat min|----lat avg|----lat max|-overrun|—msw|—lat best|–lat worst
RTD| 0.587| 1.454| 88.391| 1| 0| 0.070| 167.149
RTD| 0.298| 1.436| 8.258| 1| 0| 0.070| 167.149
RTD| 0.670| 1.405| 11.138| 1| 0| 0.070| 167.149
RTD| 0.417| 1.448| 5.063| 1| 0| 0.070| 167.149
RTD| 0.201| 1.497| 8.388| 1| 0| 0.070| 167.149
RTD| 0.273| 1.460| 7.163| 1| 0| 0.070| 167.149
RTD| 0.224| 1.544| 7.259| 1| 0| 0.070| 167.149
RTD| 0.199| 1.586| 8.507| 1| 0| 0.070| 167.149
RTD| 0.523| 1.382| 8.158| 1| 0| 0.070| 167.149
RTD| 0.354| 1.312| 8.098| 1| 0| 0.070| 167.149
RTD| 0.642| 1.324| 7.136| 1| 0| 0.070| 167.149
RTD| 0.365| 1.324| 9.153| 1| 0| 0.070| 167.149
RTD| 0.521| 1.368| 17.231| 1| 0| 0.070| 167.149
RTD| 0.496| 1.370| 7.195| 1| 0| 0.070| 167.149
RTD| 0.351| 1.571| 30.495| 1| 0| 0.070| 167.149
RTD| 0.363| 1.641| 47.734| 1| 0| 0.070| 167.149
RTD| 0.279| 1.464| 9.942| 1| 0| 0.070| 167.149
RTD| 0.614| 1.660| 8.249| 1| 0| 0.070| 167.149
RTD| 0.385| 1.565| 8.296| 1| 0| 0.070| 167.149
RTD| 0.132| 1.317| 15.283| 1| 0| 0.070| 167.149
RTD| 0.264| 1.297| 7.719| 1| 0| 0.070| 167.149
RTT| 00:00:43 (periodic user-mode task, 100 us period, priority 99)
RTH|----lat min|----lat avg|----lat max|-overrun|—msw|—lat best|–lat worst
RTD| 0.095| 1.372| 6.350| 1| 0| 0.070| 167.149
RTD| 0.203| 1.416| 140.959| 2| 0| 0.070| 167.149
RTD| 0.191| 1.493| 11.571| 2| 0| 0.070| 167.149
RTD| 0.274| 1.469| 11.582| 2| 0| 0.070| 167.149
RTD| 0.706| 1.340| 8.041| 2| 0| 0.070| 167.149
RTD| 0.369| 1.393| 8.844| 2| 0| 0.070| 167.149
RTD| 0.692| 1.497| 10.873| 2| 0| 0.070| 167.149
RTD| 0.560| 1.503| 8.843| 2| 0| 0.070| 167.149
RTD| 0.919| 1.446| 8.542| 2| 0| 0.070| 167.149
RTD| 0.763| 1.403| 121.735| 3| 0| 0.070| 167.149
RTD| 0.666| 1.615| 8.049| 3| 0| 0.070| 167.149
RTD| 0.618| 1.363| 117.100| 4| 0| 0.070| 167.149
RTD| 0.377| 1.541| 7.279| 4| 0| 0.070| 167.149
RTD| 0.665| 1.362| 33.822| 4| 0| 0.070| 167.149
RTD| 0.592| 1.502| 4.829| 4| 0| 0.070| 167.149
RTD| 0.639| 1.484| 68.959| 4| 0| 0.070| 167.149
RTD| 0.315| 1.754| 6.209| 4| 0| 0.070| 167.149
RTD| 0.410| 1.803| 82.379| 4| 0| 0.070| 167.149
RTD| 0.194| 1.529| 5.824| 4| 0| 0.070| 167.149
RTD| 0.265| 1.509| 5.583| 4| 0| 0.070| 167.149
RTD| 0.264| 1.560| 10.817| 4| 0| 0.070| 167.149
RTT| 00:01:04 (periodic user-mode task, 100 us period, priority 99)
可以看到平均延时时间1.5us左右
step16:修复负延时问题
$ echo 0 > /proc/xenomai/latency
Now run the latency test
If the minimum latency value is positive, then get the lowest value from the latency test (ex: 0.088 us)
and write it to the calibration file ( here you have to write 88 ns) :
$ echo my_super_value_in_ns > /proc/xenomai/latency

例如:
RTS| -0.042| 1.166| 135.696| 1| 0| 00:00:41/00:00:41
root@iimt:/usr/xenomai/bin# echo 42 >/proc/xenomai/latency
dell textbook

在这里插入图片描述在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

orocos and rtt_ros_integration

OROCOS RTT on Xenomai

Orocos RTT is fully compatible with Xenomai, but it needs to be built from source.

The only difference in the build process is the need to set export OROCOS_TARGET=xenomai before compiling.
Orocos Toolchain 2.9 on Xenomai

Compile for Xenomai

export OROCOS_TARGET=xenomai

mkdir -p ~/isir/orocos-2.9_ws/src
cd ~/isir/orocos-2.9_ws/src

Get all the packages

wstool init
wstool merge https://raw.githubusercontent.com/kuka-isir/rtt_lwr/rtt_lwr-2.0/lwr_utils/config/orocos_toolchain-2.9.rosinstall
wstool update -j2

Get the latest updates (OPTIONAL)

cd orocos_toolchain
git submodule foreach git checkout toolchain-2.9
git submodule foreach git pull

cd ~/isir/orocos-2.9_ws/

Install dependencies

source /opt/ros/kinetic/setup.bash
rosdep install --from-paths ~/isir/orocos-2.9_ws/src --ignore-src --rosdistro kinetic -y -r

Configure the build in Release (recommended), and enable extra transport methods (optional)

catkin config --init --install --extend /opt/ros/kinetic/ --cmake-args -DCMAKE_BUILD_TYPE=Release -DENABLE_MQ=ON -DENABLE_CORBA=ON -DCORBA_IMPLEMENTATION=OMNIORB

Build

catkin build

RTT ROS Integration 2.9 on Xenomai

Compile for Xenomai

export OROCOS_TARGET=xenomai

mkdir -p ~/isir/rtt_ros-2.9_ws/src
cd ~/isir/rtt_ros-2.9_ws/src

Get all the packages

wstool init
wstool merge https://github.com/kuka-isir/rtt_lwr/raw/rtt_lwr-2.0/lwr_utils/config/rtt_ros_integration-2.9.rosinstall
wstool update -j2

cd ~/isir/rtt_ros-2.9_ws/

Install dependencies

source ~/isir/orocos-2.9_ws/install/setup.bash
rosdep install --from-paths ~/isir/rtt_ros-2.9_ws/src --ignore-src --rosdistro kinetic -y -r

Configure the build in Release (recommended), and enable extra transport methods (optional)

catkin config --init --install --extend ~/isir/orocos-2.9_ws/install --cmake-args -DCMAKE_BUILD_TYPE=Release -DENABLE_MQ=ON -DENABLE_CORBA=ON -DCORBA_IMPLEMENTATION=OMNIORB

Build (this can take a while)

catkin build

Tip

Always build for Xenomai on the Xenomai computer : echo ‘export OROCOS_TARGET=xenomai’ >> ~/.bashrc

Note

Libraries built with xenomai will have -xenomai.so appended to the library name (ex libmycontroller-xenomai.so)
在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/694592
推荐阅读
相关标签
  

闽ICP备14008679号