Merge branch 'refactor/make_mspi_hal_independent' into 'master'

refactor(mspi): Make mspi hal layer independent

See merge request espressif/esp-idf!42035
This commit is contained in:
C.S.M
2025-09-28 22:23:59 +08:00
91 changed files with 292 additions and 308 deletions

View File

@@ -32,6 +32,7 @@ set(optional_reqs ulp
soc
esp-tls
esp_https_ota
esp_hal_mspi
esp_hw_support)
idf_build_get_property(build_components BUILD_COMPONENTS)

View File

@@ -618,7 +618,7 @@ static const esp_err_msg_t esp_err_msg_table[] = {
# ifdef ESP_ERR_FLASH_OP_TIMEOUT
ERR_TBL_IT(ESP_ERR_FLASH_OP_TIMEOUT), /* 24578 0x6002 */
# endif
// components/hal/include/hal/esp_flash_err.h
// components/esp_hal_mspi/include/hal/esp_flash_err.h
# ifdef ESP_ERR_FLASH_NOT_INITIALISED
ERR_TBL_IT(ESP_ERR_FLASH_NOT_INITIALISED), /* 24579 0x6003 */
# endif

View File

@@ -0,0 +1,29 @@
idf_build_get_property(target IDF_TARGET)
idf_build_get_property(esp_tee_build ESP_TEE_BUILD)
set(srcs)
set(includes "include" "${target}/include")
if(esp_tee_build)
if(CONFIG_SECURE_TEE_EXT_FLASH_MEMPROT_SPI1)
list(APPEND srcs "spi_flash_hal.c")
endif()
elseif(NOT BOOTLOADER_BUILD)
if(NOT CONFIG_APP_BUILD_TYPE_PURE_RAM_APP)
if(CONFIG_SOC_SPI_FLASH_SUPPORTED)
list(APPEND srcs "spi_flash_hal.c" "spi_flash_hal_iram.c")
endif()
if(CONFIG_SOC_FLASH_ENC_SUPPORTED)
list(APPEND srcs "spi_flash_encrypt_hal_iram.c")
endif()
endif()
if(CONFIG_SOC_GPSPI_SUPPORTED AND NOT CONFIG_IDF_TARGET_ESP32)
list(APPEND srcs "spi_flash_hal_gpspi.c")
endif()
endif()
idf_component_register(SRCS ${srcs}
INCLUDE_DIRS ${includes}
REQUIRES soc hal)

View File

@@ -0,0 +1,9 @@
# `esp_hal_mspi`
⚠️ This HAL component is still under heavy development at the moment, so we don't guarantee the stability and backward-compatibility among versions.
The `esp_hal_mspi` component provides a **Hardware Abstraction Layer** of mspi for all targets supported by ESP-IDF.
In a broad sense, the HAL layer consists of two sub-layers: HAL (upper) and Low-Level(bottom). The HAL layer defines the steps and data that is required to operate a peripheral (e.g. initialization, start and stop). The low-level is a translation layer above the register files under the `soc` component, it only covers general conceptions to register configurations.
The functions in this file mainly provide hardware abstraction for IDF peripheral drivers. For advanced developers, the HAL layer functions can also be directly used to assist in implementing their own drivers. However, it needs to be mentioned again that the interfaces here do not guarantee stability.

View File

@@ -26,8 +26,7 @@ extern "C" {
#endif
/// Choose type of chip you want to encrypt manually
typedef enum
{
typedef enum {
FLASH_ENCRYPTION_MANU = 0, ///!< Manually encrypt the flash chip.
PSRAM_ENCRYPTION_MANU = 1 ///!< Manually encrypt the psram chip.
} flash_encrypt_ll_type_t;

View File

@@ -36,7 +36,6 @@ extern "C" {
dev_id; \
})
typedef union {
gpspi_flash_ll_clock_reg_t gpspi;
spimem_flash_ll_clock_reg_t spimem;

View File

@@ -363,7 +363,6 @@ static inline void spimem_flash_ll_set_buffer_data(spi_mem_dev_t *dev, const voi
}
}
/**
* Program a page of the flash chip. Call ``spimem_flash_ll_set_address`` before
* this to set the address to program.

View File

@@ -26,8 +26,7 @@ extern "C" {
#endif
/// Choose type of chip you want to encrypt manually
typedef enum
{
typedef enum {
FLASH_ENCRYPTION_MANU = 0, ///!< Manually encrypt the flash chip.
PSRAM_ENCRYPTION_MANU = 1 ///!< Manually encrypt the psram chip.
} flash_encrypt_ll_type_t;

View File

@@ -36,7 +36,6 @@ extern "C" {
dev_id; \
})
typedef union {
gpspi_flash_ll_clock_reg_t gpspi;
spimem_flash_ll_clock_reg_t spimem;
@@ -99,7 +98,6 @@ typedef union {
#define spi_flash_ll_set_common_command_register_info(dev, ctrl_reg, user_reg, user1_reg, user2_reg) spimem_flash_ll_set_common_command_register_info((spi_mem_dev_t*)dev, ctrl_reg, user_reg, user1_reg, user2_reg)
#define spi_flash_ll_get_common_command_register_info(dev, ctrl_reg, user_reg, user1_reg, user2_reg) spimem_flash_ll_get_common_command_register_info((spi_mem_dev_t*)dev, ctrl_reg, user_reg, user1_reg, user2_reg)
#endif
#ifdef __cplusplus

View File

@@ -365,7 +365,6 @@ static inline void spimem_flash_ll_set_buffer_data(spi_mem_dev_t *dev, const voi
}
}
/**
* Program a page of the flash chip. Call ``spimem_flash_ll_set_address`` before
* this to set the address to program.

View File

@@ -27,8 +27,7 @@ extern "C" {
#endif
/// Choose type of chip you want to encrypt manually
typedef enum
{
typedef enum {
FLASH_ENCRYPTION_MANU = 0, ///!< Manually encrypt the flash chip.
PSRAM_ENCRYPTION_MANU = 1 ///!< Manually encrypt the psram chip.
} flash_encrypt_ll_type_t;

View File

@@ -104,7 +104,6 @@ typedef union {
#define spi_flash_ll_get_common_command_register_info(dev, ctrl_reg, user_reg, user1_reg, user2_reg) spimem_flash_ll_get_common_command_register_info((spi_mem_dev_t*)dev, ctrl_reg, user_reg, user1_reg, user2_reg)
#define spi_flash_ll_wb_mode_enable(dev, wb_mode_enale) spimem_flash_ll_wb_mode_enable((spi_mem_dev_t*)dev, wb_mode_enale)
#endif
#ifdef __cplusplus

View File

@@ -386,7 +386,6 @@ static inline void spimem_flash_ll_set_buffer_data(spi_mem_dev_t *dev, const voi
}
}
/**
* Program a page of the flash chip. Call ``spimem_flash_ll_set_address`` before
* this to set the address to program.

View File

@@ -26,8 +26,7 @@ extern "C" {
#endif
/// Choose type of chip you want to encrypt manually
typedef enum
{
typedef enum {
FLASH_ENCRYPTION_MANU = 0, ///!< Manually encrypt the flash chip.
PSRAM_ENCRYPTION_MANU = 1 ///!< Manually encrypt the psram chip.
} flash_encrypt_ll_type_t;

View File

@@ -100,7 +100,6 @@ typedef union {
#define spi_flash_ll_set_common_command_register_info(dev, ctrl_reg, user_reg, user1_reg, user2_reg) spimem_flash_ll_set_common_command_register_info((spi_mem_dev_t*)dev, ctrl_reg, user_reg, user1_reg, user2_reg)
#define spi_flash_ll_get_common_command_register_info(dev, ctrl_reg, user_reg, user1_reg, user2_reg) spimem_flash_ll_get_common_command_register_info((spi_mem_dev_t*)dev, ctrl_reg, user_reg, user1_reg, user2_reg)
#endif
#ifdef __cplusplus

View File

@@ -366,7 +366,6 @@ static inline void spimem_flash_ll_set_buffer_data(spi_mem_dev_t *dev, const voi
}
}
/**
* Program a page of the flash chip. Call ``spimem_flash_ll_set_address`` before
* this to set the address to program.

View File

@@ -100,7 +100,6 @@ static inline __attribute__((always_inline)) void mspi_timing_ll_enable_core_clo
PCR.mspi_conf.mspi_clk_en = enable;
}
/**
* Reset the MSPI clock
*/
@@ -427,7 +426,6 @@ static inline void mspi_timing_ll_get_psram_dummy(uint8_t mspi_id, int *usr_rdum
*extra_dummy = REG_GET_FIELD(SPI_SMEM_TIMING_CALI_REG(mspi_id), SPI_SMEM_EXTRA_DUMMY_CYCLELEN);
}
#ifdef __cplusplus
}
#endif

View File

@@ -27,8 +27,7 @@ extern "C" {
#endif
/// Choose type of chip you want to encrypt manually
typedef enum
{
typedef enum {
FLASH_ENCRYPTION_MANU = 0, ///!< Manually encrypt the flash chip.
PSRAM_ENCRYPTION_MANU = 1 ///!< Manually encrypt the psram chip.
} flash_encrypt_ll_type_t;

View File

@@ -102,7 +102,6 @@ typedef union {
#define spi_flash_ll_set_common_command_register_info(dev, ctrl_reg, user_reg, user1_reg, user2_reg) spimem_flash_ll_set_common_command_register_info((spi_mem_dev_t*)dev, ctrl_reg, user_reg, user1_reg, user2_reg)
#define spi_flash_ll_get_common_command_register_info(dev, ctrl_reg, user_reg, user1_reg, user2_reg) spimem_flash_ll_get_common_command_register_info((spi_mem_dev_t*)dev, ctrl_reg, user_reg, user1_reg, user2_reg)
#endif
#ifdef __cplusplus

View File

@@ -379,7 +379,6 @@ static inline void spimem_flash_ll_set_buffer_data(spi_mem_dev_t *dev, const voi
}
}
/**
* Program a page of the flash chip. Call ``spimem_flash_ll_set_address`` before
* this to set the address to program.

View File

@@ -30,8 +30,7 @@ extern "C" {
#endif
/// Choose type of chip you want to encrypt manually
typedef enum
{
typedef enum {
FLASH_ENCRYPTION_MANU = 0, ///!< Manually encrypt the flash chip.
PSRAM_ENCRYPTION_MANU = 1 ///!< Manually encrypt the psram chip.
} flash_encrypt_ll_type_t;

View File

@@ -100,7 +100,6 @@ typedef union {
#define spi_flash_ll_set_common_command_register_info(dev, ctrl_reg, user_reg, user1_reg, user2_reg) spimem_flash_ll_set_common_command_register_info((spi_mem_dev_t*)dev, ctrl_reg, user_reg, user1_reg, user2_reg)
#define spi_flash_ll_get_common_command_register_info(dev, ctrl_reg, user_reg, user1_reg, user2_reg) spimem_flash_ll_get_common_command_register_info((spi_mem_dev_t*)dev, ctrl_reg, user_reg, user1_reg, user2_reg)
#endif
#ifdef __cplusplus

View File

@@ -367,7 +367,6 @@ static inline void spimem_flash_ll_set_buffer_data(spi_mem_dev_t *dev, const voi
}
}
/**
* Program a page of the flash chip. Call ``spimem_flash_ll_set_address`` before
* this to set the address to program.

View File

@@ -27,8 +27,7 @@ extern "C" {
#endif
/// Choose type of chip you want to encrypt manually
typedef enum
{
typedef enum {
FLASH_ENCRYPTION_MANU = 0, ///!< Manually encrypt the flash chip.
PSRAM_ENCRYPTION_MANU = 1 ///!< Manually encrypt the psram chip.
} flash_encrypt_ll_type_t;

View File

@@ -96,7 +96,6 @@ typedef union {
#define spi_flash_ll_set_common_command_register_info(dev, ctrl_reg, user_reg, user1_reg, user2_reg) spimem_flash_ll_set_common_command_register_info((spi_mem_dev_t*)dev, ctrl_reg, user_reg, user1_reg, user2_reg)
#define spi_flash_ll_get_common_command_register_info(dev, ctrl_reg, user_reg, user1_reg, user2_reg) spimem_flash_ll_get_common_command_register_info((spi_mem_dev_t*)dev, ctrl_reg, user_reg, user1_reg, user2_reg)
#endif
#ifdef __cplusplus

View File

@@ -367,7 +367,6 @@ static inline void spimem_flash_ll_set_buffer_data(spi_mem_dev_t *dev, const voi
}
}
/**
* Program a page of the flash chip. Call ``spimem_flash_ll_set_address`` before
* this to set the address to program.
@@ -725,7 +724,6 @@ static inline void spimem_flash_ll_set_common_command_register_info(spi_mem_dev_
dev->user2.val = user2_reg;
}
#define SPIMEM_FLASH_LL_SUSPEND_END_INTR SPI_MEM_PES_END_INT_ENA_M
#define SPIMEM_FLASH_LL_INTERRUPT_SOURCE ETS_MSPI_INTR_SOURCE

View File

@@ -28,8 +28,7 @@ extern "C" {
#endif
/// Choose type of chip you want to encrypt manually
typedef enum
{
typedef enum {
FLASH_ENCRYPTION_MANU = 0, ///!< Manually encrypt the flash chip.
PSRAM_ENCRYPTION_MANU = 1 ///!< Manually encrypt the psram chip.
} flash_encrypt_ll_type_t;

View File

@@ -365,7 +365,6 @@ static inline void spimem_flash_ll_set_buffer_data(spi_mem_dev_t *dev, const voi
}
}
/**
* Program a page of the flash chip. Call ``spimem_flash_ll_set_address`` before
* this to set the address to program.
@@ -724,7 +723,6 @@ static inline void spimem_flash_ll_set_common_command_register_info(spi_mem_dev_
dev->user2.val = user2_reg;
}
#define SPIMEM_FLASH_LL_SUSPEND_END_INTR SPI_MEM_PES_END_INT_ENA_M
#define SPIMEM_FLASH_LL_INTERRUPT_SOURCE ETS_MSPI_INTR_SOURCE

View File

@@ -225,7 +225,6 @@ static inline void mspi_timing_ll_enable_dqs(bool en)
}
}
/**
* Set all MSPI pin drive
*
@@ -366,7 +365,6 @@ static inline void mspi_timinng_ll_enable_flash_timing_adjust_clk(uint8_t spi_nu
REG_GET_BIT(SPI_MEM_C_TIMING_CALI_REG, SPI_MEM_C_TIMING_CLK_ENA);
}
/**
* Set MSPI Flash din mode
*

View File

@@ -38,7 +38,6 @@ extern "C" {
#define PSRAM_CTRLR_LL_FIFO_MAX_BYTES 64
/**
* @brief Set PSRAM write cmd
*

View File

@@ -26,8 +26,7 @@ extern "C" {
#endif
/// Choose type of chip you want to encrypt manually
typedef enum
{
typedef enum {
FLASH_ENCRYPTION_MANU = 0, ///!< Manually encrypt the flash chip.
PSRAM_ENCRYPTION_MANU = 1 ///!< Manually encrypt the psram chip.
} flash_encrypt_ll_type_t;

View File

@@ -102,7 +102,6 @@ typedef union {
#define spi_flash_ll_set_common_command_register_info(dev, ctrl_reg, user_reg, user1_reg, user2_reg) spimem_flash_ll_set_common_command_register_info((spi_mem_dev_t*)dev, ctrl_reg, user_reg, user1_reg, user2_reg)
#define spi_flash_ll_get_common_command_register_info(dev, ctrl_reg, user_reg, user1_reg, user2_reg) spimem_flash_ll_get_common_command_register_info((spi_mem_dev_t*)dev, ctrl_reg, user_reg, user1_reg, user2_reg)
#endif
#ifdef __cplusplus

View File

@@ -377,7 +377,6 @@ static inline void spimem_flash_ll_set_buffer_data(spi_mem_dev_t *dev, const voi
}
}
/**
* Program a page of the flash chip. Call ``spimem_flash_ll_set_address`` before
* this to set the address to program.

View File

@@ -26,8 +26,7 @@ extern "C" {
#endif
/// Choose type of chip you want to encrypt manually
typedef enum
{
typedef enum {
FLASH_ENCRYPTION_MANU = 0, ///!< Manually encrypt the flash chip.
PSRAM_ENCRYPTION_MANU = 1 ///!< Manually encrypt the psram chip.
} flash_encrypt_ll_type_t;

View File

@@ -45,6 +45,7 @@ typedef union {
#define SPIMEM_LL_CACHE SPIMEM0
#ifdef GPSPI_BUILD
#define spi_flash_ll_reset(dev) gpspi_flash_ll_reset((spi_dev_t*)dev)
#define spi_flash_ll_cmd_is_done(dev) gpspi_flash_ll_cmd_is_done((spi_dev_t*)dev)
#define spi_flash_ll_get_buffer_data(dev, buffer, read_len) gpspi_flash_ll_get_buffer_data((spi_dev_t*)dev, buffer, read_len)
@@ -68,6 +69,7 @@ typedef union {
#define spi_flash_ll_set_cs_setup(dev, cs_setup_time) gpspi_flash_ll_set_cs_setup((spi_dev_t*)dev, cs_setup_time)
#else
#define spi_flash_ll_reset(dev) spimem_flash_ll_reset((spi_mem_dev_t*)dev)
#define spi_flash_ll_cmd_is_done(dev) spimem_flash_ll_cmd_is_done((spi_mem_dev_t*)dev)
#define spi_flash_ll_erase_chip(dev) spimem_flash_ll_erase_chip((spi_mem_dev_t*)dev)
@@ -99,7 +101,6 @@ typedef union {
#define spi_flash_ll_set_common_command_register_info(dev, ctrl_reg, user_reg, user1_reg, user2_reg) spimem_flash_ll_set_common_command_register_info((spi_mem_dev_t*)dev, ctrl_reg, user_reg, user1_reg, user2_reg)
#define spi_flash_ll_get_common_command_register_info(dev, ctrl_reg, user_reg, user1_reg, user2_reg) spimem_flash_ll_get_common_command_register_info((spi_mem_dev_t*)dev, ctrl_reg, user_reg, user1_reg, user2_reg)
#endif
#ifdef __cplusplus

View File

@@ -306,7 +306,6 @@ static inline void spimem_flash_ll_set_buffer_data(spi_mem_dev_t *dev, const voi
}
}
/**
* Program a page of the flash chip. Call ``spimem_flash_ll_set_address`` before
* this to set the address to program.

View File

@@ -346,7 +346,6 @@ static inline void gpspi_flash_ll_set_usr_address(spi_dev_t *dev, uint32_t addr,
dev->addr = (addr << (32 - bitlen)) | padding_ones;
}
/**
* Set the address to send. Should be called before commands that requires the address e.g. erase sector, read, write...
*

View File

@@ -78,7 +78,8 @@ static inline void mspi_timing_ll_set_all_pin_drive(uint8_t spi_num, uint32_t va
IO_MUX_GPIO31_REG, IO_MUX_GPIO32_REG,
IO_MUX_GPIO33_REG, IO_MUX_GPIO34_REG,
IO_MUX_GPIO35_REG, IO_MUX_GPIO36_REG,
IO_MUX_GPIO37_REG};
IO_MUX_GPIO37_REG
};
for (int i = 0; i < ARRAY_SIZE(regs); i++) {
PIN_SET_DRV(regs[i], val);
}

View File

@@ -26,8 +26,7 @@ extern "C" {
#endif
/// Choose type of chip you want to encrypt manually
typedef enum
{
typedef enum {
FLASH_ENCRYPTION_MANU = 0, ///!< Manually encrypt the flash chip.
PSRAM_ENCRYPTION_MANU = 1 ///!< Manually encrypt the psram chip.
} flash_encrypt_ll_type_t;

View File

@@ -21,7 +21,6 @@
extern "C" {
#endif
#define spi_flash_ll_calculate_clock_reg(host_id, clock_div) (((host_id)<=SPI1_HOST) ? spimem_flash_ll_calculate_clock_reg(clock_div) \
: gpspi_flash_ll_calculate_clock_reg(clock_div))
@@ -46,7 +45,6 @@ typedef union {
#define SPIMEM_LL_CACHE SPIMEM0
#ifdef GPSPI_BUILD
#define spi_flash_ll_reset(dev) gpspi_flash_ll_reset((spi_dev_t*)dev)
#define spi_flash_ll_cmd_is_done(dev) gpspi_flash_ll_cmd_is_done((spi_dev_t*)dev)
#define spi_flash_ll_get_buffer_data(dev, buffer, read_len) gpspi_flash_ll_get_buffer_data((spi_dev_t*)dev, buffer, read_len)
@@ -70,7 +68,6 @@ typedef union {
#define spi_flash_ll_set_cs_setup(dev, cs_setup_time) gpspi_flash_ll_set_cs_setup((spi_dev_t*)dev, cs_setup_time)
#else
#define spi_flash_ll_reset(dev) spimem_flash_ll_reset((spi_mem_dev_t*)dev)
#define spi_flash_ll_cmd_is_done(dev) spimem_flash_ll_cmd_is_done((spi_mem_dev_t*)dev)
#define spi_flash_ll_erase_chip(dev) spimem_flash_ll_erase_chip((spi_mem_dev_t*)dev)
@@ -102,7 +99,6 @@ typedef union {
#define spi_flash_ll_set_common_command_register_info(dev, ctrl_reg, user_reg, user1_reg, user2_reg) spimem_flash_ll_set_common_command_register_info((spi_mem_dev_t*)dev, ctrl_reg, user_reg, user1_reg, user2_reg)
#define spi_flash_ll_get_common_command_register_info(dev, ctrl_reg, user_reg, user1_reg, user2_reg) spimem_flash_ll_get_common_command_register_info((spi_mem_dev_t*)dev, ctrl_reg, user_reg, user1_reg, user2_reg)
#endif
#ifdef __cplusplus

View File

@@ -368,7 +368,6 @@ static inline void spimem_flash_ll_set_buffer_data(spi_mem_dev_t *dev, const voi
}
}
/**
* Program a page of the flash chip. Call ``spimem_flash_ll_set_address`` before
* this to set the address to program.

View File

@@ -17,7 +17,7 @@ extern "C" {
* Possible errors returned from esp flash internal functions, these error codes
* should be consistent with esp_err_t codes. But in order to make the source
* files less dependent to esp_err_t, they use the error codes defined in this
* replacable header. This header should ensure the consistency to esp_err_t.
* replaceable header. This header should ensure the consistency to esp_err_t.
*/
enum {

View File

@@ -62,8 +62,7 @@ typedef struct {
} spi_flash_sus_cmd_conf;
/// Structure for flash encryption operations.
typedef struct
{
typedef struct {
/**
* @brief Enable the flash encryption
*/
@@ -111,7 +110,6 @@ typedef struct {
// Implementations can wrap this structure into their own ones, and append other data here
} spi_flash_host_inst_t ;
/** Host driver configuration and context structure. */
struct spi_flash_host_driver_s {
/**

View File

@@ -126,7 +126,6 @@ esp_err_t spi_flash_hal_init(spi_flash_hal_context_t *data_out, const spi_flash_
data_out->clock_conf = (spi_flash_ll_clock_reg_t)spi_flash_cal_clock(cfg);
}
if (cfg->auto_sus_en) {
data_out->flags |= SPI_FLASH_HOST_CONTEXT_FLAG_AUTO_SUSPEND;
data_out->flags |= SPI_FLASH_HOST_CONTEXT_FLAG_AUTO_RESUME;
@@ -159,7 +158,6 @@ bool spi_flash_hal_supports_direct_write(spi_flash_host_inst_t *host, const void
return direct_write;
}
bool spi_flash_hal_supports_direct_read(spi_flash_host_inst_t *host, const void *p)
{
(void)p;

View File

@@ -78,7 +78,7 @@ if(NOT non_os_build)
esp_timer
esp_pm)
list(APPEND priv_requires esp_mm)
list(APPEND priv_requires esp_mm esp_hal_mspi)
if(CONFIG_IDF_TARGET_ESP32 OR CONFIG_IDF_TARGET_ESP32S2)
list(APPEND srcs "rtc_wdt.c")

View File

@@ -7,5 +7,5 @@ set(srcs
# In order for the cases defined by `TEST_CASE` to be linked into the final elf,
# the component can be registered as WHOLE_ARCHIVE
idf_component_register(SRCS ${srcs}
PRIV_REQUIRES unity esp_timer spi_flash esp_partition
PRIV_REQUIRES unity esp_timer spi_flash esp_partition esp_hal_mspi
WHOLE_ARCHIVE)

View File

@@ -28,7 +28,6 @@
#include "hal/clk_tree_ll.h"
#include "hal/uart_ll.h"
#include "hal/uart_types.h"
#include "hal/mspi_ll.h"
#include "driver/gpio.h"

View File

@@ -10,7 +10,7 @@ if(CONFIG_SOC_SPIRAM_XIP_SUPPORTED)
list(APPEND includes xip_impl/include)
endif()
set(priv_requires heap spi_flash esp_mm)
set(priv_requires heap spi_flash esp_mm esp_hal_mspi)
if(${target} STREQUAL "esp32")
list(APPEND priv_requires bootloader_support esp_driver_spi esp_driver_gpio)
endif()

View File

@@ -10,3 +10,4 @@ components/esp_psram/test_apps/psram:
- esp_driver_gpio
- esp_driver_spi
- spi_flash
- esp_hal_mspi

View File

@@ -72,7 +72,7 @@ else()
idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS include
PRIV_REQUIRES spi_flash esp_timer esp_mm
PRIV_REQUIRES spi_flash esp_timer esp_mm esp_hal_mspi
# [refactor-todo] requirements due to init code,
# should be removable once using component init functions
# link-time registration is used.

View File

@@ -58,22 +58,9 @@ if(esp_tee_build)
"hmac_hal.c"
"ds_hal.c"
"ecc_hal.c")
if(CONFIG_SECURE_TEE_EXT_FLASH_MEMPROT_SPI1)
list(APPEND srcs "spi_flash_hal.c")
endif()
elseif(NOT BOOTLOADER_BUILD)
list(APPEND srcs "color_hal.c")
if(NOT CONFIG_APP_BUILD_TYPE_PURE_RAM_APP)
if(CONFIG_SOC_SPI_FLASH_SUPPORTED)
list(APPEND srcs "spi_flash_hal.c" "spi_flash_hal_iram.c")
endif()
if(CONFIG_SOC_FLASH_ENC_SUPPORTED)
list(APPEND srcs "spi_flash_encrypt_hal_iram.c")
endif()
endif()
if(CONFIG_SOC_CLK_TREE_SUPPORTED)
list(APPEND srcs "${target}/clk_tree_hal.c")
endif()
@@ -263,10 +250,6 @@ elseif(NOT BOOTLOADER_BUILD)
endif()
endif()
if(CONFIG_SOC_GPSPI_SUPPORTED AND NOT CONFIG_IDF_TARGET_ESP32)
list(APPEND srcs "spi_flash_hal_gpspi.c")
endif()
if(CONFIG_SOC_SDIO_SLAVE_SUPPORTED)
list(APPEND srcs "sdio_slave_hal.c")
endif()

View File

@@ -6,6 +6,7 @@ if(${target} STREQUAL "linux")
"linux/cache_utils.c"
"linux/flash_mmap.c"
INCLUDE_DIRS include
REQUIRES esp_hal_mspi
PRIV_INCLUDE_DIRS include/spi_flash)
return()
endif()
@@ -60,7 +61,7 @@ else()
endif()
idf_component_register(SRCS "${srcs}"
REQUIRES hal
REQUIRES hal esp_hal_mspi
PRIV_REQUIRES "${priv_requires}"
INCLUDE_DIRS include
PRIV_INCLUDE_DIRS include/spi_flash

View File

@@ -74,7 +74,7 @@ entries:
spi_flash_hpm_enable (noflash)
[mapping:spi_flash_hal]
archive: libhal.a
archive: libesp_hal_mspi.a
entries:
if SPI_FLASH_PLACE_FUNCTIONS_IN_IRAM = y:
spi_flash_hal_iram (noflash)

View File

@@ -14,6 +14,7 @@ components/spi_flash/test_apps/esp_flash:
- esp_driver_gpio
- esp_driver_spi
- esptool_py # Some flash related kconfigs are listed here.
- esp_hal_mspi
components/spi_flash/test_apps/esp_flash_stress:
disable:
@@ -23,6 +24,7 @@ components/spi_flash/test_apps/esp_flash_stress:
depends_components:
- esp_mm
- spi_flash
- esp_hal_mspi
components/spi_flash/test_apps/flash_encryption:
disable:
@@ -37,11 +39,13 @@ components/spi_flash/test_apps/flash_encryption:
depends_components:
- esp_mm
- spi_flash
- esp_hal_mspi
components/spi_flash/test_apps/flash_mmap:
depends_components:
- esp_mm
- spi_flash
- esp_hal_mspi
enable:
- if: CONFIG_NAME == "release" and IDF_TARGET != "linux"
- if: CONFIG_NAME == "rom_impl" and ESP_ROM_HAS_SPI_FLASH == 1
@@ -64,6 +68,7 @@ components/spi_flash/test_apps/flash_suspend:
depends_components:
- spi_flash
- esp_driver_gptimer
- esp_hal_mspi
components/spi_flash/test_apps/mspi_test:
disable:
@@ -78,3 +83,4 @@ components/spi_flash/test_apps/mspi_test:
- esp_driver_gpio
- esp_driver_spi
- esptool_py # Some flash related kconfigs are listed here.
- esp_hal_mspi

View File

@@ -163,6 +163,8 @@ INPUT = \
$(PROJECT_PATH)/components/esp_event/include/esp_event.h \
$(PROJECT_PATH)/components/esp_hal_timg/include/hal/timer_types.h \
$(PROJECT_PATH)/components/esp_hal_i2c/include/hal/i2c_types.h \
$(PROJECT_PATH)/components/esp_hal_mspi/include/hal/esp_flash_err.h \
$(PROJECT_PATH)/components/esp_hal_mspi/include/hal/spi_flash_types.h \
$(PROJECT_PATH)/components/esp_http_client/include/esp_http_client.h \
$(PROJECT_PATH)/components/esp_http_server/include/esp_http_server.h \
$(PROJECT_PATH)/components/esp_https_ota/include/esp_https_ota.h \
@@ -250,7 +252,6 @@ INPUT = \
$(PROJECT_PATH)/components/hal/include/hal/adc_types.h \
$(PROJECT_PATH)/components/hal/include/hal/color_types.h \
$(PROJECT_PATH)/components/hal/include/hal/dac_types.h \
$(PROJECT_PATH)/components/hal/include/hal/esp_flash_err.h \
$(PROJECT_PATH)/components/hal/include/hal/gpio_types.h \
$(PROJECT_PATH)/components/hal/include/hal/i2s_types.h \
$(PROJECT_PATH)/components/hal/include/hal/lcd_types.h \
@@ -262,7 +263,6 @@ INPUT = \
$(PROJECT_PATH)/components/hal/include/hal/rtc_io_types.h \
$(PROJECT_PATH)/components/hal/include/hal/sdio_slave_types.h \
$(PROJECT_PATH)/components/hal/include/hal/sdm_types.h \
$(PROJECT_PATH)/components/hal/include/hal/spi_flash_types.h \
$(PROJECT_PATH)/components/hal/include/hal/spi_types.h \
$(PROJECT_PATH)/components/hal/include/hal/temperature_sensor_types.h \
$(PROJECT_PATH)/components/hal/include/hal/twai_types.h \

View File

@@ -184,7 +184,7 @@ The ``esp_flash_t`` structure holds chip data as well as three important parts o
Host Driver
^^^^^^^^^^^
The host driver relies on an interface (``spi_flash_host_driver_t``) defined in the ``spi_flash_types.h`` (in the ``hal/include/hal`` folder). This interface provides some common functions to communicate with the chip.
The host driver relies on an interface (``spi_flash_host_driver_t``) defined in the ``spi_flash_types.h`` (in the ``esp_hal_mspi/include/hal`` folder). This interface provides some common functions to communicate with the chip.
In other files of the SPI HAL, some of these functions are implemented with existing {IDF_TARGET_NAME} memory-spi functionalities. However, due to the speed limitations of {IDF_TARGET_NAME}, the HAL layer cannot provide high-speed implementations to some reading commands (so the support for it was dropped). The files (``memspi_host_driver.h`` and ``.c``) implement the high-speed version of these commands with the ``common_command`` function provided in the HAL, and wrap these functions as ``spi_flash_host_driver_t`` for upper layer to use.

View File

@@ -184,7 +184,7 @@ SPI flash 实现
主机驱动
^^^^^^^^^^^^^^^
主机驱动依赖 ``hal/include/hal`` 文件夹下 ``spi_flash_types.h`` 定义的 ``spi_flash_host_driver_t`` 接口。该接口提供了一些常用的函数,用于与芯片通信。
主机驱动依赖 ``esp_hal_mspi/include/hal`` 文件夹下 ``spi_flash_types.h`` 定义的 ``spi_flash_host_driver_t`` 接口。该接口提供了一些常用的函数,用于与芯片通信。
在 SPI HAL 文件中,有些函数是基于现有的 {IDF_TARGET_NAME} memory-spi 来实现的。但是,由于 {IDF_TARGET_NAME} 的速度限制HAL 层无法提供某些读命令的高速实现(所以这些命令根本没有在 HAL 的文件中被实现)。``memspi_host_driver.h````.c`` 文件使用 HAL 提供的 ``common_command`` 函数实现上述读命令的高速版本,并将所有它实现的以及 HAL 函数封装为 ``spi_flash_host_driver_t`` 供更上层调用。