JetsonHacks

Developing on NVIDIA® Jetson™ for AI on the Edge

Clone Image – NVIDIA Jetson TK1

In many cases there is a large amount of work that goes into creating a working Jetson development system. This can include such things as loading drivers, compiling source files and libraries, system configuration, and so on. During development, sometimes things can go south and leave the system in a non-working state. Wouldn’t it be great if you could take a snapshot of a baseline system for just such occasions?

Well, you can! This is known as ‘cloning’ the system. In this article, we’ll cover a simple version of saving a system image from a Jetson to a file on a host PC. The host PC is the one which was originally used to run the JetPack installer to flash the Jetson. Looky here:

Guideline and Instructions

Note: This demonstration was on a Jetson originally flashed with L4T 21.4 using JetPack 1.2 on the host PC.
This is a demonstration of the simplest way to save the Jetson image. This technique will save what is called the ‘APP’ partition of the Jetson flash memory (which basically is the ‘Root File System’ and includes the working area of your system) to a file on the host PC which you used JetPack to flash the Jetson originally.

If you are a Linux expert and have added more partitions, or are working on partitions other than ‘APP’ on the system side, see the Jetson/Cloning page on the Jetson wiki for more information about cloning the Jetson. If you don’t know what any of that gibberish means (like me), then you’re in luck because this article is for you.

Cloning the Jetson is actually made up of two parts. The first part is saving the current ‘image’ from the Jetson flash memory as a file onto the JetPack PC. The second part is copying that image back to a Jetson. The Jetson may be the same one, or another Jetson TK1. As you might guess, this is useful when you are trying to replicate a Jetson on another Jetson, or multiple Jetsons.

Saving the Image

In order to save the image, first you will need to navigate to the proper directory on the host PC to begin the process. Open a Terminal and ‘cd’ to the JetPack install directory.

For example, on a default install, the install directory is ~/JetPackTK1-1.2/

$ cd ~/JetPackTK1-1.2

Then, switch over to the boot loader directory:

$ cd Linux_for_Tegra/bootloader

At this point, you’re almost ready to go. Make sure that the Jetson is attached to the PC using the supplied USB cable that you used to flash the Jetson with originally. Set the Jetson into recovery mode, as you did during the original flash. At this point, you should be able to execute on the PC:

$ lsusb

and see the Jetson which is identified as 0955:7140 Nvidia Corp.
To download the image from the Jetson, execute:

$ sudo ./nvflash --read APP clone.img --bl ardbeg/fastboot.bin --go

At this point, you should see magic happen. There will be a counter that is updated as the bytes are downloaded from the Jetson. There are 15GBs of data, so reading them takes a while over USB 2. On my machine it takes about 30 minutes. A PC system running from a virtual machine could take much longer.

Once the download is complete, you will see a file in the directory named ‘clone.img’ which is about 15 GBs in size. This is the downloaded image from the Jetson. You will want to change the permissions of clone.img:

$ sudo chmod 744 clone.img

You can move clone.img to another place to save it. Note: the file can be compressed using Gzip to about a third the size, useful for archival purposes.

Restoring the Image

Restoring a saved image consists of flashing the cloned image to a Jetson. This is the same procedure that happens ‘under the covers’ of JetPack except that instead of a basic ’empty’ system, everything that was loaded on the cloned device is flashed.

The file ‘system.img’ in the bootloader directory is the name of the file which represents the disk image of the Jetson. In order to use the cloned image, you will need to copy the file ‘clone.img’ to ‘system.img’. First, you will need to be in the boot loader directory as described before. For example:

$ cd ~/JetPackTK1-1.2/Linux_for_Tegra/bootloader

Copy the cloned image to the system image that will be flashed:

$ sudo cp clone.img system.img

Notes: The clone.img file must be decompressed if you compressed it to save space. This also assumes that clone.img is still in the bootloader directory. If it was moved or the name changed, you will have to make the necessary adjustments. In any case, the uncompressed cloned image needs to end up in system.img in the bootloader directory.

Next, make sure that the Jetson is connected to the PC through the micro connector USB cable as during normal flashing, and place the Jetson into recovery mode. At this point, you should be able to execute on the PC:

$ lsusb

and see the Jetson which is identified as 0955:7140 Nvidia Corp.

At this point, we’re ready to flash. Here’s the magic incantation:

$ cd ../
# As an example, you should be in ~/JetPackTK1-1.2/Linux_for_Tegra/
$ sudo ./flash.sh -r -S 14580MiB jetson-tk1 mmcblk0p1

The -r flag tells the flashing program to skip building and reuse the existing system.img file. The partition size (-S 14580MiB) is the default that JetPack uses.

More magic should happen as the Jetson is flashed. Note that it will take longer than normal to flash the Jetson in comparison to the empty system as it restores all 15GBs. In the demonstration, the process took about 15 minutes.

When the system is done flashing, reboot the Jetson. The Jetson will be restored to the state of the original at the time of cloning.

Discussion

During the course of developing on the Jetson it is likely that a large amount of time and effort went into loading libraries from repositories, compiling source code, adding applications, building and loading drivers, and configuration. Once a ‘work system’ is built, it can represent a substantial investment.

While almost all developers try to keep their source code updated in repositories such as Github, it seems inevitable that at some point the system represents more than its sum of parts. This is either because the system is out of synch with the external repositories, the smaller bits and pieces were over looked and not committed to the repository, or magical unicorns came through and rooted around with their horn and bonked the system.

Bonk is a technical term for when the system should work but doesn’t. This is prevalent when a project is due, or a demonstration is about to happen. You’ll find this happens most often when everything works, but an extra ‘feature’ is added at the last minute. In the rush to get the feature working, something bad happens, and … bonk.

Given enough time, people find that the cause of these problems is usually minor or a configuration issue. However, the results appear catastrophic at the time and under pressure the participants are often perplexed as to the cause.

Having a system snapshot gives the developer ‘something in their back pocket’ so that a system can be restored to a known working state, which can be invaluable during development.

Another advantage is that it makes it simple to build a system, and then flash it to other machines. This is useful for building clusters of machines, or building several prototypes at once.

Facebook
Twitter
LinkedIn
Reddit
Email
Print

20 Responses

  1. I am having issues with cloning the image on my Jetson. I installed the latest version of Jetpack on a virtual machine running a 64-bit version of Ubuntu 14.04. I went ahead and ran the command that you used in the tutorial and it started Nvflash, but it doesn’t appear to be doing anything. It doesn’t display the bits copied over bits to be copied, just “Nvflash 4.13.0000 started” and that’s it. I looked in process and found nothing of the sort that refers to this.

  2. In your article, it says “Make sure that the Jetson is attached to the PC using the supplied USB cable that you used to flash the Jetson with originally.” Do I actually have to have the “original” host PC or just any PC with JetPack installed?

    The reason I ask is that I am considering buying an http://www.autonomous.ai Deep Learning Robot that comes fully loaded with many ROS packages to a Jetson TK1. I need to be able to clone the TK1 without having the PC that autonomous.ai used to flash the TK1 originally.

    Thanks!

    1. You can use any JetPack compatible computer (PC, Ubuntu 14.04). What you’re doing is copying a disk image from the Jetson to the PC, which gives you a backup of the Jetson. You can then restore the image, which means flash it with the backup. JetPack is basically a wrapper around the lower level commands to flash and copy files to/from the Jetson. Good luck!

  3. Hello There. Just tried your methodology, and it worked, but I’d like to suggest an edit in your documentation, if you don’t mind.

    In the restoration step, where you give us the command:

    sudo ./flash.sh -r -S 14580MiB jetson-tk1 mmcblk0p1

    Your accompanying note says the following:

    The -s flag tells the flashing program to skip building and reuse the existing system.img file.

    I believe you meant to reiterate using the lowercase -r argument, instead of a lowercase -s flag in your note, right? I had to look it up to be sure it was indeed supposed to be -r so the skip action would occur.

    And another note for anyone following this thread, is that “we” had to add an additional “-L bootloader/ardbe/u-boot.bin” arg/value pair to the command line just prior to the jetson-tk1 positional argument in the command line. This made it where the system wouldn’t ignore the upgrade and use its fastboot sequence that’s probably stored in ROM.

    Thanks for this great work you’ve done to help us save some time.

    Regards,
    Carl
    Aeye, Inc.

    1. Hi Carl,
      Good catch! Sometimes it’s hard to be your own editor, you miss the obvious. I fixed the article as you advised, and thanks for your comment. Thanks for reading!

  4. I flashed the Jetson TK1 manually instead of flashing system by installing JetPack for L4T.
    In detail, first I downloade the Kernel and Driver Package ( Tegra124 Linux R21.4.0 armhf.tbz2 ) from
    http://developer.download.nvidia.com/embedded/L4T/r21_Release_v4.0/Tegra124_Linux_R21.4.0_armhf.tbz2, and I also get the Sample file system from http://developer.download.nvidia.com/embedded/L4T/r21_Release_v4.0/Tegra_Linux_Sample-Root-Filesystem_R21.4.0_armhf.tbz2
    second I download the .deb file for the CUDA Toolkit for L4T from http://developer.download.nvidia.com/embedded/L4T/r21_Release_v3.0/cuda-repo-l4t-r21.3-6-5-prod_6.5-42_armhf.deb , and I install the CUDA manually.

    Question: there is not the JetPack install directory that is ~/JetPackTK1-1.2/ ,how can I clone the TK1 system image and the installed application program ?

    Thanks!

    1. You need to find the directory ‘bootloader’ where the flash tools are located. You can do a search to find nvflash, which is the flashing programming that you need and the location to clone the image.

  5. Hello there.

    Firstly, I want to thank you for the great work you’ve done with your page, it have been of great help to me.
    I am working my dissertation on a Jetson TX1 originally flashed with L4T 28.1 using JetPack 3.1 on the host PC and I need to save the Jetson image. I want to know if is the same procedure to do it?

    Regards,
    Andrea Fernández

  6. HI
    I am trying to clone a jetson Xavier computer with Jetpack 5.1.2 and NVflash is not in that Jetpack version on my host computer. Can you help?

Leave a Reply

Your email address will not be published. Required fields are marked *

Disclaimer

Some links here are affiliate links. If you purchase through these links I will receive a small commission at no additional cost to you. As an Amazon Associate, I earn from qualifying purchases.

Books, Ideas & Other Curiosities