-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathbuild_all.sh
More file actions
executable file
·137 lines (123 loc) · 5.18 KB
/
Copy pathbuild_all.sh
File metadata and controls
executable file
·137 lines (123 loc) · 5.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/bash
set -e
if [[ $# < 1 || "$1" == "-h" ]]; then
echo "build_all.sh [--clean] [--dev-dbg] JetPack_version [JetPack_Linux_source]"
echo "build_all.sh -h"
exit 1
fi
CLEAN=0
DEVDBG=0
# Parse optional flags
while [[ "$1" == --* ]]; do
case "$1" in
--clean)
CLEAN=1
shift
;;
--dev-dbg)
DEVDBG=1
shift
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done
export DEVDIR=$(cd `dirname $0` && pwd)
NPROC=$(nproc)
. $DEVDIR/scripts/setup-common "$1"
SRCS="$DEVDIR/sources_$1"
if [[ -n "$2" ]]; then
SRCS=$(realpath $2)
fi
if [[ $(uname -m) == aarch64 ]]; then
echo
echo Native build
echo
else
if [[ "$JETPACK_VERSION" == "6.x" ]]; then
export CROSS_COMPILE=$DEVDIR/l4t-gcc/$JETPACK_VERSION/bin/aarch64-buildroot-linux-gnu-
elif [[ "$JETPACK_VERSION" == "5.x" ]]; then
export CROSS_COMPILE=$DEVDIR/l4t-gcc/$JETPACK_VERSION/bin/aarch64-buildroot-linux-gnu-
elif [[ "$JETPACK_VERSION" == "4.6.1" ]]; then
export CROSS_COMPILE=$DEVDIR/l4t-gcc/$JETPACK_VERSION/bin/aarch64-linux-gnu-
fi
fi
export LOCALVERSION=-tegra
export TEGRA_KERNEL_OUT="$DEVDIR/images/$1"
# Clean if requested
if [[ $CLEAN == 1 ]]; then
echo "Cleaning build artifacts for $1..."
if [[ -z "$TEGRA_KERNEL_OUT" ]]; then
echo "Error: TEGRA_KERNEL_OUT is not set"
exit 1
fi
rm -rf "$TEGRA_KERNEL_OUT"
rm -rf "$SRCS/out"
fi
mkdir -p "$TEGRA_KERNEL_OUT"
export KERNEL_MODULES_OUT=$TEGRA_KERNEL_OUT/modules
# Check if BUILD_NUMBER is set as it will add a postfix to the kernel name "vermagic" (normally it happens on CI who have BUILD_NUMBER defined)
[[ -n "${BUILD_NUMBER}" ]] && echo "Warning! You have BUILD_NUMBER set to ${BUILD_NUMBER}, This will affect your vermagic"
# Build jp6 out-of-tree modules
# following:
# https://docs.nvidia.com/jetson/archives/r36.2/DeveloperGuide/SD/Kernel/KernelCustomization.html#building-the-jetson-linux-kernel
if [[ "$JETPACK_VERSION" == "6.x" ]]; then
cd $SRCS
export KERNEL_HEADERS=$SRCS/kernel/kernel-jammy-src
ln -sf "$TEGRA_KERNEL_OUT" "$SRCS/out"
if [[ "$DEVDBG" == "1" ]]; then
cd $KERNEL_HEADERS
# Generate .config file from default defconfig
make ARCH=arm64 defconfig
# Update the CONFIG_DYNAMIC_DEBUG and CONFIG_DEBUG_CORE flags in .config file
scripts/config --enable DYNAMIC_DEBUG
scripts/config --enable DYNAMIC_DEBUG_CORE
# Convert the .config file into defconfig
make ARCH=arm64 savedefconfig
# Save the new generated file as custom_defconfig
cp defconfig ./arch/arm64/configs/custom_defconfig
# Remove unwanted
rm defconfig .config
make ARCH=arm64 mrproper
cd $SRCS
# Building the Image with custom_defconfig
make ARCH=arm64 KERNEL_DEF_CONFIG=custom_defconfig -C kernel
else
# Building the Image with default defconfig
make ARCH=arm64 -C kernel
fi
make ARCH=arm64 modules
make ARCH=arm64 dtbs
mkdir -p "$TEGRA_KERNEL_OUT"/rootfs/boot/dtb
cp $SRCS/nvidia-oot/device-tree/platform/generic-dts/dtbs/tegra234-p3737-0000+p3701-0000-nv.dtb $TEGRA_KERNEL_OUT/rootfs/boot/dtb/
cp $SRCS/nvidia-oot/device-tree/platform/generic-dts/dtbs/tegra234-p3737-0000+p3701-0005-nv.dtb $TEGRA_KERNEL_OUT/rootfs/boot/dtb/
cp $SRCS/nvidia-oot/device-tree/platform/generic-dts/dtbs/tegra234-camera-d4xx-overlay*.dtbo $TEGRA_KERNEL_OUT/rootfs/boot/
export INSTALL_MOD_PATH=$TEGRA_KERNEL_OUT/rootfs/
make ARCH=arm64 install -C kernel
make ARCH=arm64 modules_install
# iio support
KERNELVERSION=$(cat $KERNEL_HEADERS/include/config/kernel.release)
KERNEL_MODULES_OUT=$INSTALL_MOD_PATH/lib/modules/${KERNELVERSION}
mkdir -p $KERNEL_MODULES_OUT/extra
cp $KERNEL_MODULES_OUT/kernel/drivers/iio/buffer/kfifo_buf.ko $KERNEL_MODULES_OUT/extra/ || true
cp $KERNEL_MODULES_OUT/kernel/drivers/iio/buffer/industrialio-triggered-buffer.ko $KERNEL_MODULES_OUT/extra/ || true
cp $KERNEL_MODULES_OUT/kernel/drivers/iio/common/hid-sensors/hid-sensor-iio-common.ko $KERNEL_MODULES_OUT/extra/ || true
cp $KERNEL_MODULES_OUT/kernel/drivers/hid/hid-sensor-hub.ko $KERNEL_MODULES_OUT/extra/ || true
cp $KERNEL_MODULES_OUT/kernel/drivers/iio/accel/hid-sensor-accel-3d.ko $KERNEL_MODULES_OUT/extra/ || true
cp $KERNEL_MODULES_OUT/kernel/drivers/iio/gyro/hid-sensor-gyro-3d.ko $KERNEL_MODULES_OUT/extra/ || true
cp $KERNEL_MODULES_OUT/kernel/drivers/iio/common/hid-sensors/hid-sensor-trigger.ko $KERNEL_MODULES_OUT/extra/ || true
# RealSense cameras support
cp $KERNEL_MODULES_OUT/kernel/drivers/media/usb/uvc/uvcvideo.ko $KERNEL_MODULES_OUT/extra/ || true
cp $KERNEL_MODULES_OUT/kernel/drivers/media/v4l2-core/videodev.ko $KERNEL_MODULES_OUT/extra/ || true
else
#jp4/5
cd $SRCS/$KERNEL_DIR
make ARCH=arm64 O=$TEGRA_KERNEL_OUT tegra_defconfig
if [[ "$DEVDBG" == "1" ]]; then
scripts/config --file $TEGRA_KERNEL_OUT/.config --enable DYNAMIC_DEBUG
fi
make ARCH=arm64 O=$TEGRA_KERNEL_OUT -j${NPROC}
make ARCH=arm64 O=$TEGRA_KERNEL_OUT modules_install INSTALL_MOD_PATH=$KERNEL_MODULES_OUT
fi