Flashing Multiple Tegra Devices
Use these procedures to flash multiple Tegra devices concurrently with one host system.
Before You Begin
Before creating the flash command file, these prerequisites must be met:
• All connected Tegra devices must be the same model and revision for the board and the chip
• Connect a Tegra production device to the host system
• Place the device in force-recovery mode.
• Download and extract an L4T release.
There are two options for downloading the release:
• Navigate to the installation location on L4T, typically this is at:
<top>/Linux_for_Tegra/
Where <top> is the directory where you installed the release.
• Navigate to the the directory for your L4T Jetson device as follows:
• TX1:
64_TX1/Linux_for_Tegra_64_tx1/
• TX2/TX2i:
64_TX2/Linux_for_Tegra_64_tx2/
Creating the Flash Command File
To create the flash command file, execute one of these commands for your Jetson device:
• TX1
$ sudo ./flash.sh --no-flash jetson-tx1 mmcblk0p1
• TX2
$ sudo ./flash.sh --no-flash jetson-tx2 mmcblk0p1
• TX2i
$ sudo ./flash.sh --no-flash jetson-tx2i mmcblk0p1
Upon successful execution, the flash command is stored in a text file available at:
bootloader/flashcmd.txt
Connecting Tegra Devices to the Host
To eliminate low USB transfer performance and ensure that flashing is successful, connect the Tegra devices to the USB root ports of the host system with one device on one port as follows:
$ lsusb | grep NVidia
Bus 005 Device 012: ID 0955:7721 NVidia Corp.
Bus 003 Device 016: ID 0955:7721 NVidia Corp.
$ lsusb -t
/: Bus 06.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 5000M
/: Bus 05.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 480M
|__ Port 1: Dev 12, If 0, Class=Vendor Specific Class, Driver=usbfs, 480M
/: Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 5000M
/: Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 480M
|__ Port 1: Dev 16, If 0, Class=Vendor Specific Class, Driver=usbfs, 480M
Connecting the Tegra Devices to the Host
To eliminate low USB transfer performance and ensure that flashing is successful, connect the Tegra devices to the USB root ports of the host system with one device on one port as follows:
$ lsusb | grep NVidia
Bus 005 Device 012: ID 0955:7721 NVidia Corp.
Bus 003 Device 016: ID 0955:7721 NVidia Corp.
$ lsusb -t
/: Bus 06.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 5000M
/: Bus 05.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 480M
|__ Port 1: Dev 12, If 0, Class=Vendor Specific Class, Driver=usbfs, 480M
/: Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 5000M
/: Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 480M
|__ Port 1: Dev 16, If 0, Class=Vendor Specific Class, Driver=usbfs, 480M
Creating the Script to Flash Multiple Devices
To create a script for flashing multiple devices, add the multi_tegra_flash.sh script at:
• TX1:
64_TX1/Linux_for_Tegra_64_tx1/bootloader/
• TX2/TX2i:
64_TX2/Linux_for_Tegra_64_tx2/bootloader/
For best results, copy/paste the content of the script that follows:
#!/bin/bash
# Find devices to flash
devpaths=($(find /sys/bus/usb/devices/usb*/ \
-name devnum -print0 | {
found=()
while read -r -d "" fn_devnum; do
dir="$(dirname "${fn_devnum}")"
vendor="$(cat "${dir}/idVendor")"
if [ "${vendor}" != "0955" ]; then
continue
fi
product="$(cat "${dir}/idProduct")"
case "${product}" in
"7721")
;;
"7018")
;;
"7c18")
;;
*)
continue
;;
esac
fn_busnum="${dir}/busnum"
if [ ! -f "${fn_busnum}" ]; then
continue
fi
fn_devpath="${dir}/devpath"
if [ ! -f "${fn_devpath}" ]; then
continue
fi
busnum="$(cat "${fn_busnum}")"
devpath="$(cat "${fn_devpath}")"
found+=("${busnum}-${devpath}")
done
echo "${found[@]}"
}))
# Exit if no devices to flash
if [ ${#devpaths[@]} -eq 0 ]; then
echo "No devices to flash"
exit 1
fi
# Create a folder for saving log
pid="$$"
rm -rf "${pid}"
mkdir "${pid}"
# Flash all devices in background
echo "Start flashing; PID=${pid}"
flash_cmd="$(cat flashcmd.txt)"
if [ -z "${flash_cmd}" ]; then
echo Cannot read flashcmd.txt
exit 1
fi
flash_pids=()
for devpath in "${devpaths[@]}"; do
fn_log="${pid}/flash_${devpath}.log"
cmd="${flash_cmd} --instance ${devpath}"
(eval ${cmd} > "${fn_log}") &
flash_pid="$!"
flash_pids+=("${flash_pid}")
echo "Start flashing device: ${devpath}, PID: ${flash_pid}"
done
# Wait until all flash processes done
failure=0
while true; do
running=0
echo -n "Ongoing processes:"
new_flash_pids=()
for flash_pid in "${flash_pids[@]}"; do
if [ -e "/proc/${flash_pid}" ]; then
echo -n " ${flash_pid}"
running=$((${running} + 1))
new_flash_pids+=("${flash_pid}")
else
wait "${flash_pid}" || failure=1
fi
done
echo
if [ ${running} -eq 0 ]; then
break
fi
flash_pids=("${new_flash_pids[@]}")
sleep 5
done
if [ ${failure} -ne 0 ]; then
echo "Flash complete (WITH FAILURES)"
exit 1
fi
echo "Flash complete (SUCCESS)"
To make the script executable, enter the command:
$ chmod +x multi_tegra_flash.sh
Flashing the Devices
1. Place all the Tegra devices into force-recovery mode.
2. Run the multi_tegra_flash.sh script with the command:
$ sudo ./multi_tegra_flash.sh