Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

Nvidia Jetson TX2 — build kernel & flash image

繼 上一篇 build 完 u-boot 後,繼續 build kernel :

  1. 下載 sample root fs: Sample Root Filesystem
wget https://developer.nvidia.com/embedded/dlc/r32-3-1_Release_v1.0/t186ref_release_aarch64/Tegra_Linux_Sample-Root-Filesystem_R32.3.1_aarch64.tbz2

將 sample root fs 解壓縮,並執行 apply_binaries.sh 安裝專用的binary

cd Linux_for_Tegra
sudo tar -C rootfs/ -jxpf ../Tegra_Linux_Sample-Root-Filesystem_R32.3.1_aarch64.tbz2
sudo ./apply_binaries.sh

解壓縮 kernel source code

cd source
tar -xf public/kernel_src.tbz2
cd kernel

設定環境變數

JETSON_TX2_KERNEL_SOURCE=$(pwd)
CROSS_COMPILE=/opt/linaro/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
KERNEL_OUT=$JETSON_TX2_KERNEL_SOURCE/build
KERNEL_MODULES_OUT=$JETSON_TX2_KERNEL_SOURCE/modules

開始編譯程序,沒有要修改kernel module 就不用執行 make menuconfig

make -C kernel-4.9/ ARCH=arm64 O=$KERNEL_OUT tegra_defconfig
make -C kernel-4.9/ ARCH=arm64 O=$KERNEL_OUT menuconfig

修改 kernel 版號只是要驗證是否成功將編譯好的kernel上傳到板子裡。

General setup — ->

() Local version — append to kernel release

隨便加個字串

設定完要存檔< Save > 再離開< Exit >

繼續編譯 kernel image, dtb, kernel module

make -C kernel-4.9/ ARCH=arm64 O=$KERNEL_OUT CROSS_COMPILE=${CROSS_COMPILE} -j8 Image
make -C kernel-4.9/ ARCH=arm64 O=$KERNEL_OUT CROSS_COMPILE=${CROSS_COMPILE} -j8 dtbs
make -C kernel-4.9/ ARCH=arm64 O=$KERNEL_OUT CROSS_COMPILE=${CROSS_COMPILE} -j8 modules
make -C kernel-4.9/ ARCH=arm64 O=$KERNEL_OUT modules_install INSTALL_MOD_PATH=$KERNEL_MODULES_OUT

將編譯好的必要檔案 copy 到待會 flash.sh 會用到的路徑

cp build/arch/arm64/boot/Image ../../kernel/cp build/arch/arm64/boot/dts/tegra186-quill-p3310-1000-c03-00-base.dtb ../../kernel/dtb/sudo cp -a modules/lib ../../rootfs/

將 TX2 開發板進入 recovery mode 並執行 flash 命令

cd ../../
sudo ./flash.sh jetson-tx2 mmcblk0p1

在 console 可以看到 Linux多了 -TEST 字樣 等資訊代表成功了

在開發板裡下指令也可以查看

Reference:

Compiling Tegra Source Code | Compiling Jetson TX2 source code L4T 32.1 | Tegra X1 and X2 |…

This wiki page contains instructions to download and build kernel source code for Jetson TX2, several parts of this…

developer.ridgerun.com

https://developer.ridgerun.com/wiki/index.php?title=Compiling_Jetson_source_code_-_Jetpack_3.1#Build_DTC