Need Help In Flashing Jetson Orin NX in Two Parts

Hello, I’m trying to flash my Jetson Orin NX in two parts. First part is to make the files needed to flash and then the second part is to flash using those files. My goal is to flash an Orin NX using ONLY those files generated and delete everything else not needed in Linux_for_Tegra. So far, I’m having trouble.

This is the original command used to flash in one step. This is from Quick Start — Jetson Linux Developer Guide documentation (nvidia.com) . I used it and it works.

sudo ./tools/kernel_flash/l4t_initrd_flash.sh --external-device nvme0n1p1
-c tools/kernel_flash/flash_l4t_external.xml -p “-c bootloader/t186ref/cfg/flash_t234_qspi.xml”
–showlogs --network usb0 p3509-a02+p3767-0000 internal

These are the commands I use to do it in two parts. It is based on the readme file of the initrd flash script.

export BOARD=p3509-a02+p3767-0000

sudo ./tools/kernel_flash/l4t_initrd_flash.sh --external-device nvme0n1p1 -c tools/kernel_flash/flash_l4t_external.xml -p "-c bootloader/t186ref/cfg/flash_t234_qspi.xml" --showlogs --network usb0 --no-flash ${BOARD} internal
 sudo ./tools/kernel_flash/l4t_initrd_flash.sh --external-device nvme0n1p1 -c tools/kernel_flash/flash_l4t_external.xml -p "-c bootloader/t186ref/cfg/flash_t234_qspi.xml" --showlogs --network usb0 --flash-only ${BOARD} internal

After doing it in two parts, it’s not clear to me where the required files generated are located. Also, I was told from the log from running part 1 to run a txt file that has the flash command and it didn’t work as I get an error.

cat bootloader/flashcmd.txt

./tegraflash.py --bl uefi_jetson_with_dtb_sigheader.bin.encrypt --bct br_bct_BR.bct --securedev --bldtb tegra234-p3767-0000-p3509-a02.dtb --applet rcm_2_encrypt.rcm --applet_softfuse rcm_1_encrypt.rcm --cmd “rcmboot” --cfg secureflash.xml --chip 0x23 --mb1_bct mb1_bct_MB1_sigheader.bct.encrypt --mem_bct mem_rcm_sigheader.bct.encrypt --mb1_cold_boot_bct mb1_cold_boot_bct_MB1_sigheader.bct.encrypt --mb1_bin mb1_t234_prod_aligned_sigheader.bin.encrypt --psc_bl1_bin psc_bl1_t234_prod_aligned_sigheader.bin.encrypt --mem_bct_cold_boot mem_coldboot_sigheader.bct.encrypt --bins “psc_fw pscfw_t234_prod_sigheader.bin.encrypt; mts_mce mce_flash_o10_cr_prod_sigheader.bin.encrypt; mb2_applet applet_t234_sigheader.bin.encrypt; mb2_bootloader mb2_t234_with_mb2_cold_boot_bct_MB2_sigheader.bin.encrypt; xusb_fw xusb_t234_prod_sigheader.bin.encrypt; dce_fw display-t234-dce_sigheader.bin.encrypt; nvdec nvdec_t234_prod_sigheader.fw.encrypt; bpmp_fw bpmp_t234-TE980M-A1_prod_sigheader.bin.encrypt; bpmp_fw_dtb tegra234-bpmp-3767-0000-a02-3509-a02_with_odm_sigheader.dtb.encrypt; sce_fw camera-rtcpu-sce_sigheader.img.encrypt; rce_fw camera-rtcpu-t234-rce_sigheader.img.encrypt; ape_fw adsp-fw_sigheader.bin.encrypt; spe_fw spe_t234_sigheader.bin.encrypt; tos tos-optee_t234_sigheader.img.encrypt; eks eks_t234_sigheader.img.encrypt; kernel boot.img; kernel_dtb tegra234-p3767-0000-p3509-a02.dtb” --secondary_gpt_backup --bct_backup

sudo ./tegraflash.py --bl uefi_jetson_with_dtb_sigheader.bin.encrypt --bct br_bct_BR.bct --securedev --bldtb tegra234-p3767-0000-p3509-a02.dtb --applet rcm_2_encrypt.rcm --applet_softfuse rcm_1_encrypt.rcm --cmd “rcmboot” --cfg secureflash.xml --chip 0x23 --mb1_bct mb1_bct_MB1_sigheader.bct.encrypt --mem_bct mem_rcm_sigheader.bct.encrypt --mb1_cold_boot_bct mb1_cold_boot_bct_MB1_sigheader.bct.encrypt --mb1_bin mb1_t234_prod_aligned_sigheader.bin.encrypt --psc_bl1_bin psc_bl1_t234_prod_aligned_sigheader.bin.encrypt --mem_bct_cold_boot mem_coldboot_sigheader.bct.encrypt --bins “psc_fw pscfw_t234_prod_sigheader.bin.encrypt; mts_mce mce_flash_o10_cr_prod_sigheader.bin.encrypt; mb2_applet applet_t234_sigheader.bin.encrypt; mb2_bootloader mb2_t234_with_mb2_cold_boot_bct_MB2_sigheader.bin.encrypt; xusb_fw xusb_t234_prod_sigheader.bin.encrypt; dce_fw display-t234-dce_sigheader.bin.encrypt; nvdec nvdec_t234_prod_sigheader.fw.encrypt; bpmp_fw bpmp_t234-TE980M-A1_prod_sigheader.bin.encrypt; bpmp_fw_dtb tegra234-bpmp-3767-0000-a02-3509-a02_with_odm_sigheader.dtb.encrypt; sce_fw camera-rtcpu-sce_sigheader.img.encrypt; rce_fw camera-rtcpu-t234-rce_sigheader.img.encrypt; ape_fw adsp-fw_sigheader.bin.encrypt; spe_fw spe_t234_sigheader.bin.encrypt; tos tos-optee_t234_sigheader.img.encrypt; eks eks_t234_sigheader.img.encrypt; kernel boot.img; kernel_dtb tegra234-p3767-0000-p3509-a02.dtb” --secondary_gpt_backup --bct_backup

Welcome to Tegra Flash
version 1.0.0
Type ? or help for help and q or quit to exit
Use ! to execute system commands
Entering RCM boot
[   0.0250 ] mb1_t234_prod_aligned_sigheader.bin.encrypt filename is from --mb1_bin
[   0.0250 ] psc_bl1_t234_prod_aligned_sigheader.bin.encrypt filename is from --psc_bl1_bin
[   0.0250 ] rcm boot with presigned binaries
[   0.0276 ] tegrarcm_v2 --new_session --chip 0x23 0 --uid --download bct_br br_bct_BR.bct --download mb1 mb1_t234_prod_aligned_sigheader.bin.encrypt --download psc_bl1 psc_bl1_t234_prod_aligned_sigheader.bin.encrypt --download bct_mb1 mb1_bct_MB1_sigheader.bct.encrypt
[   0.0285 ] BR_CID: 0x80012344705E36425C000000030080C0
[   0.2295 ] Sending bct_br
[   0.4441 ] Sending mb1
[   0.4452 ] Sending psc_bl1
[   0.4552 ] Sending bct_mb1
[   0.4612 ] Generating blob for T23x
[   0.4673 ] tegrahost_v2 --chip 0x23 0 --generateblob blob.xml blob.bin
[   0.4705 ] The number of images in blob is 18
[   0.4715 ] blobsize is 61498182
[   0.4716 ] Added binary blob_uefi_jetson_with_dtb_sigheader.bin.encrypt of size 2920512
[   0.4994 ] Added binary blob_pscfw_t234_prod_sigheader.bin.encrypt of size 375168
[   0.5000 ] Added binary blob_mce_flash_o10_cr_prod_sigheader.bin.encrypt of size 190592
[   0.5007 ] Added binary blob_applet_t234_sigheader.bin.encrypt of size 277312
[   0.5012 ] Not supported type: mb2_applet
[   0.5015 ] Added binary blob_mb2_t234_with_mb2_cold_boot_bct_MB2_sigheader.bin.encrypt of size 438768
[   0.5022 ] Added binary blob_xusb_t234_prod_sigheader.bin.encrypt of size 164864
[   0.5027 ] Added binary blob_display-t234-dce_sigheader.bin.encrypt of size 9097216
[   0.5080 ] Added binary blob_nvdec_t234_prod_sigheader.fw.encrypt of size 294912
[   0.5093 ] Added binary blob_bpmp_t234-TE980M-A1_prod_sigheader.bin.encrypt of size 1051136
[   0.5102 ] Added binary blob_tegra234-bpmp-3767-0000-a02-3509-a02_with_odm_sigheader.dtb.encrypt of size 258688
[   0.5110 ] Added binary blob_camera-rtcpu-sce_sigheader.img.encrypt of size 166304
[   0.5117 ] Added binary blob_camera-rtcpu-t234-rce_sigheader.img.encrypt of size 537952
[   0.5123 ] Added binary blob_adsp-fw_sigheader.bin.encrypt of size 400864
[   0.5128 ] Added binary blob_spe_t234_sigheader.bin.encrypt of size 270336
[   0.5133 ] Added binary blob_tos-optee_t234_sigheader.img.encrypt of size 1127568
[   0.5138 ] Added binary blob_eks_t234_sigheader.img.encrypt of size 9232
[   0.5143 ] Added binary blob_boot.img of size 43569152
[   0.5393 ] Added binary blob_tegra234-p3767-0000-p3509-a02.dtb of size 346502
[   0.5840 ] tegrarcm_v2 --chip 0x23 0 --pollbl --download bct_mem mem_rcm_sigheader.bct.encrypt --download blob blob.bin
[   0.5850 ] BL: version 1.2.0.0-t234-54845784-562369e5 last_boot_error: 0
[   0.7821 ] Sending bct_mem
[   0.9922 ] Sending blob
[   3.5952 ] RCM-boot started

Jetson Orin Serial Line Log from running flash cmd txt file

[    9.624551] pci 0008:01:00.0: BAR 0: assigned [io  0x200000-0x2000ff]
[    9.631207] pci 0008:00:00.0: PCI bridge to [bus 01-ff]
[    9.636575] pci 0008:00:00.0:   bridge window [io  0x200000-0x200fff]
[    9.642339] tegra-xusb 3610000.xhci: entering ELPG done
[    9.643209] pci 0008:00:00.0:   bridge window [mem 0x3528000000-0x35280fffff]
[    9.643223] pci 0008:00:00.0: Max Payload Size set to  128/ 256 (was  256), Max Read Rq  512
[    9.664682] pci 0008:01:00.0: Max Payload Size set to  128/ 128 (was  128), Max Read Rq  512
[    9.673612] pcieport 0008:00:00.0: Adding to iommu group 10
[    9.679539] pcieport 0008:00:00.0: PME: Signaling with IRQ 59
[    9.686217] pcieport 0008:00:00.0: AER: enabled with IRQ 59
[    9.693417] irq: IRQ304: trimming hierarchy from :pmc@c360000
[    9.699397] irq: IRQ305: trimming hierarchy from :interrupt-controller@f400000-1
[    9.707082] input: gpio-keys as /devices/platform/gpio-keys/input/input0
[    9.715012] tegra-se-nvhost 15810000.se: Adding to iommu group 50
[    9.721642] tegra-se-nvhost 15810000.se: initialized
[    9.737591] tegra-se-nvhost 15810000.se: tegra_se_probe: complete
[    9.743990] tegra-se-nvhost 15820000.se: Adding to iommu group 51
[    9.750601] tegra-se-nvhost 15820000.se: initialized
[    9.758057] tegra-se-nvhost 15820000.se: tegra_se_probe: complete
[    9.764433] tegra-se-nvhost 15840000.se: Adding to iommu group 52
[    9.770993] tegra-se-nvhost 15840000.se: initialized
[    9.780365] tegra-se-nvhost 15840000.se: tegra_se_probe: complete
[    9.787284] tegra_actmon d230000.actmon: in actmon_register()...
[    9.793665] tegra_actmon d230000.actmon: bwmgr_disable = 1
[    9.799866] tegra_actmon d230000.actmon: initialization Completed for the device mc_all
[    9.808287] hvc_sysfs: hypervisor is not present
��WARNING: clock_disable: clk_power_ungate on gated domain 35 for gpc1clk
��[    9.852137] ALSA device list:
[    9.855203]   No soundcards found.
[    9.859339] Freeing unused kernel memory: 3968K
[    9.864076] Run /init as init process
[    9.880452] Root device found: mmcblk0p1
[   19.995240] ERROR: mmcblk0p1 not found
[  121.582754] random: crng init done

Any help in resolving this is greatly appreciated. Thank you for your time.

I didn’t read your question yet but just a reminder about the format as it is really not easy to read.

You can try to put your command into

command

And attach your log into a text file instead.

So that others could read it easily.

Please don’t try to delete any files in the BSP folder when you don’t even know how it’s structured.

So what exactly have you done?
Did the first two flashing commands succeed or not?

Please just ignore the message.
They have been there years ago, and should have been deprecated now.

I followed the instructions from the quick start website (I posted link above) and the flashing worked. Next, I split the last command that runs the script to flash into two parts using two different options: --on-flash and --flash-only. So, Yes, the first two flashing commands also succeeded. The question is, where are all the files generated from part 1 (–no-flash) to do part two such that it can be done on another device and how if the second command is not exactly correct? Also, the txt with the flash command is to be discarded, right?

For your purpose, you should consider massflash as indicated in Linux_for_Tegra/tools/kernel_flash/README_initrd_flash.txt.

Workflow 8: Secure initrd Massflash

Here are the steps to flash in unsecure factory floor.

First, generate a massflash package using the --no-flash and --massflash <x>
options, and specify the neccessary keys using the -u and -v options, where <x>
is the highest possible number of devices to be flashed concurrently. In the
example below, we create a flashing environment in online mode that is
capable of flashing 5 devices concurrently.

$ sudo ./tools/kernel_flash/l4t_initrd_flash.sh -u <pkckey> [-v <sbkkey>] --no-flash --massflash 5 jetson-xavier-nx-devkit-emmc mmcblk0p1

The tool generates a tarball called mfi_<target-board>.tar.gz that contains all
the minimal binaries needed to flash in an unsecure environment. Download this
tarball to the unsafe environment, and untar the tarball to create a flashing
environment. For examples,
$ scp mfi_<target-board>.tar.gz <factory-host-ip>:<factory-host-dir>
...
Untar on a factory host machine:
$ sudo tar xpfv mfi_<target-board>.tar.gz

Second, perform this procedure:
- Connect the Jetson devices to the flashing hosts.
  (Make sure all devices are in exactly the same hardware revision similar to
  the requirement in README_Massflash.txt )
- Put all of connected Jetsons into RCM mode.
- Run:
$ cd mfi_<target-board>
$ sudo ./tools/kernel_flash/l4t_initrd_flash.sh --flash-only --massflash 5
  (Optionally add --showlogs to show all of the log)

I don’t know what you mean here.
Please just run step 1 and step 2 again.

YES.
I don’t feel like we are using it anymore.

Again, please don’t do this.

Even if I use mass flash, where are all the files or package generated ? What I mean by "
how if the second command is not exactly correct" is after clearly finding all the files or package generated from --no-flash, is doing part two using these components different in terms of the command and arguments?

For example, I have mfi_jetson-agx-orin-devkit.tar.gz under Linux_for_Tegra/.
Copy this file to another host PC, extract it, and you can replicate the operation now.

Ideally, only --flash-only is required.

OK so if I do mass flash or the the first method I was doing, I just need to look for a .gz file somewhere inside Linux_for_Tegra after doing part 1 --no-flash such that this .gz file can be transferred to another Linux device that has an Orin connected in recovery mode and then, all I have to do to flash Orin is extract the .gz and run the part 2 --flash-only command, right? If yes, this is what I’m looking for the whole time.

YES.
Remember to explicitly specify --massflash <x> in the command for generating the package.

I did mass flash method and it works! Thanks a lot. One question, what is the highest number I can put for x in --massflash for my exact device?

We don’t put hard limit on --massflash <x>, and it depends on how many USB connection your host PC is able to support.

I realized that the size of the .gz file is quite big which is around 4 GB if I’m not wrong. What can I do to shorten it as much as possible?

Consider using a smaller rootfs:
https://docs.nvidia.com/jetson/archives/r35.4.1/DeveloperGuide/text/SD/RootFileSystem.html#manually-generate-a-root-file-system
Or deleting some unused packages:
https://docs.nvidia.com/jetson/archives/r35.4.1/DeveloperGuide/text/SD/StorageOptimization.html

If I use smaller rootfs, I have to remake the .gz file such that I have to re-create the Linux_for_Tegra folder, right? How can I clearly know all the exact files to delete inside the extracted folder from the .gz file such that I only have files inside the extracted folder that are needed to flash the orin which is part 2? I think the bootloader subdirectory will be required. The biggest gain would be to get rid of rootfs from the archive, because it sounds not useful at all for part2 since I have tools/kernel_flash/images/external/system.img which is the pre-build rootfs image for the SSD.

YES.

I cannot guarantee for now, but you may try.

After trying to exclude rootfs folder, it did not work where it’s needed. So, there’s no exact or established way of getting rid of all the unnecessary files in the extracted folder?

YES. As I have said multiple times, please don’t try to delete any files you are not familiar with.
Generating a smaller rootfs with the package list we provide should be the official way.

OK. So in generating a smaller rootfs with the package list, all the information about that is on the link you gave before, right?

YES, and please note that both the minimal flavor and the basic flavor rootfs does not contain GUI components, so you can only login to the device with SSH/serial console.

Also, in case you want to use the basic flavor, there are some packages missing in the current 35.4.1 release, which causes booting/flashing to fail, and here’s the full list:

diff --git a/mnt/1T-HDD/BSP/r35.4.1/Linux_for_Tegra/tools/samplefs/nvubuntu-focal-basic-aarch64-packages b/nvubuntu-focal-basic-aarch64-packages
index 5b7ef3e..a00f557 100644
--- a/mnt/1T-HDD/BSP/r35.4.1/Linux_for_Tegra/tools/samplefs/nvubuntu-focal-basic-aarch64-packages
+++ b/nvubuntu-focal-basic-aarch64-packages
@@ -24,6 +24,7 @@ docker.io
 dpkg
 e2fsprogs
 fdisk
+file
 findutils
 fontconfig-config
 fonts-dejavu-core
@@ -143,6 +144,8 @@ liblocale-gettext-perl
 liblz4-1
 liblzma5
 liblzo2-2
+libmagic-mgc
+libmagic1
 libmnl0
 libmount1
 libmpc3
1 Like