Write Fail occured in l4t_initrd_flash

We are working on Jetson Orin NX based custom board.

We have flashed firmware with l4t_initrd_flash.sh for a custom board in an L4T 35.4.1 environment,
It was found that the script terminated with an error when a specific device was connected to the HostPC.

Write Command

$ ./tools/kernel_flash/l4t_initrd_flash.sh --flash-only --massflash 5
/tools/kernel_flash/l4t_initrd_flash_internal.sh  \
--usb-instance 1-6 --device-instance 0 --flash-only --external-device nvme0n1p1 
-c "tools/kernel_flash/flash_l4t_external.xml" -S 19327352832 dx-u2200+p3767-0000 nvme0n1p1
...
Start flashing device: 1-6, rcm instance: 0, PID: 18253
Log will be saved to Linux_for_Tegra/initrdlog/flash_1-6_0_20240222-141204.log 
Ongoing processes: 18253
Ongoing processes:
Flash complete (WITH FAILURES)

real	0m5.080s
user	0m0.584s
sys	0m1.492s

In l4t_initrd_flash_internal.sh, The script searches for a SCSI device to write to.

wait_for_booting()
{
...
	while true
	do
...
		if [ -z "${network}" ] && ls /dev/sd* 1> /dev/null 2>&1; then
			echo "enter -z network"
			while IFS=  read -r -d $'\0'; do
				path="$(readlink -f "$REPLY")"
				! [ -b "${path}" ] && continue
				dev=$(get_udev_attribute "$path" vendor)
				model=$(get_udev_attribute "$path" model)
				model_id=$(get_udev_attribute "$path" idProduct)
				vendor_id=$(get_udev_attribute "$path" idVendor)
...

get_udev_attribute()
{
	path=$1
	attr=$2

	properties=$(flock -w 60 /var/lock/nvidiainitrdflash udevadm info --attribute-walk "$path")
	echo "${properties}" | sed -n "0,/^[ ]*ATTRS{$attr}==\"\(.*\)\"\$/s//\1/p" | xargs
}

Search all SCSI devices (/dev/sd*) connected to the HostPC and check if they are created by Jetson, based on the storage information.

The regular expression in get_udev_attribute() could not process the string correctly because it contained a Device Model name “2.5” SATA SSD 3T" containing double quotation marks “” during this process.
It was found that the write script terminated abnormally at the following point.

***************************************
*                                     *
*  Step 3: Start the flashing process *
*                                     *
***************************************
xargs: unmatched double quote; by default quotes are special to xargs unless you use the -0 option
Cleaning up...

The SSD information is below.

$ udevadm info --attribute-walk /dev/sda | grep model
    ATTRS{model}=="2.5" SATA SSD 3T"

$ sudo smartctl --all /dev/sda
smartctl 6.6 2016-05-31 r4324 [x86_64-linux-5.4.0-150-generic] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Device Model:     2.5" SATA SSD 3TE7
Serial Number:    BCA12306010140002

LU WWN Device Id: 5 24693e 001394245
Firmware Version: S20615
User Capacity:    960,197,124,096 bytes [960 GB]
Sector Size:      512 bytes logical/physical
Rotation Rate:    Solid State Device
Form Factor:      2.5 inches
Device is:        Not in smartctl database [for details use: -P showall]
ATA Version is:   ACS-2 (minor revision not indicated)
SATA Version is:  SATA 3.2, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Thu Feb 22 16:43:43 2024 JST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

initrdlogflash_1-6_0_20240222-141204.log (5.4 KB)

Could you fix it so that it is handled correctly even if there are devices that contain double quotes?

Can you use --network usb0 during creation and flash process?

We temporarily added network usb0 and confirmed that the error did not occur.

$ ./massflash.sh 
+ sudo ./tools/kernel_flash/l4t_initrd_flash.sh --flash-only --network usb0 --massflash 5
[sudo] password for test: 
/home/test/test2/mfi_dx-u2200+p3767-0000/tools/kernel_flash/l4t_initrd_flash_internal.sh --network usb0 --usb-instance 1-6 --device-instance 0 --flash-only --external-device nvme0n1p1 -c "tools/kernel_flash/flash_l4t_external.xml" -S 19327352832 --network usb0 dx-u2200+p3767-0000 nvme0n1p1
Start flashing device: 1-6, rcm instance: 0, PID: 25571
Log will be saved to Linux_for_Tegra/initrdlog/flash_1-6_0_20240228-085534.log 
Ongoing processes: 25571

Ongoing processes: 25571
Ongoing processes:

real	13m37.398s
user	0m2.306s
sys	0m2.599s

initlogflash_1-6_0_20240228-085534.log (42.4 KB)

However, we usually remove the network usb0 option when creating and flashing massflash blobs.
Because even though system.img is the write target, the following process copies rootfs directory as well.
In result, doubling the size of the massflash blob.

[tools/kernel_flash/l4t_initrd_flash_internal.sh]

package()
{
	local workdir="${1}"
	local cmdline="${2}"
	local tid="${3}"
	local temp_bootloader="${workdir}/bootloader"
	copy_bootloader "${temp_bootloader}" "${tid}" "${cmdline}"

	local temp_kernelflash="${workdir}/tools/kernel_flash"
	mkdir -p "${temp_kernelflash}"
	cp -a "${L4T_INITRD_FLASH_DIR}"/* "${temp_kernelflash}"
	cp "${LINUX_BASE_DIR}/${target_board}.conf" "${workdir}/"
	cp "${LINUX_BASE_DIR}/"*.common "${workdir}/"
	if [ -n "${network}" ]; then
		cp -a "${LINUX_BASE_DIR}/rootfs" "${workdir}/" //copy whole rootfs dir
	fi
}

Could you also fix the regular expression in get_udev_attribute()?
There is no problem for us to fix it internally, but we would like to see an official fix in the future L4T release.

We found that using the network is more stable so actually that will be the default way in the future release like JP6 . We are exploring options to remove the rootfs requirements in order to minimize the size.

2 Likes

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