Difference between revisions of "Compiling Jetson TX2 source code"

From RidgeRun Developer Connection
Jump to: navigation, search
(Downloading the code)
m
 
(44 intermediate revisions by 6 users not shown)
Line 1: Line 1:
'''IMPORTANT: This wiki is still WORK IN PROGRESS, writing it during the week of March 7th, thanks for your patience ;). Currently having problems to compile the kernel so we recommend to not try it yet'''
+
<seo title="NVIDIA Tegra X2 | Compiling Tegra X2 Source Code | RidgeRun" titlemode="replace" keywords="GStreamer, Linux SDK, Linux BSP,  Embedded Linux, Device Drivers, Nvidia, Jetson, TX1, TX2, Xilinx, TI, NXP, Freescale, Embedded Linux driver development, Linux Software development, Embedded Linux SDK, Embedded Linux Application development, GStreamer Multimedia Framework."  description="Find instructions to download Tegra source code to rebuild the Jetson TX2 images. Learn about compiling Tegra X2 source code with RidgeRun Developer."></seo>
  
= Introduction =
+
<table>
 +
<tr>
 +
<td><div class="clear; float:right">__TOC__</div></td>
 +
<td>
 +
{{NVIDIA Preferred Partner logo}}
 +
<td>
 +
<center>
 +
{{ContactUs Button}}
 +
</center>
 +
</tr>
 +
</table>
  
In this wiki page you are going to find the instructions to download the source code to rebuild the tegra X2 images using jetpack, several parts of this wiki were based in the document called Start_L4T_Docs.html given by Nvidia in L4T. This page should be considered a work in progress. These steps were run on Jetson TX2.<br>
+
== Newest Jetpack Versions (Jetpack 3.1 and later) ==
 +
 
 +
For newest Jetpack versions please reference this wiki page: [[Compiling_Tegra_X1/X2_source_code]]. In case you are going to use Jetpack 3.0 continue in this page.
 +
 
 +
== Introduction ==
 +
 
 +
In this wiki page you are going to find the instructions to download the source code to rebuild the Jetson TX2 images using jetpack, several parts of this wiki were based in the document called Start_L4T_Docs.html given by NVIDIA in L4T. This NVIDIA Jetson TX2 page should be considered a work in progress. These steps were run on Jetson TX2.<br>
  
 
'''Platform'''
 
'''Platform'''
Line 13: Line 29:
 
</pre>
 
</pre>
  
= Downloading the code =
+
== Download kernel code ==
  
==Option 1 Manually Download and Expand==
+
===Option 1 Manually Download and Expand===
<span style="background:#00FF00"> RECOMMENDED </span>
+
{{Ambox
 +
|type=notice
 +
|small=left
 +
|issue=<span style="background:#00FF00"> RECOMMENDED </span>
 +
|style=width: auto; margin-right: 0px;
 +
|textstyle=width: auto;
 +
}}
 +
Let's call $DEVDIR the path where you download the kernel.
  
1. In a browser, navigate to: https://developer.nvidia.com/embedded/downloads
+
'''1.''' In a browser, navigate to: https://developer.nvidia.com/embedded/downloads, Locate and download the L4T Sources (L4T Sources 27.1 2017/03/14). Also you can use wget command:
  
2. Locate and download the L4T Sources (L4T Sources 27.1 2017/03/14).
+
wget http://developer2.download.nvidia.com/embedded/L4T/r27_Release_v1.0/BSP/r27.1.0_sources.tbz2
  
3. Expand the TBZ2 file.
+
'''2.''' Copy L4T kernel sources into DEVDIR.
 +
<pre>
 +
cp r27.1.0_sources.tbz2 $DEVDIR
 +
</pre>
  
 +
'''3.''' Expand the TBZ2 file.
 
<pre>
 
<pre>
 
tar -vxjf r27.1.0_sources.tbz2
 
tar -vxjf r27.1.0_sources.tbz2
cd source/
 
 
# Decompress kernel
 
# Decompress kernel
sudo tar -vxjf kernel_src.tbz2
+
sudo tar -xjf kernel_src.tbz2
 
</pre>
 
</pre>
  
==Option 2 Sync with git==
+
===Option 2 Sync with git===
  
Let's call $DEVDIR the path where you installed your development directory or Jetpack.
+
Let's call $JETPACKDIR the path where you installed your development directory or Jetpack.
  
 
1) In order to download the source code you can run the script called source_sync.sh
 
1) In order to download the source code you can run the script called source_sync.sh
  
 
<pre>
 
<pre>
$DEVDIR/64_TX2/Linux_for_Tegra_64_tx2$ ./source_sync.sh
+
$JETPACKDIR/64_TX2/Linux_for_Tegra_64_tx2$ ./source_sync.sh
 
</pre>
 
</pre>
  
Line 98: Line 124:
  
 
<pre>
 
<pre>
cd $DEVDIR/64_TX2/Linux_for_Tegra_64_tx2/sources/kernel_source
+
cd $JETPACKDIR/64_TX2/Linux_for_Tegra_64_tx2/sources/kernel_source
 
git branch -a
 
git branch -a
 
git checkout l4t/l4t-r27.1
 
git checkout l4t/l4t-r27.1
  
cd $DEVDIR/64_TX2/Linux_for_Tegra_64_tx2/sources/u-boot_source
+
cd $JETPACKDIR/64_TX2/Linux_for_Tegra_64_tx2/sources/u-boot_source
 
git branch -a
 
git branch -a
 
git checkout l4t/l4t-r27.1
 
git checkout l4t/l4t-r27.1
Line 114: Line 140:
 
</pre>
 
</pre>
  
= Toolchain =
+
== Toolchain ==
  
Linaro or code sourcery toolchain's can be used, however, it is recommended to use the Linaro toolchain because it is newer and produces [https://devtalk.nvidia.com/default/topic/929186/jetson-tx1/jetson-tx1-kernel-compilation/post/4853151/#4853151 more optimized assembler code]
+
===Option 1===
  
1. Download the [http://releases.linaro.org/components/toolchain/binaries/5.3-2016.02/ Linaro toolchain]. You need to install two toolchains, one which is the 64bits toolchain for ARM, and the 32bits toolchain for ARM as well. In this case version 5.3-2016.02 will be used:
+
{{Ambox
 +
|type=notice
 +
|small=left
 +
|issue=<span style="background:#00FF00"> RECOMMENDED </span>
 +
|style=width: auto; margin-right: 0px;
 +
|textstyle=width: auto;
 +
}}
  
*[http://releases.linaro.org/components/toolchain/binaries/5.3-2016.02/aarch64-linux-gnu/gcc-linaro-5.3-2016.02-x86_64_aarch64-linux-gnu.tar.xz 5.3-2016.02 for 64bits PC - 64bits ARM]
+
1) Download the pre-built toolchain binaries, The AARCH64 toolchain is available at: http://developer.nvidia.com/embedded/dlc/l4t-gcc-toolchain-64-bit-27-1. The source TAR file is named: gcc-4.8.5-aarch64.tgz
*[https://releases.linaro.org/components/toolchain/binaries/latest-5/arm-linux-gnueabihf/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf.tar.xz 5.3-2016.02 for 64bits PC - 32bits ARM]
 
 
 
2. Install the toolchain
 
  
 +
2) Decompress tarball file.
 +
<pre>
 +
tar -xvf gcc-4.8.5-aarch64.tgz
 +
</pre>
 +
3) Install toolchain.
 
<pre>
 
<pre>
sudo mkdir /opt/linaro
+
mkdir /opt/jetpack3.0
sudo chmod -R 775 /opt/linaro
+
cp install /opt/jetpack3.0/ -r
sudo chown -R $USER /opt/linaro
 
cp gcc-linaro-5.3-2016.02-x86_64_aarch64-linux-gnu.tar.xz /opt/linaro
 
cp gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf.tar.xz /opt/linaro
 
cd /opt/linaro/
 
tar -xf gcc-linaro-5.3-2016.02-x86_64_aarch64-linux-gnu.tar.xz
 
tar -xf gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf.tar.xz
 
 
</pre>
 
</pre>
  
= Kernel =
+
===Option 2===
  
In order to compile the kernel please follow these steps
+
1) Download the pre-built toolchain binaries from the Embedded Download Center on the NVIDIA Developer page at:
 +
https://developer.nvidia.com/embedded/downloads (Sources for GCC Tool Chain for 64-bit BSP )
 +
 
 +
The toolchain source tarball (src_aarch64_gcc-4.8.5.tar) contains the following:
 +
*The required sources to build the toolchain.
 +
*The make-aarch64-toolchain.sh script that builds the toolchain.
 +
*A patches folder containing patches to the toolchain sources.
  
== Build Kernel ==
+
2) Decompress tarball file.
 +
<pre>
 +
tar -xvf src_aarch64_gcc-4.8.5.tar
 +
</pre>
  
1) Specify the path to the toolchain:
+
3) Run the toolchain building script.
  
 
<pre>
 
<pre>
mkdir -p $DEVDIR/images/modules
+
./make-aarch64-toolchain.sh
mkdir -p $DEVDIR/images/packages
 
export CROSS_COMPILE=/opt/linaro/gcc-linaro-5.3-2016.02-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
 
export CROSS32CC=/opt/linaro/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
 
export KERNEL_MODULES_OUT=$DEVDIR/images/modules
 
export ARCH=arm64
 
 
</pre>
 
</pre>
  
2) Clean your kernel and configuration
+
4) Install the toolchain
 
<pre>
 
<pre>
cd $DEVDIR/64_TX2/Linux_for_Tegra_64_tx2/sources/kernel_source/
+
mkdir /opt/jetpack3.0
make mrproper
+
cp install /opt/jetpack3.0/ -r
 
</pre>
 
</pre>
  
3) Configure your kernel
+
== Kernel ==
 +
 
 +
In order to compile the kernel please follow these steps
 +
 
 +
=== Build Kernel ===
  
 +
 +
Let's call $DEVDIR the path where you download the kernel code.
 +
 +
'''1.''' Specify the path to the toolchain and architecture:
 
<pre>
 
<pre>
make tegra21_defconfig
+
export CROSS_COMPILE=/opt/jetpack3.0/install/bin/aarch64-unknown-linux-gnu-
make menuconfig
+
export ARCH=arm64
 
</pre>
 
</pre>
  
4) Compile kernel, device tree and modules
+
'''2.''' Define and create destination directories.
 +
 
 
<pre>
 
<pre>
make zImage
+
export TEGRA_KERNEL_OUT=/home/$USER/devdirs/tegra-kernel/r27.1.0_sources/images
make dtbs
+
export TEGRA_MODULES_OUT=/home/$USER/devdirs/tegra-kernel/r27.1.0_sources/modules
make modules
+
mkdir -p $TEGRA_KERNEL_OUT
make modules_install INSTALL_MOD_PATH=$KERNEL_MODULES_OUT
+
mkdir -p $TEGRA_MODULES_OUT
 
</pre>
 
</pre>
  
5) Save your binaries in the images directory
+
'''3.''' Clean your kernel and configuration
 
<pre>
 
<pre>
cp arch/arm64/boot/Image arch/arm64/boot/zImage $DEVDIR/images/
+
make -C kernel/kernel-4.4/ mrproper
 
</pre>
 
</pre>
  
6) Create kernel_supplements.tbz2 with kernel modules, this package is needed by Jetpack
+
'''4.''' Configure your kernel
  
 
<pre>
 
<pre>
cd $DEVDIR/images/modules/lib/modules/
+
make -C kernel/kernel-4.4/ O=$TEGRA_KERNEL_OUT tegra18_defconfig
ls .
+
make -C kernel/kernel-4.4/ O=$TEGRA_KERNEL_OUT menuconfig
 
</pre>
 
</pre>
  
define a variable with the name of the modules directory
+
'''5.''' Compile kernel, device tree and modules. To speed up compilation on multiprocessor systems, use -j n, this option tells make to execute many recipes simultaneously.
 +
<pre>
 +
make -C kernel/kernel-4.4/ O=$TEGRA_KERNEL_OUT zImage
 +
make -C kernel/kernel-4.4/ O=$TEGRA_KERNEL_OUT dtbs
 +
make -C kernel/kernel-4.4/ O=$TEGRA_KERNEL_OUT modules
 +
make -C kernel/kernel-4.4/ O=$TEGRA_KERNEL_OUT modules_install INSTALL_MOD_PATH=$TEGRA_MODULES_OUT
 +
</pre>
  
 +
'''6.''' Save your Images and device tree
 
<pre>
 
<pre>
export KERNEL_MODULES_NAME=3.10.96+
+
mkdir boot
 +
cp images/arch/arm64/boot/Image boot/
 +
cp images/arch/arm64/boot/dts/* boot/
 
</pre>
 
</pre>
  
fix the symbolic links on the kernel modules directory
+
=== Flash your Kernel image using Jetpack 3.0 root file system===
 +
 
 +
'''1.''' Install jetpack 3.0: http://developer.ridgerun.com/wiki/index.php?title=Installing_Jetpack_3.0
 +
 
 +
'''2.''' Flash your board with Jetpack, the root file system will be on an SD card
 +
 
 +
'''3.''' Go to Linux_for_Tegra_64_tx2 directory
 
<pre>
 
<pre>
cd $DEVDIR/images/modules/lib/modules/$KERNEL_MODULES_NAME
+
cd $JETPACKDIR/64_TX2/Linux_for_Tegra_64_tx2/
rm build source
 
 
</pre>
 
</pre>
  
create tarball
+
'''4.''' Put the board into force USB Recovery Mode:
 
<pre>
 
<pre>
cd $DEVDIR/images/modules/
+
1. Power down the device. If connected, remove the AC adapter from the device. The device must be
tar -cjf kernel_supplements.tbz2 *
+
powered OFF, and not in a suspend or sleep state.
mv kernel_supplements.tbz2 $DEVDIR/images/packages
+
2. Connect the Micro-B plug on the USB cable to the Recovery (USB Micro-B) Port on the device and
 +
the other end to an available USB port on the host PC.
 +
3. Connect the power adapter to the device.
 +
4. Press POWER button
 +
5. Press and hold the RECOVERY FORCE (REC) button.
 +
6. While pressing the RECOVERY FORCE button, press and release the RESET button.
 +
7. Wait 2 seconds and release the RECOVERY FORCE button
 
</pre>
 
</pre>
  
7) Besides creating the modules and the kernel image you need to create again your kernel_headers.tbz2 file (needed by Jetpack). By default when you patch the kernel code and you don't check your changes in the kernel will add a -dirty suffix to the release version (check ls $DEVDIR/images/modules/lib/modules/ for example). For this specific reason you need to generate your headers tarball again changing it the release version.
+
'''5.''' Use ./flash.sh in order to configure TX2 board, Also this script configures jetpack rootfs to be used as SD filesystem.
 +
Execute the script as follows:
  
 
<pre>
 
<pre>
cd $DEVDIR/64_TX1/Linux_for_Tegra_64_tx1/kernel
+
sudo ./flash.sh jetson-tx2 mmcblk1p1
tar -xf kernel_headers.tbz2
 
tar -cjf kernel_headers_custom.tbz2 linux-headers-$KERNEL_MODULES_NAME
 
mv kernel_headers_custom.tbz2 $DEVDIR/images/packages
 
rm -rf linux-headers-$KERNEL_MODULES_NAME
 
 
</pre>
 
</pre>
  
8) Create the dtb directory
+
'''6.''' Create ext4 partition called "rootfs".
  
<pre>
+
sudo mkfs.ext4 /dev/mmcblk0p1 -L "rootfs"
mkdir -p $DEVDIR/images/dtb
 
cp $DEVDIR/64_TX1/Linux_for_Tegra_64_tx1/sources/kernel_source/arch/arm64/boot/dts/*.dtb $DEVDIR/images/dtb/
 
</pre>
 
  
9) Copy the Device Tree Compiler (DTC)
+
'''7.''' Copy rootfs from jetpack 3.0
  
 
<pre>
 
<pre>
cp $DEVDIR/64_TX1/Linux_for_Tegra_64_tx1/sources/kernel_source/scripts/dtc/dtc $DEVDIR/images/dtc
+
sudo cp -a $JETPACKDIR/64_TX2/Linux_for_Tegra_tx2/rootfs/* /media/$USER/rootfs/
 
</pre>
 
</pre>
  
10) Create a backup of the images and packages included in Jetpack
+
'''8.''' Copy kernel image, device tree, and modules.
 +
 
 
<pre>
 
<pre>
mkdir -p $DEVDIR/images/packages-backup
+
cd $TEGRA_KERNEL_OUT
cp -rf $DEVDIR/64_TX1/Linux_for_Tegra_64_tx1/kernel/* $DEVDIR/images/packages-backup
+
sudo cp -a arch/arm64/boot/Image /media/$USER/rootfs/boot/Image
 +
sudo cp -a arch/arm64/boot/dts/tegra186-quill-p3310-1000-c03-00-base.dtb /media/$USER/rootfs/boot/
 +
cd $TEGRA_MODULES_OUT
 +
sudo cp -a lib/* /media/$USER/rootfs/lib/
 
</pre>
 
</pre>
  
11) Finally overwrite the default images with your own images to install and boot them using jetpack
+
'''9.''' Modify extlinux.conf. The Device Tree Binary (DTB) is no longer specified by default in /boot/extlinux/extlinux.conf therefore you have to set this field manually in /media/$USER/rootfs/boot/extlinux/extlinux.conf
 +
(see: http://elinux.org/Jetson/TX2_DTB)
  
 
<pre>
 
<pre>
cd $DEVDIR/images
+
TIMEOUT 30
rm -rf $DEVDIR/64_TX1/Linux_for_Tegra_64_tx1/kernel/dtb
+
DEFAULT primary
cp -rf Image zImage packages/kernel_supplements.tbz2 dtb/ dtc $DEVDIR/64_TX1/Linux_for_Tegra_64_tx1/kernel/
 
cp -rf packages/kernel_headers_custom.tbz2 $DEVDIR/64_TX1/Linux_for_Tegra_64_tx1/kernel/kernel_headers.tbz2
 
</pre>
 
  
12) Run the applybinaries script to generate the image to flash
+
MENU TITLE p2771-0000 SD Card boot options
  
<pre>
+
LABEL primary
cd $DEVDIR/64_TX1/Linux_for_Tegra_64_tx1/
+
      MENU LABEL primary kernel
sudo ./apply_binaries.sh
+
      LINUX /boot/Image
 +
      FDT /boot/tegra186-quill-p3310-1000-c03-00-base.dtb
 +
      APPEND fbcon=map:0 net.ifnames=0 console=tty0 OS=l4t console=ttyS0,115200n8 memtype=0 video=tegrafb no_console_suspend=1 earlycon=uart8250,mmio32,0x03100000 gpt tegraid=18.1.2.0.0 tegra_keep_boot_clocks maxcpus=6 android.kerneltype=normal androidboot.serialno=0335115020673 vpr_resize root=/dev/mmcblk1p1 rw rootwait
 
</pre>
 
</pre>
Output:
+
 
 +
'''10.''' Unmount the device and Put the SD into the tx2 board, and boot the board.
 
<pre>
 
<pre>
Using rootfs directory of: /home/dsoto/devdirs/tegra/Jetpack/TX1/Linux_for_Tegra_tx1/rootfs
+
umount /media/$USER/rootfs  
Extracting the NVIDIA user space components to /home/dsoto/devdirs/tegra/Jetpack/TX1/Linux_for_Tegra_tx1/rootfs
 
Extracting the BSP test tools to /home/dsoto/devdirs/tegra/Jetpack/TX1/Linux_for_Tegra_tx1/rootfs
 
Extracting the NVIDIA gst test applications to /home/dsoto/devdirs/tegra/Jetpack/TX1/Linux_for_Tegra_tx1/rootfs
 
Extracting the configuration files for the supplied root filesystem to /home/dsoto/devdirs/tegra/Jetpack/TX1/Linux_for_Tegra_tx1/rootfs
 
Creating a symbolic link nvgstplayer pointing to nvgstplayer-0.10
 
Creating a symbolic link nvgstcapture pointing to nvgstcapture-0.10
 
Adding symlink libcuda.so --> libcuda.so.1.1 in target rootfs
 
Adding symlink libGL.so --> libGL.so.1 in target rootfs
 
Adding symlink libcuda.so --> tegra/libcuda.so in target rootfs
 
Adding symlink libEGL.so --> libEGL.so.1 in target rootfs
 
Extracting the firmwares and kernel modules to /home/dsoto/devdirs/tegra/Jetpack/TX1/Linux_for_Tegra_tx1/rootfs
 
Extracting the kernel headers to /usr/src in target rootfs
 
Installing zImage into /boot in target rootfs
 
Installing Image into /boot in target rootfs
 
Installing the board *.dtb files into /boot in target rootfs
 
Success!
 
 
</pre>
 
</pre>
  
As an important note, kernel will be located not in a partition but in /boot on the filesystem this make easier a kernel update.
+
Username and password: nvidia. You can see the ipaddress connecting a keyboard, mouse and monitor to the board at this point since ubuntu would be already booted.
  
== Flash your image with Jetpack ==
+
=== DTB ===
You can flash your image with Jetpack now instead of using the scripts directly, however this takes time (around 10min) because we will need jetpack generating the system.img again
 
  
1. Backup your system.img
+
Looking into the file $JETPACKDIR/64_TX2/Linux_for_Tegra_tx2/jetson-tx2.conf the dtb used by jetson x1 is: '''tegra186-a02-bpmp-quill-p3310-1000-a00-00-te770d-ucm2.dtb'''
<pre>
 
cd $DEVDIR/64_TX1/Linux_for_Tegra_tx1/bootloader/
 
mv system.img.raw system.img $DEVDIR/images/packages-backup/
 
</pre>
 
  
2. Just run Jetpack as the first time that you install it:
 
 
<pre>
 
<pre>
cd $DEVDIR
+
#!/bin/bash
./JetPack-L4T-2.1-linux-x64.run
 
</pre>
 
  
See the [https://developer.ridgerun.com/wiki/index.php?title=Jetpack_output_when_flashing_Tegra_X1 Jetpack output while flashing]
+
# Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
 +
#
 +
# Redistribution and use in source and binary forms, with or without
 +
# modification, are permitted provided that the following conditions
 +
# are met:
 +
#  * Redistributions of source code must retain the above copyright
 +
#    notice, this list of conditions and the following disclaimer.
 +
#  * 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.
 +
#  * Neither the name of NVIDIA CORPORATION 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 ``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 OWNER 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.
  
It will notice that everything is already build and will install your new images. If you have problems detecting the IP address wait like 2 minutes and it will give you the option to enter it manually. Username and password: ubuntu. You can see the ipaddress connecting a keyboard, mouse and monitor to the board at this point since ubuntu would be already booted.
+
# p2771-0000-devkit-24x7.conf: configuration for T186-A02 te770d-UCM2 Silicon
  
== DTB ==
+
BPFDTB_FILE=tegra186-a02-bpmp-quill-p3310-1000-a00-00-te770d-ucm2.dtb;
  
Looking into the file $DEVDIR/TX1/Linux_for_Tegra_tx1/jetson-tx1.conf the dtb used by jetson x1 is: '''tegra210-jetson-tx1-p2597-2180-a01-devkit.dtb'''
+
source "${LDK_DIR}/p2771-0000.conf.common";
 
 
<pre>
 
ODMDATA=0x84000;
 
NET_BSF=;
 
EMMC_BSF=;
 
EMMC_BCT=P2180_A00_LP4_DSC_204Mhz.cfg;
 
EMMC_CFG=gnu_linux_tegraboot_emmc_full.xml;
 
BOOTPARTSIZE=8388608;
 
EMMCSIZE=31276924928;
 
ITS_FILE=;
 
SYSBOOTFILE=p2371-2180-devkit/extlinux.conf;
 
DTB_FILE=tegra210-jetson-tx1-p2597-2180-a01-devkit.dtb
 
DFLT_KERNEL=Image;
 
ROOTFSSIZE=14GiB;
 
CMDLINE_ADD="fbcon=map:0";
 
UBOOT_TEXT_BASE=0x8010e000;
 
UIMAGE_LABEL="Linux-tegra21";
 
target_board="t210ref";
 
ROOT_DEV="mmcblk0p1 ------------ internal eMMC.
 
        sda1 ----------------- external USB devices. (USB memory stick, HDD)
 
        eth0 ----------------- nfsroot via RJ45 Ethernet port.
 
        eth1 ----------------- nfsroot via USB Ethernet interface.";
 
TEGRABOOT="bootloader/${target_board}/nvtboot.bin";
 
SOSFILE="bootloader/nvtboot_recovery.bin";
 
WB0BOOT="bootloader/${target_board}/warmboot.bin";
 
FLASHAPP="bootloader/tegraflash.py";
 
FLASHER="bootloader/${target_board}/cboot.bin";
 
BOOTLOADER="bootloader/${target_board}/p2371-2180/u-boot-dtb.bin";
 
UBOOT_WITH_TBOOT=yes;
 
BCFFILE="bootloader/${target_board}/cfg/board_config_p2597-devkit.xml";
 
INITRD="bootloader/l4t_initrd.img";
 
TBCFILE="bootloader/nvtboot_cpu.bin";
 
BPFFILE="bootloader/bpmp.bin";
 
TOSFILE="bootloader/tos.img";
 
EKSFILE="bootloader/eks.img";
 
FBFILE="bootloader/reserved_fb.xml";
 
 
</pre>
 
</pre>
  
= Bootloader =
+
== Bootloader ==
  
 
The bootloader is a combination of NVIDIA T-Boot (nvtboot) and U-Boot. You can read about the BOOT FLOW in the [http://http.download.nvidia.com/tegra-public-appnotes/t210-nvtboot-flow.html nvtboot wiki page].  
 
The bootloader is a combination of NVIDIA T-Boot (nvtboot) and U-Boot. You can read about the BOOT FLOW in the [http://http.download.nvidia.com/tegra-public-appnotes/t210-nvtboot-flow.html nvtboot wiki page].  
Line 344: Line 368:
 
Inside of the bootloader directory you will find several binaries or components, to get a description of these please read the [http://http.download.nvidia.com/tegra-public-appnotes/t210-nvtboot-flow.html nvtboot wiki page].
 
Inside of the bootloader directory you will find several binaries or components, to get a description of these please read the [http://http.download.nvidia.com/tegra-public-appnotes/t210-nvtboot-flow.html nvtboot wiki page].
  
== Build DTC ==
+
=== Build DTC ===
  
 
U-boot requires the Device Tree Compiler (dtc) which is used to compile device tree files contained in the U-Boot source tree. One version is included inside of the kernel. However, that binary is too old according to u-boot when trying to use that one
 
U-boot requires the Device Tree Compiler (dtc) which is used to compile device tree files contained in the U-Boot source tree. One version is included inside of the kernel. However, that binary is too old according to u-boot when trying to use that one
Line 357: Line 381:
  
 
<pre>
 
<pre>
cd $DEVDIR/TX1/Linux_for_Tegra_tx1/sources
+
cd $JETPACKDIR/64_TX2/Linux_for_Tegra_tx2/sources
 
git clone git://git.kernel.org/pub/scm/utils/dtc/dtc.git
 
git clone git://git.kernel.org/pub/scm/utils/dtc/dtc.git
 
cd dtc
 
cd dtc
Line 364: Line 388:
 
</pre>
 
</pre>
  
== Build u-boot ==
+
=== Build u-boot ===
  
1. Backup original uboot files. You see which platform you are using checking the file in $DEVDIR/TX1/Linux_for_Tegra_tx1/jetson-tx1.conf, it says:
+
1. Backup original uboot files. You see which platform you are using checking the file in $/64_TX2/Linux_for_Tegra_tx2/jetson-tx2.conf, it says:
  
 
<pre>
 
<pre>
Line 375: Line 399:
  
 
<pre>
 
<pre>
mkdir $DEVDIR/images/packages-backup/bootloader/
+
mkdir $JETPACK/images/packages-backup/bootloader/
cp -rf $DEVDIR/TX1/Linux_for_Tegra_tx1/bootloader/t210ref/p2371-2180-devkit $DEVDIR/images/packages-backup/bootloader/
+
cp -rf $JETPACK/64_TX2/Linux_for_Tegra_tx2/bootloader/t210ref/p2371-2180-devkit $JETPACK/images/packages-backup/bootloader/
cd $DEVDIR/TX1/Linux_for_Tegra_tx1/bootloader/
+
cd $JETPACK/64_TX2/Linux_for_Tegra_tx2/bootloader/
cp nvtboot.bin nvtboot_cpu.bin u-boot-dtb.bin bpmp.bin warmboot.bin tos.img tegra210-jetson-tx1-p2597-2180-a01-devkit.dtb $DEVDIR/images/packages-backup/bootloader/
+
cp nvtboot.bin nvtboot_cpu.bin u-boot-dtb.bin bpmp.bin warmboot.bin tos.img tegra210-jetson-tx1-p2597-2180-a01-devkit.dtb $JETPACK/images/packages-backup/bootloader/
cp $DEVDIR/TX1/Linux_for_Tegra_tx1/bootloader/t210ref/p2371-2180 $DEVDIR/images/packages-backup/bootloader/
+
cp $JETPACK/64_TX2/Linux_for_Tegra_tx2/bootloader/t210ref/p2371-2180 $JETPACK/images/packages-backup/bootloader/
 
</pre>
 
</pre>
  
Line 387: Line 411:
  
 
<pre>
 
<pre>
cd $DEVDIR/TX1/Linux_for_Tegra_tx1/sources/u-boot_source/
+
cd $JETPACK/64_TX2/Linux_for_Tegra_tx2/sources/u-boot_source/
PATH=$DEVDIR/images:$PATH
+
PATH=$JETPACK/images:$PATH
 
export CROSS_COMPILE=/opt/linaro/gcc-linaro-5.3-2016.02-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
 
export CROSS_COMPILE=/opt/linaro/gcc-linaro-5.3-2016.02-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
 
export ARCH=arm64
 
export ARCH=arm64
Line 403: Line 427:
 
4. Save your new binaries
 
4. Save your new binaries
 
<pre>
 
<pre>
mkdir $DEVDIR/images/bootloader
+
mkdir $JETPACK/images/bootloader
cp $DEVDIR/TX1/Linux_for_Tegra_tx1/sources/u-boot_source/u-boot{,.bin,.dtb,-dtb.bin} $DEVDIR/images/bootloader
+
cp $JETPACK/64_TX2/Linux_for_Tegra_tx2/sources/u-boot_source/u-boot{,.bin,.dtb,-dtb.bin} $JETPACK/images/bootloader
 
</pre>
 
</pre>
  
Line 419: Line 443:
  
 
<pre>
 
<pre>
cp  $DEVDIR/images/bootloader/u-boot{,.bin,.dtb,-dtb.bin} $DEVDIR/TX1/Linux_for_Tegra_tx1/bootloader/t210ref/p2371-2180/
+
cp  $JETPACK/images/bootloader/u-boot{,.bin,.dtb,-dtb.bin} $JETPACK/64_TX2/Linux_for_Tegra_tx2/bootloader/t210ref/p2371-2180/
 
</pre>
 
</pre>
  
Line 430: Line 454:
 
If you are attached to the serial port while flashing you should see the [http://developer.ridgerun.com/wiki/index.php?title=Jetson_TX1_serial_port_output serial port output log while flashing]
 
If you are attached to the serial port while flashing you should see the [http://developer.ridgerun.com/wiki/index.php?title=Jetson_TX1_serial_port_output serial port output log while flashing]
  
== Boot sequence ==
+
=== Boot sequence ===
  
 
According to the U-boot guide provided by Nvidia uboot scans booteable devices as follows:
 
According to the U-boot guide provided by Nvidia uboot scans booteable devices as follows:
Line 450: Line 474:
 
extlinux.conf is a standard text-format sysboot configuration file that contains all boot information, it is installed in /boot according to the boot method.
 
extlinux.conf is a standard text-format sysboot configuration file that contains all boot information, it is installed in /boot according to the boot method.
  
== Boot log and uboot environment ==
+
=== Boot log and uboot environment ===
  
 
Following [http://developer.ridgerun.com/wiki/index.php?title=Jetson_TX1_Boot_Log boot log] was obtained when connected to the serial console using the [http://developer.ridgerun.com/wiki/index.php?title=Jetson_TX1_uboot_environment default uboot environment].
 
Following [http://developer.ridgerun.com/wiki/index.php?title=Jetson_TX1_Boot_Log boot log] was obtained when connected to the serial console using the [http://developer.ridgerun.com/wiki/index.php?title=Jetson_TX1_uboot_environment default uboot environment].
Line 456: Line 480:
 
The environment is defined in extlinux.conf, however, the environment variables can be set in the uboot code directly or directly when the board is booting using the typical uboot commands like: print, saveenv, printenv, etc
 
The environment is defined in extlinux.conf, however, the environment variables can be set in the uboot code directly or directly when the board is booting using the typical uboot commands like: print, saveenv, printenv, etc
  
= Filesystem =
+
== Filesystem ==
  
 
Jetpack comes with a sample filesystem with X and ubuntu and Canonical keeps updating the packages available, you can also use your own filesystem. In both cases you have to install on it the Nvidia binaries, the instructions to do that are in the file Start_L4T_Docs.html, in the Getting started section. It mentions:
 
Jetpack comes with a sample filesystem with X and ubuntu and Canonical keeps updating the packages available, you can also use your own filesystem. In both cases you have to install on it the Nvidia binaries, the instructions to do that are in the file Start_L4T_Docs.html, in the Getting started section. It mentions:
Line 476: Line 500:
 
The remaining steps on this guide assumes that you are using the default filesytem or that you already have one built, specially for the flashing section, where flashing assumes that the filesystem already exists.
 
The remaining steps on this guide assumes that you are using the default filesytem or that you already have one built, specially for the flashing section, where flashing assumes that the filesystem already exists.
  
== To receive notifications of new packages ==
+
=== To receive notifications of new packages ===
  
 
1. Locate and edit the following file:
 
1. Locate and edit the following file:
Line 500: Line 524:
 
  $ sudo apt-get install wget
 
  $ sudo apt-get install wget
  
= Flashing the board =
+
== Flashing the board ==
  
Nvidia provides several scripts to help to generate the images and to flash the resulting images. Including if you are going to install uboot or fastboot. First the board needs to be in recovery mode and then the main script to flash it is $DEVDIR/Linux_for_Tegra_tx1/flash.sh. What this script will do is to install or flash the image in the desired destination. It is important that the script is controlled by variables defined in the DTB file.
+
Nvidia provides several scripts to help to generate the images and to flash the resulting images. Including if you are going to install uboot or fastboot. First the board needs to be in recovery mode and then the main script to flash it is $JETPACK/64_TX2/Linux_for_Tegra_tx2/flash.sh. What this script will do is to install or flash the image in the desired destination. It is important that the script is controlled by variables defined in the DTB file.
  
 
<pre>
 
<pre>
Line 569: Line 593:
 
To flash the filesystem in the emmc you need to run:
 
To flash the filesystem in the emmc you need to run:
 
<pre>
 
<pre>
cd $DEVDIR/64_TX1/Linux_for_Tegra_64_tx1/
+
cd $JETPACK/64_TX2/Linux_for_Tegra_64_tx2/
sudo ./flash.sh jetson-tx1 mmcblk0p1
+
sudo ./flash.sh jetson-tx2 mmcblk0p1
 
</pre>
 
</pre>
 
==== USB ====
 
==== USB ====
Line 589: Line 613:
 
3) Copy the filesystem to the USB drive. It takes a while, its size is normally 2.4GB
 
3) Copy the filesystem to the USB drive. It takes a while, its size is normally 2.4GB
 
<pre>
 
<pre>
mkdir $DEVDIR/images/fs
+
mkdir $JETPACK/images/fs
sudo mount /dev/sdb1 $DEVDIR/images/fs  
+
sudo mount /dev/sdb1 $JETPACK/images/fs  
cd $DEVDIR/64_TX1/Linux_for_Tegra_64_tx1/rootfs/
+
cd $JETPACK/64_TX2/Linux_for_Tegra_64_tx2/rootfs/
sudo cp -a * $DEVDIR/images/fs  && sync
+
sudo cp -a * $JETPACK/images/fs  && sync
 
</pre>
 
</pre>
 
4) Unmount the USB drive and remove it
 
4) Unmount the USB drive and remove it
 
<pre>
 
<pre>
sudo umount $DEVDIR/images/fs
+
sudo umount $JETPACK/images/fs
 
</pre>
 
</pre>
 
5) Finally connect the USB drive to the Jetson board put the Jetson on recovery mode, flash the board to look for the filesystem on the USB port:
 
5) Finally connect the USB drive to the Jetson board put the Jetson on recovery mode, flash the board to look for the filesystem on the USB port:
 
<pre>
 
<pre>
cd $DEVDIR/64_TX1/Linux_for_Tegra_64_tx1/
+
cd $JETPACK/64_TX2/Linux_for_Tegra_64_tx2/
sudo ./flash.sh jetson-tx1 sda1 #it can be other mount point
+
sudo ./flash.sh jetson-tx2 sda1 #it can be other mount point
 
</pre>
 
</pre>
  
Line 608: Line 632:
 
Similar to USB but you need to replace the extlinux.conf so before copying the filesystem into the SD card run:
 
Similar to USB but you need to replace the extlinux.conf so before copying the filesystem into the SD card run:
 
<pre>
 
<pre>
sudo cp $DEVDIR/64_TX1/Linux_for_Tegra_64_tx1/bootloader/t210ref/p2371-2180-devkit/extlinux.conf.sdcard $DEVDIR/64_TX1/Linux_for_Tegra_64_tx1/rootfs/boot/extlinux/extlinux.conf
+
sudo cp $JETPACK/64_TX2/Linux_for_Tegra_64_tx2/bootloader/t210ref/p2371-2180-devkit/extlinux.conf.sdcard $JETPACK/64_TX2/Linux_for_Tegra_64_tx2/rootfs/boot/extlinux/extlinux.conf
 
</pre>
 
</pre>
  
Line 614: Line 638:
  
 
<pre>
 
<pre>
cd $DEVDIR/64_TX1/Linux_for_Tegra_64_tx1/
+
cd $JETPACK/64_TX2/Linux_for_Tegra_64_tx2/
sudo ./flash.sh jetson-tx1 mmcblk1p1  
+
sudo ./flash.sh jetson-tx2 mmcblk1p1  
 
</pre>
 
</pre>
  
Line 621: Line 645:
 
1) First you need to set up your NFS server using [https://developer.ridgerun.com/wiki/index.php/Getting_Started_Guide_for_DM8168_EVM#Setting_up_an_NFS_server these instructions].
 
1) First you need to set up your NFS server using [https://developer.ridgerun.com/wiki/index.php/Getting_Started_Guide_for_DM8168_EVM#Setting_up_an_NFS_server these instructions].
  
2) Open file in $DEVDIR/64_TX1/Linux_for_Tegra_64_tx1/rootfs/etc/network/interfaces and add
+
2) Open file in $JETPACK/64_TX2/Linux_for_Tegra_64_tx2/rootfs/etc/network/interfaces and add
 
<pre>
 
<pre>
 
auto eth0
 
auto eth0
Line 630: Line 654:
  
 
<pre>
 
<pre>
cd $DEVDIR/64_TX1/Linux_for_Tegra_64_tx1/
+
cd $JETPACK/64_TX2/Linux_for_Tegra_64_tx2/
 
MY_IPADDRESS=192.169.0.3
 
MY_IPADDRESS=192.169.0.3
sudo ./flash.sh -N $MY_IPADDRESS:$DEVDIR/64_TX1/Linux_for_Tegra_64_tx1/rootfs jetson-tx1 eth0
+
sudo ./flash.sh -N $MY_IPADDRESS:$JETPACK/64_TX2/Linux_for_Tegra_64_tx2/rootfs jetson-tx2 eth0
 
</pre>
 
</pre>
  
Line 640: Line 664:
  
 
<pre>
 
<pre>
sudo cp $DEVDIR/images/zImage $DEVDIR/images/Image $DEVDIR/64_TX1/Linux_for_Tegra_64_tx1/rootfs/boot/
+
sudo cp $JETPACK/images/zImage $JETPACK/images/Image $JETPACK/64_TX2/Linux_for_Tegra_64_tx2/rootfs/boot/
 
</pre>
 
</pre>
  
if you are not booting from NFS then you need to reflash your filesysm in order to update the kernel. However, likely you did some changes in the kernel modules so it is recommended to run the apply_binaries.sh script instead of only copying the kernel images.
+
if you are not booting from NFS then you need to reflash your filesystem in order to update the kernel. However, likely you did some changes in the kernel modules so it is recommended to run the apply_binaries.sh script instead of only copying the kernel images.
  
 
<pre>
 
<pre>
cd $DEVDIR/64_TX1/Linux_for_Tegra_64_tx1/
+
cd $JETPACK/64_TX2/Linux_for_Tegra_64_tx2/
 
sudo ./apply_binaries.sh  
 
sudo ./apply_binaries.sh  
 
</pre>
 
</pre>
Line 657: Line 681:
  
 
<pre>
 
<pre>
cd $DEVDIR/64_TX1/Linux_for_Tegra_64_tx1/
+
cd $JETPACK/64_TX2/Linux_for_Tegra_64_tx2/
sudo ./flash.sh -k EBT jetson-tx1 mmcblk1p1
+
sudo ./flash.sh -k EBT jetson-tx2 mmcblk1p1
 
</pre>
 
</pre>
  
= Serial Console =
+
== Serial Console ==
  
 
J21 contains the Serial Console signals as can be seen in the [http://jetsonhacks.com/nvidia-jetson-tx1-j21-header-pinout/ pin out header]. Basically:
 
J21 contains the Serial Console signals as can be seen in the [http://jetsonhacks.com/nvidia-jetson-tx1-j21-header-pinout/ pin out header]. Basically:
Line 668: Line 692:
 
J21 Pin 8 (UART 1 TXD) -> Cable RXD
 
J21 Pin 8 (UART 1 TXD) -> Cable RXD
 
J21 Pin 10 (UART 1 RXD) -> Cable TXD
 
J21 Pin 10 (UART 1 RXD) -> Cable TXD
TX1 J21 Pin 9 (GND) -> Cable GND
+
TX2 J21 Pin 9 (GND) -> Cable GND
 
</pre>
 
</pre>
  
 
There is a [http://jetsonhacks.com/2015/12/01/serial-console-nvidia-jetson-tx1/ nice video with details].
 
There is a [http://jetsonhacks.com/2015/12/01/serial-console-nvidia-jetson-tx1/ nice video with details].
  
= References =
+
= See also  =
  
= Articles related  =
+
*[[Gstreamer pipelines for Tegra X2]]
 +
*[[Tegra X2 or TX2]]
  
:[[Gstreamer pipelines for Tegra X2]]
+
{{ContactUs}}
:[[Tegra X2 or TX2]]
 
  
[[Category:TegraX2]][[Category:GStreamer]]
+
[[Category:Jetson|HowTo‏‎]]

Latest revision as of 12:07, 23 August 2022

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

RR Contact Us.png

Newest Jetpack Versions (Jetpack 3.1 and later)

For newest Jetpack versions please reference this wiki page: Compiling_Tegra_X1/X2_source_code. In case you are going to use Jetpack 3.0 continue in this page.

Introduction

In this wiki page you are going to find the instructions to download the source code to rebuild the Jetson TX2 images using jetpack, several parts of this wiki were based in the document called Start_L4T_Docs.html given by NVIDIA in L4T. This NVIDIA Jetson TX2 page should be considered a work in progress. These steps were run on Jetson TX2.

Platform

Baseboard: 
Jetson module:
Soc: 

Download kernel code

Option 1 Manually Download and Expand

Let's call $DEVDIR the path where you download the kernel.

1. In a browser, navigate to: https://developer.nvidia.com/embedded/downloads, Locate and download the L4T Sources (L4T Sources 27.1 2017/03/14). Also you can use wget command:

wget http://developer2.download.nvidia.com/embedded/L4T/r27_Release_v1.0/BSP/r27.1.0_sources.tbz2

2. Copy L4T kernel sources into DEVDIR.

cp r27.1.0_sources.tbz2 $DEVDIR

3. Expand the TBZ2 file.

tar -vxjf r27.1.0_sources.tbz2
# Decompress kernel
sudo tar -xjf kernel_src.tbz2

Option 2 Sync with git

Let's call $JETPACKDIR the path where you installed your development directory or Jetpack.

1) In order to download the source code you can run the script called source_sync.sh

$JETPACKDIR/64_TX2/Linux_for_Tegra_64_tx2$ ./source_sync.sh

This will download the bootloader and kernel.

2) It downloads all the kernel tree but you need to specify the tag, looking into the script it seems that the tags should be specified with k and u parameters

Use: source_sync.sh [options]
Available general options are,
     -h     :     help
     -e     : exit on sync error
     -d DIR : root of source is DIR

By default, all sources are downloaded.
Only specified sources are downloaded, if one or more of the following options are mentioned.

     -k [TAG]: Download kernel source and optionally sync to TAG
     -u [TAG]: Download u-boot source and optionally sync to TAG

Repositories JetPack 3.0 by default has 4.4 kernel version, but if you go to source_sync.sh script, the kernel version is 3.10 as follows:


k:kernel:nv-tegra.nvidia.com/linux-3.10.git:
u:u-boot:nv-tegra.nvidia.com/3rdparty/u-boot.git:

Change the kernel version removing the line:

k:kernel:nv-tegra.nvidia.com/linux-3.10.git:


and adding:

k:kernel:nv-tegra.nvidia.com/linux-4.4.git:


you can see the repositories on the web looking for:

http://nv-tegra.nvidia.com/gitweb/?o=age

kernel 4.4 and u-boot

http://nv-tegra.nvidia.com/gitweb/?p=linux-4.4.git;a=summary
http://nv-tegra.nvidia.com/gitweb/?p=3rdparty/u-boot.git;a=summary

3) It will download the git repositories for kernel and uboot but you need to specify the branch or the tag

Branch:

cd $JETPACKDIR/64_TX2/Linux_for_Tegra_64_tx2/sources/kernel_source
git branch -a
git checkout l4t/l4t-r27.1

cd $JETPACKDIR/64_TX2/Linux_for_Tegra_64_tx2/sources/u-boot_source
git branch -a
git checkout l4t/l4t-r27.1

Or if you want to download a tag then the command should look like:

./source_sync.sh -k tegra-l4t-r27.1 -u tegra-l4t-r27.1

Toolchain

Option 1

1) Download the pre-built toolchain binaries, The AARCH64 toolchain is available at: http://developer.nvidia.com/embedded/dlc/l4t-gcc-toolchain-64-bit-27-1. The source TAR file is named: gcc-4.8.5-aarch64.tgz

2) Decompress tarball file.

tar -xvf gcc-4.8.5-aarch64.tgz

3) Install toolchain.

mkdir /opt/jetpack3.0
cp install /opt/jetpack3.0/ -r

Option 2

1) Download the pre-built toolchain binaries from the Embedded Download Center on the NVIDIA Developer page at: https://developer.nvidia.com/embedded/downloads (Sources for GCC Tool Chain for 64-bit BSP )

The toolchain source tarball (src_aarch64_gcc-4.8.5.tar) contains the following:

  • The required sources to build the toolchain.
  • The make-aarch64-toolchain.sh script that builds the toolchain.
  • A patches folder containing patches to the toolchain sources.

2) Decompress tarball file.

tar -xvf src_aarch64_gcc-4.8.5.tar

3) Run the toolchain building script.

./make-aarch64-toolchain.sh

4) Install the toolchain

mkdir /opt/jetpack3.0
cp install /opt/jetpack3.0/ -r

Kernel

In order to compile the kernel please follow these steps

Build Kernel

Let's call $DEVDIR the path where you download the kernel code.

1. Specify the path to the toolchain and architecture:

export CROSS_COMPILE=/opt/jetpack3.0/install/bin/aarch64-unknown-linux-gnu-
export ARCH=arm64

2. Define and create destination directories.

export TEGRA_KERNEL_OUT=/home/$USER/devdirs/tegra-kernel/r27.1.0_sources/images
export TEGRA_MODULES_OUT=/home/$USER/devdirs/tegra-kernel/r27.1.0_sources/modules
mkdir -p $TEGRA_KERNEL_OUT
mkdir -p $TEGRA_MODULES_OUT

3. Clean your kernel and configuration

make -C kernel/kernel-4.4/ mrproper

4. Configure your kernel

make -C kernel/kernel-4.4/ O=$TEGRA_KERNEL_OUT tegra18_defconfig
make -C kernel/kernel-4.4/ O=$TEGRA_KERNEL_OUT menuconfig

5. Compile kernel, device tree and modules. To speed up compilation on multiprocessor systems, use -j n, this option tells make to execute many recipes simultaneously.

make -C kernel/kernel-4.4/ O=$TEGRA_KERNEL_OUT zImage
make -C kernel/kernel-4.4/ O=$TEGRA_KERNEL_OUT dtbs
make -C kernel/kernel-4.4/ O=$TEGRA_KERNEL_OUT modules
make -C kernel/kernel-4.4/ O=$TEGRA_KERNEL_OUT modules_install INSTALL_MOD_PATH=$TEGRA_MODULES_OUT

6. Save your Images and device tree

mkdir boot
cp images/arch/arm64/boot/Image boot/
cp images/arch/arm64/boot/dts/* boot/

Flash your Kernel image using Jetpack 3.0 root file system

1. Install jetpack 3.0: http://developer.ridgerun.com/wiki/index.php?title=Installing_Jetpack_3.0

2. Flash your board with Jetpack, the root file system will be on an SD card

3. Go to Linux_for_Tegra_64_tx2 directory

cd $JETPACKDIR/64_TX2/Linux_for_Tegra_64_tx2/

4. Put the board into force USB Recovery Mode:

1. Power down the device. If connected, remove the AC adapter from the device. The device must be
powered OFF, and not in a suspend or sleep state.
2. Connect the Micro-B plug on the USB cable to the Recovery (USB Micro-B) Port on the device and
the other end to an available USB port on the host PC.
3. Connect the power adapter to the device.
4. Press POWER button
5. Press and hold the RECOVERY FORCE (REC) button.
6. While pressing the RECOVERY FORCE button, press and release the RESET button.
7. Wait 2 seconds and release the RECOVERY FORCE button

5. Use ./flash.sh in order to configure TX2 board, Also this script configures jetpack rootfs to be used as SD filesystem. Execute the script as follows:

sudo ./flash.sh jetson-tx2 mmcblk1p1

6. Create ext4 partition called "rootfs".

sudo mkfs.ext4 /dev/mmcblk0p1 -L "rootfs"

7. Copy rootfs from jetpack 3.0

sudo cp -a $JETPACKDIR/64_TX2/Linux_for_Tegra_tx2/rootfs/* /media/$USER/rootfs/

8. Copy kernel image, device tree, and modules.

cd $TEGRA_KERNEL_OUT
sudo cp -a arch/arm64/boot/Image /media/$USER/rootfs/boot/Image 
sudo cp -a arch/arm64/boot/dts/tegra186-quill-p3310-1000-c03-00-base.dtb /media/$USER/rootfs/boot/
cd $TEGRA_MODULES_OUT
sudo cp -a lib/* /media/$USER/rootfs/lib/

9. Modify extlinux.conf. The Device Tree Binary (DTB) is no longer specified by default in /boot/extlinux/extlinux.conf therefore you have to set this field manually in /media/$USER/rootfs/boot/extlinux/extlinux.conf (see: http://elinux.org/Jetson/TX2_DTB)

TIMEOUT 30
DEFAULT primary

MENU TITLE p2771-0000 SD Card boot options

LABEL primary
      MENU LABEL primary kernel
      LINUX /boot/Image
      FDT /boot/tegra186-quill-p3310-1000-c03-00-base.dtb
      APPEND fbcon=map:0 net.ifnames=0 console=tty0 OS=l4t console=ttyS0,115200n8 memtype=0 video=tegrafb no_console_suspend=1 earlycon=uart8250,mmio32,0x03100000 gpt tegraid=18.1.2.0.0 tegra_keep_boot_clocks maxcpus=6 android.kerneltype=normal androidboot.serialno=0335115020673 vpr_resize root=/dev/mmcblk1p1 rw rootwait

10. Unmount the device and Put the SD into the tx2 board, and boot the board.

umount /media/$USER/rootfs 

Username and password: nvidia. You can see the ipaddress connecting a keyboard, mouse and monitor to the board at this point since ubuntu would be already booted.

DTB

Looking into the file $JETPACKDIR/64_TX2/Linux_for_Tegra_tx2/jetson-tx2.conf the dtb used by jetson x1 is: tegra186-a02-bpmp-quill-p3310-1000-a00-00-te770d-ucm2.dtb

#!/bin/bash

# Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#  * Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#  * 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.
#  * Neither the name of NVIDIA CORPORATION 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 ``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 OWNER 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.

# p2771-0000-devkit-24x7.conf: configuration for T186-A02 te770d-UCM2 Silicon

BPFDTB_FILE=tegra186-a02-bpmp-quill-p3310-1000-a00-00-te770d-ucm2.dtb;

source "${LDK_DIR}/p2771-0000.conf.common";

Bootloader

The bootloader is a combination of NVIDIA T-Boot (nvtboot) and U-Boot. You can read about the BOOT FLOW in the nvtboot wiki page.

According to the devtalk forum there are two ways to boot the board: fast boot and uboot

  • Fastboot is simpler, and offers no options during boot. It strictly looks for a kernel in the GPT partition from the install's "-k 6" option. This would probably be the way to go for a non-interactive embedded appliance (if not bare metal booting).
  • U-boot offers more options, and looks for a zImage in the /boot partition. Boot configuration can also be edited here, for example I threw in a couple of zImage variants (like debugging version and network options added), and edited extlinux.conf...and magically I can boot to any of those kernels at the serial console boot prompt (provided my eye is fast). No flash was required for any kernel beyond the first kernel.

Inside of the bootloader directory you will find several binaries or components, to get a description of these please read the nvtboot wiki page.

Build DTC

U-boot requires the Device Tree Compiler (dtc) which is used to compile device tree files contained in the U-Boot source tree. One version is included inside of the kernel. However, that binary is too old according to u-boot when trying to use that one

*** Your dtc is too old, please upgrade to dtc 1.4 or newer
$DEVDIR/images/dtc -v
Version: DTC 1.2.0-g37c0b6a0

In order to build it please run:

cd $JETPACKDIR/64_TX2/Linux_for_Tegra_tx2/sources
git clone git://git.kernel.org/pub/scm/utils/dtc/dtc.git
cd dtc
make
cp dtc $DEVDIR/images/

Build u-boot

1. Backup original uboot files. You see which platform you are using checking the file in $/64_TX2/Linux_for_Tegra_tx2/jetson-tx2.conf, it says:

SYSBOOTFILE=p2371-2180-devkit/extlinux.conf;

copy the files to the packages-backup directory

mkdir $JETPACK/images/packages-backup/bootloader/
cp -rf $JETPACK/64_TX2/Linux_for_Tegra_tx2/bootloader/t210ref/p2371-2180-devkit $JETPACK/images/packages-backup/bootloader/
cd $JETPACK/64_TX2/Linux_for_Tegra_tx2/bootloader/
cp nvtboot.bin nvtboot_cpu.bin u-boot-dtb.bin bpmp.bin warmboot.bin tos.img tegra210-jetson-tx1-p2597-2180-a01-devkit.dtb $JETPACK/images/packages-backup/bootloader/
cp $JETPACK/64_TX2/Linux_for_Tegra_tx2/bootloader/t210ref/p2371-2180 $JETPACK/images/packages-backup/bootloader/

Check that all these components are flashed in one partition according to Jetpack output when flashing Tegra X1. The description of each of these components in on the t210-nvtboot-flow and tegra-boot-flow pages.

2. Go to uboot and set environment variables. You need to export the images directory path in order to allow u-boot find the DTC

cd $JETPACK/64_TX2/Linux_for_Tegra_tx2/sources/u-boot_source/
PATH=$JETPACK/images:$PATH
export CROSS_COMPILE=/opt/linaro/gcc-linaro-5.3-2016.02-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
export ARCH=arm64

3. Clean and compile

make distclean
make p2371-2180_defconfig
make

4. Save your new binaries

mkdir $JETPACK/images/bootloader
cp $JETPACK/64_TX2/Linux_for_Tegra_tx2/sources/u-boot_source/u-boot{,.bin,.dtb,-dtb.bin} $JETPACK/images/bootloader

Note: L4T U-Boot does not use the kernel partition. The kernel is installed into the filesystem alongside the boot configuration file in /boot. Aside from this difference, U-Boot has the same internal eMMC partition layout as that used by cboot.

5. Now, copy your u-boot binaries to the directory used by Jetpack to look for them. As you can see in the DTB it will look for them in

target_board="t210ref";
BOOTLOADER="bootloader/${target_board}/p2371-2180/u-boot-dtb.bin";

To copy the files run

cp  $JETPACK/images/bootloader/u-boot{,.bin,.dtb,-dtb.bin} $JETPACK/64_TX2/Linux_for_Tegra_tx2/bootloader/t210ref/p2371-2180/

6. Now run jetpack or follow the steps below to use flash.sh and let it install the new binaries as we did with the kernel. You can check the serial console output to see that u-boot has a newer date

U-Boot 2015.07-rc2 (Apr 28 2016 - 19:24:09 -0600)

If you are attached to the serial port while flashing you should see the serial port output log while flashing

Boot sequence

According to the U-boot guide provided by Nvidia uboot scans booteable devices as follows:

  • External SD Card
  • Internal eMMC
  • USB Device
  • NFS Device

It looks for an extlinux.conf configuration file in the following directory of the bootable device:

<rootfs>/boot/extlinux

Upon finding the extlinux.conf file, U-Boot does the following.

  • Uses the sysboot command to read out boot configuration from extlinux.conf,
  • Loads kernel Image file and device tree file (/boot), and then
  • Boots the kernel.

extlinux.conf is a standard text-format sysboot configuration file that contains all boot information, it is installed in /boot according to the boot method.

Boot log and uboot environment

Following boot log was obtained when connected to the serial console using the default uboot environment.

The environment is defined in extlinux.conf, however, the environment variables can be set in the uboot code directly or directly when the board is booting using the typical uboot commands like: print, saveenv, printenv, etc

Filesystem

Jetpack comes with a sample filesystem with X and ubuntu and Canonical keeps updating the packages available, you can also use your own filesystem. In both cases you have to install on it the Nvidia binaries, the instructions to do that are in the file Start_L4T_Docs.html, in the Getting started section. It mentions:

Extract the sample file system to the rootfs directory with this command:

$ sudo tar jxpf ../../Tegra-Linux-Sample-Root-Filesystem_<release_type>.tbz2

Run the apply_binaries.sh script to copy the NVIDIA user space libraries into the target file system:

$ cd ..
$ sudo ./apply_binaries.sh

If you are using a different rootfs, or if you have already configured your rootfs, apply the NVIDIA user space libraries by setting the LDK_ROOTFS_DIR environment variable to point to your rootfs. Then run the script, as shown above, to copy the binaries into your target file system.

If the apply_binaries.sh script installs the binaries correctly, the last message output from the script is “Success!”.

You can create your own ubuntu filesystem using .deb packages as sources following this instructions. The sample filesystem provided is a 32 bits filesystem, however, the kernel is a 64bits kernel. According to devtalk nvidia will be releasing a 64bits filesystem.

The remaining steps on this guide assumes that you are using the default filesytem or that you already have one built, specially for the flashing section, where flashing assumes that the filesystem already exists.

To receive notifications of new packages

1. Locate and edit the following file:

/etc/apt/sources.list

2. Add the following line:

deb http://ports.ubuntu.com/ubuntu-ports <distribution>-updates main universe

Where <distribution> is the name of the Ubuntu distribution your rootfs is based on. For example, for a rootfs based on the Trusty Tahr distribution of Ubuntu, add the line:

deb http://ports.ubuntu.com/ubuntu-ports trusty-updates main universe

Prerequisite

You have attached an Ethernet cable to the device through either the Ethernet port (if available) or through the USB Ethernet adapter. To install more packages

  • Boot the target device.
  • Verify your Ethernet connection.
  • Update the package list by executing:
$ sudo apt-get update

Note: Ensure that you run sudo apt-get update and not apt-get upgrade, which upgrades already installed packages. Do not confuse the two commands.

  • Install packages using apt-get. For example, to install wget execute this command:
$ sudo apt-get install wget

Flashing the board

Nvidia provides several scripts to help to generate the images and to flash the resulting images. Including if you are going to install uboot or fastboot. First the board needs to be in recovery mode and then the main script to flash it is $JETPACK/64_TX2/Linux_for_Tegra_tx2/flash.sh. What this script will do is to install or flash the image in the desired destination. It is important that the script is controlled by variables defined in the DTB file.

# Examples:
# ./flash.sh <target_board> mmcblk0p1			- boot <target_board> from eMMC
# ./flash.sh <target_board> mmcblk1p1			- boot <target_board> from SDCARD
# ./flash.sh <target_board> sda1			- boot <target_board> from USB device
# ./flash.sh -N <IPaddr>:/nfsroot <target_board> eth0	- boot <target_board> from NFS
# ./flash.sh -k LNX <target_board> mmcblk1p1		- update <target_board> kernel
# ./flash.sh -k EBT <target_board> mmcblk1p1		- update <target_board> bootloader
#
# Optional Environment Variables:
# BCTFILE ---------------- Boot control table configuration file to be used.
# BOARDID ---------------- Pass boardid to override EEPROM value
# BOOTLOADER ------------- Bootloader binary to be flashed
# BOOTPARTLIMIT ---------- GPT data limit. (== Max BCT size + PPT size)
# BOOTPARTSIZE ----------- Total eMMC HW boot partition size.
# CFGFILE ---------------- Partition table configuration file to be used.
# CMDLINE ---------------- Target cmdline. See help for more information.
# DEVSECTSIZE ------------ Device Sector size. (default = 512Byte).
# DTBFILE ---------------- Device Tree file to be used.
# EMMCSIZE --------------- Size of target device eMMC (boot0+boot1+user).
# FLASHAPP --------------- Flash application running in host machine.
# FLASHER ---------------- Flash server running in target machine.
# IGNOREFASTBOOTCMDLINE -- Block fastboot from filling unspecified kernel
#                          cmdline parameters with its defaults.
# INITRD ----------------- Initrd image file to be flashed.
# ITSFILE ---------------- Multi image u-boot package template file.
# KERNEL_IMAGE ----------- Linux kernel zImage file to be flashed.
# MTS -------------------- MTS file name such as mts_si.
# MTSPREBOOT ------------- MTS preboot file name such as mts_preboot_si.
# NFSARGS ---------------- Static Network assignments.
#			   <C-ipa>:<S-ipa>:<G-ipa>:<netmask>
# NFSROOT ---------------- NFSROOT i.e. <my IP addr>:/exported/rootfs_dir.
# ODMDATA ---------------- Odmdata to be used.
# ROOTFSSIZE ------------- Linux RootFS size (internal emmc/nand only).
# ROOTFS_DIR ------------- Linux RootFS directory name.
# TEGRABOOT -------------- lowerlayer bootloader such as nvtboot.bin.
# UBOOTSCRIPT ------------ U-boot HUSH boot script file.
# UBOOT_TEXT_BASE -------- U-boot Image Load Address.
# UIMAGE_LABEL ----------- Kernel version for U-boot image header.
# UIMAGE_NAME ------------ uImage file name.
# WB0BOOT ---------------- Warmboot code such as nvtbootwb0.bin

Recovery mode

To put the board into force USB Recovery Mode:

1. Power down the device. If connected, remove the AC adapter from the device. The device must be
powered OFF, and not in a suspend or sleep state.
2. Connect the Micro-B plug on the USB cable to the Recovery (USB Micro-B) Port on the device and
the other end to an available USB port on the host PC.
3. Connect the power adapter to the device.
4. Press POWER button
5. Press and hold the RECOVERY FORCE (REC) button.
6. While pressing the RECOVERY FORCE button, press and release the RESET button.
7. Wait 2 seconds and release the RECOVERY FORCE button

All remaining examples assume that the board is in recovery mode

Flash filesystem

Emmc

To flash the filesystem in the emmc you need to run:

cd $JETPACK/64_TX2/Linux_for_Tegra_64_tx2/
sudo ./flash.sh jetson-tx2 mmcblk0p1

USB

Important: Only for USB tegra needs a firmware that is loaded from the filesystem so the USB port is not enabled on uboot and then it causes problems to mount the fs from there, you can read about it here.

To flash the filesystem to USB you need to put the filesystem on the USB first

1) Insert your USB flash/drive in your PC and check where it was mounted

mount
/dev/sdb1 on /media/dsoto/EF02-5626 type vfat (rw,nosuid,nodev,uid=1000,gid=1000,shortname=mixed,dmask=0077,utf8=1,showexec,flush,uhelper=udisks2)

2) Format the USB drive in your PCB

umount /dev/sdb1
sudo mkfs.ext4 /dev/sdb1

3) Copy the filesystem to the USB drive. It takes a while, its size is normally 2.4GB

mkdir $JETPACK/images/fs
sudo mount /dev/sdb1 $JETPACK/images/fs 
cd $JETPACK/64_TX2/Linux_for_Tegra_64_tx2/rootfs/
sudo cp -a * $JETPACK/images/fs  && sync

4) Unmount the USB drive and remove it

sudo umount $JETPACK/images/fs

5) Finally connect the USB drive to the Jetson board put the Jetson on recovery mode, flash the board to look for the filesystem on the USB port:

cd $JETPACK/64_TX2/Linux_for_Tegra_64_tx2/
sudo ./flash.sh jetson-tx2 sda1 #it can be other mount point

SD card

Similar to USB but you need to replace the extlinux.conf so before copying the filesystem into the SD card run:

sudo cp $JETPACK/64_TX2/Linux_for_Tegra_64_tx2/bootloader/t210ref/p2371-2180-devkit/extlinux.conf.sdcard $JETPACK/64_TX2/Linux_for_Tegra_64_tx2/rootfs/boot/extlinux/extlinux.conf

then flash it

cd $JETPACK/64_TX2/Linux_for_Tegra_64_tx2/
sudo ./flash.sh jetson-tx2 mmcblk1p1 

NFS

1) First you need to set up your NFS server using these instructions.

2) Open file in $JETPACK/64_TX2/Linux_for_Tegra_64_tx2/rootfs/etc/network/interfaces and add

auto eth0
iface eth0 inet manual

3) Then flash the board to generate and install the initrd image to use nfs, you need to do this everytime that you recompile the kernel

cd $JETPACK/64_TX2/Linux_for_Tegra_64_tx2/
MY_IPADDRESS=192.169.0.3
sudo ./flash.sh -N $MY_IPADDRESS:$JETPACK/64_TX2/Linux_for_Tegra_64_tx2/rootfs jetson-tx2 eth0

Flash kernel

To flash your kernel you just need to copy it to /boot in your filesystem. The old method to flash it in the LNX partition (./flash.sh -k LNX <target_board> mmcblk1p1) is NOT longer used

sudo cp $JETPACK/images/zImage $JETPACK/images/Image $JETPACK/64_TX2/Linux_for_Tegra_64_tx2/rootfs/boot/

if you are not booting from NFS then you need to reflash your filesystem in order to update the kernel. However, likely you did some changes in the kernel modules so it is recommended to run the apply_binaries.sh script instead of only copying the kernel images.

cd $JETPACK/64_TX2/Linux_for_Tegra_64_tx2/
sudo ./apply_binaries.sh 

then flash your filesystem again.

Flash bootloader

Update the content of the EBT partition where uboot is located

cd $JETPACK/64_TX2/Linux_for_Tegra_64_tx2/
sudo ./flash.sh -k EBT jetson-tx2 mmcblk1p1

Serial Console

J21 contains the Serial Console signals as can be seen in the pin out header. Basically:

J21 Pin 8 (UART 1 TXD) -> Cable RXD
J21 Pin 10 (UART 1 RXD) -> Cable TXD
TX2 J21 Pin 9 (GND) -> Cable GND

There is a nice video with details.

See also


RidgeRun Resources

Quick Start Client Engagement Process RidgeRun Blog Homepage
Technical and Sales Support RidgeRun Online Store RidgeRun Videos Contact Us

OOjs UI icon message-progressive.svg Contact Us

Visit our Main Website for the RidgeRun Products and Online Store. RidgeRun Engineering informations are available in RidgeRun Professional Services, RidgeRun Subscription Model and Client Engagement Process wiki pages. Please email to support@ridgerun.com for technical questions and contactus@ridgerun.com for other queries. Contact details for sponsoring the RidgeRun GStreamer projects are available in Sponsor Projects page. Ridgerun-logo.svg
RR Contact Us.png