树莓派编译实时内核

sySeDoC

硬件:树莓派2
镜像:http://downloads.raspberrypi....

树莓派安装必要软件

官方说明为:
https://www.raspberrypi.org/d...

sudo apt install git bc bison flex libssl-dev make

推荐安装:

sudo apt-get install bc
sudo apt-get install libncurses-dev libssl-dev
sudo apt-get install build-essential kmod cpio flex cpio bison

下载内核

https://codeload.github.com/r...

或者

git clone https://github.com/raspberrypi/linux.git -b rpi-4.19.y-rt

创建内核目录,解压内核

cd /usr/src
sudo mkdir linux
cd linux
mv /内核文件存放目录.../rpi-4.19.y-rt.zip .
unzip rpi-4.19.y-rt.zip

配置内核

Raspberry Pi 1,Pi Zero,Pi Zero W 和 Compute Module

cd rpi-4.19.y-rt
KERNEL=kernel7
make bcmrpi_defconfig
make menuconfig

Raspberry Pi 2,Pi 3,Pi 3+和Compute Module 3

cd rpi-4.19.y-rt
KERNEL=kernel7
make bcm2709_defconfig
make menuconfig

Raspberry Pi 4

cd rpi-4.19.y-rt
KERNEL=kernel7l
make bcm2711_defconfig
make menuconfig

找到Preemption Model(Fully Preemptible Kernel (RT)),选择Fully Preemptible Kernel (RT),保存退出。

编译内核

make -j4 zImage modules dtbs

安装模块

sudo make modules_install

将编译好的文件复制到/boot文件夹中

sudo cp arch/arm/boot/dts/*.dtb /boot/
sudo cp arch/arm/boot/dts/overlays/*.dtb* /boot/overlays/
sudo cp arch/arm/boot/dts/overlays/README /boot/overlays/

替换内核

sudo chmod a+x scripts/mkknlimg
sudo scripts/mkknlimg arch/arm/boot/zImage /boot/kernel-my.img
sudo nano /boot/config.txt
添加一行
kernel=kernel-my.img

重启树莓派

sudo reboot

检查是否成功

uname -a

如果出现 PREEMPT RT,表示成功

测试实时性

sudo apt-get install rt-tests
sudo cyclictest -l100000000 -m -Sp99 -i200 -h400 -q
阅读 1.5k
1 声望
0 粉丝
0 条评论
1 声望
0 粉丝
宣传栏