Copying filesystem from TX1 memory to SD card

Today I unfortunately ran out of space on the internal memory of the TX1. I could not login or get to a terminal (ctrl + alt + F1), so I made a copy of my board:

sudo ./tegraflash.py --bl t210ref/cboot.bin --applet nvtboot_recovery.bin --chip 0x21 --cmd "read APP my_backup.img"

I have re-flashed the board (kernel and bootloader) for SD card using:

sudo ./flash.sh jetson-tx1 mmcblk1p1

and I have moved the sample filesystem on the SD Card. The board boots fine.

Now I am trying to recover the filesystem back into the sd card (minus bootloader and kernel), and I am trying to use the following:

sudo ./tegraflash.py --bl t210ref/cboot.bin --applet nvtboot_recovery.bin --chip 0x21 --cmd "write APP my_backup.img"

but I am getting the following error:

[   0.0248 ] Boot Rom communication
[   0.0262 ] tegrarcm --chip 0x21 --rcm rcm_list_signed.xml
[   0.0276 ] BootRom is not running
[   0.2363 ] 
[   0.2364 ] Sending bootloader and pre-requisite binaries
[   0.2379 ] tegrarcm --download ebt /home/rudy/Downloads/Jetson_TX1/Linux_for_Tegra/bootloader/t210ref/cboot.bin 0 0
[   0.2395 ] USB communication failed.Check if device is in recovery
[   0.4483 ] 
Error: Return value 8
Command tegrarcm --download ebt /home/ubuntu/Downloads/Jetson_TX1/Linux_for_Tegra/bootloader/t210ref/cboot.bin 0 0

I am struggling to recover the filesystem. I would be okay to copy the filesystem directly to the SD Card. What should I do to recover my system image and put it on my SD Card please?

Just to verify, was the Jetson in recovery mode (any flash program use requires this)? Also, if any operation was done in recovery mode, then the recovery mode must be restarted to do a second operation. For example, if you clone a partition in recovery mode, it is not possible to flash without restarting recovery mode.

FYI, flash is not needed to put a root partition on an SD card. dd or file copy will put root partition on SD card (apply_binaries.sh with -r option is a file copy).

To clarify, did you clone the eMMC root partition, or use direct file copy to copy eMMC? Where or what is the device where your backup copy is which needs to be put back onto Jetson?

Flash to mmcblk1p1 may have different results than simply pointing extlinux.conf at SD card. There can be a subtle but very important difference between boot loader requiring extlinux.conf to be in “/boot” of SD card versus being in “/boot” of eMMC.

My mistake:

sudo ./tegraflash.py --bl t210ref/cboot.bin --applet nvtboot_recovery.bin --chip 0x21 --cmd "write APP my_backup.img"

just worked but I had to go back into recovery mode, as you mentioned. Thanks!

That unfortunately reflashed the boot loader and kernel.

I ran “read APP” on host Linux machine (seems like I copied bootloader, kernel, etc… I’m interested in the root file system (where I ran a bunch of apt-get install and compiled code from source).

After flashing mmcblk1p1 and having made sure I can boot on a sample filesystem, how can I retrieve the filesystem from my_backup.img so I can copy it to the SD card please?

The root partition is in fact the APP partition. Boot loader is not written when writing APP. However, when you flashed earlier to mmcblk1p1 instead of mmcblk0p1, this may have changed some of the other partition information beyond what an edit to extlinux.conf would have changed.

On your host, if you just want to see what is on my_backup.img, you can loopback mount it. For example, to make this available on “/mnt”:

sudo mount -o loop my_backup.img /mnt
# examine "/mnt"...
# If wanted, remove irrelevant files to make more room available...
# Then deactivate the mount of that image...cd out of the "/mnt" followed by:
sudo umount /mnt

This is a large file (about 15GB), so copying it around is slow. However, if you copy my_backup.img to the driver package subdirectory “bootloader” as file “system.img” (remove the old system.img.raw), and use the “-r” flash parameter, then this backup image will be installed to the root partition of the Jetson. FYI, the size of the uncompressed clone will match the original "-S " flash parameter if divided by the correct multiple of “1024”. For example, if flash was first run with “-S 14580MiB”, then cloned file size is “14580 * 1024 * 1024” == 15288238080 bytes. If the original flash had been “-S 14GiB”, then the exact image size would be “14 * 1024 * 1024 * 1024” == 15032385536 bytes. Partition layout would reflect this if you were to look at exact partition offsets. You may not need to name the “-S” size during image re-use, but I always do anyway. I’ve always used “-S 14580MiB” so when I restore a clone it would be this:

sudo flash.sh -S 14580MiB -r jetson-tx1 mmcblk0p1

Note: There are multiple ways to copy the backup image to SD card. For example “sudo cp -adpr /mnt/* /some/sd/card/mount/point/for/first/SD/partition”. “dd” is another way.