In Part 1 of this article, we went over the boot sequence of the Jetson Xavier NX Developer Kit. Now lets down to work and actually do some updating!
Updating to JetPack 5
There are a few different ways to upgrade the Jetson NX Developer Kit to JetPack 5. We know from the discussion above that we must upgrade the QSPI to replace the bootloaders. We discuss here how to upgrade a system that runs from a SD card. Here’s three ways:
- Create a new JetPack 5 SD card and upgrade the QSPI from a Xavier NX system running JetPack 4.5+. The advantage of this approach is that there is no Ubuntu host machine required. However, you will need a different computer to flash the SD card (Windows, Macintosh, Linux). You will also need flashing software for the SD card, NVIDIA recommends Etcher.
- Download the Jetson Linux 35.1 Board Support Package (BSP) and root file system to a host x86 Ubuntu system. Ubuntu 18.04 or 20.04. Then, build the QSPI image and flash the Jetson using a USB cable.
- Use the NVIDIA SDK Manager. This is the best way if:
- You do not have a running Xavier NX System and are unfamiliar with the command line flashing utilities
- You intend to run the system from an external storage device other than the SD card (NVMe SSD, USB, and so on).
Here’s one thing to keep in mind. The bootloader versions must match the version of JetPack in use. If you upgrade to JetPack 5 (Jetson Linux 35.1), you will not be able to use a JetPack 4.X SD card with it. And visa versa. This means that you will want to know how to flash the QSPI for the JetPack 4.X version that matches your SD card.
Unfortunately it’s not quite as easy to flash the JetPack 4.X QSPI. There is no QSPI image readily available from NVIDIA like there is for the JetPack 5 version. So it’s either download the JetPack 4.X BSP and root file system and flash the QSPI or use the NVIDIA SDK manager to downgrade.
With all that said, let’s get down to work.
Upgrade Directly On Jetson
If you have a running Xavier NX Dev Kit running JetPack 4.5+, you can do the following. I flash both a JetPack 5.0 card and a JetPack 4.6 card on a separate computer (Windows, Macintosh, Linux). Make sure that the SD card is at least 64GB for the JetPack 5.0 install. Here are a few that I use. Shop around, prices always be changing! (Amazon links):
- PNY technologies 64GB Elite Class
- Samsung EVO Select 64GB
- SanDisk 64GB Ultra
From there, it is the same method as usual for creating a Jetson SD card:
- Download JetPack 5.0.2 SD Card Image:
- Go to: https://developer.nvidia.com/embedded/jetpack-sdk-502
- There is a link to the Xavier NX SD Card image under the section “SD Card Image Method”-“Jetson Xavier NX Developer Kit”. Currently it points to the latest SD card image https://developer.nvidia.com/jetson-nx-developer-kit-sd-card-image
- Download Etcher: https://www.balena.io/etcher/
- Burn SD Card Image using Etcher from the new image
- Download JetPack 4.6.1 SD Card Image
- There is a link to the Xavier NX SD Card image under the section “SD Card Image Method”-“Jetson Xavier NX Developer Kit” there: https://developer.nvidia.com/embedded/l4t/r32_release_v7.1/jp_4.6.1_b110_sd_card/jetson_xavier_nx/jetson-nx-jp461-sd-card-image.zip
- Burn SD Card Image
Let’s switch over to the Jetson. Boot the Jetson from the new 4.6 card. This is the safest way in that you don’t put one of your regular development SD cards at risk.
Download the QSPI image file from the Jetson Linux 35.1 page. It’s toward the bottom of the page. Currently it points to Jetson_Xavier_NX_QSPI_35.1.tbz2 You may want to put this in a new folder. Navigate to the folder where the QSPI image is stored. Open a Terminal on that location.
You are ready to flash the QSPI. As usual, the $ below represents a prompt; it is not part of the command.
$ sudo flash_eraseall /dev/mtd0 $ tar -xvf Jetson_Xavier_NX_QSPI_35.1.tbz2 jetson-xavier-nx-devkit.spi.img $ sudo flashcp jetson-xavier-nx-devkit.spi.img /dev/mtd0
Once the flashcp command finishes, power down the Xavier NX. Replace the JetPack 4.6 SD card with the JetPack 5.0 card and apply power to the Jetson again. The machine will boot and you will be in the goodness of JetPack 5 land.
Downgrade to JetPack 4.X
In case you need to go back to run an earlier version of JetPack, you can use one of two methods. The first method is to use the NVIDIA SDK Manager. This is well documented, we won’t be covering that method here.
The second method is to download the Board Support Package (BSP) and root file system (rootfs) for the version of JetPack 4.X you need. Download the files to a x86 host machine running Ubuntu 16.04 or Ubuntu 18.04. The archives for Jetson Linux are here. Note: you should go directly to the NVIDIA website to download these packages, links are here for illustration:
From the page Jetson Linux 32.7.2: https://developer.nvidia.com/embedded/linux-tegra-r3272
In the Jetson Linux Developer Guide (32.7.2) there is a section “Preparing a Jetson Developer Kit for Use“. The section goes over the steps to setup and flash the Xavier NX.
Once the BSP and rootfs are on the host, open a Terminal and set the directory to that of where the BSP and rootfs are located. At that point, you are ready to build the target images.
First, set the environment variables. For example for 32.7.2 :
$ BOARD=jetson-xavier-nx-devkit $ L4T_RELEASE_PACKAGE=jetson_linux_r32.7.2_aarch64.tbz2 $ SAMPLE_FS_PACKAGE=tegra_linux_sample-root-filesystem_r32.7.2_aarch64.tbz2
Then untar the files and assemble the rootfs:
$ tar xf ${L4T_RELEASE_PACKAGE} $ cd Linux_for_Tegra/rootfs/ $ sudo tar xpf ../../${SAMPLE_FS_PACKAGE} $ cd .. $ sudo ./apply_binaries.sh
You also need to make sure the dependencies on the host are met:
$ sudo apt-get install qemu-user-static
Place the Jetson into Force Recovery Mode:
- Using a data USB cable, connect the host to the micro-USB connector on the dev kit.
- Place a jumper across pins 9 and 10 (FC REC and GND) of the button header (J14), located on the edge of the carrier board under the Jetson module.
- Connect power – The developer kit powers on and enters Force Recovery Mode
- Check to make sure that you can “see” the dev kit from the host. (See note below)
- Remove the jumper from pins 9 and 10 of the button header
Note: From the command line on the host, enter the command:
$ lsusb
You should see an entry for NVIDIA, 955:7e19 which indicates that the Xavier NX is in force recovery mode. If the entry is 955:7e20, then the Jetson is connected, but not in force recovery mode.
You are now ready to flash. To flash only the QSPI, go to the Linux_for_Tegra directory and execute:
$ sudo ./flash jetson-xavier-nx-devkit-qspi mmcblk0p1
This will take around 3 or 4 minutes to complete. Upon completion, the Jetson is ready to use with the JetPack 4 SD card created earlier. Turn the power off, insert the JetPack 4 card, and then restart the Jetson. You can also disconnect the Jetson from the host computer.
You can flash both the QSPI and a SD card using this method. Note: The SD card will be erased. Instead of the last command above, place a SD card in the Jetson, and execute:
$ sudo ./flash jetson-xavier-nx-devkit mmcblk0p1
It usually takes quite a bit longer to go this route than flashing just the QSPI and separately flashing the SD card using Etcher.
JetPack 5 QSPI Flash
You can also use the method outline above to flash the QSPI for JetPack 5 from a host computer.
Jetson Linux 35.1 is part of JetPack 5.0.2: https://developer.nvidia.com/embedded/jetpack-sdk-502
Jetson Linux 35.1: https://developer.nvidia.com/embedded/jetson-linux-r351
In the Jetson Linux Developer Guide there is a section “Preparing a Jetson Developer Kit for Use” which you will find useful. In a nutshell it is the same steps as the JetPack 4.X versions, but with different files.
Once the BSP and rootfs are on the host, make sure you place the JetPack 5 files in a different directory than the JetPack 4 files. Open a Terminal and set the directory to that of where the BSP and rootfs of JetPack 5 are located. At that point, you are ready to build the target images.
First, set the environment variables. As an example for 35.1 :
$ BOARD=jetson-xavier-nx-devkit $ L4T_RELEASE_PACKAGE=jetson_linux_r35.1.0_aarch64.tbz2 $ SAMPLE_FS_PACKAGE=tegra_linux_sample-root-filesystem_r35.1.0_aarch64.tbz2
Then untar the files and assemble the rootfs:
$ tar xf ${L4T_RELEASE_PACKAGE} $ cd Linux_for_Tegra/rootfs/ $ sudo tar xpf ../../${SAMPLE_FS_PACKAGE} $ cd .. $ sudo ./apply_binaries.sh
You also need to make sure the dependencies on the host are met:
$ sudo apt-get install qemu-user-static
Place the Jetson into Force Recovery Mode:
- Using a data USB cable, connect the host to the micro-USB connector on the dev kit.
- Place a jumper across pins 9 and 10 (FC REC and GND) of the button header (J14), located on the edge of the carrier board under the Jetson module.
- Connect power – The developer kit powers on and enters Force Recovery Mode
- Check to make sure that you can “see” the dev kit from the host. (See note below)
- Remove the jumper from pins 9 and 10 of the button header
Note: From the command line on the host, enter the command:
$ lsusb
You should see an entry for NVIDIA, 955:7e19 which indicates that the Xavier NX is in force recovery mode. If the entry is 955:7e20, then the Jetson is connected, but not in force recovery mode.
You are now ready to flash. To flash only the QSPI, go to the Linux_for_Tegra directory and execute:
$ sudo ./flash jetson-xavier-nx-devkit-qspi mmcblk0p1
This will take around 3 or 4 minutes to complete. Upon completion, the Jetson is ready to use with the JetPack 5 SD card created earlier. Turn the power off, insert the JetPack 5 card, and then restart the Jetson. You can also disconnect the Jetson from the host computer.
You can flash both the QSPI and a SD card using this method. Note: The SD card will be erased. Instead of the command above, place a SD card in the Jetson, and execute:
$ sudo ./flash jetson-xavier-nx-devkit mmcblk0p1
It usually takes quite a bit longer to go this route than flashing just the QSPI and separately flashing the SD card using Etcher.
Summary
This article has been more of an explainer than anything else. The take away is that the bootloading sequence on the Jetson is non-trivial. There are a lot of factors that go into bringing a modern system up. We only went through a high level overview. When you start modifying the bootloaders, device tree and other low level components in the boot sequence, you will need to know a whole lot more. But at least you know what to start looking for, and where.
The post Upgrade Jetson Xavier NX to JetPack 5 – Part II appeared first on JetsonHacks.