├── .github
└── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
├── LICENSE
├── README.md
├── copyImage.sh
├── editConfig.sh
├── getKernelSources.sh
├── makeKernel.sh
├── makeModules.sh
├── removeAllKernelSources.sh
└── scripts
├── copyImage.sh
├── getKernelSources.sh
├── jetson_variables.sh
├── makeKernel.sh
├── makeModules.sh
└── removeAllKernelSources.sh
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Issue report
3 | about: Create a report to help us improve
4 | title: "[BUG]"
5 | labels: bug
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the issue**
11 | Please describe the issue
12 |
13 | **What version of L4T/JetPack**
14 | L4T/JetPack version:
15 |
16 | **Which Jetson**
17 | Jetson:
18 |
19 | **To Reproduce**
20 | Steps to reproduce the behavior:
21 | For example, what command line did you run?
22 |
23 | **Expected behavior**
24 | A clear and concise description of what you expected to happen.
25 |
26 | **Additional context**
27 | Add any other context about the problem here.
28 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: "[FEATURE REQUEST]"
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020-2021 Jetsonhacks
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 |
23 | --------------
24 | jetson_variables.sh
25 | See scripts/jetson_variables.sh for full copyright info
26 | Copyright (c) 2020-2021 Raffaello Bonghi.
27 | Part of the jetson_stats package (https://github.com/rbonghi/jetson_stats or http://rnext.it).
28 |
29 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # buildJetsonXavierNXKernel
2 | ## Deprecated
3 | For version of L4T newere than L4T 32.6.1 please see jetson-linux-build https://github.com/jetsonhacks/jetson-linux-build
4 |
5 | ## README
6 | Scripts to help build the 4.9.253 kernel and modules onboard the Jetson Xavier NX (L4T 32.6.1, JetPack 4.6).
7 |
8 | Note: The kernel source version must match the version of firmware flashed on the Jetson. For example, the source for the 4.9.253 kernel here is matched with L4T 32.6.1. This kernel compiled using this source tree may not work with newer versions or older versions of L4T.
9 |
10 | As of this writing, the "official" way to build the Jetson Xavier NX 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 Xavier NX, and then compile the kernel and selected modules. The newly compiled kernel can then be installed. The kernel sources and build objects consume ~3GB.
11 |
12 | These scripts are for building the kernel for the 64-bit L4T 32.6.1 (Ubuntu 18.04 based) operating system on the NVIDIA Jetson Xavier NX. The scripts should be run directly after flashing the Jetson with JetPack 4.6/L4T 32.6.1 from a host PC, or after flashing an SD card. There are six scripts:
13 |
14 | ### getKernelSources.sh
15 |
16 | 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
17 |
18 | ### makeKernel.sh
19 |
20 | Please read the notes below about installing the kernel. 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.
21 |
22 | 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.
23 |
24 | ### makeModules.sh
25 |
26 | Compiles the modules using make and then installs them.
27 |
28 | ### copyImage.sh
29 |
30 | Please read the notes below about installing the kernel. 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.
31 |
32 | You will want to make a copy of the original Image before the copy, something like:
33 |
34 | ```
35 | $ cp /boot/Image $INSTALL_DIR/Image.orig
36 | $ ./copyImage.sh
37 | $ echo "New Image created and placed in /boot"
38 | ```
39 |
40 | ### editConfig.sh
41 |
42 | 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.
43 |
44 | ### removeAllKernelSources.sh
45 |
46 | Removes all of the kernel sources and compressed source files. You may want to make a backup of the files before deletion.
47 |
48 |
49 | ## Notes:
50 |
51 | **Note** Starting with JetPack 4.5, the kernel is now stored in QSPI-Nor flash memory. The kernel may be signed, making a kernel installed independently not work correctly. While there are workarounds, none are implemented in this repository. Copying the image may not take effect.
52 |
53 | ### Make sure to update the eMMC
54 |
55 | 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.
56 |
57 | ## Release Notes
58 |
59 | ### September, 2021
60 | * JetPack 4.6
61 | * vL4T32.6.1
62 | * L4T 32.6.1
63 |
64 | ### March, 2021
65 | * JetPack 4.5.1
66 | * vL4T32.5.1
67 | * L4T 32.5.1 (JetPack 4.5.1)
68 |
69 | ### February, 2021
70 | * JetPack 4.5
71 | * vL4T32.5.0
72 | * L4T 32.5.0 (JetPack 4.5)
73 |
74 | ### July, 2020
75 | * JetPack 4.4
76 | * vL4T32.4.3
77 | * L4T 32.4.3 (JetPack 4.4)
78 |
79 | ### July, 2020
80 | * Initial release
81 | * vL4T32.4.1
82 | * L4T 32.4.1 (JetPack 4.4 DP)
83 |
84 | ## License
85 | MIT License
86 |
87 | Copyright (c) 2017-2021 Jetsonhacks
88 |
89 | Permission is hereby granted, free of charge, to any person obtaining a copy
90 | of this software and associated documentation files (the "Software"), to deal
91 | in the Software without restriction, including without limitation the rights
92 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
93 | copies of the Software, and to permit persons to whom the Software is
94 | furnished to do so, subject to the following conditions:
95 |
96 | The above copyright notice and this permission notice shall be included in all
97 | copies or substantial portions of the Software.
98 |
99 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
100 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
101 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
102 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
103 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
104 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
105 | SOFTWARE.
106 |
--------------------------------------------------------------------------------
/copyImage.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | sudo ./scripts/copyImage.sh
3 |
--------------------------------------------------------------------------------
/editConfig.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Edit the kernel configuration for NVIDIA Jetson Xavier NX Developer 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
51 |
--------------------------------------------------------------------------------
/getKernelSources.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Get the kernel source for NVIDIA Jetson Xavier NX Developer Kit, L4T
3 | # Copyright (c) 2016-2021 Jetsonhacks
4 | # MIT License
5 |
6 | # Install the kernel source for L4T
7 | source scripts/jetson_variables.sh
8 | #Print Jetson version
9 | echo "$JETSON_DESCRIPTION"
10 | #Print Jetpack version
11 | echo "Jetpack $JETSON_JETPACK [L4T $JETSON_L4T]"
12 | #Print Kernel Version
13 |
14 | SOURCE_TARGET="/usr/src"
15 | L4TTarget="32.6.1"
16 | KERNEL_RELEASE="4.9"
17 |
18 | function usage
19 | {
20 | echo "usage: ./getKernelSources.sh [[-d directory ] | [-h]]"
21 | echo "-h | --help This message"
22 | }
23 |
24 | # Iterate through command line inputs
25 | while [ "$1" != "" ]; do
26 | case $1 in
27 | -d | --directory ) shift
28 | SOURCE_TARGET=$1
29 | ;;
30 | -h | --help ) usage
31 | exit
32 | ;;
33 | * ) usage
34 | exit 1
35 | esac
36 | shift
37 | done
38 |
39 | red=`tput setaf 1`
40 | green=`tput setaf 2`
41 | reset=`tput sgr0`
42 | # e.g. echo "${red}The red tail hawk ${green}loves the green grass${reset}"
43 |
44 | LAST="${SOURCE_TARGET: -1}"
45 | if [ $LAST != '/' ] ; then
46 | SOURCE_TARGET="$SOURCE_TARGET""/"
47 | fi
48 |
49 | INSTALL_DIR=$PWD
50 |
51 | # Error out if something goes wrong
52 | set -e
53 |
54 |
55 | # Check to make sure we're installing the correct kernel sources
56 | if [ $JETSON_L4T != $L4TTarget ] ; then
57 | echo ""
58 | tput setaf 1
59 | echo "==== L4T Kernel Version Mismatch! ============="
60 | tput sgr0
61 | echo ""
62 | echo "This repository branch is for installing the kernel sources for L4T "$L4TTarget
63 | echo "You are attempting to use these kernel sources on a L4T "$JETSON_L4T "system."
64 | echo "The kernel sources do not match their L4T release!"
65 | echo ""
66 | echo "Please git checkout the appropriate kernel sources for your release"
67 | echo " "
68 | echo "You can list the tagged versions."
69 | echo "$ git tag -l"
70 | echo "And then checkout the latest version: "
71 | echo "For example"
72 | echo "$ git checkout v1.0-L4T"$JETSON_L4T
73 | echo ""
74 | exit
75 | fi
76 |
77 | # Check to see if source tree is already installed
78 | PROPOSED_SRC_PATH="$SOURCE_TARGET""kernel/kernel-"$KERNEL_RELEASE
79 | echo "Proposed source path: ""$PROPOSED_SRC_PATH"
80 | if [ -d "$PROPOSED_SRC_PATH" ]; then
81 | tput setaf 1
82 | echo "==== Kernel source appears to already be installed! =============== "
83 | tput sgr0
84 | echo "The kernel source appears to already be installed at: "
85 | echo " ""$PROPOSED_SRC_PATH"
86 | echo "If you want to reinstall the source files, first remove the directories: "
87 | echo " ""$SOURCE_TARGET""kernel"
88 | echo " ""$SOURCE_TARGET""hardware"
89 | echo "then rerun this script"
90 | exit 1
91 | fi
92 |
93 | export SOURCE_TARGET
94 | # -E preserves environment variables
95 | sudo -E ./scripts/getKernelSources.sh
96 |
97 |
98 |
--------------------------------------------------------------------------------
/makeKernel.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Make the kernel for NVIDIA Jetson Xavier NX Developer 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: ./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
52 |
--------------------------------------------------------------------------------
/makeModules.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Make kernel modules for NVIDIA Jetson Xavier NX Developer 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: ./makeModules.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/makeModules.sh
52 |
--------------------------------------------------------------------------------
/removeAllKernelSources.sh:
--------------------------------------------------------------------------------
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.9
5 | echo "Removing All Kernel Sources"
6 | sudo ./scripts/removeAllKernelSources.sh
7 | echo "Kernel sources removed"
8 |
--------------------------------------------------------------------------------
/scripts/copyImage.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | cd /usr/src/kernel/kernel-4.9
3 | # On the stock Jetson Xavier NX install, there is no zImage in the boot directory
4 | # So we just copy the Image file over
5 | # If the zImage is needed, you must either
6 | # $ make zImage
7 | # or
8 | # $ make
9 | # Both of these commands must be executed in /usr/src/kernel/kernel-4.9
10 | # sudo cp arch/arm64/boot/zImage /boot/zImage
11 | # Note that if you are compiling on an external device, like a SSD, you should probably
12 | # copy this over to the internal eMMC if that is where the Jetson boots
13 | sudo cp arch/arm64/boot/Image /boot/Image
14 |
15 |
16 |
--------------------------------------------------------------------------------
/scripts/getKernelSources.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Get Kernel sources for NVIDIA Jetson NX Xavier
3 | apt-add-repository universe
4 | apt-get update
5 | apt-get install pkg-config -y
6 | # We use 'make menuconfig' to edit the .config file; install dependencies
7 | apt-get install libncurses5-dev -y
8 |
9 |
10 | echo "Installing kernel sources in: ""$SOURCE_TARGET"
11 | if [ ! -d "$SOURCE_TARGET" ]; then
12 | # Target directory does not exist; create
13 | echo "Creating directory: ""$SOURCE_TARGET"
14 | mkdir -p "$SOURCE_TARGET"
15 | fi
16 |
17 | cd "$SOURCE_TARGET"
18 | echo "$PWD"
19 | # L4T Driver Package (BSP) Sources
20 | # For this version, TX2 and AGX Xavier and Xavier NX have the same source files
21 | wget -N https://developer.nvidia.com/embedded/l4t/r32_release_v6.1/sources/t186/public_sources.tbz2
22 |
23 | # l4t-sources is a tbz2 file
24 | tar -xvf public_sources.tbz2 Linux_for_Tegra/source/public/kernel_src.tbz2 --strip-components=3
25 | tar -xvf kernel_src.tbz2
26 | # Space is tight; get rid of the compressed kernel source
27 | rm -r kernel_src.tbz2
28 | cd kernel/kernel-4.9
29 | # Copy over the module symbols
30 | # These should be part of the default rootfs
31 | # When the kernel itself is compiled, it should generate its own Module.symvers and place it here
32 | cp /usr/src/linux-headers-4.9.253-tegra-ubuntu18.04_aarch64/kernel-4.9/Module.symvers .
33 | # Go get the current kernel config file; this becomes the base system configuration
34 | zcat /proc/config.gz > .config
35 | # Make a backup of the original configuration
36 | cp .config config.orig
37 | # Default to the current local version
38 | KERNEL_VERSION=$(uname -r)
39 | # For L4T 32.6.1 the kernel is 4.9.253-tegra ;
40 | # Everything after '4.9.253' is the local version
41 | # This removes the suffix
42 | LOCAL_VERSION=${KERNEL_VERSION#$"4.9.253"}
43 | # Should be "-tegra"
44 | bash scripts/config --file .config \
45 | --set-str LOCALVERSION $LOCAL_VERSION
46 |
47 |
--------------------------------------------------------------------------------
/scripts/jetson_variables.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # This file is part of the jetson_stats package (https://github.com/rbonghi/jetson_stats or http://rnext.it).
3 | # Copyright (c) 2020 Raffaello Bonghi.
4 | #
5 | # This program is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU Affero General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # This program is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU Affero General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU Affero General Public License
16 | # along with this program. If not, see .
17 |
18 |
19 | # TODO Add enviroments variables:
20 | # - UID -> https://devtalk.nvidia.com/default/topic/996988/jetson-tk1/chip-uid/post/5100481/#5100481
21 | # - GCID, BOARD, EABI
22 |
23 | ###########################
24 | #### JETPACK DETECTION ####
25 | ###########################
26 | # Write version of jetpack installed
27 | # https://developer.nvidia.com/embedded/jetpack-archive
28 | jetson_jetpack()
29 | {
30 | local JETSON_L4T=$1
31 | local JETSON_JETPACK=""
32 | case $JETSON_L4T in
33 | "35.1.0") JETSON_JETPACK="5.0.2" ;;
34 | "34.1.1") JETSON_JETPACK="5.0.1 DP" ;;
35 | "34.1.0") JETSON_JETPACK="5.0 DP" ;;
36 | "32.7.2") JETSON_JETPACK="4.6.2" ;;
37 | "32.7.1") JETSON_JETPACK="4.6.1" ;;
38 | "32.6.1") JETSON_JETPACK="4.6" ;;
39 | "32.5.1" | "32.5.2") JETSON_JETPACK="4.5.1" ;;
40 | "32.5.0" | "32.5") JETSON_JETPACK="4.5" ;;
41 | "32.4.4") JETSON_JETPACK="4.4.1" ;;
42 | "32.4.3") JETSON_JETPACK="4.4" ;;
43 | "32.4.2") JETSON_JETPACK="4.4 DP" ;;
44 | "32.3.1") JETSON_JETPACK="4.3" ;;
45 | "32.2.3") JETSON_JETPACK="4.2.3" ;;
46 | "32.2.1") JETSON_JETPACK="4.2.2" ;;
47 | "32.2.0" | "32.2") JETSON_JETPACK="4.2.1" ;;
48 | "32.1.0" | "32.1") JETSON_JETPACK="4.2" ;;
49 | "31.1.0" | "31.1") JETSON_JETPACK="4.1.1" ;;
50 | "31.0.2") JETSON_JETPACK="4.1" ;;
51 | "31.0.1") JETSON_JETPACK="4.0" ;;
52 | "28.4.0") JETSON_JETPACK="3.3.3" ;;
53 | "28.2.1") JETSON_JETPACK="3.3 | 3.2.1" ;;
54 | "28.2.0" | "28.2") JETSON_JETPACK="3.2" ;;
55 | "28.1.0" | "28.1") JETSON_JETPACK="3.1" ;;
56 | "27.1.0" | "27.1") JETSON_JETPACK="3.0" ;;
57 | "24.2.1") JETSON_JETPACK="3.0 | 2.3.1" ;;
58 | "24.2.0" | "24.2") JETSON_JETPACK="2.3" ;;
59 | "24.1.0" | "24.1") JETSON_JETPACK="2.2.1 | 2.2" ;;
60 | "23.2.0" | "23.2") JETSON_JETPACK="2.1" ;;
61 | "23.1.0" | "23.1") JETSON_JETPACK="2.0" ;;
62 | "21.5.0" | "21.5") JETSON_JETPACK="2.3.1 | 2.3" ;;
63 | "21.4.0" | "21.4") JETSON_JETPACK="2.2 | 2.1 | 2.0 | 1.2 DP" ;;
64 | "21.3.0" | "21.3") JETSON_JETPACK="1.1 DP" ;;
65 | "21.2.0" | "21.2") JETSON_JETPACK="1.0 DP" ;;
66 | *) JETSON_JETPACK="UNKNOWN" ;;
67 | esac
68 | # return type jetpack
69 | echo $JETSON_JETPACK
70 | }
71 | ###########################
72 |
73 | JETSON_MODEL="UNKNOWN"
74 | # Extract jetson model name
75 | if [ -f /sys/firmware/devicetree/base/model ]; then
76 | JETSON_MODEL=$(tr -d '\0' < /sys/firmware/devicetree/base/model)
77 | fi
78 |
79 | # Extract jetson chip id
80 | JETSON_CHIP_ID=""
81 | if [ -f /sys/module/tegra_fuse/parameters/tegra_chip_id ]; then
82 | JETSON_CHIP_ID=$(cat /sys/module/tegra_fuse/parameters/tegra_chip_id)
83 | fi
84 | # Ectract type board
85 | JETSON_SOC=""
86 | if [ -f /proc/device-tree/compatible ]; then
87 | # Extract the last part of name
88 | JETSON_SOC=$(tr -d '\0' < /proc/device-tree/compatible | sed -e 's/.*,//')
89 | fi
90 | # Extract boardids if exists
91 | JETSON_BOARDIDS=""
92 | if [ -f /proc/device-tree/nvidia,boardids ]; then
93 | JETSON_BOARDIDS=$(tr -d '\0' < /proc/device-tree/nvidia,boardids)
94 | fi
95 |
96 | # Code name
97 | JETSON_CODENAME=""
98 | JETSON_MODULE="UNKNOWN"
99 | JETSON_CARRIER="UNKNOWN"
100 | list_hw_boards()
101 | {
102 | # Extract from DTS the name of the boards available
103 | # Reference:
104 | # 1. https://unix.stackexchange.com/questions/251013/bash-regex-capture-group
105 | # 2. https://unix.stackexchange.com/questions/144298/delete-the-last-character-of-a-string-using-string-manipulation-in-shell-script
106 | local s=$1
107 | local regex='p([0-9-]+)' # Equivalent to p([\d-]*-)
108 | while [[ $s =~ $regex ]]; do
109 | local board_name=$(echo "P${BASH_REMATCH[1]}" | sed 's/-*$//' )
110 | # Load jetson type
111 | # If jetson type is not empty the module name is the same
112 | if [ $JETSON_MODULE = "UNKNOWN" ] ; then
113 | JETSON_MODULE=$board_name
114 | echo "JETSON_MODULE=\"$JETSON_MODULE\""
115 | else
116 | JETSON_CARRIER=$board_name
117 | echo "JETSON_CARRIER=\"$JETSON_CARRIER\""
118 | fi
119 | # Find next match
120 | s=${s#*"${BASH_REMATCH[1]}"}
121 | done
122 | }
123 | # Read DTS file
124 | # 1. https://devtalk.nvidia.com/default/topic/1071080/jetson-nano/best-way-to-check-which-tegra-board/
125 | # 2. https://devtalk.nvidia.com/default/topic/1014424/jetson-tx2/identifying-tx1-and-tx2-at-runtime/
126 | # 3. https://devtalk.nvidia.com/default/topic/996988/jetson-tk1/chip-uid/post/5100481/#5100481
127 | if [ -f /proc/device-tree/nvidia,dtsfilename ]; then
128 | # ../hardware/nvidia/platform/t210/porg/kernel-dts/tegra210-p3448-0000-p3449-0000-b00.dts
129 | # The last third is the codename of the board
130 | JETSON_CODENAME=$(tr -d '\0' < /proc/device-tree/nvidia,dtsfilename)
131 | JETSON_CODENAME=$(echo ${JETSON_CODENAME#*"/hardware/nvidia/platform/"} | tr '/' '\n' | head -2 | tail -1 )
132 | # The basename extract the board type
133 | JETSON_DTS="$(tr -d '\0' < /proc/device-tree/nvidia,dtsfilename | sed 's/.*\///')"
134 | # List of all boards
135 | eval $(list_hw_boards "$JETSON_DTS")
136 | fi
137 |
138 | # Export variables
139 | export JETSON_MODEL
140 | export JETSON_CHIP_ID
141 | export JETSON_SOC
142 | export JETSON_BOARDIDS
143 | export JETSON_CODENAME
144 | export JETSON_MODULE
145 | export JETSON_CARRIER
146 |
147 | # Write CUDA architecture
148 | # https://developer.nvidia.com/cuda-gpus
149 | # https://devtalk.nvidia.com/default/topic/988317/jetson-tx1/what-should-be-the-value-of-cuda_arch_bin/
150 | case $JETSON_MODEL in
151 | *Orin*) JETSON_CUDA_ARCH_BIN="8.7" ;;
152 | *Xavier*) JETSON_CUDA_ARCH_BIN="7.2" ;;
153 | *TX2*) JETSON_CUDA_ARCH_BIN="6.2" ;;
154 | *TX1* | *Nano*) JETSON_CUDA_ARCH_BIN="5.3" ;;
155 | *TK1*) JETSON_CUDA_ARCH_BIN="3.2" ;;
156 | * ) JETSON_CUDA_ARCH_BIN="NONE" ;;
157 | esac
158 | # Export Jetson CUDA ARCHITECTURE
159 | export JETSON_CUDA_ARCH_BIN
160 |
161 | # Serial number
162 | # https://devtalk.nvidia.com/default/topic/1055507/jetson-nano/nano-serial-number-/
163 | JETSON_SERIAL_NUMBER=""
164 | if [ -f /sys/firmware/devicetree/base/serial-number ]; then
165 | JETSON_SERIAL_NUMBER=$(tr -d '\0' &2
25 | echo "Retrying ... "
26 | # Single thread this time
27 | make Image
28 | if [ $? -eq 0 ] ; then
29 | echo "Image make successful"
30 | echo "Image file is here: "
31 | echo "$SOURCE_TARGET""kernel/kernel-4.9/arch/arm64/boot/Image"
32 | else
33 | # Try to make again
34 | echo "Make did not successfully build" >&2
35 | echo "Please fix issues and retry build"
36 | exit 1
37 | fi
38 | fi
39 |
40 |
41 |
--------------------------------------------------------------------------------
/scripts/makeModules.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Builds modules and installs them
3 | # Assumes that the .config file is available in /proc/config.gz
4 | # Added check to see if make builds correctly; retry once if not
5 |
6 | echo "Source Target: "$SOURCE_TARGET
7 |
8 | MAKE_DIRECTORY="$SOURCE_TARGET"kernel/kernel-4.9
9 |
10 | cd "$SOURCE_TARGET"kernel/kernel-4.9
11 | # Get the number of CPUs
12 | NUM_CPU=$(nproc)
13 |
14 | # Make the kernel Image
15 | time make -j$(($NUM_CPU - 1)) modules
16 | if [ $? -eq 0 ] ; then
17 | echo "Modules make successful"
18 | else
19 | # Try to make again; Sometimes there are issues with the build
20 | # because of lack of resources or concurrency issues
21 | echo "Make did not build " >&2
22 | echo "Retrying ... "
23 | # Single thread this time
24 | make modules
25 | if [ $? -eq 0 ] ; then
26 | echo "Module make successful"
27 | else
28 | # Try to make again
29 | echo "Make did not successfully build modules" >&2
30 | echo "Please fix issues and retry build"
31 | exit 1
32 | fi
33 | fi
34 |
35 | make modules_install
36 |
37 |
38 |
--------------------------------------------------------------------------------
/scripts/removeAllKernelSources.sh:
--------------------------------------------------------------------------------
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 public_sources.tbz2
7 |
8 |
--------------------------------------------------------------------------------