Skip to content

Commit

Permalink
arm-trusted-firmware-mediatek: fix NAND read failure on SNFI
Browse files Browse the repository at this point in the history
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: mtk-openwrt/arm-trusted-firmware#11
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
  • Loading branch information
dangowrt authored and c-herz committed Sep 5, 2024
1 parent 599c0e9 commit 07e2711
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package/boot/arm-trusted-firmware-mediatek/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 07e2711

Please sign in to comment.