NVIDIA Jetson 内核定制

个人流水账,实操请参考官网

硬件:NVIDIA Jetson Xavier NX

软件:JetPack L4t_32.6.1

步骤:

  1. 获取内核源码(网络原因没下成功,使用2.手动下载)
    $ cd ~/L4t_32.6.1/Linux_for_Tegra
    $ sudo ./source_sync.sh
  2. 手动下载
    下载地址:https://developer.nvidia.com/embedded/downloads
    https://developer.nvidia.com/embedded/linux-tegra-r3261
    解压到Linux_for_Tegra/source/public目录

    $ cd Linux_for_Tegra/source/public
    $ tar –xjf kernel_src.tbz2
  3. 前提条件
    $ sudo apt install build-essential bc
  4. 编译步骤
    设置环境变量

    $ TEGRA_KERNEL_OUT=<outdir>
    $ export CROSS_COMPILE=<cross_prefix>
    $ export LOCALVERSION=-tegra

    生成.config文件

    $ cd <kernel_source>
    $ mkdir -p $TEGRA_KERNEL_OUT
    $ make ARCH=arm64 O=$TEGRA_KERNEL_OUT tegra_defconfig

    编译

    $ make ARCH=arm64 O=$TEGRA_KERNEL_OUT -j8

    替换<release_packagep>/Linux_for_Tegra/kernel/Image

    $TEGRA_KERNEL_OUT/arch/arm64/boot/Image

    替换Linux_for_Tegra/kernel/dtb/

    $TEGRA_KERNEL_OUT/arch/arm64/boot/dts/

    安装内核模块

    $ sudo make ARCH=arm64 O=$TEGRA_KERNEL_OUT modules_install \
    INSTALL_MOD_PATH=<top>/Linux_for_Tegra/rootfs/

    打包内核模块(可选)

    $ sudo make ARCH=arm64 O=$TEGRA_KERNEL_OUT modules_install \
    INSTALL_MOD_PATH=<top>/Linux_for_Tegra/rootfs/
  5. 安装L4T实时内核
    编辑apt源

    $ sudo vi /etc/apt/sources.list.d/nvidia-l4t-apt-source.list

    添加仓库

    deb https://repo.download.nvidia.com/jetson/rt-kernel r32.5 main

    安装实时内核补丁

    $ sudo apt update
    $ sudo apt install nvidia-l4t-rt-kernel nvidia-l4t-rt-kernel-headers

    重启生效。

    卸载

    $ sudo apt remove nvidia-l4t-rt-kernel nvidia-l4t-rt-kernel-headers

    重启生效。

  6. 切换内核
    编辑/boot/extlinux/extlinux.conf,real-time表示实时内核,primary表示原内核

    TIMEOUT 30
    DEFAULT real-time

参考:NVIDIA Jetson Linux Driver Package Software Features : Kernel Customization | NVIDIA Docs