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


#105

I've added support for booting LEDE from both partition sets in this pull request, which has been merged to LEDE master on November 6th 2017.

https://github.com/lede-project/source/pull/1476

The current sysupgrade support in LEDE however does not yet alternate between these partition sets, adding this would be trivial though (right now I do like to keep the OEM firmware for reference) - all information necessary to support this is known.

I've now published a simple example script (nbg6817-dualboot) to read- and modify the dualboot flag (and some related information) at

This is working on both LEDE and the ZyXEL OEM firmware, it can be copied as-is to the overlay and be executed from there. I've licensed it under the ISC license, which is compatible to BSD, GPL2/ GPL3.

The only missing bits and pieces for a 'perfect' representation in luci-app-advanced-reboot would be if LEDE could write the version header to header (/dev/mmcblk0p3) and header_1 (/dev/mmcblk0p6) as described in my previous post, but that's mostly cosmetic.


#106

I need your help -- where (partition and offset) the partition "label" (ie: LEDE vs Stock) and the kernel version are stored so I could read them with the dd? Ideally post the complete command and the output WHILE BOOTED TO LEDE.


#107

ZyXEL OEM firmware, version "V1.00(ABCS.2)C0":

header (/dev/mmcblk0p3):

# cat /dev/mmcblk0p3 | hexdump -C | head -n 5
00000000  00 00 a7 74 01 32 f0 00  56 31 2e 30 30 28 41 42  |...t.2..V1.00(AB|
00000010  43 53 2e 32 29 43 30 00  ff ff ff ff ff ff ff ff  |CS.2)C0.........|
00000020  ff ff ff ff ff ff ff ff  00 00 d5 dc 4e 42 47 36  |............NBG6|
00000030  38 31 37 00 ff ff ff ff  ff ff ff ff ff ff ff ff  |817.............|
00000040  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|

# dd if=/dev/mmcblk0p3 bs=1 skip=8 count=16 2>/dev/null
V1.00(ABCS.2)C0

kernel (/dev/mmcblk0p4):

# cat /dev/mmcblk0p4 | hexdump -C | head -n 5
00000000  27 05 19 56 30 17 e6 cf  57 9b 19 4c 00 1c 6a 58  |'..V0...W..L..jX|
00000010  41 50 80 00 41 50 80 00  c4 29 7c 36 05 02 02 00  |AP..AP...)|6....|
00000020  4c 69 6e 75 78 2d 33 2e  34 2e 31 30 33 00 00 00  |Linux-3.4.103...|
00000030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000040  00 00 a0 e1 00 00 a0 e1  00 00 a0 e1 00 00 a0 e1  |................|

# dd if=/dev/mmcblk0p4 bs=1 skip=32 count=25 2>/dev/null
Linux-3.4.103

rootfs (/dev/mmcblk0p5):

<this contains rootfs, the OEM overlay is on /dev/mmcblk0p1 (rootfs_data)>

ZyXEL OEM firmware, version "V1.00(ABCS.5)C0":

header_1:

# cat /dev/mmcblk0p6 | hexdump -C | head -n 5
00000000  00 00 bf 94 01 46 d8 00  56 31 2e 30 30 28 41 42  |.....F..V1.00(AB|
00000010  43 53 2e 35 29 43 30 00  ff ff ff ff ff ff ff ff  |CS.5)C0.........|
00000020  ff ff ff ff ff ff ff ff  00 00 d6 5a 4e 42 47 36  |...........ZNBG6|
00000030  38 31 37 00 ff ff ff ff  ff ff ff ff ff ff ff ff  |817.............|
00000040  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|

# dd if=/dev/mmcblk0p6 bs=1 skip=8 count=16 2>/dev/null
V1.00(ABCS.5)C0

kernel_1:

# cat /dev/mmcblk0p7 | hexdump -C | head -n 5
00000000  27 05 19 56 6a 19 f0 c0  58 dc e4 a7 00 1c 56 20  |'..Vj...X.....V |
00000010  41 50 80 00 41 50 80 00  71 34 fe 9c 05 02 02 00  |AP..AP..q4......|
00000020  4c 69 6e 75 78 2d 33 2e  34 2e 31 30 33 00 00 00  |Linux-3.4.103...|
00000030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000040  00 00 a0 e1 00 00 a0 e1  00 00 a0 e1 00 00 a0 e1  |................|

# dd if=/dev/mmcblk0p7 bs=1 skip=32 count=25 2>/dev/null
Linux-3.4.103

rootfs_1 (/dev/mmcblk0p8):

<this contains rootfs, the OEM overlay is on /dev/mmcblk0p1 (rootfs_data)>

LEDE/ master:

header (/dev/mmcblk0p3):

not yet updated by LEDE, so whatever was previously left there by an OEM firmware

kernel (/dev/mmcblk0p4):

# cat /dev/mmcblk0p4 | hexdump -C | head -n 5
00000000  27 05 19 56 67 c0 a3 ba  5a 2b 05 67 00 1e e5 fe  |'..Vg...Z+.g....|
00000010  42 20 80 00 42 20 80 00  cf 2d f2 d2 05 02 02 00  |B ..B ...-......|
00000020  41 52 4d 20 4f 70 65 6e  57 72 74 20 4c 69 6e 75  |ARM OpenWrt Linu|
00000030  78 2d 34 2e 39 2e 36 37  00 00 00 00 00 00 00 00  |x-4.9.67........|
00000040  00 00 a0 e1 00 00 a0 e1  00 00 a0 e1 00 00 a0 e1  |................|

# dd if=/dev/mmcblk0p4 bs=1 skip=32 count=25 2>/dev/null
ARM OpenWrt Linux-4.9.67

rootfs (/dev/mmcblk0p5):

<this contains rootfs and overlay>

Difference between LEDE/ release (prior to rebranding back to OpenWrt):

$ wget -qO- https://downloads.lede-project.org/releases/17.01.4/targets/ipq806x/generic/lede-17.01.4-ipq806x-NBG6817-squashfs-mmcblk0p4-kernel.bin | hexdump -C | head -n 5
00000000  27 05 19 56 ec f1 4c e3  59 e6 41 ec 00 1c 71 81  |'..V..L.Y.A...q.|
00000010  42 20 80 00 42 20 80 00  15 fd a6 c5 05 02 02 00  |B ..B ..........|
00000020  41 52 4d 20 4c 45 44 45  20 4c 69 6e 75 78 2d 34  |ARM LEDE Linux-4|
00000030  2e 34 2e 39 32 00 00 00  00 00 00 00 00 00 00 00  |.4.92...........|
00000040  00 00 a0 e1 00 00 a0 e1  00 00 a0 e1 00 00 a0 e1  |................|

$ wget -qO- https://downloads.lede-project.org/releases/17.01.4/targets/ipq806x/generic/lede-17.01.4-ipq806x-NBG6817-squashfs-mmcblk0p4-kernel.bin | dd bs=1 skip=32 count=25 2>/dev/null
ARM LEDE Linux-4.4.92

and current LEDE master (post rebranding back to OpenWrt):

$ wget -qO- https://downloads.lede-project.org/snapshots/targets/ipq806x/generic/openwrt-ipq806x-NBG6817-squashfs-mmcblk0p4-kernel.bin | hexdump -C | head -n 5
00000000  27 05 19 56 d0 2f aa f9  5a 3d 41 53 00 1f 5a f6  |'..V./..Z=AS..Z.|
00000010  42 20 80 00 42 20 80 00  68 04 c4 25 05 02 02 00  |B ..B ..h..%....|
00000020  41 52 4d 20 4f 70 65 6e  57 72 74 20 4c 69 6e 75  |ARM OpenWrt Linu|
00000030  78 2d 34 2e 39 2e 37 30  00 00 00 00 00 00 00 00  |x-4.9.70........|
00000040  00 00 a0 e1 00 00 a0 e1  00 00 a0 e1 00 00 a0 e1  |................|

$ wget -qO- https://downloads.lede-project.org/snapshots/targets/ipq806x-NBG6817-squashfs-mmcblk0p4-kernel.bin | dd bs=1 skip=32 count=25 2>/dev/null
ARM OpenWrt Linux-4.9.70

Kernel and rootfs (and therefore label/ kernel version) are only stored on the eMMC (/dev/mmcblk0), which has a normal GPT partition table - accordingly the partitioning is identical between the OEM firmware and LEDE. Nothing firmware version specific ever touches the SPI-NOR, it's all contained within the eMMC.

What does differ is the partitioning of the SPI-NOR flash, this makes the numbering of the mtd partitions slightly volatile. Both LEDE and the OEM firmware only use the mtd label via find_mtd_part() from /lib/functions.sh; unfortunately this label also differs between OEM ("dualflag") and LEDE ("0:DUAL_FLAG"). This bootflag is the only data that 'ever' gets modified on the SPI-NOR flash.

I've detailed the partitioning for SPI-NOR and eMMC under LEDE and the OEM firmware as well.


#108

I've added a simple version decoder to my example script:

https://github.com/pkgadd/nbg6817/commit/4dc641c9c52feaed7e26792c835647e80435887b

Lede/ master:

# /tmp/nbg6817-dualboot --get-version /dev/mmcblk0p5
HEADER partition is located at "/dev/mmcblk0p3"
KERNEL partition is located at "/dev/mmcblk0p4"
ROOTFS partition is located at "/dev/mmcblk0p5"
 
FIRMWARE_VERSION="LEDE/ Openwrt <unknown revision>"
KERNEL_VERSION="ARM OpenWrt Linux-4.9.67"
UNAME_VERSION="4.9.67"

ZyXEL OEM Firmware, version V1.00(ABCS.5)C0:

# /tmp/nbg6817-dualboot --get-version /dev/mmcblk0p8
HEADER partition is located at "/dev/mmcblk0p6"
KERNEL partition is located at "/dev/mmcblk0p7"
ROOTFS partition is located at "/dev/mmcblk0p8"
 
FIRMWARE_VERSION="V1.00(ABCS.5)C0"
KERNEL_VERSION="Linux-3.4.103"
UNAME_VERSION="3.4.103"

#109

The NBG6817 doesn't have an equivalent to the syscfg partition, but it can be powered off by the kernel (/sbin/poweroff).


#110

Thanks to tremendous amount of support and testing from @slh, support for ZyXEL NBG6817 has been added to the build 25 which is available in my repo. I've also sent a PR for the latest changes to be back-ported to current release tree.


#111

Great application I have it installed on a EA8500
I also own a EA9500 would it be possible to get support for this device as well?

Would you need any input from me? Log files or anything?

Thanks


#112

What must I do to make dual-boot work on x86?
I have LEDE installed on a SSD with dos partion table and GRUB in /dev/sda1 and root in /dev/sda2. There is a lot of free space after sda2.


#113

Outside the scope of this package. Core devs (or their code for dual-boot capable routers) might answer your question.


#114

I updated the Linksys EA3500 to the newest trunk

  {"Linksys Audi (EA3500)", "linksys,audi", "mtd3", "mtd5", 32, "boot_part", 1, 2, "bootcmd", "run nandboot", "run altnandboot"},

It appears to be working perfectly.


#115

Hey Mike, with device names changing across the board (pun intended), I'm changing how the the dual-boot devices are identified. I will probably need to update the entries for the WRT-series later, but the luci-app-advanced-reboot 26b03 should support the newest trunk on EA3500 without duplicating its entry for the older builds. Please test it and let me know.


#116

I tried but it still doesn't work. Actually though all that is needed to fix it though is

linksys-audi -> linksys,audi


#117

Unless I start duplicating the entries (which I'd like to avoid), that would break support of the current LEDE release.

Could you please confirm the actual version you've updated to?


#118

Love to see the x86 variants supported.


#119

Could support for the WRT32X be added to this now that OpenWrt has added support? The board name is "armada-385-linksys-venom".


#120

I need the dump of relevant partitions (probably the first 1k would be enough) to figure out the offset to the kernel info.


#121

As I said in a different thread: Need New DavidC502 Thread

So if you wanted to do this you need to dump the full thing, decompress it, then find the offset.
To be honest, I’d just disable the kernel detection for this device and just let it do the partition rebooting.

It’s a “nice to have” but not required.


#122

I can look into this if someone posts compressed mtd5 or mtd7, ideally both with Linksys FW and the OpenWrt/LEDE.

For now I've pushed luci-app-advanced-reboot 29 to my private repo which should show both partitions as Unknown for WRT32X.


#123

I'm happy to post whatever you need. I just need to know how? Sorry for the ask - my Linux knowledge is nill.
Currently on Linksys Stock Venom Firmware

Thanks!


#124

If you could confirm wherever revision 29 works that'd be a good start.

Do you know how to SSH to your router and transfer files from it to your computer?