From: Daniel Golle Date: Sun, 11 Aug 2024 22:18:53 +0000 (+0100) Subject: arm-trusted-firmware-mediatek: fix NAND read failure on SNFI X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=c22ba7544eaa556bee92725d6ec13061247d25ad;p=openwrt%2Fstaging%2Fthess.git 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 --- diff --git a/package/boot/arm-trusted-firmware-mediatek/Makefile b/package/boot/arm-trusted-firmware-mediatek/Makefile index d8eef07f5e..91be884757 100644 --- a/package/boot/arm-trusted-firmware-mediatek/Makefile +++ b/package/boot/arm-trusted-firmware-mediatek/Makefile @@ -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 index 0000000000..857ecd0595 --- /dev/null +++ b/package/boot/arm-trusted-firmware-mediatek/patches/0004-mediatek-snfi-fix-return-code-when-reading.patch @@ -0,0 +1,27 @@ +From 94802b344195d3574701ca6ab5122f6b7615a6eb Mon Sep 17 00:00:00 2001 +From: Daniel Golle +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 +--- + 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; + }