Repository navigation
Expand file tree
/
Copy pathinstall_kernel.sh
More file actions
executable file
·106 lines (85 loc) · 3.19 KB
/
Copy pathinstall_kernel.sh
File metadata and controls
executable file
·106 lines (85 loc) · 3.19 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
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=common.sh
source "${SCRIPT_DIR}/common.sh"
usage() {
cat <<EOF
Usage: $0 [--activate] [--verbose]
Install the kernel built by build_kernel.sh beside the stock kernel and add the
oai-sctp entry to extlinux.conf. The default boot entry changes only with
--activate.
Options:
--activate Make oai-sctp the default boot entry
-v, --verbose Show all command output instead of one status line per step
-h, --help Show this help
Environment:
JETSON_KERNEL_WORKSPACE Build directory (default: ~/jetson-kernel-build)
JETSON_EXTLINUX_CONF Boot configuration (default: /boot/extlinux/extlinux.conf)
EOF
}
ACTIVATE=0
for arg in "$@"; do
case "${arg}" in
--activate) ACTIVATE=1 ;;
-v | --verbose) VERBOSE=1 ;;
-h | --help) usage; exit 0 ;;
*) fail "unknown option: ${arg}" "Run $0 --help to see the options." ;;
esac
done
STEP_TOTAL=6
[[ -f "${KERNEL_DIR}/arch/arm64/boot/Image" && -f "${SOURCE_ROOT}/build-inputs.txt" ]] ||
fail "no finished build in $(pretty_path "${SOURCE_ROOT}")" \
"Run ${TOOL} build first."
KERNEL_RELEASE="$(make -s -C "${KERNEL_DIR}" kernelrelease)"
IMAGE_PATH="/boot/Image-${KERNEL_RELEASE}"
INITRD_PATH="/boot/initrd.img-${KERNEL_RELEASE}"
if (( ACTIVATE == 1 )); then
BOOT_NOTE="oai-sctp, made the default"
else
BOOT_NOTE="oai-sctp, default entry unchanged"
fi
start_log install
header "install"
field "Release" "${KERNEL_RELEASE}"
field "Boot" "${BOOT_NOTE}"
field "Config" "${EXTLINUX_CONF}"
field "Log" "$(pretty_path "${LOG_FILE}")"
printf '\n'
need_sudo "write to /boot and /lib/modules"
sudo test -f "${EXTLINUX_CONF}" ||
fail "${EXTLINUX_CONF} does not exist" \
"Set JETSON_EXTLINUX_CONF when the boot configuration is somewhere else."
backup_extlinux
step "Install kernel image"
run sudo install -m 0644 "${KERNEL_DIR}/arch/arm64/boot/Image" "${IMAGE_PATH}"
end_step "${IMAGE_PATH}"
step "Install in-tree modules"
run sudo make -C "${KERNEL_DIR}" modules_install INSTALL_MOD_PATH=/
end_step "/lib/modules/${KERNEL_RELEASE}"
step "Install NVIDIA OOT modules"
export KERNEL_HEADERS="${KERNEL_DIR}"
run sudo -E make -C "${SOURCE_DIR}" modules_install INSTALL_MOD_PATH=/
end_step
step "Build initramfs"
run sudo depmod -a "${KERNEL_RELEASE}"
run sudo mkinitramfs -o "${INITRD_PATH}" "${KERNEL_RELEASE}"
end_step "${INITRD_PATH}"
step "Add boot entry"
run sudo "${SCRIPT_DIR}/update_extlinux.sh" add "${EXTLINUX_CONF}" "${KERNEL_RELEASE}" "${ACTIVATE}"
end_step "${BOOT_NOTE}"
fmt_time TOTAL_TIME "${SECONDS}"
printf '\n%s in %s.\n' "${GREEN}${BOLD}Installed ${KERNEL_RELEASE}${RESET}" "${TOTAL_TIME}"
field "Backup" "${BACKUP_PATH}"
field "Log" "$(pretty_path "${LOG_FILE}")"
printf '\n%s\n' "${BOLD}Next steps${RESET}"
if (( ACTIVATE == 1 )); then
printf ' 1. %s\n' "sudo reboot"
printf ' 2. %s\n' "${TOOL} verify"
printf '\n%s\n' "${DIM}To go back to the stock kernel: ${TOOL} rollback, then reboot.${RESET}"
else
printf ' 1. %s\n' "Review ${EXTLINUX_CONF}"
printf ' 2. %s\n' "${TOOL} activate"
printf ' 3. %s\n' "sudo reboot"
printf ' 4. %s\n' "${TOOL} verify"
fi