Last time, I explained the procedure to build the Kernel for introducing Xenomai. This time, I will build Xenomai itself so that I can use the functions of Xenomai on Raspberry Pi. If Xenomai can be introduced into a microcomputer, operations that require real-time performance, such as robot operation, will be possible.
It's a continuation of the last time, so if you haven't seen it yet, I recommend reading this first.
https://qiita.com/TordanHatiman/items/697aaa520914e159de2b
The specifications etc. are not different from the first one, so they are omitted.
--Work content --Operation check
Work in a cross-compile environment where you built the Kernel for Xenomai as before. Xenomai itself is also located in the same working directory. (The previous working directory was kernel_cnst)
Let's work now. First, build the Xenomai libraries. Since it is a cross-compilation environment, pass the path to the cross-compiler. (Same as what I did last time)
linux_user@TN-201709Fxxxx:~$ cd ~/kernel_cnst
linux_user@TN-201709Fxxxx:~$ cd ./Xenomai3.x/
linux_user@TN-201709Fxxxx:~$ export CROSS_COMPILE=../tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-
Next, build Xenomai, but create a directory to store the built files in order to move the built files to RPi.
linux_user@TN-201709Fxxxx:~$ mkdir ~/kernel_cnst/target
linux_user@TN-201709Fxxxx:~$ ./scripts/bootstrap
linux_user@TN-201709Fxxxx:~$ ./configure CFLAGS="-march=armv7-a -mtune=cortex-a8 -mfloat-abi=hard -mfpu=neon -ffast-math" --enable-smp --with-core=cobalt
linux_user@TN-201709Fxxxx:~$ make -j4 install DESTDIR=~/kernel_cnst/target/
If the build passes, the compilation is complete. Compress the files as before and bring them to RPi. (You can also transfer with SSH, but I do not recommend it for security)
linux_user@TN-201709Fxxxx:~$ cd ~/kernel_cnst
linux_user@TN-201709Fxxxx:~$ tar -zcvf xenomai_tools.tgz ./target
Bring it to a suitable place and defrost it -------- Work with RPi from here --------
linux_user@TN-201709Fxxxx:~$ cd ~/workspace(It's a place to unzip, so it can be anywhere)
linux_user@TN-201709Fxxxx:~$ tar -zxvf ./target.tgz
After unzipping, install the file you brought into RPi
linux_user@TN-201709Fxxxx:~$ sudo cp -rd ./target/dev/* /dev/
linux_user@TN-201709Fxxxx:~$ sudo cp -rd ./target/usr/* /usr/
Also at this time, be sure to make a backup of / dev / and / usr / before installation </ font> This completes the introduction of Xenomai itself.
When the Xenomai installation work is completed without any errors, execute the following
linux_user@TN-201709Fxxxx:~$ sudo /usr/xenomai/bin/latency
If it works normally, the latency will be measured as follows.
== Sampling period: 1000 us
== Test mode: periodic user-mode task
== All results in microseconds
warming up...
RTT| 00:00:01 (periodic user-mode task, 1000 us period, priority 99)
RTH|----lat min|----lat avg|----lat max|-overrun|---msw|---lat best|--lat worst
RTD| 12.239| 12.693| 19.427| 0| 0| 12.239| 19.427
RTD| 12.291| 12.720| 16.926| 0| 0| 12.239| 19.427
RTD| 12.290| 12.701| 17.447| 0| 0| 12.239| 19.427
RTD| 12.238| 12.709| 14.634| 0| 0| 12.238| 19.427
Exhibitor: https://lemariva.com/blog/2018/07/raspberry-pi-xenomai-patching-tutorial-for-kernel-4-14-y (I forgot to take this log this time, so I referred to the above.)
In this way, Xenomai has real-time performance that can process even application operations in 1ms units. Application operation check code using Xenomai functions in C language is also published on the net, so you may want to check that.
I actually measured the Latency of Xenomai, but it is true that the Latency works at 1ms ± 0.1ms at the latest for a program that runs at 1ms cycle, and most of them return a response at 1ms, so a Linux-based microcomputer operates in real time. I think it's the best way to get it done. (Measurement data cannot be posted due to various circumstances .....)
Since there are almost no Japanese-based materials for introducing Xenomai, it is quite difficult unless you are accustomed to reading and understanding overseas materials. If you get stuck trying to do the same, feel free to ask. (I will answer as much as possible)
I will write about the patch in another article. I'm sorry for those who want to see it in writing, but please wait until then ...
See you later!
Recommended Posts