< >
Home » ROS2入门教程 » ROS2入门教程-构建实时Linux

ROS2入门教程-构建实时Linux

说明:

  • 介绍如何构建实时Linux

步骤:

  • 在主目录中创建一个目录
mkdir ~/kernel
  • 进入目录
cd ~/kernel
  • 用浏览器访问https://mirrors.edge.kernel.org/pub/linux/kernel/v5.x/并查看版本是否存在

  • 使用wget下载

wget https://mirrors.edge.kernel.org/pub/linux/kernel/v5.x/linux-5.4.78.tar.gz
  • 解压
tar -xzf linux-5.4.78.tar.gz
  • 下载与我们刚刚在http://cdn.kernel.org/pub/linux/kernel/projects/rt/5.4/下载的内核版本匹配的 rt_preempt 补丁
wget http://cdn.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patch-5.4.78-rt44.patch.gz
  • 解压
gunzip patch-5.4.78-rt44.patch.gz
  • 进入linux目录
cd linux-5.4.78/
  • 使用实时补丁修补内核
patch -p1 < ../patch-5.4.78-rt44.patch
  • 复制Ubuntu配置
cp /boot/config-5.4.0-54-generic .config
  • 打开软件和更新。在 Ubuntu 软件菜单中勾选“源代码”框

  • 安装工具

sudo apt-get build-dep linux
sudo apt-get install libncurses-dev flex bison openssl libssl-dev dkms libelf-dev libudev-dev libpci-dev libiberty-dev autoconf fakeroot
  • 启用所有 Ubuntu 配置
yes '' | make oldconfig
  • 在内核中启用rt_preempt
make menuconfig
  • 设置以下内容
# Enable CONFIG_PREEMPT_RT
 -> General Setup
  -> Preemption Model (Fully Preemptible Kernel (Real-Time))
   (X) Fully Preemptible Kernel (Real-Time)

# Enable CONFIG_HIGH_RES_TIMERS
 -> General setup
  -> Timers subsystem
   [*] High Resolution Timer Support

# Enable CONFIG_NO_HZ_FULL
 -> General setup
  -> Timers subsystem
   -> Timer tick handling (Full dynticks system (tickless))
    (X) Full dynticks system (tickless)

# Set CONFIG_HZ_1000 (note: this is no longer in the General Setup menu, go back twice)
 -> Processor type and features
  -> Timer frequency (1000 HZ)
   (X) 1000 HZ

# Set CPU_FREQ_DEFAULT_GOV_PERFORMANCE [=y]
 ->  Power management and ACPI options
  -> CPU Frequency scaling
   -> CPU Frequency scaling (CPU_FREQ [=y])
    -> Default CPUFreq governor (<choice> [=y])
     (X) performance
  • 保存并退出 menuconfig

  • 构建内核

make -j `nproc` deb-pkg
  • 检查 debian 包
ls ../*deb
../linux-headers-5.4.78-rt41_5.4.78-rt44-1_amd64.deb  ../linux-image-5.4.78-rt44-dbg_5.4.78-rt44-1_amd64.deb
../linux-image-5.4.78-rt41_5.4.78-rt44-1_amd64.deb    ../linux-libc-dev_5.4.78-rt44-1_amd64.deb
  • 安装所有内核 debian 包
sudo dpkg -i ../*.deb
  • 重新启动系统并检查新的内核版本
sudo reboot
uname -a
Linux ros2host 5.4.78-rt44 #1 SMP PREEMPT_RT Fri Nov 6 10:37:59 CET 2020 x86_64 xx

纠错,疑问,交流: 请进入讨论区点击加入Q群

获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号


标签: ros2入门教程