Power off Jetson instead of rebooting when flash is successful

Hi,

When I flash (JP 6.0) a Jetson Orin Nano (or NX 16GB) using ./tools/kernel_flash/l4t_initrd_flash.sh, it reboots automatically the Jetson.

End of the log is:

tar: Read checkpoint 1950000
tar: Read checkpoint 1960000
tar: Read checkpoint 1970000
writing item=17, 9:0:secondary_gpt, 61203267072, 16896, gpt_secondary_9_0.bin, 16896, fixed-<reserved>-0, 86deb8c9333e2faa980e173b1269dd6a16c277a7
[ 297]: l4t_flash_from_kernel: Successfully flash the external device
[ 297]: l4t_flash_from_kernel: Flashing success
[ 297]: l4t_flash_from_kernel: The device size indicated in the partition layout xml is smaller than the actual size. This utility will try to fix the GPT.
Flash is successful
Reboot device
Cleaning up...
Log is saved to Linux_for_Tegra/initrdlog/flash_3-1_0_20240712-133636.log 

I’d like to power off the Jetson instead of rebooting it, is that possible? I didn’t find the place that does it in the scripts.
Which script, and where, should I modify to power off the Jetson?

I tried to write halt -p in Linux_for_Tegra/tools/kernel_flash/l4t_flash_from_kernel.sh instead of reboot now, but no luck, system was rebooted:

if [ "${no_reboot}" = "0" ]; then
	print_log "The device is going to reboot in 5 seconds...."
	sleep 5
#	reboot now
	halt -p
fi

Thanks!

Hi,

The logic is not actually handled here because no_reboot is by default set to 1.
Please find the following section in Linux_for_Tegra/tools/kernel_flash/l4t_network_flash.func and modify it as:

	if ! sshpass -p root ssh "root@${1}" "${SSH_OPT[@]}" "NFS_ROOTFS_DIR=\"${NFS_ROOTFS_DIR}\" NFS_IMAGES_DIR=\"${NFS_IMAGES_DIR}\" /bin/${FLASH_FROM_NETWORK_SCRIPT} ${cmd[*]}"; then
		echo "Flash failure"
		debug_log=$(mktemp)
		echo "Either the device cannot mount the NFS server on the host or a flash command has failed. Debug log saved to ${debug_log}. You can access the target's terminal through \"sshpass -p root ssh root@${1}\" "
		print_debug_log > "${debug_log}"
		exit 103
	fi

	- if ! sshpass -p root ssh "root@${1}" "${SSH_OPT[@]}" "nohup reboot &>/dev/null & exit"; then
	+ if ! sshpass -p root ssh "root@${1}" "${SSH_OPT[@]}" "nohup echo o > /proc/sysrq-trigger"; then
		echo "Reboot failure"
		exit 104
	fi

You cannot do shutdown -h now here for two reasons:

  1. The shutdown binary itself is not available in initrd by default.
  2. Even if you get to include it by modifying Linux_for_Tegra/tools/ota_tools/version_upgrade/recovery_copy_binlist.txt, both /sbin/shutdown and /sbin/poweroff is a softlink to /bin/systemctl, and systemctl relies on systemd to work, which is not the case in an initrd environment.
1 Like

Thanks a lot @DaveYYY, I didn’t know this way at all, I’ll have a try.

Thanks @DaveYYY, I tested it and it’s working perfectly!

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