Failed to flash Jetson AGX Thor to USB drive

Hi NVTeam,

I am trying to flash the system to a USB drive on a Jetson AGX Thor Developer Kit running Jetson Linux R39.2.

I am using a 256GB USB flash drive. The same USB drive works perfectly when flashing an Orin Nano, but fails on the Thor.

Command used:

sudo ./l4t_initrd_flash.sh --external-device sda1 --erase-all jetson-agx-thor-devkit internal

This command fails.

I saw in the forum that for Thor, when using storage smaller than 256GB, we should add EXT_NUM_SECTORS=251658240. Since my USB shows only ~230GB in Windows, I tried:

sudo EXT_NUM_SECTORS=251658240 ./l4t_initrd_flash.sh --external-device sda1 --erase-all jetson-agx-thor-devkit internal

But it still fails.

Flash log:

flash_Thor_USB_39.2.log (590.8 KB)

Additional questions:

Could you please confirm whether the Jetson AGX Thor officially supports USB drive as a boot device?

If yes, what is the correct procedure to make it work?

I believe this worked.

lsblk # confirm usbdrive letter

USB=/dev/sdX   # replace with the real host USB drive, for example /dev/sdb
SECTORS=$(sudo blockdev --getsz "$USB")

# Make a Thor USB specific copy of t264_nvme.xml and set num_sectors to the usb drive size:
cp tools/kernel_flash/flash_l4t_t264_nvme.xml \
   tools/kernel_flash/flash_l4t_t264_usb_230gb.xml

Following will edit xml and insert correct number of sectors.

python3 - <<PY
from pathlib import Path
import re

p = Path("tools/kernel_flash/flash_l4t_t264_usb_230gb.xml")
s = p.read_text()

sectors = "${SECTORS}"

s, n = re.subn(
    r'num_sectors="[^"]+"',
    f'num_sectors="{sectors}"',
    s,
    count=1
)

if n != 1:
    raise SystemExit("ERROR: did not find exactly one num_sectors entry to replace")

p.write_text(s)
print(f"Wrote {p} with num_sectors={sectors}")
PY

Attach Thor to host with usb cable. Put Thor in recovery mode. Keeping usb drive connected to host. Following is a direct host to usbdrive flash method.

sudo ADDITIONAL_DTB_OVERLAY_OPT="BootOrderUsb.dtbo" ./l4t_initrd_flash.sh \
  -c ./tools/kernel_flash/flash_l4t_t264_usb_230gb.xml \
  -S 200GiB \
  --external-device sda1 \  # Leave this sda1. That is rootfs partition as boot device attached to Thor. 
  --direct sdb \ # Change to your usb drive letter found with `lsblk`
  jetson-agx-thor-devkit external
  1. Wait until l4t_initrd_flash.sh fully completes successfully.
  2. On the host, flush pending writes:
    sync
  3. Unmount/eject the USB drive from the host.
    Example, if the host USB drive is /dev/sdb:
    sudo umount /dev/sdb*
    sudo eject /dev/sdb
    If eject says it cannot eject, you may want to power off host prior to detach usb drive.
  4. Power off Thor.
  5. Move the flashed USB drive from the host PC to Thor.
  6. Power on Thor.
  7. Enter UEFI Boot Manager, press Esc or F11 during early boot.
  8. Choose the USB drive / USB boot entry.
  9. Thor will reset and then will continue boot.

Sorry, I’m a little confused about the procedure.

Do you mean I should insert the USB drive into the host Ubuntu machine to flash it, and once the flashing is finished, insert the USB drive into the Jetson AGX Thor to boot the system from it?

Yes. That is one way to direct flash to the usb drive that skips potential flashing over usb-cable-timeouts.

https://docs.nvidia.com/jetson/archives/r39.2/DeveloperGuide/SD/FlashingSupportJetsonThor.html

--direct <dev>

Flash specified device directly connected to host. Example: 
sudo ./l4t_initrd_flash.sh --direct sdb --external-device sda -c flash_external.xml jetson-agx-thor-devkit sda1

Sorry to bother you again.

I followed your steps, but it still failed. Here is the failure log:

log

Save initrd flashing command parameters to /media/nvfae2204/Data/NV_SDK/jetpack7/BSP39.2JP7.2/Linux_for_Tegra/tools/kernel_flash/initrdflashparam.txt
Translating from L4T rcm-boot to unified format
/media/nvfae2204/Data/NV_SDK/jetpack7/BSP39.2JP7.2/Linux_for_Tegra
Success
Cleaning up...
Finish generating flash package.
/media/nvfae2204/Data/NV_SDK/jetpack7/BSP39.2JP7.2/Linux_for_Tegra/tools/kernel_flash/l4t_initrd_flash_internal.sh --external-only --network usb0 --direct sdb --usb-instance 1-10 --device-instance 0 --flash-only --external-device sda1 -c "./tools/kernel_flash/flash_l4t_t264_usb_230gb.xml" -S 200GiB --direct sdb --network usb0 jetson-agx-thor-devkit external
*************************************************************
*                                                           *
*  Step 1: Start the host connected device flashing process *
*                                                           *
*************************************************************
blockdev: cannot open /dev/mmcblk0boot0: No such file or directory
11:42:25.380 - Warning: Serial number sysfs node doesn't exist.
11:42:25.385 - Info: Starting to create the GPT for the external device.
11:42:25.389 - Debug: Active index file is /media/nvfae2204/Data/NV_SDK/jetpack7/BSP39.2JP7.2/Linux_for_Tegra/tools/kernel_flash/images/external/flash.idx
11:42:25.418 - Debug: Number of lines is 14
11:42:25.423 - Debug: max_index=13
11:42:25.472 - Debug: writing item=1, 9:0:primary_gpt, 512, 19968, gpt_primary_9_0.bin, 16896, fixed-<reserved>-0, 0fe9e57e96c4d9417e269dcd320e6843c0e350e8

Error: Partition(s) on /dev/sdb are being used.
Cleaning up...

Question:

What could be the cause of this error?
Error: Partition(s) on /dev/sdb are being used.

At that time, my USB drive was plugged into the host PC and I was not doing any operation on it (no mounting, no file browsing, etc.).

# Check what's mounted from that drive:
lsblk /dev/sdb

# Unmount every mounted partition on it 
sudo umount /dev/sdb?*

# If anything says "target is busy," find the process with 
sudo fuser -vm /dev/sdb1 (etc.) and close it.

# Turn off automount while you are flashing and turn back on when it is done.
gsettings set org.gnome.desktop.media-handling automount false
gsettings set org.gnome.desktop.media-handling automount-open false

Run same l4t_initrd_flash.sh command.

If it still fails, you might need a larger usb drive.

First maybe run lsblk |grep sd again to ensure usbdrive is sdb

There is still a process holding something on sdb.

sudo fuser -vm /dev/sdb /dev/sdb*
Stop any processes.

You could try:
sudo wipefs -a /dev/sdb
sudo sgdisk --zap-all /dev/sdb
sync
sudo partprobe /dev/sdb

It might be that the USB drive was automatically mounted by the system. I manually unmounted it and ran the flashing command again.

Now the flashing process is still running. The log has already passed the previous error point (Partition(s) on /dev/sdb are being used), but the speed is quite slow. I’m still waiting for it to finish.

Thank you very much for your help!

Your troubleshooting steps were very helpful. The issue turned out to be that the USB drive was being automatically mounted by the host.

After unmounted it with:

sudo umount /dev/sdb*

the flashing process completed successfully.

Thank you again for your guidance and patience. I really appreciate your support! Hopefully this will also help others who encounter the same issue.