自己做了一块Xavier载板,硬件裁剪了一些功能,导致官方镜像usb无法使用,我使用的是jetpack4.6.1(R32.7.1),所以进行驱动修改,重新编译内核。
在Windows下安装虚拟机Ubuntu18.04
Jetson Linux R32.7.1 Release Page | NVIDIA Developer
下载图中三个文件
mkdir ~/xavier
u@u-vm:~/xavier$ ls
Jetson_Linux_R32.7.1_aarch64.tbz2
Tegra_Linux_Sample-Root-Filesystem_R32.7.1_aarch64.tbz2
public_sources.tbz2
u@u-vm:~/xavierx$ tar xf Tegra186_Linux_R32.4.2_aarch64.tbz2
u@u-vm:~/xavier$ ls
Linux_for_Tegra
Jetson_Linux_R32.7.1_aarch64.tbz2
Tegra_Linux_Sample-Root-Filesystem_R32.7.1_aarch64.tbz2
public_sources.tbz2
u@u-vm:~/xavier$ cd Linux_for_Tegra/rootfs/
u@u-vm:~/xavier/Linux_for_Tegra/rootfs$ sudo tar xpf ../../Tegra_Linux_Sample-Root-Filesystem_R32.7.1_aarch64.tbz2
u@u-vm:~/xavier/Linux_for_Tegra/rootfs$ ls
bin dev etc home lib media mnt opt proc README.txt root run sbin snap srv sys tmp usr var
u@u-vm:~/xavier$ tar -xjf public_sources.tbz2
在你的source路径下,就会多出来一些源码包了:
u@u-vm:~/xavier/Linux_for_Tegra/source$ ls
nv_src_build.sh public
进入kernel源码路径,执行解压
u@u-vm:~/xavier/Linux_for_Tegra/source/public$ tar -xjf kernel_src.tbz2
可以观察到多了kernel源码文件夹,进入路径就可以看到kernel源码结构了:
u@u-vm:~/xavier/Linux_for_Tegra/source/public/kernel/kernel-4.9$ ls
arch build.config.goldfish.x86 drivers Kconfig NVIDIA-REVIEWERS signing_key
block build.config.goldfish.x86_64 firmware kernel README signing_key.x509
build.config.cuttlefish.x86_64 certs fs lib REPORTING-BUGS sound
build.config.goldfish.arm COPYING include MAINTAINERS rt-patches tools
build.config.goldfish.arm64 CREDITS init Makefile samples usr
build.config.goldfish.mips crypto ipc mm scripts verity_dev_keys.x509
build.config.goldfish.mips64 Documentation Kbuild net security virt
u@u-vm:~/xavier/Linux_for_Tegra$ ls
apply_binaries.sh jetson-xavier-slvs-ec.conf p2972-0000-devkit-maxn.conf
bootloader kernel p2972-0000-devkit-slvs-ec.conf
build_l4t_bup.sh l4t_generate_soc_bup.sh p2972-0006-devkit.conf
flash.sh l4t_sign_image.sh p2972-as-galen-8gb.conf
jetson-tx2-4GB.conf nvmassflashgen.sh p3449-0000+p3668-0000-qspi-sd.conf
jetson-tx2-as-4GB.conf nv_tegra p3449-0000+p3668-0001-qspi-emmc.conf
jetson-tx2.conf p2771-0000-0888.conf p3509-0000+p3668-0000-qspi.conf
jetson-tx2i.conf p2771-0000-as-0888.conf p3509-0000+p3668-0000-qspi-sd.conf
jetson-xavier-8gb.conf p2771-0000.conf.common p3509-0000+p3668-0001-qspi-emmc.conf
jetson-xavier-as-8gb.conf p2771-0000-devkit.conf p3668.conf.common
jetson-xavier-as-xavier-nx.conf p2771-0000-dsi-hdmi-dp.conf README_Massflash.txt
jetson-xavier.conf p2771-3489-ucm1.conf rootfs
jetson-xavier-maxn.conf p2771-3489-ucm2.conf source
jetson-xavier-nx-devkit.conf p2822+p2888-0001-as-p3668-0001.conf source_sync.sh
jetson-xavier-nx-devkit-emmc.conf p2972-0000.conf.common tools
jetson-xavier-nx-devkit-qspi.conf p2972-0000-devkit.conf
修改文件home/u/xavier/Linux_for_Tegra/source/public/hardware/nvidia/platform/t19x/galen/kernel-dts/common/tegra194-p2888-0001-p2822-0000-common.dtsi
如上图所示,找到此文件,有两个地方需要修改,如下图
Jetpack 4.6.1 , MTTCAN 配置发生了变化, CAN时钟默认为低功耗设置(没使能PLLAON), CAN工作不正常。
修改文件home/u/xavier/Linux_for_Tegra/source/public/hardware/nvidia/platform/t19x/galen/kernel-dts/common/tegra194-p2888-0001-p2822-0000-common.dtsi
# Linux_for_Tegra/source/public/hardware/nvidia/platform/t19x/galen/kernel-dts/common/tegra194-p2888-0001-p2822-0000-common.dtsi
clocks-init {
compatible = "nvidia,clocks-config";
status = "okay";
disable {
//clocks = <&aon_clks TEGRA194_CLK_PLLAON>,
//<&bpmp_clks TEGRA194_CLK_CAN1>,
//<&bpmp_clks TEGRA194_CLK_CAN2>;
};
};
# Linux_for_Tegra/source/public/hardware/nvidia/platform/t19x/galen/kernel-dts/common/tegra194-p2888-0001-p2822-0000-common.dtsi
mttcan@c310000 {
status = "okay";
pll_source = "pllaon";
clocks = <&bpmp_clks TEGRA194_CLK_CAN1_CORE>,
<&bpmp_clks TEGRA194_CLK_CAN1_HOST>,
<&bpmp_clks TEGRA194_CLK_CAN1>,
<&bpmp_clks TEGRA194_CLK_PLLAON>;
clock-names = "can_core", "can_host","can","pllaon";
};
mttcan@c320000 {
status = "okay";
pll_source = "pllaon";
clocks = <&bpmp_clks TEGRA194_CLK_CAN2_CORE>,
<&bpmp_clks TEGRA194_CLK_CAN2_HOST>,
<&bpmp_clks TEGRA194_CLK_CAN2>,
<&bpmp_clks TEGRA194_CLK_PLLAON>;
clock-names = "can_core", "can_host","can","pllaon";
};
# 可参考 Linux_for_Tegra/source/public/hardware/nvidia/soc/t19x/kernel-dts/tegra194-soc/tegra194-soc-can.dtsi
修改完成,进行下步操作。
在linux操作系统上只使用gcc编译是不够的,还要安装编译程序必须的软件包
sudo apt install build-essential bc
sudo apt-get install qemu-user-static
下载完成后解压到~/xavier/tools 文件夹
u@u-vm:~/xavier/Linux_for_Tegra/source/public/kernel/kernel-4.9$ vim ~/.bashrc
在 “.bashrc” 末尾添加如下配置(路径注意和自己的电脑保持一致),保存退出:
export LOCALVERSION=-tegra
export TEGRA_KERNEL_OUT=/home/u/xavier/Linux_for_Tegra/source/public/kernel/kernel-4.9/okernel
export CROSS_COMPILE=/home/u/xavier/tools/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
刷新环境变量
u@u-vm:~/xavier/Linux_for_Tegra/source/public/kernel/kernel-4.9$ source ~/.bashrc
u@u-vm:~/xavier/Linux_for_Tegra/source/public/kernel/kernel-4.9$ mkdir -p $TEGRA_KERNEL_OUT
u@u-vm:~/xavier/Linux_for_Tegra/source/public/kernel/kernel-4.9$ make ARCH=arm64 O=$TEGRA_KERNEL_OUT tegra_defconfig
出现如下打印信息
make[1]: Entering directory '/home/u/xavier/Linux_for_Tegra/source/public/kernel/kernel-4.9/okernel'
HOSTCC scripts/basic/fixdep
GEN ./Makefile
HOSTCC scripts/kconfig/conf.o
SHIPPED scripts/kconfig/zconf.tab.c
SHIPPED scripts/kconfig/zconf.lex.c
SHIPPED scripts/kconfig/zconf.hash.c
HOSTCC scripts/kconfig/zconf.tab.o
HOSTLD scripts/kconfig/conf
#
# configuration written to .config
#
make[1]: Leaving directory '/home/u/xavier/Linux_for_Tegra/source/public/kernel/kernel-4.9/okernel'u
u@u-vm:~/xavier/Linux_for_Tegra/source/public/kernel/kernel-4.9$ make ARCH=arm64 O=$TEGRA_KERNEL_OUT -j8
备注: 在编译过程中可能会报错:“… is not clean, please run ‘make mrproper’”,则在kernel-4.9路径下执行“make mrproper” 命令即可。
u@u-vm:~/xavier/Linux_for_Tegra/source/public/kernel/kernel-4.9/okernel/arch/arm64/boot$ cp Image /home/u/xavier/Linux_for_Tegra/kernel/Image
u@u-vm:~/xavier/Linux_for_Tegra/source/public/kernel/kernel-4.9/okernel/arch/arm64/boot$ cp dts/* /home/u/xavier/Linux_for_Tegra/kernel/dtb/ -rf
u@u-vm:~/xavier/Linux_for_Tegra/source/public/kernel/kernel-4.9$ sudo make ARCH=arm64 O=$TEGRA_KERNEL_OUT modules_install INSTALL_MOD_PATH=/home/u/xavier/Linux_for_Tegra/rootfs
使用以下命令归档已安装的内核模块,执行完后可以看到多了“kernel_supplements.tbz2”
u@u-vm:~/xavier/Linux_for_Tegra/rootfs$ sudo tar --owner root --group root -cjf kernel_supplements.tbz2 lib/modules
u@u-vm:~/xavier/Linux_for_Tegra/rootfs$ ls
bin dev home lib mnt proc root sbin srv tmp var
boot etc kernel_supplements.tbz2 media opt README.txt run snap sys usr
将 “kernel_supplements.tbz2”替换到“u@u-vm:~/xavier/Linux_for_Tegra/kernel$”路径下
u@u-vm:~/xavier/Linux_for_Tegra/rootfs$ sudo cp kernel_supplements.tbz2 ../kernel/kernel_supplements.tbz2
15、执行 apply_binaries.sh 脚本
u@u-vm:~/xavier/Linux_for_Tegra$ sudo ./apply_binaries.sh
至此编译完成。
不同模组对应烧写文件不同,注意选择正确的文件,我的是Xavier工业版的,如果是常规版选择jetson-agx-xavier-devkit就行了。
Xavier进入刷机模式,使用usb-type-c线连接虚拟机,执行烧写命令
cd ~/xavier/Linux_for_Tegra
sudo ./flash.sh jetson-agx-xavier-industrial mmcblk0p1
感谢大佬
Jetson Xavier 设置 CANFD (Jetpack 4.6, 开启pllaon)_weifengdq的博客-CSDN博客
Jetson Xavier NX 内核编译、源码编译流程_知秋贺的博客-CSDN博客
Jetson Xavier NX 内核编译、源码编译流程_知秋贺的博客-CSDN博客