From 23bc693c653a950da87e2bc810a1ad1f29a9d947 Mon Sep 17 00:00:00 2001 From: jetsonhacks Date: Sun, 5 Jan 2020 15:05:05 -0800 Subject: [PATCH 1/2] L4T 32.3.1 --- LICENSE | 2 +- editConfig.sh | 50 ++++++++++ getKernelSources.sh | 156 +++++++++++++++++++++++++----- getKernelSourcesNoGUI.sh | 33 ------- makeKernel.sh | 50 +++++++++- makeModules.sh | 51 ++++++++++ scripts/getKernelSources.sh | 42 +++++++-- scripts/getKernelSourcesNoGUI.sh | 14 --- scripts/jetson_variables LICENSE | 22 ----- scripts/jetson_variables.sh | 157 ------------------------------- scripts/makeKernel.sh | 39 +++----- scripts/makeModules.sh | 37 ++++++++ 12 files changed, 372 insertions(+), 281 deletions(-) create mode 100755 editConfig.sh delete mode 100755 getKernelSourcesNoGUI.sh create mode 100755 makeModules.sh delete mode 100755 scripts/getKernelSourcesNoGUI.sh delete mode 100644 scripts/jetson_variables LICENSE delete mode 100755 scripts/jetson_variables.sh create mode 100755 scripts/makeModules.sh diff --git a/LICENSE b/LICENSE index 1a6a38d..1358616 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2017-19 Jetsonhacks +Copyright (c) 2017-20 Jetsonhacks Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/editConfig.sh b/editConfig.sh new file mode 100755 index 0000000..89c7dc2 --- /dev/null +++ b/editConfig.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# Edit the kernel configuration for NVIDIA Jetson TX2 Development Kit +# Copyright (c) 2016-20 Jetsonhacks +# MIT License + +SOURCE_TARGET="/usr/src" +KERNEL_RELEASE="4.9" + +function usage +{ + echo "usage: ./editConfig.sh [[-d directory ] | [-h]]" + echo "-d | --directory Directory path to parent of kernel" + echo "-h | --help This message" +} + +# Iterate through command line inputs +while [ "$1" != "" ]; do + case $1 in + -d | --directory ) shift + SOURCE_TARGET=$1 + ;; + -h | --help ) usage + exit + ;; + * ) usage + exit 1 + esac + shift +done + +LAST="${SOURCE_TARGET: -1}" +if [ $LAST != '/' ] ; then + SOURCE_TARGET="$SOURCE_TARGET""/" +fi + +# Check to see if source tree is already installed +PROPOSED_SRC_PATH="$SOURCE_TARGET""kernel/kernel-"$KERNEL_RELEASE +echo "Proposed source path: ""$PROPOSED_SRC_PATH" +if [ ! -d "$PROPOSED_SRC_PATH" ]; then + tput setaf 1 + echo "==== Cannot find kernel source! =============== " + tput sgr0 + echo "The kernel source does not appear to be installed at: " + echo " ""$PROPOSED_SRC_PATH" + echo "Unable to edit kernel configuration." + exit 1 +fi + +cd "$PROPOSED_SRC_PATH" +sudo make menuconfig diff --git a/getKernelSources.sh b/getKernelSources.sh index 94d57ac..25beb50 100755 --- a/getKernelSources.sh +++ b/getKernelSources.sh @@ -1,34 +1,148 @@ #!/bin/bash -# Install the kernel source for L4T -source scripts/jetson_variables.sh -#Print Jetson version -echo "$JETSON_DESCRIPTION" -#Print Jetpack version -echo "Jetpack $JETSON_JETPACK [L4T $JETSON_L4T]" +# Get the kernel source for NVIDIA Jetson Nano Developer Kit, L4T +# Copyright (c) 2016-2020 Jetsonhacks +# MIT License + +JETSON_MODEL="TX2" +L4T_TARGET="32.3.1" +SOURCE_TARGET="/usr/src" +KERNEL_RELEASE="4.9" + +#Get the Board Model +JETSON_BOARD="UNKNOWN" + +if [ -f /sys/module/tegra_fuse/parameters/tegra_chip_id ]; then + JETSON_BOARD=$(case $(cat /sys/module/tegra_fuse/parameters/tegra_chip_id) in + 64) + echo TK1 ;; + 33) + echo Nano/TX1 ;; + 24) + echo TX2 ;; + 25) + echo AGX Xavier ;; + esac) + JETSON_DESCRIPTION="NVIDIA Jetson $JETSON_BOARD" +fi +echo "Jetson Model: "$JETSON_BOARD + +JETSON_L4T="" + +# Starting with L4T 32.2, the recommended way to find the L4T Release Number +# is to use dpkg +# L4T 32.3.1, NVIDIA added back /etc/nv_tegra_release +function check_L4T_version() +{ + if [ -f /etc/nv_tegra_release ]; then + JETSON_L4T_STRING=$(head -n 1 /etc/nv_tegra_release) + JETSON_L4T_RELEASE=$(echo $JETSON_L4T_STRING | cut -f 2 -d ' ' | grep -Po '(?<=R)[^;]+') + JETSON_L4T_REVISION=$(echo $JETSON_L4T_STRING | cut -f 2 -d ',' | grep -Po '(?<=REVISION: )[^;]+') + JETSON_L4T_VERSION=$JETSON_L4T_RELEASE.$JETSON_L4T_REVISION + + else + echo "$LOG Reading L4T version from \"dpkg-query --show nvidia-l4t-core\"" + + JETSON_L4T_STRING=$(dpkg-query --showformat='${Version}' --show nvidia-l4t-core) + # For example: 32.2.1-20190812212815 + JETSON_L4T_VERSION=$(echo $JETSON_L4T_STRING | cut -d '-' -f 1) + JETSON_L4T_RELEASE=$(echo $JETSON_L4T_VERSION | cut -d '.' -f 1) + # # operator remove prefix in string operations in bash script. Don't forget . eg "32." + JETSON_L4T_REVISION=${JETSON_L4T_VERSION#$JETSON_L4T_RELEASE.} + fi + echo "$LOG Jetson BSP Version: L4T R$JETSON_L4T_VERSION" + +} + +echo "Getting L4T Version" +check_L4T_version +JETSON_L4T="$JETSON_L4T_VERSION" + +function usage +{ + echo "usage: ./getKernelSources.sh [[-d directory ] | [-h]]" + echo "-h | --help This message" +} + +# Iterate through command line inputs +while [ "$1" != "" ]; do + case $1 in + -d | --directory ) shift + SOURCE_TARGET=$1 + ;; + -h | --help ) usage + exit + ;; + * ) usage + exit 1 + esac + shift +done + +red=`tput setaf 1` +green=`tput setaf 2` +reset=`tput sgr0` +# e.g. echo "${red}The red tail hawk ${green}loves the green grass${reset}" + +LAST="${SOURCE_TARGET: -1}" +if [ $LAST != '/' ] ; then + SOURCE_TARGET="$SOURCE_TARGET""/" +fi + +INSTALL_DIR=$PWD + +# Error out if something goes wrong +set -e # Check to make sure we're installing the correct kernel sources -L4TTarget="32.1.0" -if [ $JETSON_L4T == $L4TTarget ] ; then - echo "Getting kernel sources" - sudo ./scripts/getKernelSources.sh -else +# Determine the correct kernel version +# The KERNEL_BUILD_VERSION is the release tag for the JetsonHacks buildKernel repository +KERNEL_BUILD_VERSION=master +if [ "$JETSON_BOARD" == "$JETSON_MODEL" ] ; then + if [ $JETSON_L4T == "$L4T_TARGET" ] ; then + KERNEL_BUILD_VERSION=$L4T_TARGET + else echo "" tput setaf 1 echo "==== L4T Kernel Version Mismatch! =============" tput sgr0 echo "" - echo "This repository branch is for installing the kernel sources for L4T "$L4TTarget - echo "You are attempting to use these kernel sources on a L4T "$JETSON_L4T "system." - echo "The kernel sources do not match their L4T release!" + echo "This repository is for modifying the kernel for a L4T "$L4T_TARGET "system." + echo "You are attempting to modify a L4T "$JETSON_MODEL "system with L4T "$JETSON_L4T + echo "The L4T releases must match!" echo "" - echo "Please git checkout the appropriate kernel sources for your release" - echo " " - echo "You can list the tagged versions." - echo "$ git tag -l" - echo "And then checkout the latest version: " - echo "For example" - echo "$ git checkout v1.0-L4T"$JETSON_L4T + echo "There may be versions in the tag/release sections that meet your needs" echo "" + exit 1 + fi +else + tput setaf 1 + echo "==== Jetson Board Mismatch! =============" + tput sgr0 + echo "Currently this script works for the $JETSON_MODEL." + echo "This processor appears to be a $JETSON_BOARD, which does not have a corresponding script" + echo "" + echo "Exiting" + exit 1 fi +# Check to see if source tree is already installed +PROPOSED_SRC_PATH="$SOURCE_TARGET""kernel/kernel-"$KERNEL_RELEASE +echo "Proposed source path: ""$PROPOSED_SRC_PATH" +if [ -d "$PROPOSED_SRC_PATH" ]; then + tput setaf 1 + echo "==== Kernel source appears to already be installed! =============== " + tput sgr0 + echo "The kernel source appears to already be installed at: " + echo " ""$PROPOSED_SRC_PATH" + echo "If you want to reinstall the source files, first remove the directories: " + echo " ""$SOURCE_TARGET""kernel" + echo " ""$SOURCE_TARGET""hardware" + echo "then rerun this script" + exit 1 +fi + +export SOURCE_TARGET +# -E preserves environment variables +sudo -E ./scripts/getKernelSources.sh + diff --git a/getKernelSourcesNoGUI.sh b/getKernelSourcesNoGUI.sh deleted file mode 100755 index 0a49e54..0000000 --- a/getKernelSourcesNoGUI.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash -# Install the kernel source for L4T -source scripts/jetson_variables.sh -#Print Jetson version -echo "$JETSON_DESCRIPTION" -#Print Jetpack version -echo "Jetpack $JETSON_JETPACK [L4T $JETSON_L4T]" - -# Check to make sure we're installing the correct kernel sources -L4TTarget="32.1.0" -if [ $JETSON_L4T == $L4TTarget ] ; then - echo "Getting kernel sources" - sudo ./scripts/getKernelSourcesNoGUI.sh -else - echo "" - tput setaf 1 - echo "==== L4T Kernel Version Mismatch! =============" - tput sgr0 - echo "" - echo "This repository branch is for installing the kernel sources for L4T "$L4TTarget - echo "You are attempting to use these kernel sources on a L4T "$JETSON_L4T "system." - echo "The kernel sources do not match their L4T release.!" - echo "" - echo "Please git checkout the appropriate kernel sources for your release" - echo " " - echo "You can list the tagged versions." - echo "$ git tag -l" - echo "And then checkout the latest version: " - echo "For example" - echo "$ git checkout v1.0-L4T"$JETSON_L4T - echo "" -fi - diff --git a/makeKernel.sh b/makeKernel.sh index f65d963..28c97df 100755 --- a/makeKernel.sh +++ b/makeKernel.sh @@ -1,3 +1,51 @@ #!/bin/bash -sudo ./scripts/makeKernel.sh +# Make the kernel for NVIDIA Jetson TX2 Developer Kit +# Copyright (c) 2016-20 Jetsonhacks +# MIT License +SOURCE_TARGET="/usr/src" +KERNEL_RELEASE="4.9" + +function usage +{ + echo "usage: ./makeKernel.sh [[-d directory ] | [-h]]" + echo "-d | --directory Directory path to parent of kernel" + echo "-h | --help This message" +} + +# Iterate through command line inputs +while [ "$1" != "" ]; do + case $1 in + -d | --directory ) shift + SOURCE_TARGET=$1 + ;; + -h | --help ) usage + exit + ;; + * ) usage + exit 1 + esac + shift +done + +LAST="${SOURCE_TARGET: -1}" +if [ $LAST != '/' ] ; then + SOURCE_TARGET="$SOURCE_TARGET""/" +fi + +# Check to see if source tree is already installed +PROPOSED_SRC_PATH="$SOURCE_TARGET""kernel/kernel-"$KERNEL_RELEASE +echo "Proposed source path: ""$PROPOSED_SRC_PATH" +if [ ! -d "$PROPOSED_SRC_PATH" ]; then + tput setaf 1 + echo "==== Cannot find kernel source! =============== " + tput sgr0 + echo "The kernel source does not appear to be installed at: " + echo " ""$PROPOSED_SRC_PATH" + echo "Unable to start making kernel." + exit 1 +fi + +export SOURCE_TARGET +# E Option carries over environment variables +sudo -E ./scripts/makeKernel.sh diff --git a/makeModules.sh b/makeModules.sh new file mode 100755 index 0000000..3065a3c --- /dev/null +++ b/makeModules.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# Make kernel modules for NVIDIA Jetson TX2 Developer Kit +# Copyright (c) 2016-20 Jetsonhacks +# MIT License + +SOURCE_TARGET="/usr/src" +KERNEL_RELEASE="4.9" + +function usage +{ + echo "usage: ./makeModules.sh [[-d directory ] | [-h]]" + echo "-d | --directory Directory path to parent of kernel" + echo "-h | --help This message" +} + +# Iterate through command line inputs +while [ "$1" != "" ]; do + case $1 in + -d | --directory ) shift + SOURCE_TARGET=$1 + ;; + -h | --help ) usage + exit + ;; + * ) usage + exit 1 + esac + shift +done + +LAST="${SOURCE_TARGET: -1}" +if [ $LAST != '/' ] ; then + SOURCE_TARGET="$SOURCE_TARGET""/" +fi + +# Check to see if source tree is already installed +PROPOSED_SRC_PATH="$SOURCE_TARGET""kernel/kernel-"$KERNEL_RELEASE +echo "Proposed source path: ""$PROPOSED_SRC_PATH" +if [ ! -d "$PROPOSED_SRC_PATH" ]; then + tput setaf 1 + echo "==== Cannot find kernel source! =============== " + tput sgr0 + echo "The kernel source does not appear to be installed at: " + echo " ""$PROPOSED_SRC_PATH" + echo "Unable to start making kernel." + exit 1 +fi + +export SOURCE_TARGET +# E Option carries over environment variables +sudo -E ./scripts/makeModules.sh diff --git a/scripts/getKernelSources.sh b/scripts/getKernelSources.sh index 3abdcd4..24b4c1b 100755 --- a/scripts/getKernelSources.sh +++ b/scripts/getKernelSources.sh @@ -1,8 +1,38 @@ #!/bin/bash -# Get the source ; -source scripts/getKernelSourcesNoGUI.sh -# We use QT 5 for the configuration GUI -apt-get install qt5-default -y -cd /usr/src/kernel/kernel-4.9 -make xconfig +# Get Kernel sources for NVIDIA Jetson TX2 +apt-add-repository universe +apt-get update +apt-get install pkg-config -y +# We use 'make menuconfig' to edit the .config file; install dependencies +apt-get install libncurses5-dev -y +echo "Installing kernel sources in: ""$SOURCE_TARGET" +if [ ! -d "$SOURCE_TARGET" ]; then + # Target directory does not exist; create + echo "Creating directory: ""$SOURCE_TARGET" + mkdir -p "$SOURCE_TARGET" +fi + +cd "$SOURCE_TARGET" +echo "$PWD" + +wget -N https://developer.nvidia.com/embedded/dlc/r32-3-1_Release_v1.0/Sources/T186/public_sources.tbz2 +# l4t-sources is a tbz2 file +tar -xvf public_sources.tbz2 Linux_for_Tegra/source/public/kernel_src.tbz2 --strip-components=3 +tar -xvf kernel_src.tbz2 +# Space is tight; get rid of the compressed kernel source +rm -r kernel_src.tbz2 +cd kernel/kernel-4.9 +# Go get the default config file; this becomes the new system configuration +zcat /proc/config.gz > .config +# Make a backup of the original configuration +cp .config config.orig +# Default to the current local version +KERNEL_VERSION=$(uname -r) +# For L4T 32.3 the kernel is 4.9.140-tegra ; +# Everything after '4.9.140' is the local version +# This removes the suffix +LOCAL_VERSION=${KERNEL_VERSION#$"4.9.140"} +# Should be "-tegra" +bash scripts/config --file .config \ + --set-str LOCALVERSION $LOCAL_VERSION diff --git a/scripts/getKernelSourcesNoGUI.sh b/scripts/getKernelSourcesNoGUI.sh deleted file mode 100755 index 1d75c38..0000000 --- a/scripts/getKernelSourcesNoGUI.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -apt-add-repository universe -apt-get update -apt-get install pkg-config -y -cd /usr/src -wget -N https://developer.download.nvidia.com/embedded/L4T/r32_Release_v1.0/jax-tx2/BSP/JAX-TX2-public_sources.tbz2 -sudo tar -xvf JAX-TX2-public_sources.tbz2 public_sources/kernel_src.tbz2 -tar -xvf public_sources/kernel_src.tbz2 -# Space is tight; get rid of the compressed kernel source -rm -r public_sources -cd kernel/kernel-4.9 -# Go get the default config file; this becomes the new system configuration -zcat /proc/config.gz > .config - diff --git a/scripts/jetson_variables LICENSE b/scripts/jetson_variables LICENSE deleted file mode 100644 index 14f9f37..0000000 --- a/scripts/jetson_variables LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015-19 Raffaello Bonghi - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - diff --git a/scripts/jetson_variables.sh b/scripts/jetson_variables.sh deleted file mode 100755 index dfc2977..0000000 --- a/scripts/jetson_variables.sh +++ /dev/null @@ -1,157 +0,0 @@ -#!/bin/bash -# Copyright (C) 2018, Raffaello Bonghi -# All rights reserved -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. Neither the name of the copyright holder nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, -# BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -# NVIDIA Identify version -# reference: -# https://devtalk.nvidia.com/default/topic/1014424/jetson-tx2/identifying-tx1-and-tx2-at-runtime/ -# https://devtalk.nvidia.com/default/topic/996988/jetson-tk1/chip-uid/post/5100481/#5100481 - -if [ -f /sys/module/tegra_fuse/parameters/tegra_chip_id ]; then - case $(cat /sys/module/tegra_fuse/parameters/tegra_chip_id) in - 64) - JETSON_BOARD="TK1" ;; - 33) - JETSON_BOARD="TX1" ;; - 24) - JETSON_BOARD="TX2" ;; - *) - JETSON_BOARD="UNKNOWN" ;; - esac - JETSON_DESCRIPTION="NVIDIA Jetson $JETSON_BOARD" -fi -export JETSON_BOARD - -# NVIDIA Jetson version -# reference https://devtalk.nvidia.com/default/topic/860092/jetson-tk1/how-do-i-know-what-version-of-l4t-my-jetson-tk1-is-running-/ -if [ -f /etc/nv_tegra_release ]; then - # L4T string - JETSON_L4T_STRING=$(head -n 1 /etc/nv_tegra_release) - - # Load release and revision - JETSON_L4T_RELEASE=$(echo $JETSON_L4T_STRING | cut -f 1 -d ',' | sed 's/\# R//g' | cut -d ' ' -f1) - JETSON_L4T_REVISION=$(echo $JETSON_L4T_STRING | cut -f 2 -d ',' | sed 's/\ REVISION: //g' ) - # unset variable - unset JETSON_L4T_STRING - - # Write Jetson description - JETSON_L4T="$JETSON_L4T_RELEASE.$JETSON_L4T_REVISION" - - # Write version of jetpack installed - # https://developer.nvidia.com/embedded/jetpack-archive - if [ "$JETSON_BOARD" = "TX2i" ] ; then - case $JETSON_L4T in - "32.1.0") - JETSON_JETPACK="4.2" ;; - "28.2.1") - JETSON_JETPACK="3.2.1" ;; - "28.2") - JETSON_JETPACK="3.2" ;; - *) - JETSON_JETPACK="UNKNOWN" ;; - esac - elif [ "$JETSON_BOARD" = "TX2" ] ; then - case $JETSON_L4T in - "32.1.0") - JETSON_JETPACK="4.2" ;; - "28.2.1") - JETSON_JETPACK="3.2.1" ;; - "28.2") - JETSON_JETPACK="3.2" ;; - "28.1") - JETSON_JETPACK="3.1" ;; - "27.1") - JETSON_JETPACK="3.0" ;; - *) - JETSON_JETPACK="UNKNOWN" ;; - esac - elif [ "$JETSON_BOARD" = "TX1" ] ; then - case $JETSON_L4T in - "28.2") - JETSON_JETPACK="3.2 or 3.2.1" ;; - "28.1") - JETSON_JETPACK="3.1" ;; - "24.2.1") - JETSON_JETPACK="3.0 or 2.3.1" ;; - "24.2") - JETSON_JETPACK="2.3" ;; - "24.1") - JETSON_JETPACK="2.2.1 or 2.2" ;; - "23.2") - JETSON_JETPACK="2.1" ;; - "23.1") - JETSON_JETPACK="2.0" ;; - *) - JETSON_JETPACK="UNKNOWN" ;; - esac - elif [ "$JETSON_BOARD" ="TK1" ] ; then - case $JETSON_L4T in - "21.5") - JETSON_JETPACK="2.3.1 or 2.3" ;; - "21.4") - JETSON_JETPACK="2.2 or 2.1 or 2.0 or DP 1.2" ;; - "21.3") - JETSON_JETPACK="DP 1.1" ;; - "21.2") - JETSON_JETPACK="DP 1.0" ;; - *) - JETSON_JETPACK="UNKNOWN" ;; - esac - else - # Unknown board - JETSON_JETPACK="UNKNOWN" - fi -fi - -# Read CUDA version -if [ -f /usr/local/cuda/version.txt ]; then - JETSON_CUDA=$(cat /usr/local/cuda/version.txt | sed 's/\CUDA Version //g') -else - JETSON_CUDA="NOT INSTALLED" -fi - -# Read opencv version -pkg-config --exists opencv -if [ $? == "0" ] ; then - JETSON_OPENCV=$(pkg-config --modversion opencv) -else - JETSON_OPENCV="NOT INSTALLED" -fi - -export JETSON_BOARD -export JETSON_CUDA -export JETSON_JETPACK -export JETSON_L4T - -# TODO Add enviroments variables: -# - UID -> https://devtalk.nvidia.com/default/topic/996988/jetson-tk1/chip-uid/post/5100481/#5100481 -# - GCID, BOARD, EABI -# - cuDNN -# - TensorRT -# - Visionworks - diff --git a/scripts/makeKernel.sh b/scripts/makeKernel.sh index e006418..57c2b75 100755 --- a/scripts/makeKernel.sh +++ b/scripts/makeKernel.sh @@ -1,17 +1,23 @@ #!/bin/bash -# Builds the kernel and modules +# Builds modules and installs them # Assumes that the .config file is available in /proc/config.gz # Added check to see if make builds correctly; retry once if not -cd /usr/src/kernel/kernel-4.9 -make prepare -make modules_prepare -# Make alone will build the dts files too +echo "Source Target: "$SOURCE_TARGET + +MAKE_DIRECTORY="$SOURCE_TARGET"kernel/kernel-4.9 + +cd "$SOURCE_TARGET"kernel/kernel-4.9 +# make prepare # Get the number of CPUs NUM_CPU=$(nproc) + +# Make the kernel Image time make -j$(($NUM_CPU - 1)) Image if [ $? -eq 0 ] ; then echo "Image make successful" + echo "Image file is here: " + echo "$SOURCE_TARGET""kernel/kernel-4.9/arch/arm64/boot/Image" else # Try to make again; Sometimes there are issues with the build # because of lack of resources or concurrency issues @@ -21,6 +27,8 @@ else make Image if [ $? -eq 0 ] ; then echo "Image make successful" + echo "Image file is here: " + echo "$SOURCE_TARGET""kernel/kernel-4.9/arch/arm64/boot/Image" else # Try to make again echo "Make did not successfully build" >&2 @@ -29,25 +37,4 @@ else fi fi -time make -j$(($NUM_CPU - 1)) modules -if [ $? -eq 0 ] ; then - echo "Modules make successful" -else - # Try to make again; Sometimes there are issues with the build - # because of lack of resources or concurrency issues - echo "Make did not build " >&2 - echo "Retrying ... " - # Single thread this time - make modules - if [ $? -eq 0 ] ; then - echo "Module make successful" - else - # Try to make again - echo "Make did not successfully build" >&2 - echo "Please fix issues and retry build" - exit 1 - fi -fi - -make modules_install diff --git a/scripts/makeModules.sh b/scripts/makeModules.sh new file mode 100755 index 0000000..e3cddbb --- /dev/null +++ b/scripts/makeModules.sh @@ -0,0 +1,37 @@ +#!/bin/bash +# Builds modules and installs them +# Assumes that the .config file is available in /proc/config.gz +# Added check to see if make builds correctly; retry once if not + +echo "Source Target: "$SOURCE_TARGET + +MAKE_DIRECTORY="$SOURCE_TARGET"kernel/kernel-4.9 + +cd "$SOURCE_TARGET"kernel/kernel-4.9 +# Get the number of CPUs +NUM_CPU=$(nproc) + +# Make the kernel Image +time make -j$(($NUM_CPU - 1)) modules +if [ $? -eq 0 ] ; then + echo "Modules make successful" +else + # Try to make again; Sometimes there are issues with the build + # because of lack of resources or concurrency issues + echo "Make did not build " >&2 + echo "Retrying ... " + # Single thread this time + make modules + if [ $? -eq 0 ] ; then + echo "Module make successful" + else + # Try to make again + echo "Make did not successfully build modules" >&2 + echo "Please fix issues and retry build" + exit 1 + fi +fi + +make modules_install + + From 6351a9f68aa1dc5a2c4184d25be9e315ec692812 Mon Sep 17 00:00:00 2001 From: Jetsonhacks Date: Sun, 5 Jan 2020 17:46:48 -0800 Subject: [PATCH 2/2] Update README for L4T 32.3.1 --- README.md | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 56c6630..b6dcae0 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,46 @@ # buildJetsonTX2Kernel -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. +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. -Note: 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. +Note: 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. + +Note: 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. 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. -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: +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: getKernelSources.sh -Downloads the kernel sources for L4T from the NVIDIA website, decompresses them and opens a graphical editor on the .config file. +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 -getKernelSourcesNoGUI.sh +makeKernel.sh -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. +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. +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. -makeKernel.sh +makeModules.sh -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. +Compiles the modules using make and then installs them. copyImage.sh 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. +You will want to make a copy of the original Image before the copy, something like: + +``` +$ cp /boot/Image $INSTALL_DIR/Image.orig +$ ./copyImage.sh +$ echo "New Image created and placed in /boot" +``` + +editConfig.sh + +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. + removeAllKernelSources.sh + Removes all of the kernel sources and compressed source files. You may want to make a backup of the files before deletion. @@ -39,6 +55,11 @@ Special thanks to Shreeyak (https://github.com/Shreeyak) for discussing alternat Special thanks to Alexander Rashed (@alexrashed on Github) for vL4T32.1.0 release ### Release Notes + +January, 2020 +* vL4T32.3.1 +* L4T 32.3.1 (JetPack 4.3) + May, 2019 * vL4T32.1.0 * L4T 32.1.0 (JetPack 4.2) @@ -79,7 +100,7 @@ March, 2017 ## License MIT License -Copyright (c) 2017-2018 Jetsonhacks +Copyright (c) 2017-2020 Jetsonhacks Portions Copyright (c) 2015-2018 Raffaello Bonghi (jetson_easy) Permission is hereby granted, free of charge, to any person obtaining a copy