arm-trusted-firmware-mediatek: fix NAND read failure on SNFI

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>
This commit is contained in:
Daniel Golle 2024-08-11 23:18:53 +01:00
parent 81481c805a
commit c22ba7544e
2 changed files with 28 additions and 1 deletions

View 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

View File

@ -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;
}