Orin nx massflash

你好,按照README_backup_restore.txt 中第三步workflow 3,
第一步:sudo ./tools/backup_restore/l4t_backup_restore.sh -b -c 顺利的进行完毕,后,将设备断电重新进入到恢复模式
第二步:sudo ./tools/kernel_flash/l4t_initrd_flash.sh --use-backup-image --no-flash --network usb0 --massflash 5 p3509-a02+p3767-0000 nvme0n1p1 执行后失败:
11.txt (59.5 KB)

你備份用的這一包BSP之前有燒過別的裝置嗎,還是是為了備份新下載的?
沒有的話請用同一包BSP執行flash和備份/還原的步驟

Hi DaveYYY,

我看到这位User在使用中文,那么我也直接写中文了,谢谢!

我也正在测试backup-restore工具的workflow3是否可用,因为直到L4T 35.4.1的Linux Guide中,仍然有一个Note写着Massflash backup image对于Orin NX不可用。(按照我对硬件的理解,意味着Orin NX/Orin Nano均不可用)
我使用的组合是:Orin Nano DevKit + SSD +L4T 35.4.1

我的操作步骤如下:
Step1:新下载了35.4.1的BSP包和RootFS,并flash了我的Orin Nano DevKit以及SSD。套件正常工作,完成了初始设置,并下载了JetPack组件和其它内容供测试使用。

Step2:在同一个BSP包里,去生成backup image。L4T 35.4.1下,添加-e nvme0n1去指定备份SSD;同时按照workflow3的指示,添加-c。我猜“-c”指“copy”?使得backup image后续可被initrd_flash使用。

sudo ./tools/backup_restore/l4t_backup_restore.sh -e nvme0n1 -b -c jetson-orin-nano-devkit

一段时间后,备份完成。在这个过程中,nvbackup_partitions.sh看上去工作良好,最终显示成功。

Step3:出于检查的目的,我分别查看了/tools/backup_restore/images,以及/tools/kernel_flash/images/internal,结果如下:

cecport@cecport-B8251T83E8HR-2T-N:~/wzztest/35.4.1-backup/Linux_for_Tegra/tools/kernel_flash/images/internal$ ls -lh
total 9.0G
-rw-r--r-- 1 root root  330 12月  5 15:00 flash.idx
-rw-r--r-- 1 root root  17K 12月  5 14:58 gptbackup.img
-rw-r--r-- 1 root root  20K 12月  5 14:58 gptmbr.img
-rw-r--r-- 1 root root 293M 12月  5 14:58 nvme0n1p10_bak.img
-rw-r--r-- 1 root root 326K 12月  5 14:58 nvme0n1p11_bak.img
-rw-r--r-- 1 root root  81M 12月  5 14:58 nvme0n1p12_bak.img
-rw-r--r-- 1 root root 516K 12月  5 14:58 nvme0n1p13_bak.img
-rw-r--r-- 1 root root  57M 12月  5 14:58 nvme0n1p14_bak.img
-rw-r--r-- 1 root root 8.2G 12月  5 15:00 nvme0n1p1.tar.gz
-rw-r--r-- 1 root root  23M 12月  5 15:00 nvme0n1p2_bak.img
-rw-r--r-- 1 root root  77K 12月  5 15:00 nvme0n1p3_bak.img
-rw-r--r-- 1 root root  25M 12月  5 15:00 nvme0n1p4_bak.img
-rw-r--r-- 1 root root 109M 12月  5 15:00 nvme0n1p5_bak.img
-rw-r--r-- 1 root root 505K 12月  5 15:00 nvme0n1p6_bak.img
-rw-r--r-- 1 root root  32M 12月  5 15:00 nvme0n1p7_bak.img
-rw-r--r-- 1 root root  54M 12月  5 15:00 nvme0n1p8_bak.img
-rw-r--r-- 1 root root 250K 12月  5 15:00 nvme0n1p9_bak.img
-rw-r--r-- 1 root root 1.8K 12月  5 15:00 nvpartitionmap.txt
-rw-r--r-- 1 root root  64M 12月  5 15:00 QSPI0.img
drwxr-xr-x 3 root root 4.0K 12月  5 15:00 tmp

以及:

cecport@cecport-B8251T83E8HR-2T-N:~/wzztest/35.4.1-backup/Linux_for_Tegra/tools/backup_restore/images$ ls -lh
total 9.0G
-rw-r--r-- 1 root root  17K 12月  5 14:42 gptbackup.img
-rw-r--r-- 1 root root  20K 12月  5 14:42 gptmbr.img
-rw-r--r-- 1 root root 293M 12月  5 14:58 nvme0n1p10_bak.img
-rw-r--r-- 1 root root 326K 12月  5 14:58 nvme0n1p11_bak.img
-rw-r--r-- 1 root root  81M 12月  5 14:58 nvme0n1p12_bak.img
-rw-r--r-- 1 root root 516K 12月  5 14:58 nvme0n1p13_bak.img
-rw-r--r-- 1 root root  57M 12月  5 14:58 nvme0n1p14_bak.img
-rw-r--r-- 1 root root 8.2G 12月  5 14:55 nvme0n1p1.tar.gz
-rw-r--r-- 1 root root  23M 12月  5 14:57 nvme0n1p2_bak.img
-rw-r--r-- 1 root root  77K 12月  5 14:57 nvme0n1p3_bak.img
-rw-r--r-- 1 root root  25M 12月  5 14:57 nvme0n1p4_bak.img
-rw-r--r-- 1 root root 109M 12月  5 14:57 nvme0n1p5_bak.img
-rw-r--r-- 1 root root 505K 12月  5 14:57 nvme0n1p6_bak.img
-rw-r--r-- 1 root root  32M 12月  5 14:57 nvme0n1p7_bak.img
-rw-r--r-- 1 root root  54M 12月  5 14:58 nvme0n1p8_bak.img
-rw-r--r-- 1 root root 250K 12月  5 14:58 nvme0n1p9_bak.img
-rw-r--r-- 1 root root 1.8K 12月  5 14:58 nvpartitionmap.txt
-rw-r--r-- 1 root root  64M 12月  5 14:42 QSPI0.img
drwxr-xr-x 3 root root 4.0K 12月  5 14:42 tmp

看上去是一致的,但是/tools/kernel_flash/images/internal下多一个flash.idx

cecport@cecport-B8251T83E8HR-2T-N:~/wzztest/35.4.1-backup/Linux_for_Tegra/tools/kernel_flash/images/internal$ cat flash.idx
0, 3:0:qspi0,0,34359738368,QSPI0.img,67108864,fixed-<reserved>-0,2f91f1a2b3eda433b016abd9325c16645054e413
1, 1:3:primary_gpt,0,20480,gptmbr.img,20480,fixed-<reserved>-0,24b6f8a6e59fb00b2e2a438a77b3dddc867431d9
2, 1:3:secondary_gpt,128035659264,16896,gptbackup.img,16896,fixed-<reserved>-0,48652ad6b96ee6f6d9112d501c3854fb08f19985

Step 4:继续在此BSP包里,尝试使用backup image,去生成mfi包

sudo ./tools/kernel_flash/l4t_initrd_flash.sh --use-backup-image --no-flash --network usb0 --massflash 5 jetson-orin-nano-devkit nvme0n1p1

遇到了和这个topic的用户一样的问题,缺少了flash.cfg:

*** no-flash flag enabled. Exiting now... ***

User can run above saved command in factory environment without
providing pkc and sbk keys to flash a device

Example:

    $ cd bootloader
    $ sudo bash ./flashcmd.txt

Save initrd flashing command parameters to /home/cecport/wzztest/35.4.1-backup/Linux_for_Tegra/tools/kernel_flash/initrdflashparam.txt
/tmp/tmp.rfl286eTZd /home/cecport/wzztest/35.4.1-backup/Linux_for_Tegra
writing boot image config in bootimg.cfg
extracting kernel in zImage
extracting ramdisk in initrd.img
/tmp/tmp.rfl286eTZd/initrd /tmp/tmp.rfl286eTZd /home/cecport/wzztest/35.4.1-backup/Linux_for_Tegra
58248 blocks
cp: cannot stat '/home/cecport/wzztest/35.4.1-backup/Linux_for_Tegra/tools/kernel_flash/images/internal/flash.cfg': No such file or directory
Cleaning up...

通过浏览其它topic,目前打算按照这里的方式进行处理,手动为它添加flash.cfg进行尝试。很重要的一点是,这位use在35.2.1下就成功过Orin NX的backup image massflash,即便后续面对全新拆封的Module有别的问题。

目前正在看怎么写flash.cfg适合我的Orin Nano DevKit,也就是P3767-0005的Module。不过看起来这位user的问题似乎是可以复现的,不知道NVIDIA团队是否有一些看法。

谢谢!

Hi,

我剛才看了一下script,看起來使用external device (NVMe drive/USB drive) 的情況下的確是不支援將備份的image轉成massflash package的
這部份我內部確認一下之後再回覆你們

Hi,

我們內部已經在看這個問題了,原本的script確實不支援用NVMe/USB的備份檔製作massflash package
問題解決之後會在這篇文更新,謝謝

Hi,

不確定兩位是否還需要support,如果需要的話請在Linux_for_Tegra/tools/backup_restore/l4t_backup_restore.func加上下面的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
-
-}

1 Like

Hi DaveYYY,

感谢您和团队的努力,抱歉没有及时看到更新,我测试后也给出一个结果反馈。谢谢您!

B&R
zzw

另外說一下,這只是一個暫時的解法,不會出現在之後release的正式版裡面
我們是希望能讓backup/restore tool支援同時備份internal和external device,比方說在AGX Orin上能夠同時備份eMMC和NVMe,等這部分做完之後才會處理massflash的問題

1 Like

Hi DaveYYY,

充分理解你们的想法。坦诚讲,看上去目前最简单的方式仍然是单独为模块刷QSPI,同时利用拷贝机去复制SSD,再组合。这样也能达到目的。

但massflash在未来的进一步更新也是我们所期待的,对于工厂环境来说,它确实是很有意义的一个workflow。

谢谢您帮忙!

Best Regards

1 Like

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