[RFT] Linksys Dual-Boot; Rework of Boot-Counter Reset

As discussed at Add support for Linksys EA6350 v3, there was some "strangeness" in how the boot-counter reset was implemented. As a result, I've hopefully improved the script, adding in logging and managing the possibility that the boot is from NOR (as opposed to the more typical NAND). However, I don't have any of the potentially impacted devices.

Edit: The reason behind this is that the port of mtd resetbc to the ipq40xx platform hard-set the record size to 16, which works for the EA6350v3, but fails on the NAND-based EA8300 (under development). The code is in mtd and is by platform, not by device.

If you have time and can test out the patch at https://patchwork.ozlabs.org/patch/1060597/, I'd definitely appreciate it. Impacted devices include:

  • ipq40xx
    • EA8350v3 (NOR boot)
  • ipq806x
    • EA8500
  • kirkwood
    • audi
    • viper
  • mvebu
    • armada-385-linksys-caiman
    • armada-385-linksys-cobra
    • armada-385-linksys-rango
    • armada-385-linksys-shelby
    • armada-385-linksys-venom
    • armada-xp-linksys-mamba

You should be able to verify that the boot count is properly increasing and being reset by looking at the partition used, typically s_env. Once you know the partition, something like

hexdump -C /dev/mtd9ro

should show the boot-count records, typically being set by the boot loader to 01 and then being reset by the running OS to 00 after successful boot. (See, for an example, the post 286, direct linked by Add support for Linksys EA6350 v3 )

You should also see a log message near the end of the startup sequence, similar to

Thu Mar 21 11:57:01 2019 daemon.notice procd: /etc/rc.d/S99bootcount: Boot count reset to zero.

(For other devices, the script name may be different.)

Has there been some indication of an issue?

I believe that it should be transparent to any NAND-based device as the logic still takes the "record size" from the MTD write size.

I'm just not willing to suggest that it be incorporated into mainline OpenWrt without confirmation that my logic is correct and that there aren't any "weird" situations where the writesize is under 16 (where the logic overrides it and sets the "record size" to 16, as seen on the EA6350v3).

Edit: The reason behind this is that the port of mtd resetbc to the ipq40xx platform hard-set the record size to 16, which works for the EA6350v3, but fails on the NAND-based EA8300 (under development). The code is in mtd and is by-platform, not by device.

Got around to taking a kick at this today but the patch fails to apply.

1 Like

I'll need to update the patchwork patch, but the following should work

wget https://gist.githubusercontent.com/jeffsf/a4c008c92ed39fa76ae26caaa9daec47/raw/a2c75a57492de87db3c6b491cdc2d35937aa1d7d/patch-bootcount-2019-03-20.patch
git apply patch-bootcount-2019-03-20.patch