1下载内核和补丁
运行uname -a可以看到当前内核版本。
补丁地址: https://www.kernel.org/pub/linux/kernel/projects/rt/ 从中选择一个与当前内核版本接近并且更新的补丁下载(系统启动时会自动选择版本更高的内核)
内核地址: http://www.kernel.org/pub/linux/kernel/ 根据下载的补丁版本下载内核,内核版本要和补丁一致。
下面以linux-4.14.0内核(xilinx)与patch-4.14.0-rt1.patch补丁为例进行说明。
2.打补丁
将解压后的补丁放到解压后的内核文件夹里面
patch -p1 < patch-4.14-rt1.patch
patch -R -p1 < patch-4.14-rt1.patch(卸载补丁)
3.内核配置
1.安装几个必要的套件
sudo apt-get install libncurses5-dev flex bison
2.然后设置内核抢占模式
Preemption Model
Fully Preemptible Kernel(Real-Time
config - Linux/arm 4.14.0 Kernel Configuration> Kernel Features - - Kernel Features. Arrow keys navigate the menu. <Enter> selects submenus ---> (or empty submenus ----). Highlighted letters are hotkeys. Pressing <Y> includes<N> excludes, <M> modularizes features. Press <Esc><Esc> to exit,<?> for Help, </> for Search. Legend: [*] built-in [] ↑(=)- (4) Maximum number of CPUs(2-32)_ * _ Support for hot-pluggable CPUs Support for the Arm Power State Coordination Interface (PSCI) Preemption Model (Fully Preemptible Kernel (RT)) ---> Timer frequency (100 Hz) ---> [ ] Compile the kernel in Thumb-2 mode [*] Runtime patch udiv/sdiv instructions into aeabi {u}idiv().*_ Use the ARM EABI to compile the kernel [] Allow old ABI binaries to run with this kernel (EXPERIMENTA[*] High Memory Support↓(+) Select> < Exit > < Help > Save > < Load > < Hx--1024
.config - Linux/arm 4.14.0 Kernel Configuration→ Kernel Features Preemption Model Use the arrow keys to navigate this window or press the hotkey of the item you wish to select followed by the <SPACE BAR>,Press <?> for additional information about this () No Forced Preemption (Server) () Voluntary Kernel Preemption (Desktop) ( ) Preemptible Kernel (Low-Latency Desktop) Preemptible Kernel (Basic RT)(x) Fully Preemptible Kernel (RT) Select> < Help > Hx--1024
注意:由于Linux的版本不同,位置可能不一样,直接/在menuconfig里面不知道什么原因时搜索Preemption Model时搜不到的,怀疑没有编写进kconfig,所以可以查询到配置页面的kconfig文件,先判断有没有将执行语句编写进去,可以加一句容易搜索的测试用于定位
vim Kconfig.preempt
5 1 config UCAS TEST bool "ucas test" config PREEMPT NONE bool "No Forced Preemption (Server)" 9 help 1日 This is the traditional Linux preemption model, geared towards throughput. It will still provide good latencies most of the time. but there are no auarantees and occasional lonaer delavs are possible. 14 5 Select this option if you are building a kernel for a server or 26 scientific/computation system, or if you want to maximize the raw processing power of the kernel, irrespective of scheduling 18 10 latencies. Hx--1024
3.make mrproper # 删除目录下残留的.o文件和其他从属文件
make menuconfig
回到上一层,进入”Device Drivers”中,去掉“Staging drivers”
Device Drivers Arrow keys navigate the menu. <Enter> selects submenus ---> (or empty submenus----). Highlighted letters are hotkeys. Pressing <Y> includes,<N> excludes,<M> modularizes features. Press <Esc><Esc> to exit,<?> for Help,</> for Search. Legend: [*] built-in [ ] A(a)- [*] virtio drivers ---> Microsoft Hyper-V guest support ---> Xen driver support ---><M> Greybus support ---> i ] staging drivers ---. .*. x86 Platform Specific Device Drivers ---> [1platform support for Goldfish virtual devices -...<M> platform support for chrome hardware (transitional) <Select> < Exit > < Help > < Save > <Load >Hx--1024
4.编译内核重启
root@zynq:~# cd root@zyng:/# ls bin boot root@zyng:/# cd mnt dev etc home.lib media mnt proc run sbin root@zynq:/mnt# ls 1.txt root@zynq:/mnt# uname -r 4.14.0-rtl-xilinx rootdzynq:/mnt# uname -a Linuxzyng4.14.0-rt1-xilinx#1 SMP PREEMPT RT Fri Ju1 2319:40:37 PDT 2021 root@zynq:/mnt# Xterm by subscribing to the professional edition here:http://mobaxterm.mobatek.net
查看内核版本 妥了!