Difference between revisions of "NVIDIA Jetson Orin/JetPack 5.0.2/Compiling Code"

From RidgeRun Developer Connection
Jump to: navigation, search
m (Install the Toolchain)
 
(20 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
<noinclude>
 
<noinclude>
{{NVIDIA Jetson Orin/Head|previous=JetPack 5.0‎/Getting_Started/Components|next=JetPack 5.0‎/Compiling Code/Kernel|keywords=jetpack,compiling,compile,building}}
+
{{NVIDIA Jetson Orin/Head|previous=JetPack 5.0‎.2/Getting_Started/Components|next=JetPack_5.0.2/Flashing_Board|metakeywords=jetpack,compiling,compile,building,Jetpack 5.0.2}}
  
</noinclude>
+
{{DISPLAYTITLE:NVIDIA Jetson Orin - Compiling Source Code|noerror}}
<!-- If you want a custom title for the page, un-comment and edit this line:
 
{{DISPLAYTITLE:NVIDIA Jetson Oin - <descriptive page name>|noerror}}
 
-->
 
  
 
Learning to build the BSP and OS components enables developers to customize the software for their specific project needs.
 
Learning to build the BSP and OS components enables developers to customize the software for their specific project needs.
 
<br>
 
<br>
  
 
+
This section will guide you through the process of building the BSP and OS components for the NVIDIA Jetson Orin. For this section you are going to need Jetpack 5.0.2 for Orin AGX installed on your host computer, we assume that you got this installed following through our [[NVIDIA_Jetson_Orin/JetPack_5.0.2/Getting_Started|Getting Started]] and [[NVIDIA_Jetson_Orin/JetPack_5.0.2/Getting_Started/Installing_Jetpack|Installing Jetpack]] sections.
This section will guide you through the process of building the BSP and OS components for the NVIDIA Jetson Orin. For this section you are going to need Jetpack 5.0 for Orin AGX installed on your host computer, we assume that you got this installed following through our [[NVIDIA_Jetson_Orin/JetPack_5.0/Getting_Started|Getting Started]] and [[NVIDIA_Jetson_Orin/JetPack_5.0/Getting_Started/Installing_Jetpack|Installing Jetpack]] sections.
 
 
<br>
 
<br>
  
 
+
==Assumptions==
We divide this section into the following components:
 
 
 
# [[NVIDIA Jetson Orin/JetPack_5.0/Compiling_Code/Kernel | Build the kernel]]
 
# [[NVIDIA Jetson Orin/JetPack_5.0/Compiling_Code/Kernel | Build the dtb]]
 
# [[NVIDIA Jetson Orin/JetPack_5.0/Compiling_Code/Bootloader | Build the bootloader]]
 
# [[NVIDIA Jetson Orin/JetPack_5.0/Compiling_Code/Bootloader | Customize the Root Filesystem]]
 
 
 
 
 
=Assumptions=
 
 
# The build of the BSP/OS components source code will be performed by cross-compiling on a host computer running a Linux OS.
 
# The build of the BSP/OS components source code will be performed by cross-compiling on a host computer running a Linux OS.
# The host computer used for the cross-compilation has Jetpack 5.0 (L4T 34.1) for Orin AGX installed. The Jetpack path is: <syntaxhighlight lang=bash> /home/$USER/nvidia/nvidia_sdk/JetPack_5.0_DP_Linux_DP_JETSON_AGX_ORIN_TARGETS/Linux_for_Tegra </syntaxhighlight> This is the default path where the SDK Manager installs the Jetpack 5.0 tools for the Orin AGX. If you chose to install Jetpack on a different path, make sure to adjust the instructions accordingly.
 
 
# Make sure the following dependencies are installed on your system:
 
# Make sure the following dependencies are installed on your system:
 
** wget
 
** wget
Line 42: Line 28:
 
sudo apt install wget lbzip2 build-essential bc zip libgmp-dev libmpfr-dev libmpc-dev vim-common
 
sudo apt install wget lbzip2 build-essential bc zip libgmp-dev libmpfr-dev libmpc-dev vim-common
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
==Downloading and compiling==
 +
===Download the JetPack sources===
 +
 +
You can obtain the JetPack 5.0.2 DP sources by doing the following:
 +
 +
1. Go to https://developer.nvidia.com/embedded/jetson-linux-archive and download the source files for your release.
 +
 +
2. Extract the .tbz2 file:
 +
<pre>
 +
tar -xjf public_sources.tbz2
 +
</pre>
 +
3. Extract the kernel source file:
 +
<pre>
 +
cd Linux_for_Tegra/source/public
 +
JETSON_SOURCES=$PWD
 +
tar -xjf kernel_src.tbz2
 +
</pre>
 +
This extracts the kernel source to the kernel/ subdirectory.
 +
 +
===Kernel build instructions===
 +
 +
Once the sources have been downloaded, perform the following steps in order to build.
 +
 +
====Install the Toolchain====
 +
First, download the [https://developer.nvidia.com/embedded/jetson-linux Bootlin toolchain binaries] from the NVIDIA Jetson Linux home page. Go to the bottom of the page and click on the Bootlin Toolchain gcc option as shown in the image below:
 +
<br>
 +
<br>
 +
[[File:Toolchain.png|thumb|center|650px]]
 +
<br>
 +
After that do:
 +
<syntaxhighlight lang=bash>
 +
mkdir $HOME/l4t-gcc
 +
cd $HOME/l4t-gcc
 +
tar xf <path_to_toolchain_archive>
 +
</syntaxhighlight>
 +
 +
====Build the kernel====
 +
 +
* Establish the building paths and create directories:
 +
<pre>
 +
KERNEL_OUT=$JETSON_SOURCES/kernel_out
 +
MODULES_OUT=$JETSON_SOURCES/modules_out
 +
mkdir -p $KERNEL_OUT
 +
mkdir -p $MODULES_OUT
 +
</pre>
 +
 +
* Use the following command to install dependencies on Ubuntu:
 +
<pre>
 +
sudo apt install libncurses-dev
 +
</pre>
 +
 +
* Export environment variables:
 +
<pre>
 +
export CROSS_COMPILE_AARCH64_PATH=$HOME/l4t-gcc
 +
export CROSS_COMPILE_AARCH64=$HOME/l4t-gcc/bin/aarch64-buildroot-linux-gnu-
 +
</pre>
 +
 +
* Compile kernel:
 +
<pre>
 +
cd $JETSON_SOURCES
 +
./nvbuild.sh -o $KERNEL_OUT
 +
</pre>
 +
 +
*Install the modules
 +
<pre>
 +
make -C $JETSON_SOURCES/kernel/kernel-5.10/ ARCH=arm64 O=$KERNEL_OUT LOCALVERSION=-tegra INSTALL_MOD_PATH=$MODULES_OUT modules_install
 +
</pre>
  
 
<noinclude>
 
<noinclude>
{{NVIDIA Jetson Orin/Foot|JetPack 5.0‎/Getting_Started/Components|JetPack 5.0‎/Compiling Code/Kernel}}
+
{{NVIDIA Jetson Orin/Foot|JetPack 5.0‎.2/Getting_Started/Components|JetPack_5.0.2/Flashing_Board}}
 
</noinclude>
 
</noinclude>

Latest revision as of 13:24, 17 August 2023



Previous: JetPack 5.0‎.2/Getting_Started/Components Index Next: JetPack_5.0.2/Flashing_Board


Nvidia-preferred-partner-badge-rgb-for-screen.png




Learning to build the BSP and OS components enables developers to customize the software for their specific project needs.

This section will guide you through the process of building the BSP and OS components for the NVIDIA Jetson Orin. For this section you are going to need Jetpack 5.0.2 for Orin AGX installed on your host computer, we assume that you got this installed following through our Getting Started and Installing Jetpack sections.

Assumptions

  1. The build of the BSP/OS components source code will be performed by cross-compiling on a host computer running a Linux OS.
  2. Make sure the following dependencies are installed on your system:
    • wget
    • lbzip2
    • build-essential
    • bc
    • zip
    • libgmp-dev
    • libmpfr-dev
    • libmpc-dev
    • vim-common # For xxd

In Debian based systems you can run the following:

sudo apt install wget lbzip2 build-essential bc zip libgmp-dev libmpfr-dev libmpc-dev vim-common

Downloading and compiling

Download the JetPack sources

You can obtain the JetPack 5.0.2 DP sources by doing the following:

1. Go to https://developer.nvidia.com/embedded/jetson-linux-archive and download the source files for your release.

2. Extract the .tbz2 file:

tar -xjf public_sources.tbz2

3. Extract the kernel source file:

cd Linux_for_Tegra/source/public
JETSON_SOURCES=$PWD
tar -xjf kernel_src.tbz2

This extracts the kernel source to the kernel/ subdirectory.

Kernel build instructions

Once the sources have been downloaded, perform the following steps in order to build.

Install the Toolchain

First, download the Bootlin toolchain binaries from the NVIDIA Jetson Linux home page. Go to the bottom of the page and click on the Bootlin Toolchain gcc option as shown in the image below:

Toolchain.png


After that do:

mkdir $HOME/l4t-gcc
cd $HOME/l4t-gcc
tar xf <path_to_toolchain_archive>

Build the kernel

  • Establish the building paths and create directories:
KERNEL_OUT=$JETSON_SOURCES/kernel_out
MODULES_OUT=$JETSON_SOURCES/modules_out
mkdir -p $KERNEL_OUT
mkdir -p $MODULES_OUT
  • Use the following command to install dependencies on Ubuntu:
sudo apt install libncurses-dev
  • Export environment variables:
export CROSS_COMPILE_AARCH64_PATH=$HOME/l4t-gcc
export CROSS_COMPILE_AARCH64=$HOME/l4t-gcc/bin/aarch64-buildroot-linux-gnu-
  • Compile kernel:
cd $JETSON_SOURCES
./nvbuild.sh -o $KERNEL_OUT
  • Install the modules
make -C $JETSON_SOURCES/kernel/kernel-5.10/ ARCH=arm64 O=$KERNEL_OUT LOCALVERSION=-tegra INSTALL_MOD_PATH=$MODULES_OUT modules_install



Previous: JetPack 5.0‎.2/Getting_Started/Components Index Next: JetPack_5.0.2/Flashing_Board