forked from machinekit/machinekit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.xenomai
220 lines (157 loc) · 7.86 KB
/
README.xenomai
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
217
LinuxCNC on Xenomai
-------------------
This is a development snapshot of LinuxCNC running on Xenomai 3.2.21 with kernel threads; note that eventually also the Xenomai user thread branch will be merged as this is the proposed route by the Xenomai road map.
This is still unpolished and not ready for a merge yet - I'm publishing this at this stage to enable feedback.
Status
------
As of now, this has been tried on x86 only. ARM and others might need some work on header files (some inline assembly) and the rtapi_math_i386.h code needs to be ported to ARM, or replaced by library routines from src/rtapi/xeno_math.
Build requisites:
-----------------
You need:
- a machine running Ubuntu 10.04 lts
- a 3.2.21 kernel with Xenomai 2.6.1 patches applied (see below for packages)
- the Xenomai 2.6.1 userland support package configured with --enable-dlopen-skins
- if you have a multicore CPU: a grub configuration isolates the RT thread core
It is ok to install on a LinuxCNC CD installed machine; the kernel and the Xenomai userland support packages will be 'ships in the night" with respect to the RTAI installation.
You can build under RTAI; to run it, of course you need to boot the 3.2.21 xenomai kernel.
Package download:
-----------------
you will need from http://static.mah.priv.at/public/xenomai-debs/:
libxenomai-dev_2.6.1_i386.deb
libxenomai1_2.6.1_i386.deb
linux-headers-3.2.21-xenomai+_0.1_i386.deb
linux-image-3.2.21-xenomai+_0.1_i386.deb
xenomai-runtime_2.6.1_i386.deb
Install these packages as root with 'dpkg -i *.deb'.
Verify initrd has been created
------------------------------
The lucid dpkg & friends tools are very outdated, and fail to create
an initramfs after the above 'dpkg -i *.deb' step.
Depending on your installation, this might have happened or not.
See if this has happened:
$ ls -l /boot/initrd.img-3.2.21-xenomai+
If this file does not exist, create it manually as root like so
# update-initramfs -c -k 3.2.21-xenomai+
and then, still as root, one must update grub to include the newly
generated initrd.img-3.2.21-xenomai+ file
# update-grub
Now reboot, and Xenomai should come up. Verify this by:
$ dmesg |grep Xenomai
[ 3.250972] I-pipe: head domain Xenomai registered.
[ 3.340753] Xenomai: hal/i386 started.
[ 3.410749] Xenomai: scheduling class idle registered.
[ 3.511046] Xenomai: scheduling class rt registered.
[ 3.664165] Xenomai: real-time nucleus v2.6.1 (Light Years Away) loaded.
[ 3.830540] Xenomai: debug mode enabled.
[ 3.891351] Xenomai: starting native API services.
[ 4.030965] Xenomai: starting POSIX services.
[ 4.240531] Xenomai: starting RTDM services.
Building your own kernels
-------------------------
if you want to build yourself, eg to explore kernel options, try these repos:
Kernel:
-------
http://git.mah.priv.at/gitweb/linuxcnc-kernel.git/shortlog/refs/heads/linuxcnc-3.2.21-xenomai-x86
see files under linuxcnc:
http://git.mah.priv.at/gitweb/linuxcnc-kernel.git/tree/93403bfda8fc98061f8adceac605203ae4424626:/linuxcnc
Building your own Xenomai userland support:
-------------------------------------------
http://git.mah.priv.at/gitweb/xenomai-linuxcnc.git/shortlog/refs/heads/linuxcnc-v2.6.1
again, see files under linuxcnc:
http://git.mah.priv.at/gitweb/xenomai-linuxcnc.git/tree/79a0c12f7f56b9f777a56eb40ef09b9a26c2b96b:/linuxcnc
NB: note the --enable-dlopen-skins switch I added in debian/rules; it is needed or Python import of '_hal.so' fails miserably.
Grub configuration:
-------------------
This branch supports binding the RT thread(s) to an isolated CPU. If you have a multi-core CPU,
like an Atom DW525, add "isolcpus=1" to the GRUB_CMDLINE_LINUX_DEFAULT line in /etc/default/grub,
then run 'update-grub' as root.
Building:
---------
Fetch the xenomai-integration-mah-kernel from git.mah.priv.at like so:
$ git remote add mah git://git.mah.priv.at/emc2-dev.git
$ git fetch mah
$ git branch --track xenomai-integration-mah-kernel mah/xenomai-integration-mah-kernel
$ git checkout xenomai-integration-mah-kernel
$ cd emc2-dev/src
$ sh autogen.sh
$ ./configure --with-threads=xenomai-kernel
If you compile under RTAI, you need to point configure to kernel config file like so:
$ ./configure --with-threads=xenomai-kernel --with-kernel=/boot/config-3.2.21-xenomai+
Then make, and sudo make setuid.
Undefined symbol "pow"
----------------------
Start realtime like so:
$ . emc2-dev/rip-environment
$ realtime start
$ dmesg
If dmesg shows an undefined symbol "pow": I have no idea why, but on precise the following
snippet needs to be activated in src/rtap/xeno_math/libm.c:
#if 1
double __ieee754_pow(double x, double y);
double pow(double x, double y)
{
return __ieee754_pow(x,y);
}
#endif
replace by '#if 0' if you get duplicate symbols during 'realtime start', and 'make' again.
Running:
--------
You need to add the linuxcnc user to the xenomai group; if you dont you get errors like
'Xenomai: binding failed: Cannot allocate memory.' and the like.
$ sudo adduser <your-userid> xenomai
latency-test and various config work as usual.
I tried a mesa 5i25 config which seems to work fine.
Observing status:
-----------------
Xenomai has some /proc support. To see the shared memory segments:
mah@atom$ cat /proc/xenomai/heap
TOTAL USED PAGESZ NAME
8192 80 4096 global sem heap
259584 64 512 main heap
129536 32768 512 stack pool
12288 12288 4096 rt_heap: rtapi_master <--- rtapi_data
262144 262144 4096 rt_heap: shm-1 <--- the HAL segment
8192 0 4096 private sem heap [1492]
8192 0 4096 private sem heap [1495]
While running latency-test:
mah@atom$ cat /proc/xenomai/stat
CPU PID MSW CSW PF STAT %CPU NAME
0 0 0 0 0 00500080 96.4 ROOT/0
1 0 0 39745053 0 00500080 95.6 ROOT/1
1 0 0 39042570 0 00100084 4.1 fast <--- HAL thread name
1 0 0 976053 0 00100084 0.1 slow <--- HAL thread name
0 0 0 40051620 0 00000000 3.5 IRQ2312: [timer]
/proc/rtapi/status has three extra counters for realtime delays:
mah@atom$ cat /proc/rtapi/status
******* RTAPI STATUS ********
RT Modules = 3
UL Modules = 4
Tasks = 2/64
Shared memory = 1/32
FIFOs = 0/32
Semaphores = 0/64
Interrupts = 0
RT task CPU = 1 <---- isolcpus at work: RT thread on CPU #1
Timer status = Running
Timer period = 25000 nSec
Wait errors = 0 <---- how many times the scheduling deadline was missed
Last overrun = 0 <---- last # of overruns reported
Total overruns = 0 <---- total # of overruns reported
Message level = 1
Issues
------
- kernel options have not been explored thoroughly, e.g more specific CPU support.
- latency: on my Atom board I get very good figures EXCEPT a random overrun,esp when networking is involved
On RTAI, the latency-test figures are roughly 11/17 usec
with Xenomai, I have around 9/12usec except for an occasional spike at ca 50usec in the RT thread
- Precise: this builds and runs now. the kernel math module (src/rtap/xeno_math) needs work to export
the math symbols properly under precise; I'd be grateful for hints why this klduge is needed.
- 2.6.38.8 xenomai kernel: build + run is ok, but modules are marked as '[permanent]' and cannot be unloaded; this needs tracking down. This does not happen on the 3.2.21 kernel.
- debian/configure support for building packages is not in place yet.
Misc Notes
----------
- trying the Xenomai examples:
there are a few (userland RT) examples in /usr/share/libxenomai-dev/examples/native .
copy this directory elsewhere, or make as root.
The linker on precise is much more touchy wrt library ordering than the lucid linker,
so I updated the Makefile there to add explicit rules for sigdebug and trivial-periodic.