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

If you send PR against my repo I can build a new IPK with the new board supported and wait until someone can test it on master before sending PR to the OpenWrt packages repo.

Or, you can send your own PR to the OpenWrt packages repo, but please do test on master beforehand.

Thank you @djadair for the PR, the updated IPK is available here: https://dev.melmac.net/repo/luci-app-advanced-reboot_1.0.1-2_all.ipk

Can you see who submitted the patch to have that router supported and contact the "maintainer" to see if they are willing to test it on snapshot? But also, with the advanced reboot/dual partitions supported, can you maybe flash snapshot on alternative partition and test?

Also, you've done a great job with your PR to my private repo, maybe you should send the PR to the OpenWrt luci master and 21.02 yourself, I forgot to tell you to bump the version number tho.

Oh that was dumb, yea I don't have to compile to load snapshot and getting back without hooking up the serial port was the whole point. Thanks for the patience.
If I fix the bug I inserted with MTD numbers and use 13,15

     "partition1MTD": "mtd13",
     "partition2MTD": "mtd15",

The change works for both master and 21.02.

Since master seems to be working I'll try to set up a proper build. Might take a few days.

Please force-reinstall last IPK, I've switched the partition numbers there.

Sorry for the delay. I downloaded and force-installed the new package.
Contents were identical to the one I built and operate as shown above.

Managed to get a local luci build of master so I generated a PR as suggested. Will do 21-02 the next time I rebuild that branch.

Thanks for creating this. Using it routinely now :slight_smile:

1 Like

Great job! If you want your fix merged for 21.02 as well, please send a separate PR.

there is a way to mount rom and edit the /etc/config/fstab there while you are with extroot mounted as root.
I done that some time ago, I can help.

Could you please add EA7500v2? Thanks

can anyone help on this : Feature Request - Advanced Reboot - emmc / sdcard - #2 by erdoukki

thanks

Reading footnotes here: https://git.openwrt.org/?p=openwrt/openwrt.git;a=commit;h=31b49f02ca8a82a36f920d4b29626f2845e9eb50 makes me believe that there's no elegant way to boot into secondary partition without the power toggle trick. If I'm wrong and there's a command-line way to accomplish it, please advise.

This was discussed earlier in this thread, if anyone is willing to contribute the code, it's all open source.

Hello.
I'm trying to add support to the Linksys E9500 (panamera):

// WIP
{
	"vendorName": "Linksys",
	"deviceName": "EA9500",
	"boardNames": [ "linksys,panamera" ],
	"partition1MTD": "mtd3",
	"partition2MTD": "mtd5",
	"labelOffset": 32,
	"bootEnv1": "boot_part",
	"bootEnv1Partition1Value": 1,
	"bootEnv1Partition2Value": 2,
	"bootEnv2": null,
	"bootEnv2Partition1Value": null,
	"bootEnv2Partition2Value": null
}

The partitions are:

root@OpenWrt:/# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00080000 00020000 "boot"
mtd1: 00100000 00020000 "nvram"
mtd2: 00080000 00020000 "nvram"
mtd3: 01d00000 00020000 "firmware"
mtd4: 003fffe4 00020000 "linux"
mtd5: 01900000 00020000 "ubi"
mtd6: 06100000 00020000 "failsafe"

In: Build for Linksys EA9500 - #69 by npcomplete

Changing the bootpartition in CLI:
nvram set bootpartition=0 && nvram set partialboots=0 && nvram commit

bootpartition can be 0 or 1.

The "labelOffset" parameter is undocumented. Could you explain how can I define it?

Thanks.

That's incorrect, this is for the CFE terminal, not CLI. From the commit it doesn't look like both partitions are accessible/flashable from OpenWrt.

PS. labelOffset is an offset (in bytes) for locating partition/kernel data within partition.

The US version needs to be flashed from a serial interface, unlike the non-US ones that allow from the web gui.

There are 2 partitions, firmware + failsafe, flashable by Openwrt:

  mtd write /mnt/openwrt-bcm53xx-generic-linksys_ea9500-squashfs.trx firmware
  mtd write /mnt/openwrt-bcm53xx-generic-linksys_ea9500-squashfs.trx failsafe
  nvram set bootpartition=0 && nvram set partialboots=0 && nvram commit

In: https://openwrt.org/toh/linksys/ea9500_v1?s[]=linksys&s[]=ea9500

Could you add support then, please? :slight_smile:

Thanks!

Thanks for bringing this to my attention. Can you post how to switch partitions and how to obtain the information about current partition and partition information?

To switch partitions your may execute the following instruction:

# for booting mtd3
nvram set bootpartition=0 && nvram set partialboots=0 && nvram commit
# for booting mtd5
nvram set bootpartition=1 && nvram set partialboots=0 && nvram commit

The syslog reports the following partitions:

Sun Oct  3 21:55:21 2021 kern.notice kernel: [    2.014191] 6 fixed-partitions partitions found on MTD device brcmnand.0
Sun Oct  3 21:55:21 2021 kern.notice kernel: [    2.020907] Creating 6 MTD partitions on "brcmnand.0":
Sun Oct  3 21:55:21 2021 kern.notice kernel: [    2.026066] 0x000000000000-0x000000080000 : "boot"
Sun Oct  3 21:55:21 2021 kern.notice kernel: [    2.031357] 0x000000080000-0x000000180000 : "nvram"
Sun Oct  3 21:55:21 2021 kern.notice kernel: [    2.036695] 0x000000180000-0x000000200000 : "devinfo"
Sun Oct  3 21:55:21 2021 kern.notice kernel: [    2.042498] 0x000000200000-0x000001f00000 : "firmware"
Sun Oct  3 21:55:21 2021 kern.notice kernel: [    2.049038] 2 trx partitions found on MTD device firmware
Sun Oct  3 21:55:21 2021 kern.notice kernel: [    2.054474] Creating 2 MTD partitions on "firmware":
Sun Oct  3 21:55:21 2021 kern.notice kernel: [    2.059453] 0x00000000001c-0x000000400000 : "linux"
Sun Oct  3 21:55:21 2021 kern.notice kernel: [    2.064974] 0x000000400000-0x000001d00000 : "ubi"
Sun Oct  3 21:55:21 2021 kern.notice kernel: [    2.070351] 0x000001f00000-0x000003c00000 : "backup"
Sun Oct  3 21:55:21 2021 kern.notice kernel: [    2.076040] 0x000005200000-0x000008000000 : "system"

The current partition could be checked from:

# nvram get bootpartition
0

Could you enable this, replacing mtd6 by mtd5?

@npcomplete , would you mind giving a hand on this, please? :slight_smile:

It will be more involved than that as this is the only router that I know of which uses nvram to set boot environment variables, I'll have to adjust the rpcd parts.

If between @ReDaLeRt and @npcomplete you could link the commit/PR merge to OpenWrt repo containing support for EA9500 and its nvram command and save me time from looking it up, I'd appreciate it.

Good Morning! :))

I just got my hands on an unused Linksys EA8100-v1 and started to explore. I can see that is has partitions for dual boot and I can select the firmware to boot by setting boot_part in uboot. I created a json config for the router in devices and it seems to be fine, but the fw_setenv fails because mtd1 is read only when in OWRT.

I tried to figure out how you do it with other devices and I see that in the dts files of similar hardware the this partition is also set to read only.

Help! :)) How did you make it writeable to set the boot_part variable?

Also, is that actually a good idea? Kind of looks to me like its a good idea to have that locked up. I wonder ...

Cheers,
Fred

If dual-booting is sorted via u-boot-env, u-boot-env can't be marked read-only.

Oh, I think I was wrong. Looking at the dts config again and comparing my rampis device with one that is in the list of supported devices - Linksys EA6350 v4 for example - both dts include mt7621_linksys_ea7xxx.dtsi, which contains the definition of the partitions. Here read-only is not set for the

  95                 partition@80000 {
  96                         label = "u_env";
  97                         reg = <0x80000 0x40000>;
  98                 };

Interestingly alt_kernel and alt_rootfs are. Need to work that out later :))

I do not see overwrites of that configuration in any of the device specific files that I looked at. So there must be something I miss when the system is up that you need to do before you can use fw_setenv.

Will keep looking, hints welcome.