notice:以下内容仅适用于jetson nano A02 -- Linux R32.7.1
STEP1:kernel源码下载
Jetson Linux R32.7.1 Release Page | NVIDIA Developer
STEP2:解压文件
tar -xf public_sources.tbz2 #解压安装包
cd Linux_for_Tegra/source/public/
tar -xjf kernel_src.tbz2 #解压kernel 源码
最后解压后在Linux_for_Tegra/source/public/目录下出现两个文件夹
STEP3:创建编译脚本
#!/bin/bash
TEGRA_KERNEL_OUT=build_kernel_out #编译输出目录
mkdir -p $TEGRA_KERNEL_OUT
#导出环境变量
export CROSS_COMPILE=/usr/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
#配置defconfig
make ARCH=arm64 O=$TEGRA_KERNEL_OUT tegra_defconfig
#进行图像化配置
make ARCH=arm64 O=$TEGRA_KERNEL_OUT menuconfig
#开始编译
make ARCH=arm64 O=$TEGRA_KERNEL_OUT -j4
在Linux_for_Tegra/source/public/kernel/kernel-4.9/目录下运行编译脚本,首先会进入内核图像化配置界面,配置结束后按ESC两次退出后自动开始编译,第一次编译时间较长,具体时间依赖编译主机性能。
报错处理
1、执行
make ARCH=arm64 O=$TEGRA_KERNEL_OUT menuconfig
进行图形化配置时报缺少<command-line>:0:12: fatal error: curses.h: No such file or directory
解决方法:安装 libncurses5-dev
sudo apt install libncurses5-dev
2、执行
make ARCH=arm64 O=$TEGRA_KERNEL_OUT -j4
时报错.. is not clean, please run 'make mrproper'
解决方法,删除未完成编译的输出文件夹build_kernel_out
sudo rm -rf build_kernel_out
STEP4:获取成果
Image文件所在目录: `$TEGRA_KERNEL_OUT/arch/arm64/boot/Image`
dts文件所在目录:`$TEGRA_KERNEL_OUT/arch/arm64/boot/dts`