Backup restore, workflow #3 massflash jetson orin nano problem

Hello everyone,

I have custom carrier board which trying to mass clone, restore to one device are working fine, but with 500+ will be hell, so I trying to use workflow #3 from initrd README

First step make a backup from prepared device, success

./tools/backup_restore/l4t_backup_restore.sh -b -c p3509-a02+p3767-0000

Seconds step, create package for mass flashing, in guide last argument are mmcblk0p1 but I have only nvme inside so I replace it with nvme0n1, success

./tools/kernel_flash/l4t_initrd_flash.sh --use-backup-image --no-flash --network usb0 --massflash 10 p3509-a02+p3767-0000 

Third step, crashed after device rebooted for SSH commands, I dont fully understand why its trying to create GPT for emmc, which I dont have one, tried even manually removed it from scripts ( there was horrible things will happen if I do this ) failed

Attempts to add external device param dont do anything

./tools/kernel_flash/l4t_initrd_flash.sh --flash-only --massflash 10 --network usb0

Another variation of command and output

./tools/kernel_flash/l4t_initrd_flash.sh --flash-only --massflash 2 --network usb0 --external-device nvme0n1p1 -c ./tools/kernel_flash/flash_l4t_external.xml p3509-a02+p3767-0000 nvme0n1p1
.../JetPack_5.1.1_Linux_JETSON_ORIN_NANO_TARGETS/Linux_for_Tegra/tools/kernel_flash/l4t_initrd_flash_internal.sh --network usb0 --usb-instance 3-5.2 --device-instance 0 --flash-only --network usb0 p3509-a02+p3767-0000 nvme0n1
Start flashing device: 3-5.2, rcm instance: 0, PID: 52248
Log will be saved to Linux_for_Tegra/initrdlog/flash_3-5.2_0_20240124-125026.log
.../JetPack_5.1.1_Linux_JETSON_ORIN_NANO_TARGETS/Linux_for_Tegra/tools/kernel_flash/l4t_initrd_flash_internal.sh --network usb0 --usb-instance 3-13 --device-instance 1 --flash-only --network usb0 p3509-a02+p3767-0000 nvme0n1
Start flashing device: 3-13, rcm instance: 1, PID: 52249
Log will be saved to Linux_for_Tegra/initrdlog/flash_3-13_1_20240124-125026.log
Ongoing processes: 52248 52249
Ongoing processes: 52248 52249
Ongoing processes: 52248 52249
Ongoing processes: 52248 52249
Ongoing processes: 49879 49881
Ongoing processes: 49879 49881
Ongoing processes: 49879 49881
Ongoing processes: 49879 49881
Ongoing processes: 49879 49881
Ongoing processes: 49879 49881
Ongoing processes: 49879 49881
Ongoing processes: 49879 49881
Ongoing processes: 49879 49881
Ongoing processes:
Flash complete (WITH FAILURES)
***************************************
*                                     *
*  Step 3: Start the flashing process *
*                                     *
***************************************
Waiting for target to boot-up...
<removed duplications>
Waiting for target to boot-up...
Waiting for device to expose ssh ......RTNETLINK answers: File exists
RTNETLINK answers: File exists
Waiting for device to expose ssh ...Run command: flash on fc00:1:1:1::2
SSH ready
blockdev: cannot open /dev/mmcblk0boot0: No such file or directory
[ 0]: l4t_flash_from_kernel: Starting to create gpt for emmc
Active index file is /mnt/internal/flash.idx
Number of lines is 17
max_index=16
writing item=1, 1:3:primary_gpt,0,20480,gptmbr.img,20480,fixed-<reserved>-0,5efbf594a175ca3dc7abcde2a6d8c0d9b9e895f0
Error: Could not stat device /dev/mmcblk0 - No such file or directory.
Flash failure
Cleaning up...

Tried different commands from this topic

Nothing works, still the same error

Hi,

I don’t believe this would succeed. Are you sure you have stuff like nvme0n1p<x>.img populated?
Please replace every instance of mmcblk0 with nvme0n1 in nvbackup_partitions.sh and nvrestore_partitions.sh and generate the image again.

Also, the function of converting backup image from external devices to massflash image does not work with the current setup.
It’s guaranteed to fail as of now.
Please apply this patch:

diff --git a/scripts/backup-restore/l4t_backup_restore.func b/scripts/backup-restore/l4t_backup_restore.func
index 2726eaa9..a5c0628d 100644
--- a/scripts/backup-restore/l4t_backup_restore.func
+++ b/scripts/backup-restore/l4t_backup_restore.func
@@ -54,7 +54,8 @@ convert_backup_image_to_initrd_flash()
        local source="${1}"
        local destination="${2}"
        local line_index=0
-       local final_text
+       local internal_text
+       local external_text=""
        local mmc_text=""
        local mmcboot_text=""
        local qspi_text=""
@@ -65,7 +66,16 @@ convert_backup_image_to_initrd_flash()
        pushd "${source}"
 
        mkdir -p "${destination}/internal"
-       cp  -r * "${destination}/internal/"
+
+       local external_images="$(ls | grep -E 'nvme0n1*|sda*|mmcblk1*')"
+       if [[ -n "${external_images}" ]]; then
+               mkdir -p "${destination}/external"
+               ls | grep -v -E 'gpt*|nvme0n1*|sda*|mmcblk1*' | xargs cp -r -t "${destination}/internal/"
+               ls | grep -E 'gpt*|nvme0n1*|sda*|mmcblk1*' | xargs cp -r -t "${destination}/external/"
+       else
+               cp  -r * "${destination}/internal/"
+       fi
+
        while read -r p; do
                if [ "${line_index}" = "0" ]; then
                        line_index=$((line_index + 1))
@@ -81,17 +91,29 @@ convert_backup_image_to_initrd_flash()
                        sha1_chksum_gen=$(sha1sum "${FIELDS[1]}" | cut -d\  -f 1)
                        local size_file=
                        size_file=$(stat -c%s "${FIELDS[1]}")
-                       mmc_text+="$(addentry "1:3:primary_gpt" "$((FIELDS[3] * 512))" "$((FIELDS[4] * 512))" \
-                               "${FIELDS[1]}" "${size_file}" "fixed-<reserved>-0" "${sha1_chksum_gen}")"
-                       mmc_text+="\n"
+                       if [[ -n "$external_images" ]]; then
+                               external_text+="$(addentry "9:0:primary_gpt" "$((FIELDS[3] * 512))" "$((FIELDS[4] * 512))" \
+                                       "${FIELDS[1]}" "${size_file}" "fixed-<reserved>-0" "${sha1_chksum_gen}")"
+                               external_text+="\n"
+                       else
+                               mmc_text+="$(addentry "1:3:primary_gpt" "$((FIELDS[3] * 512))" "$((FIELDS[4] * 512))" \
+                                       "${FIELDS[1]}" "${size_file}" "fixed-<reserved>-0" "${sha1_chksum_gen}")"
+                               mmc_text+="\n"
+                       fi
                elif [ "${FIELDS[2]}" = "gpt_2" ]; then
                        local sha1_chksum_gen=
                        sha1_chksum_gen=$(sha1sum "${FIELDS[1]}" | cut -d\  -f 1)
                        local size_file=
                        size_file=$(stat -c%s "${FIELDS[1]}")
-                       mmc_text+="$(addentry "1:3:secondary_gpt" "$((FIELDS[3] * 512))" "$((FIELDS[4] * 512))" \
-                               "${FIELDS[1]}" "${size_file}" "fixed-<reserved>-0" "${sha1_chksum_gen}")"
-                       mmc_text+="\n"
+                       if [[ -n "$external_images" ]]; then
+                               external_text+="$(addentry "9:0:secondary_gpt" "$((FIELDS[3] * 512))" "$((FIELDS[4] * 512))" \
+                                       "${FIELDS[1]}" "${size_file}" "fixed-<reserved>-0" "${sha1_chksum_gen}")"
+                               external_text+="\n"
+                       else
+                               mmc_text+="$(addentry "1:3:secondary_gpt" "$((FIELDS[3] * 512))" "$((FIELDS[4] * 512))" \
+                                       "${FIELDS[1]}" "${size_file}" "fixed-<reserved>-0" "${sha1_chksum_gen}")"
+                               mmc_text+="\n"
+                       fi
                elif [[ "${FIELDS[2]}" =~ mmcblk0boot ]]; then
                        local sha1_chksum_gen=
                        sha1_chksum_gen=$(sha1sum "${FIELDS[1]}" | cut -d\  -f 1)
@@ -133,6 +155,55 @@ convert_backup_image_to_initrd_flash()
                        mmc_text+="$(addentry "1:3:${partition_name}" "$((FIELDS[3] * 512))" "$((FIELDS[4] * 512))" \
                                "${FIELDS[1]}" "$((FIELDS[4] * 512))" "fixed-<reserved>-${partition_index}" "${sha1_chksum_gen}")"
                        mmc_text+="\n"
+               elif [[ "${FIELDS[2]}" =~ nvme0n1 || "${FIELDS[2]}" =~ sda || "${FIELDS[2]}" =~ mmcblk1 ]]; then
+                       echo "${FIELDS[1]}"
+                       local partition_name
+                       local sha1_chksum_gen=
+                       sha1_chksum_gen=$(sha1sum "${FIELDS[1]}" | cut -d\  -f 1)
+                       local size_file=
+                       local partition_index
+                       if [[ "${FIELDS[2]}" =~ nvme0n1 ]]; then
+                               partition_index=$([[ ${FIELDS[1]} =~ nvme0n1p([[:digit:]]+) ]] && echo "${BASH_REMATCH[1]}")
+                       elif [[ "${FIELDS[2]}" =~ sda ]]; then
+                               partition_index=$([[ ${FIELDS[1]} =~ sda([[:digit:]]+) ]] && echo "${BASH_REMATCH[1]}")
+                       else
+                               partition_index=$([[ ${FIELDS[1]} =~ mmcblk1([[:digit:]]+) ]] && echo "${BASH_REMATCH[1]}")
+                       fi
+                       if is_tar_archive "${FIELDS[1]}"; then
+                               partition_name="APP"
+                               APPcount=$((APPcount+1))
+                               if [ ${APPcount} -eq 2 ]; then
+                                       partition_name="APP_b"
+                               fi
+                               APP="${FIELDS[1]}"
+
+                external_device=${FIELDS[2]%[0-9]}
+                external_device=${external_device%p}
+
+                               echo "external_device=${external_device}" >> "${destination}/internal/flash.cfg"
+                               echo "${partition_name}_ext=${APP}" >> "${destination}/external/flash.cfg"
+                               echo "external_device=${external_device}" >> "${destination}/external/flash.cfg"
+                               echo "${partition_name}_ext=${APP}" >> "${destination}/external/flash.cfg"
+                               echo "external_device=${external_device}" >> "${destination}/external/flash.cfg"
+                               pushd "${destination}/external"
+                               gzip -vd "${APP}"
+                               mv "${APP/%.gz/}" "${APP}"
+                               sha1sum "${APP}" > "${destination}/external/${APP}.sha1sum"
+                               popd
+                       else
+                               if [ "${FIELDS[2]}" = nvme0n1 ]; then
+                                       partition_name="nvme0n1p${partition_index}"
+                               elif [ "${FIELDS[2]}" = sda ]; then
+                                       partition_name="sda${partition_index}"
+                               else
+                                       partition_name="mmcblk1p${partition_index}"
+                               fi
+                               pushd "${destination}/external"
+                               gzip -S img -vd "${FIELDS[1]}"
+                               mv "${FIELDS[1]/%img/}" "${FIELDS[1]}"
+                               popd
+                       fi
+                       external_text+="$(addentry "9:0:${partition_name}" "$((FIELDS[3] * 512))" "$((FIELDS[4] * 512))" \
+                               "${FIELDS[1]}" "$((FIELDS[4] * 512))" "fixed-<reserved>-${partition_index}" "${sha1_chksum_gen}")"
+                       external_text+="\n"
                elif [[ "${FIELDS[2]}" =~ qspi ]]; then
                        local sha1_chksum_gen=
                        sha1_chksum_gen=$(sha1sum "${FIELDS[1]}" | cut -d\  -f 1)
@@ -145,15 +216,24 @@ convert_backup_image_to_initrd_flash()
                fi
                line_index=$((line_index + 1))
        done < "nvpartitionmap.txt"
-       final_text="${mmcboot_text}${qspi_text}${mmc_text}"
-       line_index=0
 
-       final_text="$(echo -en "${final_text}" | while read -r line; do
+       internal_text="${mmcboot_text}${qspi_text}${mmc_text}"
+       line_index=0
+       internal_text="$(echo -en "${internal_text}" | while read -r line; do
                echo "${line_index}, ${line}"; line_index=$((line_index + 1))
                done
                )"
+       echo -e "${internal_text}" > "${destination}/internal/flash.idx"
+
+       if [ -n "${external_text}" ]; then
+               line_index=0
+               external_text="$(echo -en "${external_text}" | while read -r line; do
+                       echo "${line_index}, ${line}"; line_index=$((line_index + 1))
+                       done
+                       )"
+               echo -e "${external_text}" > "${destination}/external/flash.idx"
+       fi
+
        cp "${destination}/../l4t_flash_from_kernel.sh" "${destination}"
-       echo -e "${final_text}" > "${destination}/internal/flash.idx"
        popd
-
-}

Hi Dave,

Thank you for quick answer, my bad as I forgot to mention, this was already done

Please replace every instance of mmcblk0 with nvme0n1 in nvbackup_partitions.sh and nvrestore_partitions.sh and generate the image again.

Backup and restore to one device are working

I applied patch manually instead of git apply as it said patch are corrupted, and last bracket should not be deleted probably

After command ./tools/backup_restore/l4t_backup_restore.sh -b -c p3509-a02+p3767-0000
I get output was backup was done successfully but while conversion to initrd image popup error

gzip nvme0n1p1.tar.gz not found

I checked the folders Linux_for_Tegra/tools/backup_restore/images# ls -lah

drwxr-xr-x 3 root root 4.0K Jan 25 09:51 .
drwxr-xr-x 4 root root 4.0K Jan 25 09:27 ..
-rw-r--r-- 1 root root  64M Jan 25 09:27 QSPI0.img
-rw-r--r-- 1 root root  17K Jan 25 09:27 gptbackup.img
-rw-r--r-- 1 root root  20K Jan 25 09:27 gptmbr.img
-rw-r--r-- 1 root root  11G Jan 25 09:42 nvme0n1p1.tar.gz
-rw-r--r-- 1 root root 269M Jan 25 09:50 nvme0n1p10_bak.img
-rw-r--r-- 1 root root 320K Jan 25 09:50 nvme0n1p11_bak.img
-rw-r--r-- 1 root root  70M Jan 25 09:51 nvme0n1p12_bak.img
-rw-r--r-- 1 root root 464K Jan 25 09:51 nvme0n1p13_bak.img
-rw-r--r-- 1 root root  38M Jan 25 09:51 nvme0n1p14_bak.img
-rw-r--r-- 1 root root  23M Jan 25 09:50 nvme0n1p2_bak.img
-rw-r--r-- 1 root root  76K Jan 25 09:50 nvme0n1p3_bak.img
-rw-r--r-- 1 root root 143K Jan 25 09:50 nvme0n1p4_bak.img
-rw-r--r-- 1 root root  34M Jan 25 09:50 nvme0n1p5_bak.img
-rw-r--r-- 1 root root 111K Jan 25 09:50 nvme0n1p6_bak.img
-rw-r--r-- 1 root root  22M Jan 25 09:50 nvme0n1p7_bak.img
-rw-r--r-- 1 root root  59M Jan 25 09:50 nvme0n1p8_bak.img
-rw-r--r-- 1 root root 252K Jan 25 09:50 nvme0n1p9_bak.img
-rw-r--r-- 1 root root 1.8K Jan 25 09:51 nvpartitionmap.txt
drwxr-xr-x 3 root root 4.0K Jan 25 09:27 tmp

File are there, all seems correct and file was inside Linux_for_Tegra/tools/kernel_flash/images/external

I still tried to proceed to creating package via command

./tools/kernel_flash/l4t_initrd_flash.sh --use-backup-image --no-flash --network usb0 --massflash 10 p3509-a02+p3767-0000 nvme0n1p1

Package seems created and tar file are there, but look like its corrupted

Linux_for_Tegra: ls -lah mfi*
-rw-r--r-- 1 root root  13G Jan 25 10:29 mfi_p3509-a02+p3767-0000.tar.gz

mfi_p3509-a02+p3767-0000:
total 96K
drwxr-xr-x  5 root    root    4.0K Jan 25 10:18 .
drwxrwxr-x 13 root root 4.0K Jan 25 10:19 ..
drwxr-xr-x  3 root    root     32K Jan 25 10:17 bootloader
-rw-r--r--  1 root    root    9.4K Jan 25 10:18 p2972-0000.conf.common
-rw-r--r--  1 root    root    3.5K Jan 25 10:18 p3509-a02+p3767-0000.conf
-rw-r--r--  1 root    root    6.2K Jan 25 10:18 p3668.conf.common
-rw-r--r--  1 root    root    9.9K Jan 25 10:18 p3701.conf.common
-rw-r--r--  1 root    root    7.5K Jan 25 10:18 p3767.conf.common
drwxr-xr-x 18 root    root    4.0K Jan 25 07:46 rootfs
drwxr-xr-x  3 root    root    4.0K Jan 25 10:17 tools

If I try to use this package with mass flash it crash with error

***************************************
*                                     *
*  Step 3: Start the flashing process *
*                                     *
***************************************
Waiting for target to boot-up...
Waiting for target to boot-up...
Waiting for device to expose ssh ......RTNETLINK answers: File exists
RTNETLINK answers: File exists
Waiting for device to expose ssh ...Run command: flash on fc00:1:1:1::2
SSH ready
chroot: failed to run command '/mnt/l4t_flash_from_kernel.sh': No such file or directory
Flash failure
Cleaning up...
  1. Is there any chance you can send me archived tools directly with patched scripts?
  2. Can I start conversion from backup without making backup from device each time?
  3. Also is it possible just run restore commands in sequence when last device started in initrd mode for ssh restore? As I have big problems with converting image maybe there is second way?
    ./tools/backup_restore/l4t_backup_restore.sh -r p3509-a02+p3767-0000

Hi,

#!/bin/bash

# SPDX-FileCopyrightText: Copyright (c) 2021-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Contributor License Agreement (CLA):
# https://github.com/NVIDIA/DALI_extra/blob/main/NVIDIA_CLA_v1.0.1.docx

L4T_BACKUP_PARTITIONS_SCRIPT="nvbackup_partitions.sh"
L4T_RESTORE_PARTITIONS_SCRIPT="nvrestore_partitions.sh"


function is_tar_archive
{
	[[ "${1}" =~ \.tar\.gz ]]
}

addentry() {
	if [ "$#" -ne 7 ]; then
		print_message "addentry function needs 6 parameters when adding an entry to partition map."
		return 1
	fi
	# shellcheck disable=SC2001
	echo "${@}" | sed s/" "/,/g
}

convert_backup_image_to_initrd_flash()
{
	local source="${1}"
	local destination="${2}"
	local line_index=0
	local internal_text
	local external_text=""
	local mmc_text=""
	local mmcboot_text=""
	local qspi_text=""
	local APPcount=0

	rm -rf "${destination:?}"/*

	pushd "${source}"

	mkdir -p "${destination}/internal"

	local external_images="$(ls | grep -E 'nvme0n1*|sda*|mmcblk1*')"
	if [[ -n "${external_images}" ]]; then
		mkdir -p "${destination}/external"
		ls | grep -v -E 'gpt*|nvme0n1*|sda*|mmcblk1*' | xargs cp -r -t "${destination}/internal/"
		ls | grep -E 'gpt*|nvme0n1*|sda*|mmcblk1*' | xargs cp -r -t "${destination}/external/"
	else
		cp  -r * "${destination}/internal/"
	fi

	while read -r p; do
		if [ "${line_index}" = "0" ]; then
			line_index=$((line_index + 1))
			continue
		fi
		declare -a FIELDS
		for part in {1..6}; do
			FIELDS[part]=$(echo "$p" | awk -F, -v part="${part}" '{print $part}')
		done

		if [ "${FIELDS[2]}" = "gpt_1" ]; then
			local sha1_chksum_gen=
			sha1_chksum_gen=$(sha1sum "${FIELDS[1]}" | cut -d\  -f 1)
			local size_file=
			size_file=$(stat -c%s "${FIELDS[1]}")
			if [[ -n "$external_images" ]]; then
				external_text+="$(addentry "9:0:primary_gpt" "$((FIELDS[3] * 512))" "$((FIELDS[4] * 512))" \
					"${FIELDS[1]}" "${size_file}" "fixed-<reserved>-0" "${sha1_chksum_gen}")"
				external_text+="\n"
			else
				mmc_text+="$(addentry "1:3:primary_gpt" "$((FIELDS[3] * 512))" "$((FIELDS[4] * 512))" \
					"${FIELDS[1]}" "${size_file}" "fixed-<reserved>-0" "${sha1_chksum_gen}")"
				mmc_text+="\n"
			fi
		elif [ "${FIELDS[2]}" = "gpt_2" ]; then
			local sha1_chksum_gen=
			sha1_chksum_gen=$(sha1sum "${FIELDS[1]}" | cut -d\  -f 1)
			local size_file=
			size_file=$(stat -c%s "${FIELDS[1]}")
			if [[ -n "$external_images" ]]; then
				external_text+="$(addentry "9:0:secondary_gpt" "$((FIELDS[3] * 512))" "$((FIELDS[4] * 512))" \
					"${FIELDS[1]}" "${size_file}" "fixed-<reserved>-0" "${sha1_chksum_gen}")"
				external_text+="\n"
			else
				mmc_text+="$(addentry "1:3:secondary_gpt" "$((FIELDS[3] * 512))" "$((FIELDS[4] * 512))" \
					"${FIELDS[1]}" "${size_file}" "fixed-<reserved>-0" "${sha1_chksum_gen}")"
				mmc_text+="\n"
			fi
		elif [[ "${FIELDS[2]}" =~ mmcblk0boot ]]; then
			local sha1_chksum_gen=
			sha1_chksum_gen=$(sha1sum "${FIELDS[1]}" | cut -d\  -f 1)
			local size_file=
			size_file=$(stat -c%s "${FIELDS[1]}")
			local partition_index
			partition_index=$([[ ${FIELDS[2]} =~ mmcblk0boot([[:digit:]]+) ]] && echo "${BASH_REMATCH[1]}")
			mmcboot_text+="$(addentry "0:3:${FIELDS[2]}" "$(((FIELDS[3] + FIELDS[4] * partition_index) * 512))" "$((FIELDS[4] * 512 * (partition_index + 1)))" \
				"${FIELDS[1]}" "${size_file}" "fixed-<reserved>-0" "${sha1_chksum_gen}")"
			mmcboot_text+="\n"
		elif [[ "${FIELDS[2]}" =~ mmcblk0 ]]; then
			local partition_name
			local sha1_chksum_gen=
			sha1_chksum_gen=$(sha1sum "${FIELDS[1]}" | cut -d\  -f 1)
			local size_file=
			local partition_index
			partition_index=$([[ ${FIELDS[1]} =~ mmcblk0p([[:digit:]]+) ]] && echo "${BASH_REMATCH[1]}")
			if is_tar_archive "${FIELDS[1]}"; then
				partition_name="APP"
				APPcount=$((APPcount+1))
				if [ ${APPcount} -eq 2 ]; then
					partition_name="APP_b"
				fi
				APP="${FIELDS[1]}"

				echo "${partition_name}=${APP}" >> "${destination}/internal/flash.cfg"
				pushd "${destination}/internal"
				gzip -vd "${APP}"
				mv "${APP/%.gz/}" "${APP}"
				sha1sum "${APP}" > "${destination}/internal/${APP}.sha1sum"
				popd
			else
				partition_name="mmcblk0p${partition_index}"
				pushd "${destination}/internal"
				gzip -S img -vd "${FIELDS[1]}"
				mv "${FIELDS[1]/%img/}" "${FIELDS[1]}"
				popd
			fi
			mmc_text+="$(addentry "1:3:${partition_name}" "$((FIELDS[3] * 512))" "$((FIELDS[4] * 512))" \
				"${FIELDS[1]}" "$((FIELDS[4] * 512))" "fixed-<reserved>-${partition_index}" "${sha1_chksum_gen}")"
			mmc_text+="\n"
		elif [[ "${FIELDS[2]}" =~ nvme0n1 || "${FIELDS[2]}" =~ sda || "${FIELDS[2]}" =~ mmcblk1 ]]; then
			echo "${FIELDS[1]}"
			local partition_name
			local sha1_chksum_gen=
			sha1_chksum_gen=$(sha1sum "${FIELDS[1]}" | cut -d\  -f 1)
			local size_file=
			local partition_index
			if [[ "${FIELDS[2]}" =~ nvme0n1 ]]; then
				partition_index=$([[ ${FIELDS[1]} =~ nvme0n1p([[:digit:]]+) ]] && echo "${BASH_REMATCH[1]}")
			elif [[ "${FIELDS[2]}" =~ sda ]]; then
				partition_index=$([[ ${FIELDS[1]} =~ sda([[:digit:]]+) ]] && echo "${BASH_REMATCH[1]}")
			else
				partition_index=$([[ ${FIELDS[1]} =~ mmcblk1([[:digit:]]+) ]] && echo "${BASH_REMATCH[1]}")
			fi
			if is_tar_archive "${FIELDS[1]}"; then
				partition_name="APP"
				APPcount=$((APPcount+1))
				if [ ${APPcount} -eq 2 ]; then
					partition_name="APP_b"
				fi
				APP="${FIELDS[1]}"

                external_device=${FIELDS[2]%[0-9]}
                external_device=${external_device%p}

				echo "external_device=${external_device}" >> "${destination}/internal/flash.cfg"
				echo "${partition_name}_ext=${APP}" >> "${destination}/external/flash.cfg"
				echo "external_device=${external_device}" >> "${destination}/external/flash.cfg"
				pushd "${destination}/external"
				gzip -vd "${APP}"
				mv "${APP/%.gz/}" "${APP}"
				sha1sum "${APP}" > "${destination}/external/${APP}.sha1sum"
				popd
			else
				if [ "${FIELDS[2]}" = nvme0n1 ]; then
					partition_name="nvme0n1p${partition_index}"
				elif [ "${FIELDS[2]}" = sda ]; then
					partition_name="sda${partition_index}"
				else
					partition_name="mmcblk1p${partition_index}"
				fi
				pushd "${destination}/external"
				gzip -S img -vd "${FIELDS[1]}"
				mv "${FIELDS[1]/%img/}" "${FIELDS[1]}"
				popd
			fi
			external_text+="$(addentry "9:0:${partition_name}" "$((FIELDS[3] * 512))" "$((FIELDS[4] * 512))" \
				"${FIELDS[1]}" "$((FIELDS[4] * 512))" "fixed-<reserved>-${partition_index}" "${sha1_chksum_gen}")"
			external_text+="\n"
		elif [[ "${FIELDS[2]}" =~ qspi ]]; then
			local sha1_chksum_gen=
			sha1_chksum_gen=$(sha1sum "${FIELDS[1]}" | cut -d\  -f 1)
			local size_file=
			size_file=$(stat -c%s "${FIELDS[1]}")
			local partition_index
			qspi_text+="$(addentry "3:0:${FIELDS[2]}" "$((FIELDS[3] * 512))" "$((FIELDS[4] * 512))" \
				"${FIELDS[1]}" "${size_file}" "fixed-<reserved>-0" "${sha1_chksum_gen}")"
			qspi_text+="\n"
		fi
		line_index=$((line_index + 1))
	done < "nvpartitionmap.txt"

	internal_text="${mmcboot_text}${qspi_text}${mmc_text}"
	line_index=0
	internal_text="$(echo -en "${internal_text}" | while read -r line; do
		echo "${line_index}, ${line}"; line_index=$((line_index + 1))
		done
		)"
	echo -e "${internal_text}" > "${destination}/internal/flash.idx"

	if [ -n "${external_text}" ]; then
		line_index=0
		external_text="$(echo -en "${external_text}" | while read -r line; do
			echo "${line_index}, ${line}"; line_index=$((line_index + 1))
			done
			)"
		echo -e "${external_text}" > "${destination}/external/flash.idx"
	fi

	cp "${destination}/../l4t_flash_from_kernel.sh" "${destination}"
	popd
}

This is the full script.
I built this patch on top of 35.4.1, and I’m sure it’s working fine on 35.4.1.
I didn’t verify on 35.3.1, so maybe there are something different between these two versions leading to the error.

Sure. Just run the l4t_backup_restore.func script directly.
You need some trick to set the folder path and move the code out of the function block.

I don’t see why you cannot.

Hi,

I verified on 35.3.1 again with the full script I posted earlier, and it was working fine.
Please give it a try.

Hi Dave,

I used your complete file and it seems start working
Thank you very much for help, I will proceed testing

Good morning Dave,

I have additional questions, if you can answer, I will be very grateful

When I am flashing multiple devices at the same time, seems like speed divided by numbers of devices, I made small research, for fix that we need:

  • usb hub with external power

Also seems like OTG socket in jetson are USB-2.0

Question 1: do we need special usb hub 2.0 with multi tt technology for improve USB-2.0 into semi USB-3.0?

Question 2: if we will use hub with USB-3.0 and external power ( which come without multi tt ) means our write speed will be limited to USB-2.0 but at least not divided when we are using regular usb hub from PC?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.