Web UI to reboot to another partition (for Linksys/ZyXEL dual-partition routers) and to power off/power down

Would it be possible to add support for the Linksys E8450/Belkin RT3200?
I have one and would gladly provide any info needed.

1 Like

The Linksys WHW01 has just been merged into master and it has dual-partitions
https://openwrt.org/toh/linksys/whw01_v1
Would it be possible for support to be added for this?

again we need more info... how the 2 partition are swapped... with uboot? do we have correct walues to access uboot env?

I'm not sure how the partitions are swapped inside uboot but I do know that after a number of unsuccessful boot attempt it does flash the second partition to the first one. I'll see if I can find more info on it though

If it does flash then it's a no god (i think)

looking at the uboot environment, there appears to be a bootpart1 and bootpart2 command and a boot_part variable what is set to 1. I dont have much experience with uboot though.

can you give output of fw_printenv

altkern=5000000
auto_recovery=yes
baudrate=115200
boot_part_ready=3
bootcmd=if test $auto_recovery = no; then bootipq; elif test $boot_part = 1; then run bootpart1; else run bootpart2; fi
bootdelay=2
bootpart1=set bootargs $partbootargs && nand device 1 && nand read $loadaddr $prikern $kernsize && bootm $loadaddr
bootpart2=set bootargs $partbootargs2 && nand device 1 && nand read $loadaddr $altkern $kernsize && bootm $loadaddr
ethact=eth0
fdt_high=87000000
fileaddr=84124c58
filesize=012e0000
flash_type=0
flashimg=tftpboot $loadaddr $image && nand erase $prikern $imgsize && nand write $loadaddr $prikern $filesize
flashimg2=tftpboot $loadaddr $image && nand erase $altkern $imgsize && nand write $loadaddr $altkern $filesize
image=nodes-jr.img
imgsize=5000000
ipaddr=192.168.1.1
kernsize=600000
loadaddr=81000000
machid=8010100
maxpartialboots=3
partbootargs=init=/sbin/init rootfstype=squashfs ubi.mtd=rootfs root=mtd:squashfs rootwait
partbootargs2=init=/sbin/init rootfstype=squashfs ubi.mtd=alt_rootfs root=mtd:squashfs rootwait
prikern=0
serverip=192.168.1.236
stderr=serial
stdin=serial
stdout=serial
boot_part=1

ok it's easy... it's all controlled by boot_part
that controls what partition to load... nothings gets flashed/overwritten :smiley:

yeah it does look like it has that, it still does do a flash of the alt part to the main part after 3 partial boots but it looks like that can be controlled using maxpartialboots

i wonder if the way would be disable auto_recovery and change the bootcmd to

if test $boot_part = 1; then run bootpart1; else run bootpart2; fi

but to me it seems just a recovery thing like the linksys recovery thing on mvebu... that for sure something to handle in a pr

that does sound like a possibility

Would be great to know how the kernel/rootfs and altkernel/altrootfs are mounted while in OpenWrt. I've seen the partition description in the original support PR, but I can't figure it out based on that.

df should show all mounts shouldnt it? i normally use findmnt on standard linux machines to list mounts but obv this is embedded and doesnt have it

I assume they are handled by

partbootargs=init=/sbin/init rootfstype=squashfs ubi.mtd=rootfs root=mtd:squashfs rootwait
partbootargs2=init=/sbin/init rootfstype=squashfs ubi.mtd=alt_rootfs root=mtd:squashfs rootwait

@sniff122 can you check if the bootargs match the one from uboot?

init=/sbin/init rootfstype=squashfs ubi.mtd=rootfs root=mtd:squashfs rootwait root=/dev/ubiblock0_0
this is the bootargs of the running system

this comes probably from a bootagrs-append in the dts... so it's problematic

ill see if i can use the bootpart2 within uboot to manually boot to the second partition and see how it behaves. Im not sure but i have a feeling that ubi.mtd=rootfs might be setting what partition is at /dev/ubiblock0_0, ill add another reply with my findings

If it's possible to use a shell command (or two commands) to make the router reboot to another partition, the support for it in WebUI can be implemented. Every router supported in its own json-file, which given the level of your expertise demonstrated in this thread, shouldn't be too hard for you to create.

If you need any help from me, let me know!

Just had a look at one if the JSON files for the devices and it looks pretty easy to implement a new device, I'll see if I can get it working