Advanced reboot - "Warning: Unable to obtain device information!"

I'm tracking current and building every week or so... Advanced reboot is not displaying the partitions, showing the above message instead. It does appear to be updating the image and functioning fine otherwise. Is this something I might have messed up or might it be a problem with the current build?

The build I am using is OpenWrt SNAPSHOT r11735-4ebc9dc9c4 / LuCI Master git-19.354.24352-2096d67 and the board is Linksys EA6350v3

One thing I did note is that

cat /tmp/sysinfo/board_name
linksys,ea6350v3

Not sure if the advanced reboot code is actually looking for upper case...

Seeing the same on wrtpac device, ping @stangri (apologies), I'm at r11697.

untested hack but may help
#!/bin/sh

cat <<EOF >devices.tmp
"Linksys EA3500", "linksys-audi", "mtd3", "mtd5", 32, "boot_part", 1, 2, "bootcmd", "run nandboot", "run altnandboot"
"Linksys E4200v2/EA4500", "linksys-viper", "mtd3", "mtd5", 32, "boot_part", 1, 2, "bootcmd", "run nandboot", "run altnandboot"
"Linksys EA6350v3", "linksys-ea6350v3", "mtd10", "mtd12", 192, "boot_part", 1, 2
"Linksys EA8300", "linksys-ea8300", "mtd10", "mtd12", 192, "boot_part", 1, 2
"Linksys EA8500", "ea8500", "mtd13", "mtd15", 32, "boot_part", 1, 2
"Linksys EA9500", "linksys-panamera", "mtd3", "mtd6", 28, "boot_part", 1, 2
"Linksys WRT1200AC", "linksys-caiman", "mtd4", "mtd6", 32, "boot_part", 1, 2, "bootcmd", "run nandboot", "run altnandboot"
"Linksys WRT1900AC", "linksys-mamba", "mtd4", "mtd6", 32, "boot_part", 1, 2, "bootcmd", "run nandboot", "run altnandboot"
"Linksys WRT1900ACv2", "linksys-cobra", "mtd4", "mtd6", 32, "boot_part", 1, 2, "bootcmd", "run nandboot", "run altnandboot"
"Linksys WRT1900ACS", "linksys-shelby", "mtd4", "mtd6", 32, "boot_part", 1, 2, "bootcmd", "run nandboot", "run altnandboot"
"Linksys WRT3200ACM", "linksys-rango", "mtd5", "mtd7", 32, "boot_part", 1, 2, "bootcmd", "run nandboot", "run altnandboot"
"NETGEAR WNDR3700", "netgear-wndr3700v2", "mtd3", "mtd1", nil, "boot_part", 1, 2, "bootcmd", "run nandboot", "run altnandboot"
"Synology RT2600AC", "rt2600ac", "mmcblk0p1", "mmcblk0p3", 256, "emmc", 1, 2
"ZyXEL NBG6817","nbg6817","mmcblk0p4","mmcblk0p7", 32, nil, 255, 1
EOF

MODEL=$(cat /etc/board.json 2>/dev/null | jsonfilter -e '@["model"]["id"]' 2>/dev/null)
RTRNAME=$(cat /etc/board.json 2>/dev/null | jsonfilter -e '@["model"]["name"]' 2>/dev/null)



if ! cat /proc/cmdline | grep -q 'root='; then
	echo "no root= on cmdline"; sleep 2
	rootdev="`cat /proc/mtd | grep kernel | cut -d':' -f1`"
else

	if read cmdline < /proc/cmdline; then
                case "$cmdline" in
                        *root=*)
                                rootpart="${cmdline##*root=}" #echo "rootpart1: $rootpart"
                                rootpart="${rootpart%% *}"
                                rootdev="`echo ${rootpart} | cut -b6-`"
                        ;;
                esac
	else
		echo "cannot read cmdline" && exit 1
	fi

fi


while IFS=, read dev nm p1 p2 oset un1 un1v1 un1v2 un2 un2v1 un2v2; do

	#echo "dbg1: un1: $un1"
	if [ "$un1" = "nil" -o "$un1v1" -eq 255 ]; then
		rtrclass=3;
	elif [ -z "$un2" ]; then
		rtrclass=1;
	else
		rtrclass=2;
	fi

	echo "############################################## CLASS:$rtrclass"
	echo "    device: $dev $nm"
	echo "       un1: $un1:$un1v1 $p1"
	echo "       un1: $un1:$un1v2 $p2"
	echo "    offset: $oset"
	if [ ! -z "$un2" ]; then echo "       un2: $un2"; fi
	if [ ! -z "$un2v1" ]; then echo "     un2v1: $un2v1"; fi
	if [ ! -z "$un2v2" ]; then echo "     un2v2: $un2v2"; fi

	dev=$(echo $dev | cut -d'"' -f2)
	un1=$(echo $un1 | cut -d'"' -f2)
	un1v1=$(echo $un1v1 | cut -d'"' -f2)
	un1v2=$(echo $un1v2 | cut -d'"' -f2)
	p1=$(echo $p1 | cut -d'"' -f2)
	p2=$(echo $p2 | cut -d'"' -f2)
	un2=$(echo $un2 | cut -d'"' -f2)
	un2v1=$(echo $un2v1 | cut -d'"' -f2)
	un2v2=$(echo $un2v2 | cut -d'"' -f2)
	oset=$(echo $oset | sed "s! !!")

	if [ "$RTRNAME" == "$dev" ]; then
		thisclass="$rtrclass"
		echo "$dev [match]"
		break
	else
		echo "$dev [no match]"
	fi
done < devices.tmp
if [ -z "$thisclass" ]; then echo "model: $RTRNAME unsupported" && exit 1; fi



echo "############################################## CLASS:$rtrclass"
echo "    device: $dev $nm"
echo "       un1: $un1:$un1v1 $p1"
echo "       un1: $un1:$un1v2 $p2"
echo "    offset: $oset"
if [ ! -z "$un2" ]; then echo "       un2: $un2"; fi
if [ ! -z "$un2v1" ]; then echo "     un2v1: $un2v1"; fi
if [ ! -z "$un2v2" ]; then echo "     un2v2: $un2v2"; fi
echo ""
sleep 2

if [ "$rootdev" != "$p1" ]; then
	echo "################ current rootdev: $rootdev is not p1:$p1"
else
	echo "################ current rootdev: $rootdev is p1:$p1"
fi
if [ "$rootdev" != "$p2" ]; then
	echo "################ current rootdev: $rootdev is not p2:$p2"
else
	echo "################ current rootdev: $rootdev is p2:$p2"
fi


case "$osp1" in
	*"LEDE"*)
		echo "os-p1: is LEDE"
	;;
	*"OpenWrt"*)
		echo "os-p1: is OpenWrt"
	;;
	*"Linksys"*)
		echo "os-p1: is Linksys"
	;;
	*"ZyXEL"*)
		echo "os-p1: is ZyXEL"
	;;
	*"Synology"*)
		echo "os-p1: is Synology"
	;;
	*)
		echo "os-p1: is unknown"
	;;
esac

case "$osp2" in
	*"LEDE"*)
		echo "os-p1: is LEDE"
	;;
	*"OpenWrt"*)
		echo "os-p1: is OpenWrt"
	;;
	*"Linksys"*)
		echo "os-p1: is Linksys"
	;;
	*"ZyXEL"*)
		echo "os-p1: is ZyXEL"
	;;
	*"Synology"*)
		echo "os-p1: is Synology"
	;;
	*"DD-WRT"*)
		echo "os-p1: is DD-WRT"
	;;
	*)
		echo "os-p1: is unknown"
	;;
esac




case $thisclass in

	1)
		curu1="`fw_printenv | grep "$un1=" | cut -d'=' -f2`"
			if [ "$curu1" = "$un1v1" ]; then
				newun1="$un1v2"
				pcheck="$p1"
				echo "current env1: $un1 is $curu1 > $newun1"
			elif [ "$curu1" = "$un1v2" ]; then
				newu1="$un1v1"
				pcheck="${p2}"
				echo "current env1: $un1 is $curu1 > $newun1"
			else
				echo "un1: $un1 is $curu1 no match for 1:$un1v1 2:$un1v2"
			fi

			if ! echo $rootpart | grep -q "$pcheck"; then
				echo "warning: rootpart $rootpart checkfail != $pcheck"
			fi
			echo ""

			echo "> fw_setenv $un1 $newun1"
			echo "> reboot"
	;;

	2)


		curu1="`fw_printenv | grep "$un1=" | cut -d'=' -f2`"
			if [ "$curu1" = "$un1v1" ]; then
				newun1="$un1v2"
				pcheck="$p1"
				echo "un1: $un1 is $curu1 > $newun1"
			elif [ "$curu1" = "$un1v2" ]; then
				newu1="$un1v1"
				pcheck="${p2}"
				echo "un1: $un1 is $curu1 > $newun1"
			else
				echo "un1: $un1 is $curu1 no match for 1:$un1v1 2:$un1v2"
			fi


		curu2="`fw_printenv | grep "$un2=" | cut -d'=' -f2`"
			if [ "$curu2" = "$un2v1" ]; then
				newun2="$un2v2"
				echo "current env2: $un2 is $curu2 > $newun2"
			elif [ "$curu2" = "$un2v2" ]; then
				newun2="$un2v1"
				echo "current env2: $un2 is $curu2 > $newun2"
			else
				echo "un2: $un2 is $curu2 no match for 1:$un2v1 or 2:$un2v2"
			fi

			echo "> fw_setenv $un1 $newun1"
			echo "> fw_setenv $un2 $newun2"
			echo "> reboot"


			if ! echo $rootpart | grep -q "$pcheck"; then
				echo "###### warning: rootpart $rootpart checkfail != $pcheck ######"
			fi

	;;
	3)
		echo "fw_printenv CLASS3 | grep $un2 | grep $un2v1"
	;;
	5)
		echo "fw_printenv CLASS5 | grep $un2 | grep $un2v1"
	;;
	*)
		echo "fw_printenv disabled unknown class: $thisclass"
		:
	;;

esac


exit 0

missing the payload end... but might be enough for you to squeeze your specific disk read logix in... from memory the linksys stuff is mostly grouped under the same logic so you might be catching an edge case on it. badblocks maybe...

LuCI recently had some changes where it refactored dispatcher.lua and moving more things from Lua to JS (in this case, JSON).

And these might be relevant @stangri


https://git.openwrt.org/?p=project/rpcd.git;a=commit;h=aaa08366e6384d9933a405d1218b03c1b167f9e5

It's an issue with the variable scope in Lua which I guess got changed due to move to JS.

I'll have to consult with @jow on that before I can come up with the solution.

You need to encapsulate the logic in line 90 to 180 in a function and call that from your template or even better, replace template("advanced_reboot/advanced_reboot") with post("action_template") then declare a function action_template() containing the code from line 90-180 and invoking ltemplate.render("advanced_reboot/advanced_reboot", { ... }) with the required scope variable in the end.

1 Like

Thanks! I need the code in 90-180 to be global to the controller as some of the variables obtained there are used by other action_ functions.

However I did modify the index and when trying to access Advanced Reboot page I get the HTTP 405 error.

According to the logs, the code in lines 90-180 runs, but the template rendering fails. Any idea why?

PS. Would it be more elegant to still wrap 90-180 into obtain_device_info function and then call it from other functions than leave it global?

PPS. Testing on 18.06.5, not sure if it matters.

Yeah that was my fault, you need to change post() to call() for that initial template action.

Yes, definitely.

1 Like

Thank you @jow!

@mvh, @anomeome -- I would appreciate full testing (including rebooting to alternative partition) of the new package on the master/snapshot images. Just do the opkg update; opkg upgrade luci-app-advanced-reboot; if you have my repo added to your router or install the package from https://dev.melmac.net/openwrt-repo/luci-app-advanced-reboot_git-19.356.80423-2417ad5-47_all.ipk.

As soon as I receive some positive feedback on the new version, I'll send a PR.

2 Likes

I can confirm this to fix the issue on my nbg6817, it works fine again. Thanks a lot for looking into this.

Thank you (and @anomeome), PR sent.

3 Likes

Can confirm that the boot display is working again against master (PR has been applied)!

1 Like

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