From 90dd358dcbbd0f5e225075ec274dcd365237122b Mon Sep 17 00:00:00 2001 From: armando Date: Fri, 5 Jun 2026 11:34:11 +0800 Subject: [PATCH] feat(mspi): added mspi flash error (aligned with rom) --- .../bootloader_flash/src/bootloader_flash.c | 2 +- components/esp_mspi/CMakeLists.txt | 2 ++ components/esp_mspi/include/spi_flash_err.h | 21 +++++++++++++++++++ components/spi_flash/CMakeLists.txt | 3 +-- components/spi_flash/include/esp_flash_err.h | 3 +-- components/spi_flash/include/spi_flash_mmap.h | 2 +- 6 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 components/esp_mspi/include/spi_flash_err.h diff --git a/components/bootloader_support/bootloader_flash/src/bootloader_flash.c b/components/bootloader_support/bootloader_flash/src/bootloader_flash.c index a2032ae8eee..d9c084a14c7 100644 --- a/components/bootloader_support/bootloader_flash/src/bootloader_flash.c +++ b/components/bootloader_support/bootloader_flash/src/bootloader_flash.c @@ -13,8 +13,8 @@ #include "hal/efuse_ll.h" #include "hal/efuse_hal.h" #include "hal/spi_flash_types.h" -#include "hal/esp_flash_err.h" #include "spi_flash_defs.h" +#include "spi_flash_err.h" #if !NON_OS_BUILD #include "spi_flash_mmap.h" diff --git a/components/esp_mspi/CMakeLists.txt b/components/esp_mspi/CMakeLists.txt index 653759501ee..1dc054ea060 100644 --- a/components/esp_mspi/CMakeLists.txt +++ b/components/esp_mspi/CMakeLists.txt @@ -83,6 +83,8 @@ idf_component_register(SRCS "${srcs}" INCLUDE_DIRS ${include_dirs} LDFRAGMENTS ${ldfragments}) +idf_define_esp_err_codes(HEADERS include/spi_flash_err.h) + if(NOT non_os_build AND NOT CONFIG_APP_BUILD_TYPE_PURE_RAM_APP) if(CONFIG_SPIRAM) # esp_mspi_get_io() queries esp_psram_io_get_cs_io() for the PSRAM CS pin diff --git a/components/esp_mspi/include/spi_flash_err.h b/components/esp_mspi/include/spi_flash_err.h new file mode 100644 index 00000000000..878f3d02f78 --- /dev/null +++ b/components/esp_mspi/include/spi_flash_err.h @@ -0,0 +1,21 @@ +/* + * SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include +#include "esp_err.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ESP_ERR_FLASH_OP_FAIL (ESP_ERR_FLASH_BASE+1) ///< aligned with rom +#define ESP_ERR_FLASH_OP_TIMEOUT (ESP_ERR_FLASH_BASE+2) ///< aligned with rom + +#ifdef __cplusplus +} +#endif diff --git a/components/spi_flash/CMakeLists.txt b/components/spi_flash/CMakeLists.txt index 5eb8ea646a0..813ec029f3b 100644 --- a/components/spi_flash/CMakeLists.txt +++ b/components/spi_flash/CMakeLists.txt @@ -6,8 +6,7 @@ if(${target} STREQUAL "linux") "linux/flash_mmap.c" "spi_flash_blockdev.c" INCLUDE_DIRS include - REQUIRES esp_hal_mspi esp_blockdev - PRIV_REQUIRES esp_mspi) + REQUIRES esp_hal_mspi esp_mspi esp_blockdev) return() endif() diff --git a/components/spi_flash/include/esp_flash_err.h b/components/spi_flash/include/esp_flash_err.h index 8f255ed6cf7..d22620c8c90 100644 --- a/components/spi_flash/include/esp_flash_err.h +++ b/components/spi_flash/include/esp_flash_err.h @@ -8,6 +8,7 @@ #include #include "esp_err.h" +#include "spi_flash_err.h" #ifdef __cplusplus extern "C" { @@ -30,8 +31,6 @@ enum { }; //The ROM code has already taken 1 and 2, to avoid possible conflicts, start from 3. -#define ESP_ERR_FLASH_OP_FAIL (ESP_ERR_FLASH_BASE+1) ///< aligned with rom -#define ESP_ERR_FLASH_OP_TIMEOUT (ESP_ERR_FLASH_BASE+2) ///< aligned with rom #define ESP_ERR_FLASH_NOT_INITIALISED (ESP_ERR_FLASH_BASE+3) ///< esp_flash_chip_t structure not correctly initialised by esp_flash_init(). #define ESP_ERR_FLASH_UNSUPPORTED_HOST (ESP_ERR_FLASH_BASE+4) ///< Requested operation isn't supported via this host SPI bus (chip->spi field). #define ESP_ERR_FLASH_UNSUPPORTED_CHIP (ESP_ERR_FLASH_BASE+5) ///< Requested operation isn't supported by this model of SPI flash chip. diff --git a/components/spi_flash/include/spi_flash_mmap.h b/components/spi_flash/include/spi_flash_mmap.h index 2498002eaea..7ad85cf9a57 100644 --- a/components/spi_flash/include/spi_flash_mmap.h +++ b/components/spi_flash/include/spi_flash_mmap.h @@ -21,7 +21,7 @@ #include "esp_attr.h" #include "sdkconfig.h" #include "esp_spi_flash_counters.h" -#include "hal/esp_flash_err.h" +#include "esp_flash_err.h" #ifdef __cplusplus extern "C" {