Skip to content
This repository was archived by the owner on Nov 22, 2022. It is now read-only.

Commit b066cf9

Browse files
authored
Merge pull request #27 from jetsonhacks/L4T32.3.1-dev
L4T32.3.1 dev
2 parents adb91d5 + 6351a9f commit b066cf9

13 files changed

+402
-290
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2017-19 Jetsonhacks
3+
Copyright (c) 2017-20 Jetsonhacks
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,46 @@
11
# buildJetsonTX2Kernel
2-
Scripts to help build the 4.9.140 kernel and modules onboard the Jetson TX2 (L4T 32.1.0, JetPack 4.2). For previous versions, visit the 'tags' section.
2+
Scripts to help build the 4.9.140 kernel and modules onboard the Jetson TX2 (L4T 32.3.1, JetPack 4.3). For previous versions, visit the 'tags' section.
33

4-
<em><strong>Note:</strong> The kernel source version must match the version of firmware flashed on the Jetson. For example, the source for the 4.9.140 kernel here is matched with L4T 32.1.0. This kernel compiled using this source tree will not work with newer versions or older versions of L4T, only 32.1.0.</em>
4+
<em><strong>Note:</strong> The kernel source version must match the version of firmware flashed on the Jetson. For example, the source for the 4.9.140 kernel here is matched with L4T 32.3.1. This kernel compiled using this source tree will not work with newer versions or older versions of L4T, only 32.3.1.</em>
5+
6+
<em><strong>Note:</strong> You will probably only use these scripts to build and install modules. Even though there are scripts provided to build and copy the new kernel to the boot directory of the device, there is no effect. In newer versions of L4T, the kernel Image is actually signed and stored in a different partition on disk. The copyImage.sh script is legacy. In order to place the newly created Image, you will need to copy it to the correct place on the host and flash the eMMC. It is probably easier to build it on the host in the first place. The flash process on the host signs the Image, and copies it to the appropriate partition.</em>
57

68
As of this writing, the "official" way to build the Jetson TX2 kernel is to use a cross compiler on a Linux PC. This is an alternative which builds the kernel onboard the Jetson itself. These scripts will download the kernel source to the Jetson TX2, and then compile the kernel and selected modules. The newly compiled kernel can then be installed. The kernel sources and build objects consume ~3GB.
79

8-
These scripts are for building the kernel for the 64-bit L4T 32.1.0 (Ubuntu 18.04 based) operating system on the NVIDIA Jetson TX2. The scripts should be run directly after flashing the Jetson with L4T 32.1.0 from a host PC. There are five scripts:
10+
These scripts are for building the kernel for the 64-bit L4T 32.3.1 (Ubuntu 18.04 based) operating system on the NVIDIA Jetson TX2. The scripts should be run directly after flashing the Jetson with L4T 32.3.1 from a host PC. There are six scripts:
911

1012
<strong>getKernelSources.sh</strong>
1113

12-
Downloads the kernel sources for L4T from the NVIDIA website, decompresses them and opens a graphical editor on the .config file.
14+
Downloads the kernel sources for L4T from the NVIDIA website, decompresses them and opens a graphical editor on the .config file. Note that this also sets the .config file to the current system, and also sets the local version to the current local version, i.e., -tegra
1315

14-
<strong>getKernelSourcesNoGUI.sh</strong>
16+
<strong>makeKernel.sh</strong>
1517

16-
Downloads the kernel sources for L4T from the NVIDIA website and decompresses them. This is useful when working through SSH, have a preference to edit the .config through a text editor or some other manner (e.g. nconfig), or have a predefined .config file you would like to substitute.
18+
Compiles the kernel using make. The script commands make the kernel Image file. Installing the Image file on to the system is a separate step. Note that the make is limited to the Image and modules.
1719

20+
The other parts of the kernel build, such as building the device tree, require that the result be 'signed' and flashed from the the NVIDIA tools on a host PC.
1821

19-
<strong>makeKernel.sh</strong>
22+
<strong>makeModules.sh</strong>
2023

21-
Compiles the kernel and modules using make. The script commands make the kernel Image file, makes the module files, and installs the module files. Installing the Image file on to the system is a separate step. Note that the make is limited to the Image and modules; the rest of the kernel build (such as compiling the dts files) must be done separately. Doing "sudo make" in the kernel source directory will build the entirety.
24+
Compiles the modules using make and then installs them.
2225

2326
<strong>copyImage.sh</strong>
2427

2528
Copies the Image file created by compiling the kernel to the /boot directory. Note that while developing you will want to be more conservative than this: You will probably want to copy the new kernel Image to a different name in the boot directory, and modify /boot/extlinux/extlinux.conf to have entry points at the old image, or the new image. This way, if things go sideways you can still boot the machine using the serial console.
2629

30+
You will want to make a copy of the original Image before the copy, something like:
31+
32+
```
33+
$ cp /boot/Image $INSTALL_DIR/Image.orig
34+
$ ./copyImage.sh
35+
$ echo "New Image created and placed in /boot"
36+
```
37+
38+
<strong>editConfig.sh</strong>
39+
40+
Edit the .config file located in /usr/src/kernel/kernel-4.9 This file must be present (from the getKernelSources.sh script) before launching the file. Note that if you change the local version, you will need to make both the kernel and modules and install them.
41+
2742
<strong>removeAllKernelSources.sh</strong>
43+
2844
Removes all of the kernel sources and compressed source files. You may want to make a backup of the files before deletion.
2945

3046

@@ -39,6 +55,11 @@ Special thanks to Shreeyak (https://github.com/Shreeyak) for discussing alternat
3955
Special thanks to Alexander Rashed (@alexrashed on Github) for vL4T32.1.0 release
4056

4157
### Release Notes
58+
59+
January, 2020
60+
* vL4T32.3.1
61+
* L4T 32.3.1 (JetPack 4.3)
62+
4263
May, 2019
4364
* vL4T32.1.0
4465
* L4T 32.1.0 (JetPack 4.2)
@@ -79,7 +100,7 @@ March, 2017
79100
## License
80101
MIT License
81102

82-
Copyright (c) 2017-2018 Jetsonhacks
103+
Copyright (c) 2017-2020 Jetsonhacks
83104
Portions Copyright (c) 2015-2018 Raffaello Bonghi (jetson_easy)
84105

85106
Permission is hereby granted, free of charge, to any person obtaining a copy

editConfig.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
# Edit the kernel configuration for NVIDIA Jetson TX2 Development Kit
3+
# Copyright (c) 2016-20 Jetsonhacks
4+
# MIT License
5+
6+
SOURCE_TARGET="/usr/src"
7+
KERNEL_RELEASE="4.9"
8+
9+
function usage
10+
{
11+
echo "usage: ./editConfig.sh [[-d directory ] | [-h]]"
12+
echo "-d | --directory Directory path to parent of kernel"
13+
echo "-h | --help This message"
14+
}
15+
16+
# Iterate through command line inputs
17+
while [ "$1" != "" ]; do
18+
case $1 in
19+
-d | --directory ) shift
20+
SOURCE_TARGET=$1
21+
;;
22+
-h | --help ) usage
23+
exit
24+
;;
25+
* ) usage
26+
exit 1
27+
esac
28+
shift
29+
done
30+
31+
LAST="${SOURCE_TARGET: -1}"
32+
if [ $LAST != '/' ] ; then
33+
SOURCE_TARGET="$SOURCE_TARGET""/"
34+
fi
35+
36+
# Check to see if source tree is already installed
37+
PROPOSED_SRC_PATH="$SOURCE_TARGET""kernel/kernel-"$KERNEL_RELEASE
38+
echo "Proposed source path: ""$PROPOSED_SRC_PATH"
39+
if [ ! -d "$PROPOSED_SRC_PATH" ]; then
40+
tput setaf 1
41+
echo "==== Cannot find kernel source! =============== "
42+
tput sgr0
43+
echo "The kernel source does not appear to be installed at: "
44+
echo " ""$PROPOSED_SRC_PATH"
45+
echo "Unable to edit kernel configuration."
46+
exit 1
47+
fi
48+
49+
cd "$PROPOSED_SRC_PATH"
50+
sudo make menuconfig

getKernelSources.sh

Lines changed: 135 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,148 @@
11
#!/bin/bash
2-
# Install the kernel source for L4T
3-
source scripts/jetson_variables.sh
4-
#Print Jetson version
5-
echo "$JETSON_DESCRIPTION"
6-
#Print Jetpack version
7-
echo "Jetpack $JETSON_JETPACK [L4T $JETSON_L4T]"
2+
# Get the kernel source for NVIDIA Jetson Nano Developer Kit, L4T
3+
# Copyright (c) 2016-2020 Jetsonhacks
4+
# MIT License
5+
6+
JETSON_MODEL="TX2"
7+
L4T_TARGET="32.3.1"
8+
SOURCE_TARGET="/usr/src"
9+
KERNEL_RELEASE="4.9"
10+
11+
#Get the Board Model
12+
JETSON_BOARD="UNKNOWN"
13+
14+
if [ -f /sys/module/tegra_fuse/parameters/tegra_chip_id ]; then
15+
JETSON_BOARD=$(case $(cat /sys/module/tegra_fuse/parameters/tegra_chip_id) in
16+
64)
17+
echo TK1 ;;
18+
33)
19+
echo Nano/TX1 ;;
20+
24)
21+
echo TX2 ;;
22+
25)
23+
echo AGX Xavier ;;
24+
esac)
25+
JETSON_DESCRIPTION="NVIDIA Jetson $JETSON_BOARD"
26+
fi
27+
echo "Jetson Model: "$JETSON_BOARD
28+
29+
JETSON_L4T=""
30+
31+
# Starting with L4T 32.2, the recommended way to find the L4T Release Number
32+
# is to use dpkg
33+
# L4T 32.3.1, NVIDIA added back /etc/nv_tegra_release
34+
function check_L4T_version()
35+
{
36+
if [ -f /etc/nv_tegra_release ]; then
37+
JETSON_L4T_STRING=$(head -n 1 /etc/nv_tegra_release)
38+
JETSON_L4T_RELEASE=$(echo $JETSON_L4T_STRING | cut -f 2 -d ' ' | grep -Po '(?<=R)[^;]+')
39+
JETSON_L4T_REVISION=$(echo $JETSON_L4T_STRING | cut -f 2 -d ',' | grep -Po '(?<=REVISION: )[^;]+')
40+
JETSON_L4T_VERSION=$JETSON_L4T_RELEASE.$JETSON_L4T_REVISION
41+
42+
else
43+
echo "$LOG Reading L4T version from \"dpkg-query --show nvidia-l4t-core\""
44+
45+
JETSON_L4T_STRING=$(dpkg-query --showformat='${Version}' --show nvidia-l4t-core)
46+
# For example: 32.2.1-20190812212815
47+
JETSON_L4T_VERSION=$(echo $JETSON_L4T_STRING | cut -d '-' -f 1)
48+
JETSON_L4T_RELEASE=$(echo $JETSON_L4T_VERSION | cut -d '.' -f 1)
49+
# # operator remove prefix in string operations in bash script. Don't forget . eg "32."
50+
JETSON_L4T_REVISION=${JETSON_L4T_VERSION#$JETSON_L4T_RELEASE.}
51+
fi
52+
echo "$LOG Jetson BSP Version: L4T R$JETSON_L4T_VERSION"
53+
54+
}
55+
56+
echo "Getting L4T Version"
57+
check_L4T_version
58+
JETSON_L4T="$JETSON_L4T_VERSION"
59+
60+
function usage
61+
{
62+
echo "usage: ./getKernelSources.sh [[-d directory ] | [-h]]"
63+
echo "-h | --help This message"
64+
}
65+
66+
# Iterate through command line inputs
67+
while [ "$1" != "" ]; do
68+
case $1 in
69+
-d | --directory ) shift
70+
SOURCE_TARGET=$1
71+
;;
72+
-h | --help ) usage
73+
exit
74+
;;
75+
* ) usage
76+
exit 1
77+
esac
78+
shift
79+
done
80+
81+
red=`tput setaf 1`
82+
green=`tput setaf 2`
83+
reset=`tput sgr0`
84+
# e.g. echo "${red}The red tail hawk ${green}loves the green grass${reset}"
85+
86+
LAST="${SOURCE_TARGET: -1}"
87+
if [ $LAST != '/' ] ; then
88+
SOURCE_TARGET="$SOURCE_TARGET""/"
89+
fi
90+
91+
INSTALL_DIR=$PWD
92+
93+
# Error out if something goes wrong
94+
set -e
895

996
# Check to make sure we're installing the correct kernel sources
10-
L4TTarget="32.1.0"
11-
if [ $JETSON_L4T == $L4TTarget ] ; then
12-
echo "Getting kernel sources"
13-
sudo ./scripts/getKernelSources.sh
14-
else
97+
# Determine the correct kernel version
98+
# The KERNEL_BUILD_VERSION is the release tag for the JetsonHacks buildKernel repository
99+
KERNEL_BUILD_VERSION=master
100+
if [ "$JETSON_BOARD" == "$JETSON_MODEL" ] ; then
101+
if [ $JETSON_L4T == "$L4T_TARGET" ] ; then
102+
KERNEL_BUILD_VERSION=$L4T_TARGET
103+
else
15104
echo ""
16105
tput setaf 1
17106
echo "==== L4T Kernel Version Mismatch! ============="
18107
tput sgr0
19108
echo ""
20-
echo "This repository branch is for installing the kernel sources for L4T "$L4TTarget
21-
echo "You are attempting to use these kernel sources on a L4T "$JETSON_L4T "system."
22-
echo "The kernel sources do not match their L4T release!"
109+
echo "This repository is for modifying the kernel for a L4T "$L4T_TARGET "system."
110+
echo "You are attempting to modify a L4T "$JETSON_MODEL "system with L4T "$JETSON_L4T
111+
echo "The L4T releases must match!"
23112
echo ""
24-
echo "Please git checkout the appropriate kernel sources for your release"
25-
echo " "
26-
echo "You can list the tagged versions."
27-
echo "$ git tag -l"
28-
echo "And then checkout the latest version: "
29-
echo "For example"
30-
echo "$ git checkout v1.0-L4T"$JETSON_L4T
113+
echo "There may be versions in the tag/release sections that meet your needs"
31114
echo ""
115+
exit 1
116+
fi
117+
else
118+
tput setaf 1
119+
echo "==== Jetson Board Mismatch! ============="
120+
tput sgr0
121+
echo "Currently this script works for the $JETSON_MODEL."
122+
echo "This processor appears to be a $JETSON_BOARD, which does not have a corresponding script"
123+
echo ""
124+
echo "Exiting"
125+
exit 1
32126
fi
33127

128+
# Check to see if source tree is already installed
129+
PROPOSED_SRC_PATH="$SOURCE_TARGET""kernel/kernel-"$KERNEL_RELEASE
130+
echo "Proposed source path: ""$PROPOSED_SRC_PATH"
131+
if [ -d "$PROPOSED_SRC_PATH" ]; then
132+
tput setaf 1
133+
echo "==== Kernel source appears to already be installed! =============== "
134+
tput sgr0
135+
echo "The kernel source appears to already be installed at: "
136+
echo " ""$PROPOSED_SRC_PATH"
137+
echo "If you want to reinstall the source files, first remove the directories: "
138+
echo " ""$SOURCE_TARGET""kernel"
139+
echo " ""$SOURCE_TARGET""hardware"
140+
echo "then rerun this script"
141+
exit 1
142+
fi
143+
144+
export SOURCE_TARGET
145+
# -E preserves environment variables
146+
sudo -E ./scripts/getKernelSources.sh
147+
34148

getKernelSourcesNoGUI.sh

Lines changed: 0 additions & 33 deletions
This file was deleted.

makeKernel.sh

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,51 @@
11
#!/bin/bash
2-
sudo ./scripts/makeKernel.sh
2+
# Make the kernel for NVIDIA Jetson TX2 Developer Kit
3+
# Copyright (c) 2016-20 Jetsonhacks
4+
# MIT License
35

6+
SOURCE_TARGET="/usr/src"
7+
KERNEL_RELEASE="4.9"
8+
9+
function usage
10+
{
11+
echo "usage: ./makeKernel.sh [[-d directory ] | [-h]]"
12+
echo "-d | --directory Directory path to parent of kernel"
13+
echo "-h | --help This message"
14+
}
15+
16+
# Iterate through command line inputs
17+
while [ "$1" != "" ]; do
18+
case $1 in
19+
-d | --directory ) shift
20+
SOURCE_TARGET=$1
21+
;;
22+
-h | --help ) usage
23+
exit
24+
;;
25+
* ) usage
26+
exit 1
27+
esac
28+
shift
29+
done
30+
31+
LAST="${SOURCE_TARGET: -1}"
32+
if [ $LAST != '/' ] ; then
33+
SOURCE_TARGET="$SOURCE_TARGET""/"
34+
fi
35+
36+
# Check to see if source tree is already installed
37+
PROPOSED_SRC_PATH="$SOURCE_TARGET""kernel/kernel-"$KERNEL_RELEASE
38+
echo "Proposed source path: ""$PROPOSED_SRC_PATH"
39+
if [ ! -d "$PROPOSED_SRC_PATH" ]; then
40+
tput setaf 1
41+
echo "==== Cannot find kernel source! =============== "
42+
tput sgr0
43+
echo "The kernel source does not appear to be installed at: "
44+
echo " ""$PROPOSED_SRC_PATH"
45+
echo "Unable to start making kernel."
46+
exit 1
47+
fi
48+
49+
export SOURCE_TARGET
50+
# E Option carries over environment variables
51+
sudo -E ./scripts/makeKernel.sh

0 commit comments

Comments
 (0)