Xenomai4和EvlProject的关系,在Xenomai 4 kick-off里有写
dovetail作为原先ipipe的继承者,evl作为原先cobalt的继承者.
但是evl还在开发中,听说不稳定.想要稳定的还是得使用传统的xenomai3.2用户库+dovetail+cobalt内核.
--------------------------------
xenomai3.2 + dovetail + cobalt 记录
使用
https://mirrors.bfsu.edu.cn/armbian-releases/nanopi-r4s/archive/
armbian 21.08.1 buster kernel 5.10.60
镜像刷入nanopi-r4s的sd卡
下载xenomai3.2用户库源码
https://source.denx.de/Xenomai/xenomai/-/archive/v3.2.1/xenomai-v3.2.1.tar.bz2
解压到宿主机的/home/user/xenomai-3.2和nanopi-r4s的/home/user/xenomai-3.2上,得保证两份源码的位置一样,因为armbian打包header的时候保持了软连接
按照
https://github.com/armbian/build
下载Armbian的编译环境,运行./compile.sh安装完编译环境后和初次运行后.
添加./userpatches/lib.config文件,添加KERNELBRANCH='tag:v5.10.95-dovetail1'选择要编译的内核版本.
修改config-default.conf文件,添加下面参数使用中国镜像:
MAINLINE_MIRROR="tuna"
UBOOT_MIRROR="gitee"
GITHUB_MIRROR="fastgit"
DOWNLOAD_MIRROR="china"
如果选择了fastgit镜像,且fastgit.org访问失败的情况下,可以修改./lib/configuration.sh文件将fastgit.org修改位fastgit.xyz
选择中国镜像能加快速度,否则有些git仓库可能需要设置代理才能正常下载.
其实使用原生内核也是可以的,不过我这边网速好,就使用了denx.de提供的内核.如果网速不好,就选择tsinghua.edu.cn提供的原生内核,注意选择KERNELBRANCH版本的时候,需要选择Index of /downloads/dovetail 官网上找得到dovetail补丁的版本.
根据选择修改./lib/configuration.sh将官方kernel的git地址修改为dovetail的地址
tuna)
# MAINLINE_KERNEL_SOURCE='https://mirrors.tuna.tsinghua.edu.cn/git/linux-stable.git'
MAINLINE_KERNEL_SOURCE='https://source.denx.de/Xenomai/linux-dovetail.git'
MAINLINE_FIRMWARE_SOURCE='https://mirrors.tuna.tsinghua.edu.cn/git/linux-firmware.git'
使用./compile.sh BOARD=nanopi-r4s BRANCH=current BUILD_MINIMAL=no BUILD_DESKTOP=no KERNEL_ONLY=yes KERNEL_CONFIGURE=yes CREATE_PATCHES=yes AUFS=no
来进行编译,编译的过程中会暂停并
[ warn ] Press <Enter> after you are done [ waiting ]
第一次是编译uboot,直接Enter掉,第二次是编译kernel,这时候需要在另一个终端切换到xenomai用户库目录里,执行prepare_kernel.sh给内核打上cobalt补丁
参考Installing_Xenomai_3 · Wiki · xenomai / xenomai · GitLab
如果是原生内核,需要下载相应的dovetail补丁,然后参考上面的网站说明
如果是我例子里的v5.10.95-dovetail1内核,则可以省去下载和打dovetail补丁的参数
cd /home/user/xenoami-3.2/scripts
sudo ./prepare-kernel.sh --arch=arm64 --linux=/home/user/build/cache/sources/linux-mainline/v5.10.95-dovetail1 --verbose
如果选择了原生内核,则需要手动下载相应的补丁打进去
cd /home/user/xenoami-3.2
bzip2 -d patch-5.10.89-dovetail1.patch.bz2
sudo ./scripts/prepare-kernel.sh --dovetail=patch-5.10.89-dovetail1.patch --arch=arm64 --linux=/home/user/build/cache/sources/linux-mainline/v5.10.89 --verbose
然后会返回
Preparing kernel 5.10.95 in /home/user/build/cache/sources/linux-mainline/v5.10.95-dovetail1...
IRQ pipeline found - bypassing patch.
IRQ pipeline installed.
Links installed.
Build system ready.
显示cobalt已经打进kernel源码里了.
然后回到compile.sh那个终端,按Enter继续然后会出现新的内核选项
出现GCC Plugin选项时最好选择N,否则有可能会编译错误。
然后进入menuconfig,注意把xenomai相关的选项选上.xenomai选项会有一些警告说PAGE_MIRGATION和CPUFREQ相关的东西会影响实时性,不用理他,我关不掉PAGE_MIRGATION
我关掉了虚拟化,睡眠,Sound card support,GCC Plugin相关,cpufreq的默认策略改成performance.
然后Save & Exit继续编译
然后编译出一堆deb文件
[ o.k. ] Kernel build done [ @host ]
[ o.k. ] Target directory [ /home/user/build/output/debs/ ]
[ o.k. ] File name [ linux-image-current-rockchip64_22.02.0-trunk_arm64.deb ]
[ o.k. ] Runtime [ 81 min ]
拷贝到nanopi上安装,如果安装header时出现找不到xenomai的Kconfig文件,注意之前解压的xenomai用户库源码是不是和宿主机上的路径一样.
然后编译xenomai用户库
在nanopi-r4s上操作
cd /home/user/xenomai-3.2
./scripts/bootstrap
./configure --with-core=cobalt --enable-pshared --enable-smp
make
sudo make install
安装完成,去/usr/xenomai/bin下执行xeno-test,会报一些错,没有gdb之类的,不过不影响.
sudo ./latency 正常运行应该就可以了
nanopi-r4s:bin:% sudo ./latency
== 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| 4.084| 4.452| 6.293| 0| 0| 4.084| 6.293
RTD| 4.168| 13.355| 22.918| 0| 0| 4.084| 22.918
RTD| 14.543| 15.334| 24.876| 0| 0| 4.084| 24.876
RTD| 14.544| 15.312| 23.294| 0| 0| 4.084| 24.876
RTD| 14.628| 15.353| 24.627| 0| 0| 4.084| 24.876
RTD| 14.545| 15.336| 23.628| 0| 0| 4.084| 24.876
RTD| 4.046| 14.595| 25.629| 0| 0| 4.046| 25.629
RTD| 4.046| 4.423| 6.754| 0| 0| 4.046| 25.629
RTD| 4.046| 5.444| 17.213| 0| 0| 4.046| 25.629
RTD| 14.838| 15.338| 20.505| 0| 0| 4.046| 25.629
RTD| 14.630| 15.340| 21.255| 0| 0| 4.046| 25.629
RTD| 4.090| 14.788| 27.840| 0| 0| 4.046| 27.840
也可以装上gdb跑个完整测试
--------------------------------------------------------------------------------------------------------
下面是使用evl内核的记录,因为不稳定所以不用看了
使用
https://mirrors.bfsu.edu.cn/armbian-releases/nanopi-r4s/archive/
armbian 21.08.1 buster kernel 5.10.60
镜像刷入nanopi-r4s的sd卡
使用
https://source.denx.de/Xenomai/xenomai4/linux-evl.git
tag:v5.10.76-evl3-rebase
这个版本来编译
按照
https://github.com/armbian/build
下载Armbian的编译环境,运行./compile.sh安装完编译环境后和初次运行后.
添加./userpatches/lib.config文件,添加KERNELBRANCH='tag:v5.10.76-evl3-rebase'选择要编译的evl内核版本.
修改config-default.conf文件,添加 DOWNLOAD_MIRROR="china" 和 MAINLINE_MIRROR="tuna"
选择中国镜像能加快速度,有些git仓库可能需要设置代理才能正常下载.
然后需要修改./lib/configuration.sh将官方kernel的git地址修改为evl的地址,
tuna)
# MAINLINE_KERNEL_SOURCE='https://mirrors.tuna.tsinghua.edu.cn/git/linux-stable.git'
MAINLINE_KERNEL_SOURCE='https://source.denx.de/Xenomai/xenomai4/linux-evl.git'
MAINLINE_FIRMWARE_SOURCE='https://mirrors.tuna.tsinghua.edu.cn/git/linux-firmware.git'
可以使用./compile.sh BOARD=nanopi-r4s BRANCH=current BUILD_MINIMAL=no BUILD_DESKTOP=no KERNEL_ONLY=yes KERNEL_CONFIGURE=yes 来进行编译,编译的过程中会询问新的内核选项和进入menuconfig,注意把evl相关的选项选上.
然后编译出一堆deb文件
[ .... ] Checking out
[ o.k. ] Building firmware package [ armbian-firmware-full_22.02.0-trunk_all ]
[ o.k. ] Kernel build done [ @host ]
[ o.k. ] Target directory [ /home/user/build/output/debs/ ]
[ o.k. ] File name [ linux-image-current-rockchip64_22.02.0-trunk_arm64.deb ]
[ o.k. ] Runtime [ 81 min ]
[ o.k. ] Repeat Build Options [ ./compile.sh BOARD=nanopi-r4s BRANCH=current BUILD_MINIMAL=no BUILD_DESKTOP=no KERNEL_ONLY=yes KERNEL_CONFIGURE=yes ]
拷贝到nanopi上安装就ok了.
然后是libevl的安装.
根据
https://evlproject.org/core/build-steps/
https://source.denx.de/Xenomai/xenomai4/libevl.git
原生编译应该简单,我使用交叉编译.交叉编译器要选好,得选和nanopi上一样的gcc版本.
这里我用的是Armbian编译环境里的gcc-8.3-aarch64
export PATH=$PATH:/home/user/build/cache/toolchain/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/bin
安装meson,版本还要高于0.59,这里省去500字.........
meson setup --cross-file ~/libevl/meson/aarch64-linux-gnu -Dbuildtype=release -Dprefix=/opt/evl -Duapi=/home/user/build/cache/sources/linux-mainline/v5.10.76-evl3-rebase . /home/user/libevl
meson compile
DESTDIR=~/output meson install
cd ~/output/opt/
tar -cf libevl.tar.gz evl
编译打包完成,在nanopi上解压到/opt
把LD库位置设置一下
export LD_LIBRARY_PATH=/opt/evl/lib
cpufreq设置一下
cpufreq-set -g performance
就可以开始运行测试程序了
evl test -k
hectic -s 200
latmus -m
latmus -t
nanopi-r4s:bin:# ./evl test -k
basic-xbuf: OK
clock-timer-periodic: OK
clone-fork-exec: OK
detach-self: OK
duplicate-element: OK
element-visibility: OK
fault: OK
fpu-preload: OK
fpu-stress: OK
heap-torture: OK
mapfd: OK
monitor-deadlock: OK
monitor-event: OK
monitor-flags: OK
monitor-pi: OK
monitor-pi-deadlock: OK
monitor-pp-dynamic: OK
monitor-pp-lower: OK
monitor-pp-nested: OK
monitor-pp-pi: OK
monitor-pp-raise: OK
monitor-pp-tryenter: OK
monitor-pp-weak: OK
monitor-steal: OK
monitor-wait-multiple: OK
observable-hm: OK
observable-inband: OK
observable-master: OK
observable-onchange: OK
observable-oob: OK
observable-race: OK
observable-thread: OK
poll-close: OK
poll-flags: OK
poll-many: OK
poll-multiple: OK
poll-nested: OK
poll-observable-inband: OK
poll-observable-oob: OK
poll-sem: OK
poll-xbuf: OK
proxy-echo: OK
proxy-eventfd: OK
proxy-pipe: OK
proxy-poll: OK
sched-quota-accuracy: OK
sched-tp-accuracy: OK
sem-close-unblock: OK
sem-timedwait: OK
sem-wait: OK
simple-clone: OK
stax-lock: OK
stax-warn: OK
thread-mode-bits: OK
clock-timer-periodic.eshi: OK
detach-self.eshi: OK
heap-torture.eshi: OK
monitor-event.eshi: OK
monitor-flags.eshi: OK
monitor-wait-multiple.eshi: OK
poll-nested.eshi: OK
poll-sem.eshi: OK
proxy-eventfd.eshi: OK
proxy-pipe.eshi: OK
sem-timedwait.eshi: OK
sem-wait.eshi: OK