From d515353777ad74419e8b677cac05f315684a2566 Mon Sep 17 00:00:00 2001 From: Xu Chun Guang Date: Fri, 7 Mar 2025 16:15:01 +0800 Subject: [PATCH] feat: Improve th25q16hb flash patch --- components/spi_flash/src/patch/th25q16hb.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/components/spi_flash/src/patch/th25q16hb.c b/components/spi_flash/src/patch/th25q16hb.c index 4548e2c6..d3f255a6 100644 --- a/components/spi_flash/src/patch/th25q16hb.c +++ b/components/spi_flash/src/patch/th25q16hb.c @@ -88,8 +88,25 @@ int FLASH_PATCH_TEXT_ATTR th25q16hb_apply_patch_0(void) flash_id = spi_flash_get_id(); if (flash_id != 0x1560eb) { - ROM_PRINTF(FLASH_PATCH_STR("WARN: id=0x%x, is not TH25Q16HB\n"), flash_id); - return 0; + uint32_t data = 0; + bool is_th25q16hb = false; + if (flash_id == 0x0) { + spi_trans(0, 0x5A, 8, 0x10, 24, &data, 1, 0); + if (data == 0xEB) { + spi_trans(0, 0x5A, 8, 0x14, 24, &data, 1, 0); + if (data == 0x60) { + spi_trans(0, 0x5A, 8, 0x34, 24, &data, 4, 0); + if (data == 0xFFFFFF00) { + is_th25q16hb = true; + } + } + } + } + + if (!is_th25q16hb) { + ROM_PRINTF(FLASH_PATCH_STR("WARN: id=0x%x, is not TH25Q16HB\n"), flash_id); + return 0; + } } buffer256_0 = buffer1024;