arm-trusted-firmware-mediatek: fix NAND read failure on SNFI
authorDaniel Golle <daniel@makrotopia.org>
Sun, 11 Aug 2024 22:18:53 +0000 (23:18 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Mon, 12 Aug 2024 10:31:37 +0000 (11:31 +0100)
A bug has plagued bl2 which caused failure to boot and bricked Linksys
E8450 and Belkin RT3200 devices in case of correctable bitflips being
detected during a read operation. A simple logic error resulted in read
to be considered errornous instead of just continueing in case of
correctable bitflips.

Address this by importing a patch fixing that logic error.

The issue, which has been dubbed as the "OpenWrt Kiss of Death", and is
now a thing of the past.

Users should preemptively update bl2 to prevent their devices being at
risk.

Link: https://github.com/mtk-openwrt/arm-trusted-firmware/pull/11
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
package/boot/arm-trusted-firmware-mediatek/Makefile
package/boot/arm-trusted-firmware-mediatek/patches/0004-mediatek-snfi-fix-return-code-when-reading.patch [new file with mode: 0644]

index d8eef07f5e2d8c72bf2580cec79590451fd0a8e0..91be8847570e32568159788f4f123df1ebc9cd50 100644 (file)
@@ -9,7 +9,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=arm-trusted-firmware-mediatek
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL=https://github.com/mtk-openwrt/arm-trusted-firmware.git
diff --git a/package/boot/arm-trusted-firmware-mediatek/patches/0004-mediatek-snfi-fix-return-code-when-reading.patch b/package/boot/arm-trusted-firmware-mediatek/patches/0004-mediatek-snfi-fix-return-code-when-reading.patch
new file mode 100644 (file)
index 0000000..857ecd0
--- /dev/null
@@ -0,0 +1,27 @@
+From 94802b344195d3574701ca6ab5122f6b7615a6eb Mon Sep 17 00:00:00 2001
+From: Daniel Golle <daniel@makrotopia.org>
+Date: Sun, 11 Aug 2024 23:12:33 +0100
+Subject: [PATCH] mediatek: snfi: fix return code when reading
+
+Return 0 on succesful read, which may contain correctable bitflips.
+
+Fixes: #10
+Signed-off-by: Daniel Golle <daniel@makrotopia.org>
+---
+ plat/mediatek/apsoc_common/bl2/bl2_dev_snfi_init.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+--- a/plat/mediatek/apsoc_common/bl2/bl2_dev_snfi_init.c
++++ b/plat/mediatek/apsoc_common/bl2/bl2_dev_snfi_init.c
+@@ -29,8 +29,10 @@ static int snfi_mtd_read_page(struct nan
+       int ret;
+       ret = mtk_snand_read_page(snf, addr, (void *)buffer, NULL, false);
+-      if (ret == -EBADMSG)
++      if (ret > 0) {
++              NOTICE("corrected %d bitflips while reading page %u\n", ret, page);
+               ret = 0;
++      }
+       return ret;
+ }