-
Notifications
You must be signed in to change notification settings - Fork 0
/
Xenomai 3.0.5 + ubuntu 16.04.html
216 lines (167 loc) · 18.3 KB
/
Xenomai 3.0.5 + ubuntu 16.04.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<h1>Xenomai 3.0.5 + ubuntu 16.04</h1>
<h2>Reference website : <a href="https://rtt-lwr.readthedocs.io/en/latest/rtpc/xenomai3.html">https://rtt-lwr.readthedocs.io/en/latest/rtpc/xenomai3.html</a></h2>
<h2>Get Linux kernal</h2>
<pre><code class="code-highlighted code-bash">wget https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.9.38.tar.gz
tar xf linux-4.9.38.tar.gz</code></pre>
<h2>Get Xenomai 3.0.5</h2>
<pre><code class="code-highlighted code-bash">wget https://xenomai.org/downloads/xenomai/stable/xenomai-3.0.5.tar.bz2
tar xf xenomai-3.0.5.tar.bz2</code></pre>
<h2>Apply the Xenomai patch</h2>
<p>Assume you are building a x86-64 kernel (64bits).</p>
<pre><code class="code-highlighted code-bash"><span class="syntax-all syntax-constant">cd</span> linux-4.9.38
wget https://xenomai.org/downloads/ipipe/v4.x/x86/ipipe-core-4.9.38-x86-4.patch
../xenomai-3.0.5/scripts/prepare-kernel.sh --arch=x86_64 --ipipe=ipipe-core-4.9.38-x86-4.patch</code></pre>
<h2>Configure the kernal</h2>
<p>Take the actual working config:</p>
<pre><code class="code-highlighted code-bash">yes <span class="syntax-all syntax-string">""</span> <span class="syntax-all syntax-keyword">|</span> make oldconfig</code></pre>
<p>without GUI:</p>
<pre><code class="code-highlighted code-bash">sudo apt install libncurses5-dev
make menuconfig</code></pre>
<p>Some guidelines to configure the linux kernel:</p>
<pre><code class="code-highlighted code-bash">Recommended options:
<span class="syntax-all syntax-keyword">*</span> General setup
--<span class="syntax-all syntax-keyword">></span> Local version - append to kernel release: -xenomai-3.0.5
--<span class="syntax-all syntax-keyword">></span> Timers subsystem
--<span class="syntax-all syntax-keyword">></span> High Resolution Timer Support (Enable)
<span class="syntax-all syntax-keyword">*</span> Xenomai/cobalt
--<span class="syntax-all syntax-keyword">></span> Sizes and static limits
--<span class="syntax-all syntax-keyword">></span> Number of registry slots (512 --<span class="syntax-all syntax-keyword">></span> 4096)
--<span class="syntax-all syntax-keyword">></span> Size of system heap (Kb) (512 --<span class="syntax-all syntax-keyword">></span> 4096)
--<span class="syntax-all syntax-keyword">></span> Size of private heap (Kb) (64 --<span class="syntax-all syntax-keyword">></span> 256)
--<span class="syntax-all syntax-keyword">></span> Size of shared heap (Kb) (64 --<span class="syntax-all syntax-keyword">></span> 256)
--<span class="syntax-all syntax-keyword">></span> Maximum number of POSIX timers per process (128 --<span class="syntax-all syntax-keyword">></span> 512)
--<span class="syntax-all syntax-keyword">></span> Drivers
--<span class="syntax-all syntax-keyword">></span> CAN drivers
--<span class="syntax-all syntax-keyword">></span> RT-Socket-CAN, CAN raw socket interface(Enable)
--<span class="syntax-all syntax-keyword">></span> Enable debug output(Enable)
--<span class="syntax-all syntax-keyword">></span> Vertial CAN bus driver(Enable, modules)
--<span class="syntax-all syntax-keyword">></span> Philips SJA1000 CAN controller(Enable, modules)
--<span class="syntax-all syntax-keyword">></span> Standard ISA controllers(Enable, modules)
--<span class="syntax-all syntax-keyword">></span> Memory mapped controllers(Enable, modules)
--<span class="syntax-all syntax-keyword">></span> PEAK PCI Card(Enable, modules)
--<span class="syntax-all syntax-keyword">></span> IXXAT PCI Card(Enable, modules)
--<span class="syntax-all syntax-keyword">></span> RTnet
--<span class="syntax-all syntax-keyword">></span> RTnet, TCP/IP socket interface (Enable)
--<span class="syntax-all syntax-keyword">></span> Drivers
--<span class="syntax-all syntax-keyword">></span> New intel(R) PRO/1000 PCIe (Enable)
--<span class="syntax-all syntax-keyword">></span> Realtek 8169 (Enable)
--<span class="syntax-all syntax-keyword">></span> Loopback (Enable)
--<span class="syntax-all syntax-keyword">></span> Add-Ons
--<span class="syntax-all syntax-keyword">></span> Real-Time Capturing Support (Enable)
<span class="syntax-all syntax-keyword">*</span> Power management and ACPI options
--<span class="syntax-all syntax-keyword">></span> CPU Frequency scaling
--<span class="syntax-all syntax-keyword">></span> CPU Frequency scaling (Disable)
--<span class="syntax-all syntax-keyword">></span> ACPI (Advanced Configuration and Power Interface) Support
--<span class="syntax-all syntax-keyword">></span> Processor (Disable)
--<span class="syntax-all syntax-keyword">></span> CPU Idle
--<span class="syntax-all syntax-keyword">></span> CPU idle PM support (Disable)
<span class="syntax-all syntax-keyword">*</span> Pocessor <span class="syntax-all syntax-constant">type</span> and features
--<span class="syntax-all syntax-keyword">></span> Enable maximum number of SMP processors and NUMA nodes (Disable)
// Ref <span class="syntax-all syntax-constant">:</span> http://xenomai.org/pipermail/xenomai/2017-September/037718.html
--<span class="syntax-all syntax-keyword">></span> Processor family
--<span class="syntax-all syntax-keyword">></span> Core 2/newer Xeon (<span class="syntax-all syntax-keyword">if</span> <span class="syntax-all syntax-string">"`cat /proc/cpuinfo </span><span class="syntax-all syntax-keyword">|</span><span class="syntax-all syntax-string"> grep family`"</span> returns 6, <span class="syntax-all syntax-constant">set</span> as Generic otherwise)
// Xenomai will issue a warning about CONFIG_MIGRATION, disable those <span class="syntax-all syntax-keyword">in</span> this order
--<span class="syntax-all syntax-keyword">></span> Transparent Hugepage Support (Disable)
--<span class="syntax-all syntax-keyword">></span> Allow <span class="syntax-all syntax-keyword">for</span> <span class="syntax-all syntax-parameter">memory</span> compaction (Disable)
--<span class="syntax-all syntax-keyword">></span> Contiguous Memory Allocation (Disable)
--<span class="syntax-all syntax-keyword">></span> Allow <span class="syntax-all syntax-keyword">for</span> <span class="syntax-all syntax-parameter">memory</span> compaction
--<span class="syntax-all syntax-keyword">></span> Page Migration (Disable)
<span class="syntax-all syntax-keyword">*</span> Device Drivers
--<span class="syntax-all syntax-keyword">></span> Staging drivers
--<span class="syntax-all syntax-keyword">></span> Unisys SPAR driver support
--<span class="syntax-all syntax-keyword">></span> Unisys visorbus driver (Disable)</code></pre>
<h2>Build the real-time kernel</h2>
<pre><code class="code-highlighted code-bash">sudo apt install kernel-package libssl-dev
sudo CONCURRENCY_LEVEL=<span class="syntax-all syntax-string">$(nproc)</span> make-kpkg --rootcmd fakeroot --initrd kernel_image kernel_headers</code></pre>
<pre><code class="code-highlighted code-bash"><span class="syntax-all syntax-constant">cd</span> ..
sudo dpkg -i linux-headers-4.9.38-xenomai-3.0.5_4.9.38-xenomai-3.0.5-10.00.Custom_amd64.deb linux-image-4.9.38-xenomai-3.0.5_4.9.38-xenomai-3.0.5-10.00.Custom_amd64.deb</code></pre>
<h2>Allow non-root users</h2>
<pre><code class="code-highlighted code-bash">sudo addgroup xenomai --gid 1234
sudo addgroup root xenomai
sudo usermod -a -G xenomai <span class="syntax-all syntax-parameter">$USER</span></code></pre>
<h2>Configure GRUB and reboot</h2>
<p>Editing the grub config:</p>
<pre><code class="code-highlighted code-bash">sudo gedit /etc/default/grub</code></pre>
<pre><code class="code-highlighted code-bash">GRUB_DEFAULT=<span class="syntax-all syntax-string">"Advanced options for Ubuntu>Ubuntu, with Linux 4.9.38-xenomai-3.0.5"</span>
<span class="syntax-all syntax-comment">#GRUB_DEFAULT=saved
</span><span class="syntax-all syntax-comment">#GRUB_SAVEDEFAULT=true
</span><span class="syntax-all syntax-comment"># Comment the following lines
</span><span class="syntax-all syntax-comment">#GRUB_HIDDEN_TIMEOUT=0
</span><span class="syntax-all syntax-comment">#GRUB_HIDDEN_TIMEOUT_QUIET=true
</span>GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=<span class="syntax-all syntax-string">`lsb_release -i -s </span><span class="syntax-all syntax-keyword">2></span><span class="syntax-all syntax-string"> /dev/null </span><span class="syntax-all syntax-keyword">||</span><span class="syntax-all syntax-string"> </span><span class="syntax-all syntax-constant">echo</span><span class="syntax-all syntax-string"> Debian`</span>
GRUB_CMDLINE_LINUX_DEFAULT=<span class="syntax-all syntax-string">"quiet splash xenomai.allowed_group=1234"</span>
GRUB_CMDLINE_LINUX=<span class="syntax-all syntax-string">""</span></code></pre>
<p>If you have an Intel HD Graphics integrated GPU (any type) :</p>
<pre><code class="code-highlighted code-bash">GRUB_CMDLINE_LINUX_DEFAULT=<span class="syntax-all syntax-string">"quiet splash i915.enable_rc6=0 i915.enable_dc=0 noapic xenomai.allowed_group=1234"</span>
<span class="syntax-all syntax-comment"># This removes powersavings from the graphics, that creates disturbing interruptions.
</span></code></pre>
<p>If you have an Intel Skylake (2015 processors), you need to add nosmap to fix the latency hang </p>
<pre><code class="code-highlighted code-bash">GRUB_CMDLINE_LINUX_DEFAULT=<span class="syntax-all syntax-string">"quiet splash i915.enable_rc6=0 i915.enable_dc=0 xeno_nucleus.xenomai_gid=1234 nosmap"</span></code></pre>
<p>Update grub and reboot</p>
<pre><code class="code-highlighted code-bash">sudo update-grub
sudo reboot</code></pre>
<h2>Installing Xenomai 3.0.5 User space libraries</h2>
<p>First, make sure that you are running the cobalt kernel :</p>
<pre><code class="code-highlighted code-bash">uname -a
<span class="syntax-all syntax-comment"># Should return Linux waro-rt 4.9.38-xenomai-3.0.5 #2 SMP Wed Sep 20 16:00:12 CEST 2017 x86_64 x86_64 x86_64 GNU/Linux
</span>dmesg <span class="syntax-all syntax-keyword">|</span> grep Xenomai
<span class="syntax-all syntax-comment"># [ 1.417024] [Xenomai] scheduling class idle registered.
</span><span class="syntax-all syntax-comment"># [ 1.417025] [Xenomai] scheduling class rt registered.
</span><span class="syntax-all syntax-comment"># [ 1.417045] [Xenomai] disabling automatic C1E state promotion on Intel processor
</span><span class="syntax-all syntax-comment"># [ 1.417055] [Xenomai] SMI-enabled chipset found, but SMI workaround disabled
</span><span class="syntax-all syntax-comment"># [ 1.417088] I-pipe: head domain Xenomai registered.
</span><span class="syntax-all syntax-comment"># [ 1.417704] [Xenomai] allowing access to group 1234
</span><span class="syntax-all syntax-comment"># [ 1.417726] [Xenomai] Cobalt v3.0.5 (Sisyphus's Boulder) [DEBUG]
</span></code></pre>
<pre><code class="code-highlighted code-bash"><span class="syntax-all syntax-constant">cd</span> xenomai-3.0.5
./configure --with-pic --with-core=cobalt --enable-smp --disable-tls --enable-dlopen-libs --disable-clock-monotonic-raw
make -j<span class="syntax-all syntax-string">`nproc`</span>
sudo make install
<span class="syntax-all syntax-comment"># --disable-clock-monotonic-raw : http://xenomai.org/pipermail/xenomai/2017-September/037695.html
</span></code></pre>
<p>Update your bashrc</p>
<pre><code class="code-highlighted code-bash"><span class="syntax-all syntax-constant">echo</span> <span class="syntax-all syntax-string">'
</span><span class="syntax-all syntax-string">### Xenomai
</span><span class="syntax-all syntax-string">export XENOMAI_ROOT_DIR=/usr/xenomai
</span><span class="syntax-all syntax-string">export XENOMAI_PATH=/usr/xenomai
</span><span class="syntax-all syntax-string">export PATH=$PATH:$XENOMAI_PATH/bin:$XENOMAI_PATH/sbin
</span><span class="syntax-all syntax-string">export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$XENOMAI_PATH/lib/pkgconfig
</span><span class="syntax-all syntax-string">export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$XENOMAI_PATH/lib
</span><span class="syntax-all syntax-string">export OROCOS_TARGET=xenomai
</span><span class="syntax-all syntax-string">'</span> <span class="syntax-all syntax-keyword">>></span> <span class="syntax-all syntax-keyword">~</span>/.xenomai_rc
<span class="syntax-all syntax-constant">echo</span> <span class="syntax-all syntax-string">'source ~/.xenomai_rc'</span> <span class="syntax-all syntax-keyword">>></span> <span class="syntax-all syntax-keyword">~</span>/.bashrc
<span class="syntax-all syntax-constant">source</span> <span class="syntax-all syntax-keyword">~</span>/.bashrc
<span class="syntax-all syntax-constant">cd</span> /etc/ld.so.conf.d/
<span class="syntax-all syntax-constant">echo</span> <span class="syntax-all syntax-string">'
</span><span class="syntax-all syntax-string">### Multiarch support
</span><span class="syntax-all syntax-string">/usr/xenomai/lib
</span><span class="syntax-all syntax-string">'</span> <span class="syntax-all syntax-keyword">>></span> xenomai.conf
sudo ldconfig -v</code></pre>
<h2>Test your installation</h2>
<pre><code class="code-highlighted code-bash"><span class="syntax-all syntax-constant">cd</span> /usr/xenomai/bin
sudo ./latency</code></pre>
<p>This loop will allow you to monitor a xenomai latency. Here’s the output for an i7 4Ghz :</p>
<pre><code class="code-highlighted code-bash">== Sampling period: 100 us
== Test mode: periodic user-mode task
== All results <span class="syntax-all syntax-keyword">in</span> microseconds
warming up...
RTT<span class="syntax-all syntax-keyword">|</span> 00:00:01 (periodic user-mode task, 100 us period, priority 99)
RTH<span class="syntax-all syntax-keyword">|</span>----lat min<span class="syntax-all syntax-keyword">|</span>----lat avg<span class="syntax-all syntax-keyword">|</span>----lat max<span class="syntax-all syntax-keyword">|</span>-overrun<span class="syntax-all syntax-keyword">|</span>---msw<span class="syntax-all syntax-keyword">|</span>---lat best<span class="syntax-all syntax-keyword">|</span>--lat worst
RTD<span class="syntax-all syntax-keyword">|</span> 0.174<span class="syntax-all syntax-keyword">|</span> 0.464<span class="syntax-all syntax-keyword">|</span> 1.780<span class="syntax-all syntax-keyword">|</span> 0<span class="syntax-all syntax-keyword">|</span> 0<span class="syntax-all syntax-keyword">|</span> 0.174<span class="syntax-all syntax-keyword">|</span> 1.780
RTD<span class="syntax-all syntax-keyword">|</span> 0.088<span class="syntax-all syntax-keyword">|</span> 0.464<span class="syntax-all syntax-keyword">|</span> 1.357<span class="syntax-all syntax-keyword">|</span> 0<span class="syntax-all syntax-keyword">|</span> 0<span class="syntax-all syntax-keyword">|</span> 0.088<span class="syntax-all syntax-keyword">|</span> 1.780
RTD<span class="syntax-all syntax-keyword">|</span> 0.336<span class="syntax-all syntax-keyword">|</span> 0.464<span class="syntax-all syntax-keyword">|</span> 1.822<span class="syntax-all syntax-keyword">|</span> 0<span class="syntax-all syntax-keyword">|</span> 0<span class="syntax-all syntax-keyword">|</span> 0.088<span class="syntax-all syntax-keyword">|</span> 1.822
RTD<span class="syntax-all syntax-keyword">|</span> 0.342<span class="syntax-all syntax-keyword">|</span> 0.464<span class="syntax-all syntax-keyword">|</span> 1.360<span class="syntax-all syntax-keyword">|</span> 0<span class="syntax-all syntax-keyword">|</span> 0<span class="syntax-all syntax-keyword">|</span> 0.088<span class="syntax-all syntax-keyword">|</span> 1.822
RTD<span class="syntax-all syntax-keyword">|</span> 0.327<span class="syntax-all syntax-keyword">|</span> 0.462<span class="syntax-all syntax-keyword">|</span> 2.297<span class="syntax-all syntax-keyword">|</span> 0<span class="syntax-all syntax-keyword">|</span> 0<span class="syntax-all syntax-keyword">|</span> 0.088<span class="syntax-all syntax-keyword">|</span> 2.297
RTD<span class="syntax-all syntax-keyword">|</span> 0.347<span class="syntax-all syntax-keyword">|</span> 0.463<span class="syntax-all syntax-keyword">|</span> 1.313<span class="syntax-all syntax-keyword">|</span> 0<span class="syntax-all syntax-keyword">|</span> 0<span class="syntax-all syntax-keyword">|</span> 0.088<span class="syntax-all syntax-keyword">|</span> 2.297
RTD<span class="syntax-all syntax-keyword">|</span> 0.314<span class="syntax-all syntax-keyword">|</span> 0.464<span class="syntax-all syntax-keyword">|</span> 1.465<span class="syntax-all syntax-keyword">|</span> 0<span class="syntax-all syntax-keyword">|</span> 0<span class="syntax-all syntax-keyword">|</span> 0.088<span class="syntax-all syntax-keyword">|</span> 2.297
RTD<span class="syntax-all syntax-keyword">|</span> 0.190<span class="syntax-all syntax-keyword">|</span> 0.464<span class="syntax-all syntax-keyword">|</span> 1.311<span class="syntax-all syntax-keyword">|</span> 0<span class="syntax-all syntax-keyword">|</span> 0<span class="syntax-all syntax-keyword">|</span> 0.088<span class="syntax-all syntax-keyword">|</span> 2.297</code></pre>
<h2>Fix negative latency issues</h2>
<p>You need to be in root sudo -s, then you can set values to the latency calibration variable in nanoseconds:</p>
<pre><code class="code-highlighted code-bash">$ <span class="syntax-all syntax-constant">echo</span> 0 <span class="syntax-all syntax-keyword">></span> /proc/xenomai/latency
<span class="syntax-all syntax-comment"># Now run the latency test
</span>
<span class="syntax-all syntax-comment"># If the minimum latency value is positive,
</span><span class="syntax-all syntax-comment"># then get the lowest value from the latency test (ex: 0.088 us)
</span><span class="syntax-all syntax-comment"># and write it to the calibration file ( here you have to write 88 ns) :
</span>$ <span class="syntax-all syntax-constant">echo</span> my_super_value_in_ns <span class="syntax-all syntax-keyword">></span> /proc/xenomai/latency</code></pre>