How to flash and boot a Jetson from NVMe SSD

From RidgeRun Developer Connection
Jump to: navigation, search

Introduction

This is a quick example guide on how to use initrd (initial RAM disk) to flash and boot from NVMe SSD.

This guide was made using a Jetson AGX Xavier Devkit with JetPack 4.6 (L4T 32.6.1), however, it should also work for:

  • Jetson Xavier NX
  • Jetson TX2 series

Note: Jetson Nano and Jetson TX1 devices support booting from NVMe, but it is not stated in the NVIDIA documentation that they support being flashed with initrd.

Dependencies and considerations

  • This procedure requires the Secureboot package to be installed. See Installing the Secureboot Package.
  • In case of using a custom carrier board, make sure that it supports USB device mode.
  • Use a high-quality USB‑C / micro-USB cable.
  • Temporarily disable Automount:
sudo systemctl stop udisks2.service
  • Install the following dependencies on the host machine:
sudo apt install libxml2-utils simg2img network-manager abootimg sshpass device-tree-compiler

Note: Jetson AGX Xavier series devices need its internal eMMC to be flashed before trying to boot from NVMe SSD, since they use boot firmware that is stored there. You can use the SDK manager for this.

Flashing with initrd

You can find the initrd flash script in the following path after installing the Jetson Board Support Package with the SDK manager.

Linux_for_Tegra/tools/kernel_flash/l4t_initrd_flash.sh

To flash the Jetson's NVMe with initrd:

1. Put the Jetson device in Recovery Mode.

2. Move into the Linux_for_Tegra directory in the host machine:

cd Linux_for_Tegra

3. Run the script with the following arguments:

sudo ./tools/kernel_flash/l4t_initrd_flash.sh \
      --external-device <external-device> \
      -c <external-partition-layout> \
      -S <APP-size> \
      --external-only \
      --showlogs \
      <board-name> \
      <rootdev>

Where

  • <external-device> is the name of the external storage device you want to flash, in this case "nvme0n1p1".
  • <external-partition-layout> is the partition layout for the external storage device in XML format. You can find example layouts in the Linux_for_Tegra/tools/kernel_flash directory. For this example, we are using the example layout called flash_l4t_nvme.xml. In this file, we set num_sectors="1953000000" since we are using a 1TB SSD.
  • <APP-size> is the size of the partition that contains the operating system in bytes. This size cannot be bigger than "num_sectors" * "sector_size" specified in the <external-partition-layout> and must be small enough to fit other partitions in the partition layout. For this example, we use "900GiB".
  • <board-name> variable is the same as the <board> variable used with the flash.sh script. Here you can find a table of device names that can be used. In this case, we use "jetson-agx-xavier-devkit".
  • <rootdev> can be set to "mmcblk0p1" or "internal" for booting from internal device or "external", "sda1" or "nvme0n1p1" for booting from external device. In this case, we use "nvme0n1p1".
  • Add the --external-only option to flash only the external storage device. Without it, the above command will flash both internal and external storage devices.

Note: You can find more information about this arguments and other uses for initrd at Linux_for_Tegra/‌tools/‌kernel_flash/README_initrd_flash.txt.

The complete command should look like the following:

sudo ./tools/kernel_flash/l4t_initrd_flash.sh \
     --external-device nvme0n1p1 \
     -c ./tools/kernel_flash/flash_l4t_nvme.xml \
     -S 900GiB \
     --external-only \
     --showlogs \
     jetson-agx-xavier-devkit \
     nvme0n1p1


This process can take several minutes to complete, and the end of the log should look similar to the following:

Reboot target
Run command: sync; { sleep 1; reboot; } >/dev/null & on root@fe80::1%usb0
Success
Cleaning up...
Log is saved to Linux_for_Tegra/initrdlog/flash_3-1.3_0_20230519-172308.log

Booting from NVMe SSD

1. To boot from the SSD you need to change the boot order so that the NVMe has boot priority over the other options. By default the order is as follows:

1.sd
2.usb
3.nvme
4.emmc
5.net

For this example, it was not needed to change the order since we are not using SD or USB. If you need to change the boot order you can check the following documentation:

Note: For a Jetson AGX Xavier, the first link should be followed.

2. Follow the initial configuration by connecting an HDMI screen to the Jetson or through the serial console, using the device /dev/ttyACM0 for Jetson AGX Xavier.

References and links of interest