From 0f1dbcc6a5dbb5e2152aad347989ed7cd4bd07c2 Mon Sep 17 00:00:00 2001 From: "C.S.M" Date: Thu, 15 May 2025 15:40:09 +0800 Subject: [PATCH 1/2] fix(spi_flash): Make GD chip to be linked as default, also optimization the log information --- components/spi_flash/Kconfig | 12 ++++++------ components/spi_flash/esp32/Kconfig.soc_caps.in | 10 +++++----- components/spi_flash/esp32/flash_vendor_caps.h | 18 +++++++++--------- .../spi_flash/esp32c2/Kconfig.soc_caps.in | 14 +++++++------- .../spi_flash/esp32c2/flash_vendor_caps.h | 16 ++++++++-------- .../spi_flash/esp32c3/Kconfig.soc_caps.in | 14 +++++++------- .../spi_flash/esp32c3/flash_vendor_caps.h | 16 ++++++++-------- .../spi_flash/esp32c5/Kconfig.soc_caps.in | 6 +++++- .../spi_flash/esp32c5/flash_vendor_caps.h | 3 ++- .../spi_flash/esp32c6/Kconfig.soc_caps.in | 6 +++++- .../spi_flash/esp32c6/flash_vendor_caps.h | 3 ++- .../spi_flash/esp32c61/Kconfig.soc_caps.in | 6 +++++- .../spi_flash/esp32c61/flash_vendor_caps.h | 3 ++- .../spi_flash/esp32h2/Kconfig.soc_caps.in | 6 +++++- .../spi_flash/esp32h2/flash_vendor_caps.h | 3 ++- .../spi_flash/esp32h21/Kconfig.soc_caps.in | 6 +++++- .../spi_flash/esp32h21/flash_vendor_caps.h | 3 ++- .../spi_flash/esp32h4/Kconfig.soc_caps.in | 6 +++++- .../spi_flash/esp32h4/flash_vendor_caps.h | 3 ++- .../spi_flash/esp32p4/Kconfig.soc_caps.in | 6 +++++- .../spi_flash/esp32p4/flash_vendor_caps.h | 3 ++- .../spi_flash/esp32s2/Kconfig.soc_caps.in | 14 +++++++------- .../spi_flash/esp32s2/flash_vendor_caps.h | 16 ++++++++-------- .../spi_flash/esp32s3/Kconfig.soc_caps.in | 14 +++++++------- .../spi_flash/esp32s3/flash_vendor_caps.h | 16 ++++++++-------- components/spi_flash/spi_flash_chip_drivers.c | 18 ++++++++++-------- 26 files changed, 139 insertions(+), 102 deletions(-) diff --git a/components/spi_flash/Kconfig b/components/spi_flash/Kconfig index 5a3bcefa75..79ffd1833d 100644 --- a/components/spi_flash/Kconfig +++ b/components/spi_flash/Kconfig @@ -374,7 +374,7 @@ menu "SPI Flash driver" config SPI_FLASH_SUPPORT_ISSI_CHIP bool "ISSI" - default y if SPI_FLASH_VENDOR_ISSI_SUPPORTED + default y if SPI_FLASH_VENDOR_ISSI_SUPPORT_ENABLED default n help Enable this to support auto detection of ISSI chips if chip vendor not directly @@ -383,7 +383,7 @@ menu "SPI Flash driver" config SPI_FLASH_SUPPORT_MXIC_CHIP bool "MXIC" - default y if SPI_FLASH_VENDOR_MXIC_SUPPORTED + default y if SPI_FLASH_VENDOR_MXIC_SUPPORT_ENABLED default n help Enable this to support auto detection of MXIC chips if chip vendor not directly @@ -392,7 +392,7 @@ menu "SPI Flash driver" config SPI_FLASH_SUPPORT_GD_CHIP bool "GigaDevice" - default y if SPI_FLASH_VENDOR_GD_SUPPORTED + default y if SPI_FLASH_VENDOR_GD_SUPPORT_ENABLED default n help Enable this to support auto detection of GD (GigaDevice) chips if chip vendor not @@ -406,7 +406,7 @@ menu "SPI Flash driver" config SPI_FLASH_SUPPORT_WINBOND_CHIP bool "Winbond" - default y if SPI_FLASH_VENDOR_WINBOND_SUPPORTED + default y if SPI_FLASH_VENDOR_WINBOND_SUPPORT_ENABLED default n help Enable this to support auto detection of Winbond chips if chip vendor not directly @@ -416,7 +416,7 @@ menu "SPI Flash driver" config SPI_FLASH_SUPPORT_BOYA_CHIP bool "BOYA" # ESP32 doesn't usually use this chip, default n to save iram. - default y if SPI_FLASH_VENDOR_BOYA_SUPPORTED + default y if SPI_FLASH_VENDOR_BOYA_SUPPORT_ENABLED default n help Enable this to support auto detection of BOYA chips if chip vendor not directly @@ -426,7 +426,7 @@ menu "SPI Flash driver" config SPI_FLASH_SUPPORT_TH_CHIP bool "TH" # ESP32 doesn't usually use this chip, default n to save iram. - default y if SPI_FLASH_VENDOR_TH_SUPPORTED + default y if SPI_FLASH_VENDOR_TH_SUPPORT_ENABLED default n help Enable this to support auto detection of TH chips if chip vendor not directly diff --git a/components/spi_flash/esp32/Kconfig.soc_caps.in b/components/spi_flash/esp32/Kconfig.soc_caps.in index 530c5d7a59..fed381f618 100644 --- a/components/spi_flash/esp32/Kconfig.soc_caps.in +++ b/components/spi_flash/esp32/Kconfig.soc_caps.in @@ -3,22 +3,22 @@ # using gen_soc_caps_kconfig.py, do not edit manually ##################################################### -config SPI_FLASH_VENDOR_XMC_SUPPORTED +config SPI_FLASH_VENDOR_XMC_SUPPORT_ENABLED bool default y -config SPI_FLASH_VENDOR_GD_SUPPORTED +config SPI_FLASH_VENDOR_GD_SUPPORT_ENABLED bool default y -config SPI_FLASH_VENDOR_ISSI_SUPPORTED +config SPI_FLASH_VENDOR_ISSI_SUPPORT_ENABLED bool default y -config SPI_FLASH_VENDOR_MXIC_SUPPORTED +config SPI_FLASH_VENDOR_MXIC_SUPPORT_ENABLED bool default y -config SPI_FLASH_VENDOR_WINBOND_SUPPORTED +config SPI_FLASH_VENDOR_WINBOND_SUPPORT_ENABLED bool default y diff --git a/components/spi_flash/esp32/flash_vendor_caps.h b/components/spi_flash/esp32/flash_vendor_caps.h index 054b7158c4..c5723a6123 100644 --- a/components/spi_flash/esp32/flash_vendor_caps.h +++ b/components/spi_flash/esp32/flash_vendor_caps.h @@ -1,29 +1,29 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ /** - * This file records the flash vendor that we offically supported. + * This file records the flash vendor that we officially supported. * we have many chip-specific files, like ``spi_flash_chip_gd.c``, * which means that this file is used for GD flash chips. * - * The following definations illustrate what flash vendor is officially + * The following definitions illustrate what flash vendor is officially * supported by ESP chips. If a flash vendor is officially supported, the chip * specific file will be linked by default, vice versa. You can also adjust this * manually in Kconfig options. * * For example: - * Following `SPI_FLASH_VENDOR_ISSI_SUPPORTED` is (1), which means file `spi_flash_chip_issi.c` + * Following `SPI_FLASH_VENDOR_ISSI_SUPPORT_ENABLED` is (1), which means file `spi_flash_chip_issi.c` * will be linked. * */ #pragma once -#define SPI_FLASH_VENDOR_XMC_SUPPORTED (1) -#define SPI_FLASH_VENDOR_GD_SUPPORTED (1) -#define SPI_FLASH_VENDOR_ISSI_SUPPORTED (1) -#define SPI_FLASH_VENDOR_MXIC_SUPPORTED (1) -#define SPI_FLASH_VENDOR_WINBOND_SUPPORTED (1) +#define SPI_FLASH_VENDOR_XMC_SUPPORT_ENABLED (1) +#define SPI_FLASH_VENDOR_GD_SUPPORT_ENABLED (1) +#define SPI_FLASH_VENDOR_ISSI_SUPPORT_ENABLED (1) +#define SPI_FLASH_VENDOR_MXIC_SUPPORT_ENABLED (1) +#define SPI_FLASH_VENDOR_WINBOND_SUPPORT_ENABLED (1) diff --git a/components/spi_flash/esp32c2/Kconfig.soc_caps.in b/components/spi_flash/esp32c2/Kconfig.soc_caps.in index d1744a6196..5ba748e5aa 100644 --- a/components/spi_flash/esp32c2/Kconfig.soc_caps.in +++ b/components/spi_flash/esp32c2/Kconfig.soc_caps.in @@ -3,30 +3,30 @@ # using gen_soc_caps_kconfig.py, do not edit manually ##################################################### -config SPI_FLASH_VENDOR_XMC_SUPPORTED +config SPI_FLASH_VENDOR_XMC_SUPPORT_ENABLED bool default y -config SPI_FLASH_VENDOR_GD_SUPPORTED +config SPI_FLASH_VENDOR_GD_SUPPORT_ENABLED bool default y -config SPI_FLASH_VENDOR_ISSI_SUPPORTED +config SPI_FLASH_VENDOR_ISSI_SUPPORT_ENABLED bool default y -config SPI_FLASH_VENDOR_MXIC_SUPPORTED +config SPI_FLASH_VENDOR_MXIC_SUPPORT_ENABLED bool default y -config SPI_FLASH_VENDOR_WINBOND_SUPPORTED +config SPI_FLASH_VENDOR_WINBOND_SUPPORT_ENABLED bool default y -config SPI_FLASH_VENDOR_BOYA_SUPPORTED +config SPI_FLASH_VENDOR_BOYA_SUPPORT_ENABLED bool default y -config SPI_FLASH_VENDOR_TH_SUPPORTED +config SPI_FLASH_VENDOR_TH_SUPPORT_ENABLED bool default y diff --git a/components/spi_flash/esp32c2/flash_vendor_caps.h b/components/spi_flash/esp32c2/flash_vendor_caps.h index 88b64fdba4..65075fc4df 100644 --- a/components/spi_flash/esp32c2/flash_vendor_caps.h +++ b/components/spi_flash/esp32c2/flash_vendor_caps.h @@ -1,14 +1,14 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #pragma once -#define SPI_FLASH_VENDOR_XMC_SUPPORTED (1) -#define SPI_FLASH_VENDOR_GD_SUPPORTED (1) -#define SPI_FLASH_VENDOR_ISSI_SUPPORTED (1) -#define SPI_FLASH_VENDOR_MXIC_SUPPORTED (1) -#define SPI_FLASH_VENDOR_WINBOND_SUPPORTED (1) -#define SPI_FLASH_VENDOR_BOYA_SUPPORTED (1) -#define SPI_FLASH_VENDOR_TH_SUPPORTED (1) +#define SPI_FLASH_VENDOR_XMC_SUPPORT_ENABLED (1) +#define SPI_FLASH_VENDOR_GD_SUPPORT_ENABLED (1) +#define SPI_FLASH_VENDOR_ISSI_SUPPORT_ENABLED (1) +#define SPI_FLASH_VENDOR_MXIC_SUPPORT_ENABLED (1) +#define SPI_FLASH_VENDOR_WINBOND_SUPPORT_ENABLED (1) +#define SPI_FLASH_VENDOR_BOYA_SUPPORT_ENABLED (1) +#define SPI_FLASH_VENDOR_TH_SUPPORT_ENABLED (1) diff --git a/components/spi_flash/esp32c3/Kconfig.soc_caps.in b/components/spi_flash/esp32c3/Kconfig.soc_caps.in index d1744a6196..5ba748e5aa 100644 --- a/components/spi_flash/esp32c3/Kconfig.soc_caps.in +++ b/components/spi_flash/esp32c3/Kconfig.soc_caps.in @@ -3,30 +3,30 @@ # using gen_soc_caps_kconfig.py, do not edit manually ##################################################### -config SPI_FLASH_VENDOR_XMC_SUPPORTED +config SPI_FLASH_VENDOR_XMC_SUPPORT_ENABLED bool default y -config SPI_FLASH_VENDOR_GD_SUPPORTED +config SPI_FLASH_VENDOR_GD_SUPPORT_ENABLED bool default y -config SPI_FLASH_VENDOR_ISSI_SUPPORTED +config SPI_FLASH_VENDOR_ISSI_SUPPORT_ENABLED bool default y -config SPI_FLASH_VENDOR_MXIC_SUPPORTED +config SPI_FLASH_VENDOR_MXIC_SUPPORT_ENABLED bool default y -config SPI_FLASH_VENDOR_WINBOND_SUPPORTED +config SPI_FLASH_VENDOR_WINBOND_SUPPORT_ENABLED bool default y -config SPI_FLASH_VENDOR_BOYA_SUPPORTED +config SPI_FLASH_VENDOR_BOYA_SUPPORT_ENABLED bool default y -config SPI_FLASH_VENDOR_TH_SUPPORTED +config SPI_FLASH_VENDOR_TH_SUPPORT_ENABLED bool default y diff --git a/components/spi_flash/esp32c3/flash_vendor_caps.h b/components/spi_flash/esp32c3/flash_vendor_caps.h index 88b64fdba4..65075fc4df 100644 --- a/components/spi_flash/esp32c3/flash_vendor_caps.h +++ b/components/spi_flash/esp32c3/flash_vendor_caps.h @@ -1,14 +1,14 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #pragma once -#define SPI_FLASH_VENDOR_XMC_SUPPORTED (1) -#define SPI_FLASH_VENDOR_GD_SUPPORTED (1) -#define SPI_FLASH_VENDOR_ISSI_SUPPORTED (1) -#define SPI_FLASH_VENDOR_MXIC_SUPPORTED (1) -#define SPI_FLASH_VENDOR_WINBOND_SUPPORTED (1) -#define SPI_FLASH_VENDOR_BOYA_SUPPORTED (1) -#define SPI_FLASH_VENDOR_TH_SUPPORTED (1) +#define SPI_FLASH_VENDOR_XMC_SUPPORT_ENABLED (1) +#define SPI_FLASH_VENDOR_GD_SUPPORT_ENABLED (1) +#define SPI_FLASH_VENDOR_ISSI_SUPPORT_ENABLED (1) +#define SPI_FLASH_VENDOR_MXIC_SUPPORT_ENABLED (1) +#define SPI_FLASH_VENDOR_WINBOND_SUPPORT_ENABLED (1) +#define SPI_FLASH_VENDOR_BOYA_SUPPORT_ENABLED (1) +#define SPI_FLASH_VENDOR_TH_SUPPORT_ENABLED (1) diff --git a/components/spi_flash/esp32c5/Kconfig.soc_caps.in b/components/spi_flash/esp32c5/Kconfig.soc_caps.in index 87accd576f..443f776e07 100644 --- a/components/spi_flash/esp32c5/Kconfig.soc_caps.in +++ b/components/spi_flash/esp32c5/Kconfig.soc_caps.in @@ -3,6 +3,10 @@ # using gen_soc_caps_kconfig.py, do not edit manually ##################################################### -config SPI_FLASH_VENDOR_XMC_SUPPORTED +config SPI_FLASH_VENDOR_XMC_SUPPORT_ENABLED + bool + default y + +config SPI_FLASH_VENDOR_GD_SUPPORT_ENABLED bool default y diff --git a/components/spi_flash/esp32c5/flash_vendor_caps.h b/components/spi_flash/esp32c5/flash_vendor_caps.h index 6b127dfbd6..24ce9c86b0 100644 --- a/components/spi_flash/esp32c5/flash_vendor_caps.h +++ b/components/spi_flash/esp32c5/flash_vendor_caps.h @@ -5,4 +5,5 @@ */ #pragma once -#define SPI_FLASH_VENDOR_XMC_SUPPORTED (1) +#define SPI_FLASH_VENDOR_XMC_SUPPORT_ENABLED (1) +#define SPI_FLASH_VENDOR_GD_SUPPORT_ENABLED (1) diff --git a/components/spi_flash/esp32c6/Kconfig.soc_caps.in b/components/spi_flash/esp32c6/Kconfig.soc_caps.in index 87accd576f..443f776e07 100644 --- a/components/spi_flash/esp32c6/Kconfig.soc_caps.in +++ b/components/spi_flash/esp32c6/Kconfig.soc_caps.in @@ -3,6 +3,10 @@ # using gen_soc_caps_kconfig.py, do not edit manually ##################################################### -config SPI_FLASH_VENDOR_XMC_SUPPORTED +config SPI_FLASH_VENDOR_XMC_SUPPORT_ENABLED + bool + default y + +config SPI_FLASH_VENDOR_GD_SUPPORT_ENABLED bool default y diff --git a/components/spi_flash/esp32c6/flash_vendor_caps.h b/components/spi_flash/esp32c6/flash_vendor_caps.h index ffa84babf7..b5708c2efe 100644 --- a/components/spi_flash/esp32c6/flash_vendor_caps.h +++ b/components/spi_flash/esp32c6/flash_vendor_caps.h @@ -5,4 +5,5 @@ */ #pragma once -#define SPI_FLASH_VENDOR_XMC_SUPPORTED (1) +#define SPI_FLASH_VENDOR_XMC_SUPPORT_ENABLED (1) +#define SPI_FLASH_VENDOR_GD_SUPPORT_ENABLED (1) diff --git a/components/spi_flash/esp32c61/Kconfig.soc_caps.in b/components/spi_flash/esp32c61/Kconfig.soc_caps.in index 87accd576f..443f776e07 100644 --- a/components/spi_flash/esp32c61/Kconfig.soc_caps.in +++ b/components/spi_flash/esp32c61/Kconfig.soc_caps.in @@ -3,6 +3,10 @@ # using gen_soc_caps_kconfig.py, do not edit manually ##################################################### -config SPI_FLASH_VENDOR_XMC_SUPPORTED +config SPI_FLASH_VENDOR_XMC_SUPPORT_ENABLED + bool + default y + +config SPI_FLASH_VENDOR_GD_SUPPORT_ENABLED bool default y diff --git a/components/spi_flash/esp32c61/flash_vendor_caps.h b/components/spi_flash/esp32c61/flash_vendor_caps.h index 6b127dfbd6..24ce9c86b0 100644 --- a/components/spi_flash/esp32c61/flash_vendor_caps.h +++ b/components/spi_flash/esp32c61/flash_vendor_caps.h @@ -5,4 +5,5 @@ */ #pragma once -#define SPI_FLASH_VENDOR_XMC_SUPPORTED (1) +#define SPI_FLASH_VENDOR_XMC_SUPPORT_ENABLED (1) +#define SPI_FLASH_VENDOR_GD_SUPPORT_ENABLED (1) diff --git a/components/spi_flash/esp32h2/Kconfig.soc_caps.in b/components/spi_flash/esp32h2/Kconfig.soc_caps.in index 87accd576f..443f776e07 100644 --- a/components/spi_flash/esp32h2/Kconfig.soc_caps.in +++ b/components/spi_flash/esp32h2/Kconfig.soc_caps.in @@ -3,6 +3,10 @@ # using gen_soc_caps_kconfig.py, do not edit manually ##################################################### -config SPI_FLASH_VENDOR_XMC_SUPPORTED +config SPI_FLASH_VENDOR_XMC_SUPPORT_ENABLED + bool + default y + +config SPI_FLASH_VENDOR_GD_SUPPORT_ENABLED bool default y diff --git a/components/spi_flash/esp32h2/flash_vendor_caps.h b/components/spi_flash/esp32h2/flash_vendor_caps.h index ffa84babf7..b5708c2efe 100644 --- a/components/spi_flash/esp32h2/flash_vendor_caps.h +++ b/components/spi_flash/esp32h2/flash_vendor_caps.h @@ -5,4 +5,5 @@ */ #pragma once -#define SPI_FLASH_VENDOR_XMC_SUPPORTED (1) +#define SPI_FLASH_VENDOR_XMC_SUPPORT_ENABLED (1) +#define SPI_FLASH_VENDOR_GD_SUPPORT_ENABLED (1) diff --git a/components/spi_flash/esp32h21/Kconfig.soc_caps.in b/components/spi_flash/esp32h21/Kconfig.soc_caps.in index 87accd576f..443f776e07 100644 --- a/components/spi_flash/esp32h21/Kconfig.soc_caps.in +++ b/components/spi_flash/esp32h21/Kconfig.soc_caps.in @@ -3,6 +3,10 @@ # using gen_soc_caps_kconfig.py, do not edit manually ##################################################### -config SPI_FLASH_VENDOR_XMC_SUPPORTED +config SPI_FLASH_VENDOR_XMC_SUPPORT_ENABLED + bool + default y + +config SPI_FLASH_VENDOR_GD_SUPPORT_ENABLED bool default y diff --git a/components/spi_flash/esp32h21/flash_vendor_caps.h b/components/spi_flash/esp32h21/flash_vendor_caps.h index 4c03f22479..2d3759ecf1 100644 --- a/components/spi_flash/esp32h21/flash_vendor_caps.h +++ b/components/spi_flash/esp32h21/flash_vendor_caps.h @@ -5,4 +5,5 @@ */ #pragma once -#define SPI_FLASH_VENDOR_XMC_SUPPORTED (1) +#define SPI_FLASH_VENDOR_XMC_SUPPORT_ENABLED (1) +#define SPI_FLASH_VENDOR_GD_SUPPORT_ENABLED (1) diff --git a/components/spi_flash/esp32h4/Kconfig.soc_caps.in b/components/spi_flash/esp32h4/Kconfig.soc_caps.in index 87accd576f..443f776e07 100644 --- a/components/spi_flash/esp32h4/Kconfig.soc_caps.in +++ b/components/spi_flash/esp32h4/Kconfig.soc_caps.in @@ -3,6 +3,10 @@ # using gen_soc_caps_kconfig.py, do not edit manually ##################################################### -config SPI_FLASH_VENDOR_XMC_SUPPORTED +config SPI_FLASH_VENDOR_XMC_SUPPORT_ENABLED + bool + default y + +config SPI_FLASH_VENDOR_GD_SUPPORT_ENABLED bool default y diff --git a/components/spi_flash/esp32h4/flash_vendor_caps.h b/components/spi_flash/esp32h4/flash_vendor_caps.h index 33d7427d05..07ae467962 100644 --- a/components/spi_flash/esp32h4/flash_vendor_caps.h +++ b/components/spi_flash/esp32h4/flash_vendor_caps.h @@ -5,4 +5,5 @@ */ #pragma once -#define SPI_FLASH_VENDOR_XMC_SUPPORTED (1) +#define SPI_FLASH_VENDOR_XMC_SUPPORT_ENABLED (1) +#define SPI_FLASH_VENDOR_GD_SUPPORT_ENABLED (1) diff --git a/components/spi_flash/esp32p4/Kconfig.soc_caps.in b/components/spi_flash/esp32p4/Kconfig.soc_caps.in index 87accd576f..443f776e07 100644 --- a/components/spi_flash/esp32p4/Kconfig.soc_caps.in +++ b/components/spi_flash/esp32p4/Kconfig.soc_caps.in @@ -3,6 +3,10 @@ # using gen_soc_caps_kconfig.py, do not edit manually ##################################################### -config SPI_FLASH_VENDOR_XMC_SUPPORTED +config SPI_FLASH_VENDOR_XMC_SUPPORT_ENABLED + bool + default y + +config SPI_FLASH_VENDOR_GD_SUPPORT_ENABLED bool default y diff --git a/components/spi_flash/esp32p4/flash_vendor_caps.h b/components/spi_flash/esp32p4/flash_vendor_caps.h index ffa84babf7..b5708c2efe 100644 --- a/components/spi_flash/esp32p4/flash_vendor_caps.h +++ b/components/spi_flash/esp32p4/flash_vendor_caps.h @@ -5,4 +5,5 @@ */ #pragma once -#define SPI_FLASH_VENDOR_XMC_SUPPORTED (1) +#define SPI_FLASH_VENDOR_XMC_SUPPORT_ENABLED (1) +#define SPI_FLASH_VENDOR_GD_SUPPORT_ENABLED (1) diff --git a/components/spi_flash/esp32s2/Kconfig.soc_caps.in b/components/spi_flash/esp32s2/Kconfig.soc_caps.in index d1744a6196..5ba748e5aa 100644 --- a/components/spi_flash/esp32s2/Kconfig.soc_caps.in +++ b/components/spi_flash/esp32s2/Kconfig.soc_caps.in @@ -3,30 +3,30 @@ # using gen_soc_caps_kconfig.py, do not edit manually ##################################################### -config SPI_FLASH_VENDOR_XMC_SUPPORTED +config SPI_FLASH_VENDOR_XMC_SUPPORT_ENABLED bool default y -config SPI_FLASH_VENDOR_GD_SUPPORTED +config SPI_FLASH_VENDOR_GD_SUPPORT_ENABLED bool default y -config SPI_FLASH_VENDOR_ISSI_SUPPORTED +config SPI_FLASH_VENDOR_ISSI_SUPPORT_ENABLED bool default y -config SPI_FLASH_VENDOR_MXIC_SUPPORTED +config SPI_FLASH_VENDOR_MXIC_SUPPORT_ENABLED bool default y -config SPI_FLASH_VENDOR_WINBOND_SUPPORTED +config SPI_FLASH_VENDOR_WINBOND_SUPPORT_ENABLED bool default y -config SPI_FLASH_VENDOR_BOYA_SUPPORTED +config SPI_FLASH_VENDOR_BOYA_SUPPORT_ENABLED bool default y -config SPI_FLASH_VENDOR_TH_SUPPORTED +config SPI_FLASH_VENDOR_TH_SUPPORT_ENABLED bool default y diff --git a/components/spi_flash/esp32s2/flash_vendor_caps.h b/components/spi_flash/esp32s2/flash_vendor_caps.h index 88b64fdba4..65075fc4df 100644 --- a/components/spi_flash/esp32s2/flash_vendor_caps.h +++ b/components/spi_flash/esp32s2/flash_vendor_caps.h @@ -1,14 +1,14 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #pragma once -#define SPI_FLASH_VENDOR_XMC_SUPPORTED (1) -#define SPI_FLASH_VENDOR_GD_SUPPORTED (1) -#define SPI_FLASH_VENDOR_ISSI_SUPPORTED (1) -#define SPI_FLASH_VENDOR_MXIC_SUPPORTED (1) -#define SPI_FLASH_VENDOR_WINBOND_SUPPORTED (1) -#define SPI_FLASH_VENDOR_BOYA_SUPPORTED (1) -#define SPI_FLASH_VENDOR_TH_SUPPORTED (1) +#define SPI_FLASH_VENDOR_XMC_SUPPORT_ENABLED (1) +#define SPI_FLASH_VENDOR_GD_SUPPORT_ENABLED (1) +#define SPI_FLASH_VENDOR_ISSI_SUPPORT_ENABLED (1) +#define SPI_FLASH_VENDOR_MXIC_SUPPORT_ENABLED (1) +#define SPI_FLASH_VENDOR_WINBOND_SUPPORT_ENABLED (1) +#define SPI_FLASH_VENDOR_BOYA_SUPPORT_ENABLED (1) +#define SPI_FLASH_VENDOR_TH_SUPPORT_ENABLED (1) diff --git a/components/spi_flash/esp32s3/Kconfig.soc_caps.in b/components/spi_flash/esp32s3/Kconfig.soc_caps.in index d1744a6196..5ba748e5aa 100644 --- a/components/spi_flash/esp32s3/Kconfig.soc_caps.in +++ b/components/spi_flash/esp32s3/Kconfig.soc_caps.in @@ -3,30 +3,30 @@ # using gen_soc_caps_kconfig.py, do not edit manually ##################################################### -config SPI_FLASH_VENDOR_XMC_SUPPORTED +config SPI_FLASH_VENDOR_XMC_SUPPORT_ENABLED bool default y -config SPI_FLASH_VENDOR_GD_SUPPORTED +config SPI_FLASH_VENDOR_GD_SUPPORT_ENABLED bool default y -config SPI_FLASH_VENDOR_ISSI_SUPPORTED +config SPI_FLASH_VENDOR_ISSI_SUPPORT_ENABLED bool default y -config SPI_FLASH_VENDOR_MXIC_SUPPORTED +config SPI_FLASH_VENDOR_MXIC_SUPPORT_ENABLED bool default y -config SPI_FLASH_VENDOR_WINBOND_SUPPORTED +config SPI_FLASH_VENDOR_WINBOND_SUPPORT_ENABLED bool default y -config SPI_FLASH_VENDOR_BOYA_SUPPORTED +config SPI_FLASH_VENDOR_BOYA_SUPPORT_ENABLED bool default y -config SPI_FLASH_VENDOR_TH_SUPPORTED +config SPI_FLASH_VENDOR_TH_SUPPORT_ENABLED bool default y diff --git a/components/spi_flash/esp32s3/flash_vendor_caps.h b/components/spi_flash/esp32s3/flash_vendor_caps.h index ba081b1b13..1fdccb3856 100644 --- a/components/spi_flash/esp32s3/flash_vendor_caps.h +++ b/components/spi_flash/esp32s3/flash_vendor_caps.h @@ -1,15 +1,15 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #pragma once -#define SPI_FLASH_VENDOR_XMC_SUPPORTED (1) -#define SPI_FLASH_VENDOR_GD_SUPPORTED (1) -#define SPI_FLASH_VENDOR_ISSI_SUPPORTED (1) -#define SPI_FLASH_VENDOR_MXIC_SUPPORTED (1) -#define SPI_FLASH_VENDOR_WINBOND_SUPPORTED (1) -#define SPI_FLASH_VENDOR_BOYA_SUPPORTED (1) -#define SPI_FLASH_VENDOR_TH_SUPPORTED (1) +#define SPI_FLASH_VENDOR_XMC_SUPPORT_ENABLED (1) +#define SPI_FLASH_VENDOR_GD_SUPPORT_ENABLED (1) +#define SPI_FLASH_VENDOR_ISSI_SUPPORT_ENABLED (1) +#define SPI_FLASH_VENDOR_MXIC_SUPPORT_ENABLED (1) +#define SPI_FLASH_VENDOR_WINBOND_SUPPORT_ENABLED (1) +#define SPI_FLASH_VENDOR_BOYA_SUPPORT_ENABLED (1) +#define SPI_FLASH_VENDOR_TH_SUPPORT_ENABLED (1) diff --git a/components/spi_flash/spi_flash_chip_drivers.c b/components/spi_flash/spi_flash_chip_drivers.c index b513cad6e2..ae5190854a 100644 --- a/components/spi_flash/spi_flash_chip_drivers.c +++ b/components/spi_flash/spi_flash_chip_drivers.c @@ -17,7 +17,9 @@ #include "sdkconfig.h" #include "esp_log.h" -#define TAG "spi_flash" +__attribute__((unused)) static const char *TAG = "spi_flash"; + +#define FORMAT_STR "Detected %s flash chip but using generic driver. For optimal functionality, enable `SPI_FLASH_SUPPORT_%s_CHIP` in menuconfig" #if !CONFIG_SPI_FLASH_OVERRIDE_CHIP_DRIVER_LIST /* @@ -65,39 +67,39 @@ void spi_flash_chip_list_check(esp_flash_t *chip, uint32_t device_id) { { case SPI_FLASH_GD: if (&esp_flash_chip_gd == NULL) { - ESP_EARLY_LOGW(TAG, "GigaDevice detected but related driver is not linked, please check option `SPI_FLASH_SUPPORT_GD_CHIP`"); + ESP_EARLY_LOGW(TAG, FORMAT_STR, "GigaDevice", "GD"); } break; case SPI_FLASH_ISSI: if (&esp_flash_chip_issi == NULL) { - ESP_EARLY_LOGW(TAG, "ISSI detected but related driver is not linked, please check option `SPI_FLASH_SUPPORT_ISSI_CHIP`"); + ESP_EARLY_LOGW(TAG, FORMAT_STR, "ISSI", "ISSI"); } break; case SPI_FLASH_TH: if (&esp_flash_chip_th == NULL) { - ESP_EARLY_LOGW(TAG, "TH detected but related driver is not linked, please check option `SPI_FLASH_SUPPORT_TH_CHIP`"); + ESP_EARLY_LOGW(TAG, FORMAT_STR, "TH", "TH"); } break; case SPI_FLASH_WINBOND: if (&esp_flash_chip_winbond == NULL) { - ESP_EARLY_LOGW(TAG, "winbond detected but related driver is not linked, please check option `SPI_FLASH_SUPPORT_WINBOND_CHIP`"); + ESP_EARLY_LOGW(TAG, FORMAT_STR, "winbond", "WINBOND"); } break; case SPI_FLASH_MXIC: // Need to tell the difference between octal and quad flash. if (chip->read_mode < SPI_FLASH_OPI_FLAG) { if (&esp_flash_chip_mxic == NULL) { - ESP_EARLY_LOGW(TAG, "MXIC detected but related driver is not linked, please check option `SPI_FLASH_SUPPORT_MXIC_CHIP`"); + ESP_EARLY_LOGW(TAG, FORMAT_STR, "MXIC", "MXIC"); } } else { if (&esp_flash_chip_mxic_opi == NULL) { - ESP_EARLY_LOGW(TAG, "MXIC detected but related driver is not linked, please check option `SPI_FLASH_SUPPORT_MXIC_OPI_CHIP`"); + ESP_EARLY_LOGW(TAG, FORMAT_STR, "MXIC", "MXIC_OPI"); } } break; case SPI_FLASH_BY: if (&esp_flash_chip_boya == NULL) { - ESP_EARLY_LOGW(TAG, "boya detected but related driver is not linked, please check option `SPI_FLASH_SUPPORT_BOYA_CHIP`"); + ESP_EARLY_LOGW(TAG, FORMAT_STR, "boya", "BOYA"); } break; default: From a1c6d2a458338dac5711008bf0def7d78fc5107e Mon Sep 17 00:00:00 2001 From: Laukik Hase Date: Wed, 21 May 2025 16:22:17 +0530 Subject: [PATCH 2/2] fix(esp_tee): Fix failing SPI1 flash protection test-cases --- .../main/core/esp_secure_services_iram.c | 5 +++++ .../main/test_esp_tee_flash_prot.c | 8 ++++---- .../tee_test_fw/pytest_esp_tee_ut.py | 19 +++++++++++++++---- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/components/esp_tee/subproject/main/core/esp_secure_services_iram.c b/components/esp_tee/subproject/main/core/esp_secure_services_iram.c index ffa5110662..17b2bc2e61 100644 --- a/components/esp_tee/subproject/main/core/esp_secure_services_iram.c +++ b/components/esp_tee/subproject/main/core/esp_secure_services_iram.c @@ -212,6 +212,11 @@ uint32_t _ss_spi_flash_hal_check_status(spi_flash_host_inst_t *host) esp_err_t _ss_spi_flash_hal_common_command(spi_flash_host_inst_t *host, spi_flash_trans_t *trans) { + bool paddr_chk = esp_tee_flash_check_paddr_in_tee_region(trans->address); + if (paddr_chk) { + ESP_LOGD(TAG, "[%s] Illegal flash access at 0x%08x", __func__, trans->address); + return ESP_FAIL; + } return spi_flash_hal_common_command(host, trans); } diff --git a/components/esp_tee/test_apps/tee_test_fw/main/test_esp_tee_flash_prot.c b/components/esp_tee/test_apps/tee_test_fw/main/test_esp_tee_flash_prot.c index c6172ea3e0..7c5d3cb9b9 100644 --- a/components/esp_tee/test_apps/tee_test_fw/main/test_esp_tee_flash_prot.c +++ b/components/esp_tee/test_apps/tee_test_fw/main/test_esp_tee_flash_prot.c @@ -125,13 +125,13 @@ static void test_esp_partition_api_w(const esp_partition_t *part) TEST_ASSERT_NOT_NULL(part); uint8_t buf_w[128]; memset(buf_w, 0xA5, sizeof(buf_w)); - TEST_ESP_OK(esp_partition_write(part, 0x00, buf_w, sizeof(buf_w))); + TEST_ESP_ERR(ESP_FAIL, esp_partition_write(part, 0x00, buf_w, sizeof(buf_w))); } static void test_esp_partition_api_e(const esp_partition_t *part) { TEST_ASSERT_NOT_NULL(part); - TEST_ESP_OK(esp_partition_erase_range(part, 0x00, SPI_FLASH_SEC_SIZE)); + TEST_ESP_ERR(ESP_FAIL, esp_partition_erase_range(part, 0x00, SPI_FLASH_SEC_SIZE)); } static void test_esp_partition_api(void) @@ -229,12 +229,12 @@ static void test_esp_flash_api_w(uint32_t paddr) { uint8_t buf_w[128]; memset(buf_w, 0xA5, sizeof(buf_w)); - TEST_ESP_OK(esp_flash_write(NULL, buf_w, paddr, sizeof(buf_w))); + TEST_ESP_ERR(ESP_FAIL, esp_flash_write(NULL, buf_w, paddr, sizeof(buf_w))); } static void test_esp_flash_api_e(uint32_t paddr) { - TEST_ESP_OK(esp_flash_erase_region(NULL, paddr, SPI_FLASH_SEC_SIZE)); + TEST_ESP_ERR(ESP_FAIL, esp_flash_erase_region(NULL, paddr, SPI_FLASH_SEC_SIZE)); } static void test_esp_flash_api(void) diff --git a/components/esp_tee/test_apps/tee_test_fw/pytest_esp_tee_ut.py b/components/esp_tee/test_apps/tee_test_fw/pytest_esp_tee_ut.py index 6b4654e79e..958a9ff053 100644 --- a/components/esp_tee/test_apps/tee_test_fw/pytest_esp_tee_ut.py +++ b/components/esp_tee/test_apps/tee_test_fw/pytest_esp_tee_ut.py @@ -1,5 +1,6 @@ # SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: Apache-2.0 +import re from enum import Enum from typing import Dict from typing import Tuple @@ -20,7 +21,7 @@ CONFIG_DEFAULT = [ CONFIG_OTA = [ # 'config, target, skip_autoflash, markers', - ('ota', target, 'y', (pytest.mark.generic,)) + ('ota', target, 'y', (pytest.mark.host_test,)) for target in SUPPORTED_TARGETS ] @@ -198,8 +199,18 @@ def expect_panic_rsn(dut: IdfDut, expected_rsn: str) -> None: def run_multiple_stages(dut: IdfDut, test_case_num: int, stages: int, api: TeeFlashAccessApi) -> None: expected_ops = { - TeeFlashAccessApi.ESP_PARTITION: ['read', 'program_page', 'program_page', 'erase_sector'], - TeeFlashAccessApi.ESP_FLASH: ['program_page', 'read', 'erase_sector', 'program_page'], + TeeFlashAccessApi.ESP_PARTITION: [ + 'read', + 'program_page|common_command', + 'program_page|common_command', + 'erase_sector|common_command', + ], + TeeFlashAccessApi.ESP_FLASH: [ + 'program_page|common_command', + 'read', + 'erase_sector|common_command', + 'program_page|common_command', + ], } flash_enc_enabled = dut.app.sdkconfig.get('SECURE_FLASH_ENC_ENABLED', True) @@ -225,7 +236,7 @@ def run_multiple_stages(dut: IdfDut, test_case_num: int, stages: int, api: TeeFl r'\[_ss_spi_flash_hal_(\w+)\] Illegal flash access at \s*(0x[0-9a-fA-F]+)', timeout=10 ) actual_op = match.group(1).decode() - if actual_op != curr_op: + if not re.fullmatch(curr_op, actual_op): raise RuntimeError(f'Unexpected flash operation: {actual_op} (expected: {curr_op})') elif api == TeeFlashAccessApi.ESP_ROM_SPIFLASH: expect_panic_rsn(dut, 'APM - Authority exception')