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

Commit 6d6786c

Browse files
committed
Add remove kernel sources
1 parent f178237 commit 6d6786c

File tree

7 files changed

+255
-25
lines changed

7 files changed

+255
-25
lines changed

README.md

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Scripts to help build the 4.4.38 kernel and modules onboard the Jetson TX2 (L4T
55

66
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.
77

8-
These scripts are for building the kernel for the 64-bit L4T 28.2 (Ubuntu 16.04 based) operating system on the NVIDIA Jetson TX2. The scripts should be run directly after flashing the Jetson with L4T 28.2 from a host PC. There are four scripts:
8+
These scripts are for building the kernel for the 64-bit L4T 28.2 (Ubuntu 16.04 based) operating system on the NVIDIA Jetson TX2. The scripts should be run directly after flashing the Jetson with L4T 28.2 from a host PC. There are five scripts:
99

1010
<strong>getKernelSources.sh</strong>
1111

@@ -24,44 +24,34 @@ Compiles the kernel and modules using make. The script commands make the kernel
2424

2525
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.
2626

27+
<strong>removeAllKernelSources.sh</strong>
28+
Removes all of the kernel sources and compressed source files. You may want to make a backup of the files before deletion.
29+
30+
2731
<h2>Notes:</h2>
2832
<h3>Make sure to update the eMMC</h3>
2933

3034
The copyImage.sh script copies the Image to the current device. If you are building the kernel on an external device, for example a SSD, you will probably want to copy the Image file over to the eMMC in the eMMC's /boot directory. The Jetson will usually try to boot from the eMMC before switching to a different device. Study the boot sequence of the Jetson to properly understand which Image file is being used.
3135

32-
<h3>Save the .config file</h3>
33-
34-
The .config file is located in the kernel source tree. Any changes made are saved local to the source tree. The .config file is not saved elsewhere during the installation of the kernel. This can make it difficult to later go back and recreate or modify the system if you delete the kernel source tree to save space (which also erases the modified .config file). You should consider saving the configuration file elsewhere. The file is located:
35-
36-
/usr/src/kernel/kernel-4.4/.config
37-
38-
The .config file is normally hidden, you may want to save the copy without the preceeding '.'
39-
40-
<h3>Recovering Disk Space</h3>
41-
The kernel source files are downloaded in a .tgz2 format. After compilation you may want to remove those files. The files are located in /usr/src You will need to use sudo to remove the files, as they are in a system area. The file 'source_release.tbz2' is a large file that holds the kernel sources as well as many other TX2 specific source packages.
42-
43-
The source and build files installed are in the following directories:
44-
<ul>
45-
<li>/usr/src/kernel</li>
46-
<li>/usr/src/hardware</li>
47-
<li>/usr/src/source_release.tbz2</li>
48-
</ul>
49-
50-
You may want to save the newly built Image, kernel source and modules to external media for later development purposes. You can make a backup of source_release.tbz2 before deleting it.
5136

37+
Special thanks to Raffaello Bonghi (https://github.com/rbonghi) for jeston_easy scripts.
5238

5339

5440
### Release Notes
41+
April, 2018
42+
* vL4T28.2r3
43+
* L4T 28.2 (JetPack 3.2)
44+
* Add removeAllKernelSources.sh
45+
* Add checks to make sure kernel version matches L4T release
46+
5547
April, 2018
5648
* vL4T28.2r2
5749
* L4T 28.2 (JetPack 3.2)
58-
* Production Release
5950
* Add getKernelSourcesNoGUI.sh for cases where the user does not want to edit the .config file through a GUI.
6051

6152
March, 2018
6253
* vL4T28.2
63-
* L4T 28.2 (JetPack 3.2)
64-
* Developers Preview
54+
* L4T 28.2 (JetPack 3.2 DP)
6555
* Removed patches for make file cleanup
6656

6757
July, 2017
@@ -78,6 +68,7 @@ March, 2017
7868
MIT License
7969

8070
Copyright (c) 2017-2018 Jetsonhacks
71+
Portions Copyright (c) 2015-2018 Raffaello Bonghi (jetson_easy)
8172

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

getKernelSources.sh

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
11
#!/bin/bash
22
# Install the kernel source for L4T
3-
sudo ./scripts/getKernelSources.sh
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]"
8+
9+
# Check to make sure we're installing the correct kernel sources
10+
L4TTarget="28.2"
11+
if [ $JETSON_L4T == $L4TTarget ] ; then
12+
echo "Getting kernel sources"
13+
sudo ./scripts/getKernelSources.sh
14+
else
15+
echo ""
16+
tput setaf 1
17+
echo "==== L4T Kernel Version Mismatch! ============="
18+
tput sgr0
19+
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!"
23+
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
31+
echo ""
32+
fi
33+
34+

getKernelSourcesNoGUI.sh

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
11
#!/bin/bash
22
# Install the kernel source for L4T
3-
sudo ./scripts/getKernelSourcesNoGUI.sh
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]"
8+
9+
# Check to make sure we're installing the correct kernel sources
10+
L4TTarget="28.2"
11+
if [ $JETSON_L4T == $L4TTarget ] ; then
12+
echo "Getting kernel sources"
13+
sudo ./scripts/getKernelSourcesNoGUI.sh
14+
else
15+
echo ""
16+
tput setaf 1
17+
echo "==== L4T Kernel Version Mismatch! ============="
18+
tput sgr0
19+
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.!"
23+
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
31+
echo ""
32+
fi
33+

removeAllKernelSources.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
# Remove all of the kernel sources that were downloaded and built during the kernel build process
3+
# Note that this will also remove the possibly changed .config file in:
4+
# /usr/src/kernel/kernel-4.4
5+
echo "Removing All Kernel Sources"
6+
sudo ./scripts/removeAllKernelSources.sh
7+
echo "Kernel sources removed"

scripts/jetson_variables LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Raffaello Bonghi
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

scripts/jetson_variables.sh

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
#!/bin/bash
2+
# Copyright (C) 2018, Raffaello Bonghi <[email protected]>
3+
# All rights reserved
4+
#
5+
# Redistribution and use in source and binary forms, with or without
6+
# modification, are permitted provided that the following conditions
7+
# are met:
8+
#
9+
# 1. Redistributions of source code must retain the above copyright
10+
# notice, this list of conditions and the following disclaimer.
11+
# 2. Redistributions in binary form must reproduce the above copyright
12+
# notice, this list of conditions and the following disclaimer in the
13+
# documentation and/or other materials provided with the distribution.
14+
# 3. Neither the name of the copyright holder nor the names of its
15+
# contributors may be used to endorse or promote products derived
16+
# from this software without specific prior written permission.
17+
#
18+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19+
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
20+
# BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21+
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22+
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25+
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26+
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27+
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28+
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
30+
# NVIDIA Identify version
31+
# reference:
32+
# https://devtalk.nvidia.com/default/topic/1014424/jetson-tx2/identifying-tx1-and-tx2-at-runtime/
33+
# https://devtalk.nvidia.com/default/topic/996988/jetson-tk1/chip-uid/post/5100481/#5100481
34+
35+
if [ -f /sys/module/tegra_fuse/parameters/tegra_chip_id ]; then
36+
case $(cat /sys/module/tegra_fuse/parameters/tegra_chip_id) in
37+
64)
38+
JETSON_BOARD="TK1" ;;
39+
33)
40+
JETSON_BOARD="TX1" ;;
41+
24)
42+
JETSON_BOARD="TX2" ;;
43+
*)
44+
JETSON_BOARD="UNKNOWN" ;;
45+
esac
46+
JETSON_DESCRIPTION="NVIDIA Jetson $JETSON_BOARD"
47+
fi
48+
49+
# NVIDIA Jetson version
50+
# reference https://devtalk.nvidia.com/default/topic/860092/jetson-tk1/how-do-i-know-what-version-of-l4t-my-jetson-tk1-is-running-/
51+
if [ -f /etc/nv_tegra_release ]; then
52+
# L4T string
53+
JETSON_L4T_STRING=$(head -n 1 /etc/nv_tegra_release)
54+
55+
# Load release and revision
56+
JETSON_L4T_RELEASE=$(echo $JETSON_L4T_STRING | cut -f 1 -d ',' | sed 's/\# R//g' | cut -d ' ' -f1)
57+
JETSON_L4T_REVISION=$(echo $JETSON_L4T_STRING | cut -f 2 -d ',' | sed 's/\ REVISION: //g' | cut -d. -f1)
58+
# unset variable
59+
unset JETSON_L4T_STRING
60+
61+
# Write Jetson description
62+
JETSON_L4T="$JETSON_L4T_RELEASE.$JETSON_L4T_REVISION"
63+
64+
# Write version of jetpack installed
65+
# https://developer.nvidia.com/embedded/jetpack-archive
66+
if [ "$JETSON_BOARD" = "TX2i" ] ; then
67+
case $JETSON_L4T in
68+
"28.2")
69+
JETSON_JETPACK="3.2" ;;
70+
*)
71+
JETSON_JETPACK="UNKNOWN" ;;
72+
esac
73+
elif [ "$JETSON_BOARD" = "TX2" ] ; then
74+
case $JETSON_L4T in
75+
"28.2")
76+
JETSON_JETPACK="3.2" ;;
77+
"28.1")
78+
JETSON_JETPACK="3.1" ;;
79+
"27.1")
80+
JETSON_JETPACK="3.0" ;;
81+
*)
82+
JETSON_JETPACK="UNKNOWN" ;;
83+
esac
84+
elif [ "$JETSON_BOARD" = "TX1" ] ; then
85+
case $JETSON_L4T in
86+
"28.2")
87+
JETSON_JETPACK="3.2" ;;
88+
"28.1")
89+
JETSON_JETPACK="3.1" ;;
90+
"24.2.1")
91+
JETSON_JETPACK="3.0 or 2.3.1" ;;
92+
"24.2")
93+
JETSON_JETPACK="2.3" ;;
94+
"24.1")
95+
JETSON_JETPACK="2.2.1 or 2.2" ;;
96+
"23.2")
97+
JETSON_JETPACK="2.1" ;;
98+
"23.1")
99+
JETSON_JETPACK="2.0" ;;
100+
*)
101+
JETSON_JETPACK="UNKNOWN" ;;
102+
esac
103+
elif [ "$JETSON_BOARD" ="TK1" ] ; then
104+
case $JETSON_L4T in
105+
"21.5")
106+
JETSON_JETPACK="2.3.1 or 2.3" ;;
107+
"21.4")
108+
JETSON_JETPACK="2.2 or 2.1 or 2.0 or DP 1.2" ;;
109+
"21.3")
110+
JETSON_JETPACK="DP 1.1" ;;
111+
"21.2")
112+
JETSON_JETPACK="DP 1.0" ;;
113+
*)
114+
JETSON_JETPACK="UNKNOWN" ;;
115+
esac
116+
else
117+
# Unknown board
118+
JETSON_JETPACK="UNKNOWN"
119+
fi
120+
fi
121+
122+
# Read CUDA version
123+
if [ -f /usr/local/cuda/version.txt ]; then
124+
JETSON_CUDA=$(cat /usr/local/cuda/version.txt | sed 's/\CUDA Version //g')
125+
else
126+
JETSON_CUDA="NOT INSTALLED"
127+
fi
128+
129+
# Read opencv version
130+
if hash pkg-config --modversion opencv 2>/dev/null; then
131+
JETSON_OPENCV=$(pkg-config --modversion opencv)
132+
else
133+
JETSON_OPENCV="NOT INSTALLED"
134+
fi
135+
136+
# TODO Add enviroments variables:
137+
# - UID -> https://devtalk.nvidia.com/default/topic/996988/jetson-tk1/chip-uid/post/5100481/#5100481
138+
# - GCID, BOARD, EABI
139+
# - cuDNN
140+
# - TensorRT
141+
# - Visionworks
142+

scripts/removeAllKernelSources.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
# Remove the kernel source and compressed files
3+
cd /usr/src
4+
rm -r kernel
5+
rm -r hardware
6+
rm tx2_sources.tbz2
7+

0 commit comments

Comments
 (0)