]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
airoha: increase the size of reserved_bmt partition 23061/head
authorRussell Senior <russell@personaltelco.net>
Thu, 23 Apr 2026 05:38:51 +0000 (22:38 -0700)
committerRobert Marko <robimarko@gmail.com>
Mon, 11 May 2026 12:43:01 +0000 (14:43 +0200)
The vendor firmware checks for a bmt header in the last 528 erase blocks
of flash. The OpenWrt partition table did not respect that requirement,
and therefore the vendor and openwrt chainloader fight over those blocks
on every boot, potentially corrupting data stored in UBI blocks there.
This commit increases the size of the reserved_bmt partition to avoid
that fight.

Although the vendor bootloader only seems to touch the final 250 erase
blocks[1], the original vendor firmware system partition ended at
0x1be00000[2], so to be conservative, the consensus is to use that as
the end of mtd2 (ubi) partition and leave the last 528 blocks for mtd3
(reserved_bmt).

From https://openwrt.org/toh/gemtek/mxf-w1700k:
[1] OEM bootlog: [    5.324337] bmt pool size: 250
[2] OEM bootlog: [    5.478927] 0x000008600000-0x00001be00000 : "system"

Adds a compat_version to warn users to re-install to accomodate the
shrunken mtd2 ubi partition.

Fixed two nits suggested by Claude, zero padding a hex value and removed
an extra space.

Removed the wildcard setting of compat_version for other boards, as
suggested by Robert Marko, set compat_version only for the w1700k.

Reported-by: Loïc Yhuel <loic.yhuel@gmail.com>
Signed-off-by: Russell Senior <russell@personaltelco.net>
Link: https://github.com/openwrt/openwrt/pull/23061
Signed-off-by: Robert Marko <robimarko@gmail.com>
package/boot/uboot-airoha/patches/999-airoha-add-gemtek-w1700k.patch
target/linux/airoha/an7581/base-files/etc/board.d/05_compat-version [new file with mode: 0644]
target/linux/airoha/dts/an7581-w1700k-ubi.dts
target/linux/airoha/image/an7581.mk

index c346499dedfc463f817951ce3277805a4eb43e44..4c13fe3264422146c2fd62bec9f5673cb4934287 100644 (file)
@@ -276,13 +276,13 @@ Signed-off-by: Kenneth Kasilag <kenneth@kasilag.me>
 +
 +              ubi@700000 {
 +                      label = "ubi";
-+                      reg = <0x00700000 0x1f700000>;
++                      reg = <0x00700000 0x1b700000>;
 +              };
 +
 +              /* reserved for bad block table */
-+              reserved_bmt@1fe00000 {
++              reserved_bmt@1be00000 {
 +                      label = "reserved_bmt";
-+                      reg = <0x1fe00000 0x00200000>;
++                      reg = <0x1be00000 0x04200000>;
 +                      read-only;
 +              };
 +      };
diff --git a/target/linux/airoha/an7581/base-files/etc/board.d/05_compat-version b/target/linux/airoha/an7581/base-files/etc/board.d/05_compat-version
new file mode 100644 (file)
index 0000000..faa379f
--- /dev/null
@@ -0,0 +1,18 @@
+#
+# Copyright (C) 2020 OpenWrt.org
+#
+
+. /lib/functions.sh
+. /lib/functions/uci-defaults.sh
+
+board_config_update
+
+case "$(board_name)" in
+       gemtek,w1700k-ubi)
+               ucidef_set_compat_version "2.0"
+               ;;
+esac
+
+board_config_flush
+
+exit 0
index 6f4158599f937d9a7028fc8cf4bcfced1afb4d7a..a44610e345f48746ae501d874bd6fe77bc7520c1 100644 (file)
 
                partition@700000 {
                        label = "ubi";
-                       reg = <0x00700000 0x1f700000>;
+                       reg = <0x00700000 0x1b700000>;
                        compatible = "linux,ubi";
 
                        volumes {
                };
 
                /* reserved for bad block table */
-               reserved_bmt@1fe00000 {
+               reserved_bmt@1be00000 {
                        label = "reserved_bmt";
-                       reg = <0x1fe00000 0x00200000>;
+                       reg = <0x1be00000 0x04200000>;
                        read-only;
                };
        };
index ca90b5ee2d6f0d1c13ab7e6a753c64a8d677abdf..30a7b6e538cb8a4d9d5c47e10ea8ab933fc1ae45 100644 (file)
@@ -97,6 +97,10 @@ define Device/gemtek_w1700k-ubi
   DEVICE_ALT2_MODEL := W1700K
   DEVICE_ALT2_VARIANT := UBI
   DEVICE_DTS := an7581-w1700k-ubi
+  DEVICE_COMPAT_VERSION := 2.0
+  DEVICE_COMPAT_MESSAGE := Partition table has been changed to cooperate \
+       with the vendor bootloader with regard to the BMT/BBT partition at \
+       the end of flash. A reinstall including corrected chainloader is needed.
   DEVICE_PACKAGES := airoha-en7581-mt7996-npu-firmware \
                    fitblk kmod-i2c-an7581 kmod-hwmon-nct7802 \
                    kmod-mt7996-firmware kmod-phy-rtl8261n \