aboutsummaryrefslogtreecommitdiffstats
path: root/package
diff options
context:
space:
mode:
authorDaniel Golle <daniel@makrotopia.org>2022-08-12 22:16:00 +0200
committerDaniel Golle <daniel@makrotopia.org>2022-08-12 22:47:39 +0200
commit0038e96c275793791f151908224801beef40598e (patch)
tree4d01a0b3023c9205e03ea24bc296e76cc14440a3 /package
parent5c69416246967f3cb443195b80a3c56dc1f52413 (diff)
downloadupstream-0038e96c275793791f151908224801beef40598e.tar.gz
upstream-0038e96c275793791f151908224801beef40598e.tar.bz2
upstream-0038e96c275793791f151908224801beef40598e.zip
arm-trusted-firmware-mediatek: skip bad blocks on SPI-NAND (SNFI)
Add patch to skip bad blocks when reading from SPI-NAND. This is needed in case erase block(s) early in the flash inside the FIP area are bad and hence need to be skipped in order to be able to boot on such damaged chips. Signed-off-by: Daniel Golle <daniel@makrotopia.org> (cherry picked from commit c0109537d13650e3cfd4d4840c571a0d557b303a)
Diffstat (limited to 'package')
-rw-r--r--package/boot/arm-trusted-firmware-mediatek/patches/120-mt7622-bl2_boot_snand-skip-bad-blocks.patch40
1 files changed, 40 insertions, 0 deletions
diff --git a/package/boot/arm-trusted-firmware-mediatek/patches/120-mt7622-bl2_boot_snand-skip-bad-blocks.patch b/package/boot/arm-trusted-firmware-mediatek/patches/120-mt7622-bl2_boot_snand-skip-bad-blocks.patch
new file mode 100644
index 0000000000..31384d010e
--- /dev/null
+++ b/package/boot/arm-trusted-firmware-mediatek/patches/120-mt7622-bl2_boot_snand-skip-bad-blocks.patch
@@ -0,0 +1,40 @@
+--- a/plat/mediatek/mt7622/bl2_boot_snand.c
++++ b/plat/mediatek/mt7622/bl2_boot_snand.c
+@@ -21,6 +21,10 @@
+ #define FIP_BASE 0x80000
+ #define FIP_SIZE 0x200000
+
++#ifndef NMBM
++#define SNAND_MAX_BAD_BLOCK 3
++#endif
++
+ struct snfi_gpio_mux_info {
+ const uint32_t *pins;
+ uint32_t count;
+@@ -45,12 +49,26 @@ static size_t snand_read_range(int lba,
+ size_t sizeremain = size, chunksize;
+ uint64_t off = lba * cinfo.pagesize;
+ uint8_t *ptr = (uint8_t *)buf;
++ struct mtk_snand_chip_info info;
++ unsigned int bad_blocks = 0;
+ int ret = 0;
+
+ if (!snf)
+ return 0;
+
++ ret = mtk_snand_get_chip_info(snf, &info);
++ if (ret)
++ return 0;
++
+ while (sizeremain) {
++ while (mtk_snand_block_isbad(snf, off)) {
++ if (bad_blocks > SNAND_MAX_BAD_BLOCK)
++ return size - sizeremain;
++
++ off += info.blocksize;
++ ++bad_blocks;
++ }
++
+ chunksize = cinfo.pagesize;
+ if (chunksize > sizeremain)
+ chunksize = sizeremain;