Additional info: flash.sh is part of the “driver package”, and runs on the x86_64 PC host. When the Jetson is in recovery mode it becomes a custom USB device instead of a host. The driver package is what understands the recovery mode Jetson. The L4T R27.1 downloads page (includes driver package…JetPack is a front end to the driver package and some extra software) is at:
If you want to clone read this thread (there is a modified flash.sh script…the listing there can just be copied and pasted into a file “flash.sh” set with execute permission):
Normally the flash process goes like this:
- Unpack driver package.
- cd to the rootfs subdirectory.
- Unpack the sample rootfs using sudo.
- cd ..
- sudo ./apply_binaries.sh
- Put the Jetson in recovery mode.
- Run sudo flash.sh
- rootfs is modified with boot edits
- An empty file the size of the destination file system is created (perhaps 28GB in size).
- The blank file is formatted as ext4 under loopback.
- rootfs is copied over to the blank file under loopback.
- A "sparse" (compressed) version of that raw/uncompressed image is created.
- The sparse image is copied to the Jetson eMMC
- Flash is complete.
Historically there was not always a sparse (compressed image), but due to how long it took to copy over USB2 the sparse image had support added. Prior to sparse images the flash program just used the raw image directly. The current flash program can still use an uncompressed/raw image. The order of dealing with flash images is that “bootloader/system.img” is created; this is then moved to “bootloader/system.img.raw”, and then system.img.raw is used to compress into system.img. flash.sh does not care if system.img is raw or sparse, it works.
When you clone the root partition you can place it in the bootloader subdirectory with the name “system.img”. If you use the command line option to flash.sh of “-r”, then all of the steps to build the system.img and system.img.raw are skipped…in this case it expects system.img to already exist, and flashes that without touching it. So you clone, name the clone file system.img, put it in the bootloader subdirectory, and flash something like this:
sudo ./flash.sh -r jetson-tx2 mmcblk0p1
The raw system.img is loopback mountable so it can be edited, explored, so on. This should produce exactly the same file as dd would produce when covering the mmcblk0p1 partition. The difference is that dd requires a running Jetson, and cloning works on a recovery mode Jetson regardless of whether the Jetson can be booted or not. You could use a dd image named system.img and achieve the same results from restore with the “-r” option.
Note that there are many hidden partitions on a Jetson. Most of the time it isn’t necessary to clone those or back them up since they have no effect on most customizations. I don’t know what the command is on the current flash script to clone “all” as a single image (meaning including hidden partitions), but you could use dd on mmcblk0 instead of mmcblk0p1 and get that entire image. dd could then be used again with the proper offsets and lengths to extract the root partition and you’d once more end up with exactly the same image as what a clone or mmcblk0p1 dd would give.
Note that the “bootloader/mksparse” program is able to take a raw image and convert it to a sparse image, but as soon as you do that your clone or backup can no longer be loopback mounted or edited. You can still flash with it. For info on mksparse see the JTK1 clone info:
There are ways to convert a sparse image back to a raw image, but I have not researched that so I couldn’t tell you what the command would be.