refactor(mspi): move esp_mspi_align and mspi_mem_barrier to esp_mspi

This commit is contained in:
Armando (Dou Yiwen)
2026-09-09 14:17:00 +08:00
parent 90dd358dcb
commit 5e181236b7
15 changed files with 61 additions and 54 deletions
+1 -1
View File
@@ -17,4 +17,4 @@ idf_component_register(SRCS ${srcs}
INCLUDE_DIRS ${includes}
PRIV_INCLUDE_DIRS "."
REQUIRES esp_hal_asrc esp_driver_dma esp_mm
PRIV_REQUIRES esp_hw_support esp_pm)
PRIV_REQUIRES esp_hw_support esp_pm esp_mspi)
+1 -1
View File
@@ -50,6 +50,6 @@ idf_component_register(SRCS ${srcs}
INCLUDE_DIRS ${public_include}
PRIV_INCLUDE_DIRS "src"
REQUIRES ${requires}
PRIV_REQUIRES esp_mm efuse
PRIV_REQUIRES esp_mm efuse esp_mspi
LDFRAGMENTS "linker.lf"
)
@@ -23,7 +23,7 @@ endif()
# 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_mm esp_driver_gpio esp_psram esp_driver_dma efuse
PRIV_REQUIRES unity esp_mm esp_driver_gpio esp_psram esp_driver_dma efuse esp_mspi
WHOLE_ARCHIVE)
idf_component_get_property(lib_name esp_driver_dma COMPONENT_LIB)
+1 -1
View File
@@ -35,7 +35,7 @@ endif()
if(${target} STREQUAL "linux")
set(priv_requires esp_ringbuf)
else()
set(priv_requires esp_pm esp_driver_gpio esp_driver_dma esp_ringbuf esp_mm)
set(priv_requires esp_pm esp_driver_gpio esp_driver_dma esp_ringbuf esp_mm esp_mspi)
endif()
idf_component_register(
+2 -8
View File
@@ -14,8 +14,6 @@ endif()
set(public_include_dirs "include" "include/soc"
"ldo/include" "debug_probe/include" "etm/include"
"mspi/esp_mspi_align/include"
"mspi/mspi_mem_barrier/include"
"power_supply/include" "modem/include")
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/include/soc/${target}")
@@ -53,9 +51,6 @@ set(priv_requires efuse # only esp_hw_support/adc_share_hw_ctrl.
)
set(srcs "cpu.c" "port/${IDF_TARGET}/esp_cpu_intr.c" "esp_memory_utils.c" "port/${IDF_TARGET}/cpu_region_protect.c")
if(NOT BOOTLOADER_BUILD)
list(APPEND srcs "mspi/esp_mspi_align/esp_mspi_align.c")
endif()
if(NOT non_os_build)
list(APPEND srcs "esp_clk.c"
"clk_ctrl_os.c"
@@ -74,8 +69,7 @@ if(NOT non_os_build)
"port/${target}/esp_clk_tree.c"
"spi_bus_lock.c"
"heap_align_hw.c"
"clk_utils.c"
"mspi/mspi_mem_barrier/mspi_mem_barrier.c")
"clk_utils.c")
if(CONFIG_SOC_USB_OTG_SUPPORTED)
list(APPEND srcs "usb_phy/usb_phy.c")
endif()
@@ -189,7 +183,7 @@ idf_component_register(SRCS ${srcs}
PRIV_INCLUDE_DIRS port/include include/esp_private
REQUIRES ${requires}
PRIV_REQUIRES "${priv_requires}"
LDFRAGMENTS linker.lf ldo/linker.lf mspi/linker.lf)
LDFRAGMENTS linker.lf ldo/linker.lf)
idf_define_esp_err_codes(HEADERS include/esp_memprot_err.h)
-6
View File
@@ -1,6 +0,0 @@
[mapping:esp_mspi_align]
archive: libesp_hw_support.a
entries:
if APP_BUILD_TYPE_PURE_RAM_APP = n:
esp_mspi_align:esp_mspi_get_alignment (noflash)
esp_mspi_align:esp_mspi_buffer_alignment_satisfied (noflash)
+20 -8
View File
@@ -9,9 +9,13 @@ if(${target} STREQUAL "linux")
endif()
if(non_os_build OR CONFIG_APP_BUILD_TYPE_PURE_RAM_APP)
set(priv_requires bootloader_support soc esp_hal_gpio)
# efuse is required by esp_mspi_align.c to query the flash encryption state
set(priv_requires bootloader_support soc esp_hal_gpio efuse)
set(requires hal esp_hal_mspi)
set(srcs "spi_flash_wrap.c" "spi_flash_os_tee_stub.c")
if(NOT BOOTLOADER_BUILD)
list(APPEND srcs "esp_mspi_align/esp_mspi_align.c")
endif()
if(ESP_TEE_BUILD)
if(CONFIG_SECURE_TEE_EXT_FLASH_MEMPROT_SPI1)
list(APPEND srcs "mspi_timing_tuning/mspi_timing_tuning.c")
@@ -27,10 +31,13 @@ if(non_os_build OR CONFIG_APP_BUILD_TYPE_PURE_RAM_APP)
endif()
endif()
else()
set(priv_requires bootloader_support soc esp_hal_gpio esp_mm)
# efuse is required by esp_mspi_align.c to query the flash encryption state
set(priv_requires bootloader_support soc esp_hal_gpio esp_mm efuse)
set(requires hal esp_hal_mspi)
set(srcs "flash_brownout_hook.c" "cache_utils.c" "flash_ops.c" "spi_flash_wrap.c")
set(srcs "flash_brownout_hook.c" "cache_utils.c" "flash_ops.c" "spi_flash_wrap.c"
"esp_mspi_align/esp_mspi_align.c"
"mspi_mem_barrier/mspi_mem_barrier.c")
# MSPI0 Octal flash init
if(CONFIG_SOC_SPI_MEM_SUPPORT_FLASH_OPI_MODE)
@@ -69,13 +76,18 @@ endif()
set(include_dirs include
"mspi_timing_tuning/include"
"mspi_timing_tuning/tuning_scheme_impl/include"
"mspi_intr/include")
"mspi_intr/include"
"esp_mspi_align/include"
"mspi_mem_barrier/include")
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/${target}")
list(APPEND include_dirs "${target}")
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/${target}/include")
list(APPEND include_dirs "${target}/include")
endif()
set(ldfragments linker.lf)
set(ldfragments "")
if(NOT CONFIG_APP_BUILD_TYPE_PURE_RAM_APP)
list(APPEND ldfragments linker.lf)
endif()
idf_component_register(SRCS "${srcs}"
REQUIRES ${requires}
@@ -90,7 +102,7 @@ if(NOT non_os_build AND NOT CONFIG_APP_BUILD_TYPE_PURE_RAM_APP)
# esp_mspi_get_io() queries esp_psram_io_get_cs_io() for the PSRAM CS pin
idf_component_optional_requires(PRIVATE esp_psram)
endif()
# Force linking init_flash_os ESP_SYSTEM_INIT_FN to ensure it's not discarded by linker
# Force linking init_flash_dpd ESP_SYSTEM_INIT_FN to ensure it's not discarded by linker
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u esp_mspi_flash_ops_include_func")
endif()
+30 -26
View File
@@ -1,38 +1,42 @@
[mapping:esp_mspi]
archive: libesp_mspi.a
entries:
if APP_BUILD_TYPE_PURE_RAM_APP = n:
flash_brownout_hook (noflash)
flash_brownout_hook (noflash)
if SPI_FLASH_PLACE_FUNCTIONS_IN_IRAM = y:
spi_flash_wrap (noflash)
if SPI_FLASH_PLACE_FUNCTIONS_IN_IRAM = y:
spi_flash_wrap (noflash)
if ESPTOOLPY_OCT_FLASH = y || ESPTOOLPY_FLASH_MODE_AUTO_DETECT = y:
spi_flash_oct_flash_init (noflash)
if ESPTOOLPY_OCT_FLASH = y || ESPTOOLPY_FLASH_MODE_AUTO_DETECT = y:
spi_flash_oct_flash_init (noflash)
if SPI_FLASH_HPM_ON = y:
spi_flash_hpm_enable (noflash)
if SPI_FLASH_HPM_ON = y:
spi_flash_hpm_enable (noflash)
if ESP_SLEEP_SET_FLASH_DPD = y:
spi_flash_dpd_enable (noflash)
flash_ops: dpd_enter_func (noflash)
flash_ops: dpd_exit_func (noflash)
if ESP_SLEEP_SET_FLASH_DPD = y:
spi_flash_dpd_enable (noflash)
flash_ops: dpd_enter_func (noflash)
flash_ops: dpd_exit_func (noflash)
if SOC_GPIO_NEED_SOFT_ISOLATE_DURING_PD = y:
flash_ops: esp_mspi_get_io (noflash)
flash_ops: s_mspi_io_num_default (noflash)
if SOC_GPIO_NEED_SOFT_ISOLATE_DURING_PD = y:
flash_ops: esp_mspi_get_io (noflash)
flash_ops: s_mspi_io_num_default (noflash)
[mapping:esp_mspi_align]
archive: libesp_mspi.a
entries:
esp_mspi_align:esp_mspi_get_alignment (noflash)
esp_mspi_align:esp_mspi_buffer_alignment_satisfied (noflash)
[mapping:mspi_timing_tuning_driver]
archive: libesp_mspi.a
entries:
if APP_BUILD_TYPE_PURE_RAM_APP = n:
mspi_timing_tuning (noflash)
if SOC_MEMSPI_TIMING_TUNING_BY_MSPI_DELAY = y:
mspi_timing_by_mspi_delay (noflash)
mspi_timing_config (noflash)
if SOC_MEMSPI_TIMING_TUNING_BY_DQS = y:
mspi_timing_by_dqs (noflash)
if SOC_MEMSPI_TIMING_TUNING_BY_FLASH_DELAY = y:
mspi_timing_by_flash_delay (noflash)
if SOC_MEMSPI_TIMING_TUNING_BY_DQS = y || SOC_MEMSPI_TIMING_TUNING_BY_FLASH_DELAY = y:
mspi_timing_config (noflash)
mspi_timing_tuning (noflash)
if SOC_MEMSPI_TIMING_TUNING_BY_MSPI_DELAY = y:
mspi_timing_by_mspi_delay (noflash)
mspi_timing_config (noflash)
if SOC_MEMSPI_TIMING_TUNING_BY_DQS = y:
mspi_timing_by_dqs (noflash)
if SOC_MEMSPI_TIMING_TUNING_BY_FLASH_DELAY = y:
mspi_timing_by_flash_delay (noflash)
if SOC_MEMSPI_TIMING_TUNING_BY_DQS = y || SOC_MEMSPI_TIMING_TUNING_BY_FLASH_DELAY = y:
mspi_timing_config (noflash)
+3 -1
View File
@@ -34,7 +34,8 @@ endif()
if(NOT ${IDF_TARGET} STREQUAL "linux")
set(priv_requires soc esp_hw_support)
if(NOT BOOTLOADER_BUILD)
list(APPEND priv_requires esp_pm esp_driver_dma)
# esp_mspi provides esp_mspi_align, used by the AES and SHA DMA ports
list(APPEND priv_requires esp_pm esp_driver_dma esp_mspi)
set(requires esp_security esp_hal_security)
endif()
endif()
@@ -374,6 +375,7 @@ if((SHA_PERIPHERAL_TYPE STREQUAL "core" AND CONFIG_SOC_SHA_SUPPORT_DMA) OR AES_P
target_link_libraries(builtin PRIVATE idf::esp_hw_support)
target_link_libraries(tfpsacrypto PRIVATE idf::esp_mm)
target_link_libraries(builtin PRIVATE idf::esp_mm)
target_link_libraries(tfpsacrypto PRIVATE idf::esp_mspi)
if(CONFIG_SOC_SHA_GDMA OR CONFIG_SOC_AES_GDMA)
if(CONFIG_SOC_AXI_DMA_EXT_MEM_ENC_ALIGNMENT)
target_link_libraries(tfpsacrypto PRIVATE idf::bootloader_support)
@@ -55,7 +55,8 @@ g1_g0_components = g1_g0_components_base + get_all_esp_hal_components()
expected_dep_violations = {
'esp_system': ['esp_timer', 'bootloader_support', 'esp_pm'],
'esp_hw_support': ['efuse', 'bootloader_support', 'esp_driver_gpio', 'esp_timer', 'esp_pm'],
'esp_mspi': ['bootloader_support'],
# efuse: esp_mspi_align queries the flash encryption state to derive MSPI buffer alignment
'esp_mspi': ['bootloader_support', 'efuse'],
'cxx': ['pthread'],
}