Yocto Support for NVIDIA Jetson Platforms - Flashing the Jetson Platform

From RidgeRun Developer Wiki




Previous: Setting up Yocto Index Next: Accessing the Board




eMMC boot

1. Save the following script to deploy.sh

#!/bin/bash

image=$1
machine=$2

scriptdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
deployfile=${image}-${machine}.tegraflash.tar.gz
tmpdir=`mktemp`

rm -rf $tmpdir
mkdir -p $tmpdir
echo "Using temp directory $tmpdir"
pushd $tmpdir
cp $scriptdir/build/tmp/deploy/images/${machine}/$deployfile .
tar -xvf $deployfile
set -e
sudo ./doflash.sh
popd
echo "Removing temp directory $tmpdir"
rm -rf $tmpdir

2. Connect the USB port to the host machine and put the target board in recovery mode.

3. Use the script as follows:

./deploy.sh <IMAGE> <MACHINE>

for example:

./deploy.sh core-image-sato-dev jetson-tx2

SD Card boot

TX1/TX2

By default, meta-tegra does not include support for SD card image creation. When working on Jetson TX1/TX2 it is useful to switch to SD card boot so it makes it easier to test different images and simplifies development. This section shows how to add the WIC profile for SD image generation.

In order to add the WIC profile, create the following directory:

cd $YOCTO_DIR
mkdir meta-tegra/wic

And create the file meta-tegra/wic/jetson-sdcard.wks with the following content:

# short-description: Create SD card image
# long-description: Creates an SD card image with a single EXT4 partition for FS.

part / --source rootfs --ondisk mmcblk2 --fstype=ext4 --label root --align 4

Then add the following line to your machine configuration file $YOCTO_DIR/meta-tegra/conf/machine/<MACHINE>.conf Remember to replace <MACHINE> with your selected machine in the configuration file path.

WKS_FILE ?= "jetson-sdcard.wks"

Finally, add the new file system type wic.gz to your build/conf/local.conf file as shown below:

IMAGE_FSTYPES = "tegraflash tar.gz wic.gz"

After performing the above changes you can rebuild your image, for example:

bitbake core-image-sato-dev

This will create a new .wic.gz file in the deploy directory with the base name matching your image name as shown below:

$ ls *.wic.gz
core-image-full-cmdline-jetson-tx1-20200525213940.rootfs.wic.gz
core-image-full-cmdline-jetson-tx1.wic.gz
core-image-sato-dev-jetson-tx1-20200526003706.rootfs.wic.gz
core-image-sato-dev-jetson-tx1.wic.gz

In order to flash it to your SD just insert your SD card to your PC and dump the file contents on it using dd as follows:

# IMPORTANT: Make sure you use the right device name for your SD card, in my case it is /dev/sdd
gunzip -c core-image-sato-dev-jetson-tx1.wic.gz | sudo dd of=/dev/sdd bs=10M status=progress

Once you have flashed the SD card, you need to access the /boot/extlinux/extlinux.conf file of the SD Card and replace this line:

APPEND ${cbootargs} root=/dev/mmcblk${devnum}p${distro_bootpart} rw rootwait ${bootargs} 

for this one:

APPEND ${cbootargs} root=/dev/mmcblk2p1 rw rootwait ${bootargs} 

At this point, the SD Card is ready, so you can insert it into your Jetson board and boot from it.

Nano

1. First, you need to get and extract the tegraflash.

Note: All the flashing/sdcard operations must be done in the temp directory below, do NOT use the tegraflash directory inside the Yocto build because it will create files under sudo permissions.

cd $YOCTO_DIR

image=core-image-sato-dev
machine=jetson-nano-devkit

scriptdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
deployfile=${image}-${machine}.tegraflash.tar.gz
tmpdir=`mktemp`

rm -rf $tmpdir
mkdir -p $tmpdir
echo "Using temp directory $tmpdir"
pushd $tmpdir
cp $scriptdir/build/tmp/deploy/images/${machine}/$deployfile .
tar -xvf $deployfile
set -e

If this is the first time booting a Yocto image from the SD card or the Jetson Nano gets stuck while booting, it is necessary to program the bootloader content on the SPI flash device to make it compatible with the Yocto SD card layout:

1. Connect the Jetson Nano to the computer with a USB cable.

2. Turn on the device and set it to Forced Recovery Mode.

3. Either flash the entire device via USB:

sudo ./doflash.sh

Or only the SPI flash:

sudo ./doflash.sh --spi-only

After the first time, you can continue only flashing the SD card with new images.

You have 2 options:

  • Create an SD card image to flash it later Goto Step (2.) below or
  • Flash the SD card right away? Skip Step (2.) below and Jump to Step (3.):

2. Create SD card image

./dosdcard.sh

3. Flash the SD Card

In order to flash to your SD directly, insert your SD card to your PC and run the following:

# IMPORTANT: Make sure you use the right device name for your SD card, in my case it is /dev/mmcblk0
sudo ./dosdcard.sh /dev/mmcblk0

4. Remove temporal directory

popd
echo "Removing temp directory $tmpdir"
rm -rf $tmpdir

How to boot

After flashing the microSD card with the Yocto image you are ready to boot up the Jetson Nano platform.

You will need:

  • A Jetson Nano.
  • An microSD card with the core-image-sato-dev already flashed.
  • A monitor and a cable to connect the monitor (HDMI or DP).
  • A USB keyboard.
  • A USB mouse.
  • A power supply. It can be a 5V--2A microUSB power supply. The Jetson Nano also supports a DC barrel jack power supply.
  • A pin header jumper. Needed to use the DC barrel jack.


Procedure:

1. Insert the microSD card into the slot situated under the heat sink.

2. Connect the peripherals: monitor, keyboard, and mouse.

3. If you intend to use the barrel jack power supply, first you need to connect the J48 jumper. It is located between the DC barrel jack and the MIPI CSI-2 camera connectors. If you are planning to use a microUSB power supply do not connect the J48 jumper.

4. Connect the power supply. The green LED should turn on after this. The Jetson Nano will boot in a couple of minutes. It will show the NVIDIA logo, the Yocto logo, and then it will be ready to use.

If you try booting the Jetson with the generated Image and you are using the DP connection you will find that the result is just a black screen, that's because this image doesn't support DP, the solution to this problem is to switch to the HDMI connection.


Previous: Setting up Yocto Index Next: Accessing the Board