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

Commit

Permalink
Merge pull request #12 from jetsonhacks/development
Browse files Browse the repository at this point in the history
Development for L4T 28.2
  • Loading branch information
jetsonhacks authored Apr 21, 2018
2 parents 6273157 + 0fa70d7 commit 7f51221
Show file tree
Hide file tree
Showing 17 changed files with 354 additions and 45 deletions.
80 changes: 68 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,92 @@
# buildJetsonTX1Kernel
Scripts to help build the 4.4.38 kernel and modules onboard the Jetson TX1 (L4T 28.1, JetPack 3.1). For previous versions, visit the 'tags' section.
Scripts to help build the 4.4.38 kernel and modules onboard the Jetson TX1 (L4T 28.2, JetPack 3.2). For previous versions, visit the 'tags' section.

<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.4.38 kernel here is matched with L4T 28.1. This kernel compiled using this source tree will not work with newer versions or older versions of L4T, only 28.1.</em>
<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.4.38 kernel here is matched with L4T 28.2. This kernel compiled using this source tree will not work with newer versions or older versions of L4T, only 28.2.</em>


As of this writing, the "official" way to build the Jetson TX1 kernel is to use a cross compiler on a Linux PC. These scripts are an alternative which builds the kernel onboard the Jetson itself. These scripts will download the kernel source to the Jetson TX1, wrangle some of the Makefiles to make them work on the Jetson, and then compile the kernel and selected modules. The newly compiled kernel can then be installed.
As of this writing, the "official" way to build the Jetson TX1 kernel is to use a cross compiler on a Linux PC. These scripts are an alternative which builds the kernel onboard the Jetson itself. These scripts will download the kernel source to the Jetson TX1 and then compile the kernel and selected modules. The newly compiled kernel can then be installed.

WARNING: After flashing the Jetson TX1, there is a limited amount of room on the device. After completing these scripts there will be NO space on the device. You MUST remove some of the files that were added in the /usr/src directory. You should store the /usr/src/kernel directory offboard (like on a SATA drive or USB stick) along with the compressed sources before deleting them. You may want to use them again later.
<strong>WARNING:</strong> After flashing the Jetson TX1, there is a limited amount of room on the device. You should modify the kernel directly after flashing the device. After completing these scripts there will be little space left on the device. After building the kernel and modules, you should remove some of the files that were added in the /usr/src directory. You may want to store the /usr/src/kernel directory offboard (like on a SATA drive or USB stick) along with the compressed sources before deleting them as you may want to use them again later.

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

<strong>getKernelSources.sh</strong>

Downloads the kernel sources for L4T 28.1 from the NVIDIA website, decompresses them and opens a graphical editor on the .config file.
Downloads the kernel sources for L4T 28.2 from the NVIDIA website, decompresses them and opens a graphical editor on the .config file.

<strong>getKernelSourcesNoGUI.sh</strong>

Downloads the kernel sources for L4T 28.2 from the NVIDIA website and decompresses them. This is useful when using SSH, or you prefer a different method of editing the .config file.

<strong>makeKernel.sh</strong>

This script applies a few patches to makefiles in the kernel source, and then compiles the kernel and modules using make.
This script compiles the kernel and modules using make.

<strong>copyImage.sh</strong>

Copies the Image file created by compiling the kernel to the /boot directory
Copies the Image file created by compiling the kernel to the /boot directory. If you modify the kernel, you will probably want to make a copy of the original kernel image (/boot/Image) before copying over the newly generated one. You will also want to modify /boot/extlinux/extlinux.conf so that you can boot from the new Image or the old Image in case something untowards happens. That way, you will be able to select the old Image through the serial console.

<strong>Notes:</strong>
<strong>Note:</strong> The Image file is copied to the boot directory of the current root directory device. The Jetson generally boots from the internal eMMC. If you are developing on external media (such as a SSD or USB drive) you will probably need to manually copy the Image file to the /boot directory of the eMMC. Refer to the script for the location of the Image file in the source tree.

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 work directory 'sources' contains kernel_src-txt1.tbz2, you can remove that directory. The file 'source_release.tbz2' is a much larger file that holds the kernel sources as well as many other TX1 specific source packages. You can make a backup of source_release.tbz2 before deleting it.
<strong>removeAllKernelSources.sh</strong>
Removes all of the kernel sources and compressed source files. You may want to make a backup of the files before deletion.

You may want to save the newly built Image and modules to external media so that can be used to flash a Jetson image, or clone the disk image.

<strong>Notes:</strong>

These scripts make only the kernel Image and Modules. You will need to modify the scripts if more are needed.

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 want to copy the Image file over to the eMMC in the eMMC /boot directory if you are booting from the eMMC and using external storage as your root directory.
<strong>IMPORTANT</strong> 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 want to copy the Image file over to the eMMC in the eMMC /boot directory if you are booting from the eMMC and using external storage as your root directory.

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


### Release Notes
April, 2018
* v1.0-L4T28.2
* L4T 28.2 (JetPack 3.2)
* Add getKernelSourcesNoGUI.sh for cases where the user does not want to edit the .config file through a GUI.
* Add removeAllSources.sh for removing kernel sources and compressed files after the kernel is built.
* Check to make sure that the version of the kernel matches the sources to download

March, 2018
* v1.0-L4T28.1
* L4T 28.1 (JetPack 3.1)

July, 2017
* v1.0-L4T24.2.1
* L4T 24.2.1

April, 2017
* Initial Release
* v1.0-L4T24.2
* L4T 24.2

## License
MIT License

Copyright (c) 2017-2018 Jetsonhacks
Copyright (c) 2015-2018 Raffaello Bonghi (jetson_easy)

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.





Expand Down
19 changes: 18 additions & 1 deletion copyImage.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,19 @@
#!/bin/bash
sudo ./scripts/copyImage.sh
# Check to make sure the Image file has been generated
# The "could not stat" error seems to confuse people
if [ -f /usr/src/kernel/kernel-4.4/arch/arm64/boot/Image ] ; then
echo "Copying Image to /boot diretory"
sudo ./scripts/copyImage.sh
echo "Image copied"
tput setaf 2
echo "Please reboot for changes to take effect"
tput sgr0
else
tput setaf 1
echo "==== Image file does not exist ===="
tput sgr0
echo "Check for errors in makeKernel"
echo ""
echo "Copy failed"
fi

3 changes: 0 additions & 3 deletions diffs/devfreq/devfreq.patch

This file was deleted.

6 changes: 0 additions & 6 deletions diffs/nvgpu/nvgpu.patch

This file was deleted.

3 changes: 0 additions & 3 deletions diffs/tegra-alt/tegra-alt.patch

This file was deleted.

34 changes: 33 additions & 1 deletion getKernelSources.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
#!/bin/bash
# Install the kernel source for L4T
sudo ./scripts/getKernelSources.sh
# Make sure that we are downloading the correct kernel source
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="28.2"
if [ $JETSON_L4T == $L4TTarget ] ; then
echo "Getting kernel sources"
sudo ./scripts/getKernelSources.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


34 changes: 34 additions & 0 deletions getKernelSourcesNoGUI.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
# Install the kernel source for L4T
# Make sure that we are downloading the correct kernel source
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="28.2"
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

1 change: 0 additions & 1 deletion makeKernel.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/bin/bash
sudo ./scripts/fixMakeFiles.sh
sudo ./scripts/makeKernel.sh

7 changes: 7 additions & 0 deletions removeAllKernelSources.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
# Remove all of the kernel sources that were downloaded and built during the kernel build process
# Note that this will also remove the possibly changed .config file in:
# /usr/src/kernel/kernel-4.4
echo "Removing All Kernel Sources"
sudo ./scripts/removeAllKernelSources.sh
echo "Kernel sources removed"
2 changes: 1 addition & 1 deletion scripts/copyImage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ cd /usr/src/kernel/kernel-4.4
# sudo cp arch/arm64/boot/zImage /boot/zImage
# Note that if you are compiling on an external device, like a SSD, you should probably
# copy this over to the internal eMMC if that is where the Jetson boots
sudo cp arch/arm64/boot/Image /boot/Image
cp arch/arm64/boot/Image /boot/Image


10 changes: 0 additions & 10 deletions scripts/fixMakeFiles.sh

This file was deleted.

11 changes: 6 additions & 5 deletions scripts/getKernelSources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ apt-add-repository universe
apt-get update
apt-get install qt5-default pkg-config -y
cd /usr/src
wget http://developer.download.nvidia.com/embedded/L4T/r28_Release_v1.0/BSP/source_release.tbz2
tar -xvf source_release.tbz2 sources/kernel_src-tx1.tbz2
tar -xvf sources/kernel_src-tx1.tbz2
# Space is tight get rid of the compressed kernel source
rm sources/kernel_src-tx1.tbz2
wget -N http://developer.download.nvidia.com/embedded/L4T/r28_Release_v2.0/GA/BSP/tx1_sources.tbz2
echo "Expanding sources, please wait"
tar -xvf tx1_sources.tbz2 public_release/kernel_src.tbz2
tar -xvf public_release/kernel_src.tbz2
# Space is tight; get rid of the compressed kernel source
rm -r public_release
cd kernel/kernel-4.4
zcat /proc/config.gz > .config
make xconfig
Expand Down
14 changes: 14 additions & 0 deletions scripts/getKernelSourcesNoGUI.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
apt-add-repository universe
apt-get update
apt-get install pkg-config -y
cd /usr/src
wget -N http://developer.download.nvidia.com/embedded/L4T/r28_Release_v2.0/GA/BSP/tx1_sources.tbz2
echo "Expanding sources, please wait"
tar -xvf tx1_sources.tbz2 public_release/kernel_src.tbz2
tar -xvf public_release/kernel_src.tbz2
# Space is tight; get rid of the compressed kernel source
rm -r public_release
cd kernel/kernel-4.4
zcat /proc/config.gz > .config

22 changes: 22 additions & 0 deletions scripts/jetson_variables LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2015 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.

Loading

0 comments on commit 7f51221

Please sign in to comment.