1. 配置交叉编译环境
根据自己使用的工具链配置交叉编译环境
mips64el
export PATH=/opt/buildroot-2019.11-glibc-gcc-9.x-mips64el-r2-n64-fpu/output/host/usr/bin:$PATH
loongarch
export PATH=/opt/loongson-gnu-toolchain-8.3.novec-x86_64-loongarch64-linux-gnu-rc1.1/bin:$PATH
2. numa交叉编译
rt-tests依赖numa,numa交叉编译的方法:
git clone https://github.com/numactl/numactl.git
或者直接下载numactl-2.0.16.tar.gz源码包
tar -xf numactl-2.0.16.tar.gz
cd numactl-2.0.16
./autogen.sh
loongarch
./configure --host=mips64el-linux CC=loongarch64-linux-gnu-gcc --prefix=/home/ufo/loongson/tools/install
mips64el
./configure --host=mips64el-linux CC=mips64el-linux-gcc --prefix=/home/ufo/loongson/tools/install
make
make install
编译成功后,在/home/ufo/loongson/tools/install/目录下生成需要的库和头文件。
3. rt-tests交叉编译
在这里下载基准测试程序:
https://git.kernel.org/pub/scm/utils/rt-tests/rt-tests.git
下载测试源码后解压
tar -xf rt-tests-2.5.tar.gz
cd rt-tests-2.5
修改Makefile
CC 字段添加 -static 执行静态编译,如果不进行静态编译则不需要添加。
CPPFLAGS 字段添加 -I/home/ufo/loongson/tools/install/include
LDFLAGS 字段添加 -L/home/ufo/loongson/tools/install/lib
保存修改,然后执行:
loongarch
make CROSS_COMPILE=loongarch64-linux-gnu-
mips64el
make CROSS_COMPILE=mips64el-linux-
编译成功后,在源码目录下生成cyclictest,把cyclictest复制到板卡的根文件系统下,如果是静态编译可以直接运行不需要复制库文件。
4. 测试
./cyclictest -S -p 80 -i 1000 -D 5m -m -s -h 400 -q
测试过程中插入usb设备,或者网络ping包测试,可以看出
Voluntary Kernel Preemption (Desktop)
Preemptible Kernel (Low-Latency Desktop)
Fully Preemptible Kernel (Real-Time) 三种抢占模型
实时性的差异。
比如插入usb设备时,Voluntary Kernel Preemption (Desktop)模式下,最大延时会飙升到几千us。
而Fully Preemptible Kernel (Real-Time) 模式下,最大延时则保持稳定,这也说明该模式下内核的实时性相当强,没有被其他任务影响到实时性。
如果测试软件提示:
WARN: High resolution timers not available
内核需要选择
High Resolution Timer Support
这个选项使能后,实时性有很多改善。