1idf_build_get_property(target IDF_TARGET) 2if(${target} STREQUAL "linux") 3 idf_component_register(INCLUDE_DIRS include 4 PRIV_INCLUDE_DIRS include/spi_flash) 5 return() 6endif() 7 8if(BOOTLOADER_BUILD OR CONFIG_APP_BUILD_TYPE_PURE_RAM_APP) 9 set(srcs "spi_flash_wrap.c") 10 set(priv_requires bootloader_support soc) 11else() 12 set(srcs "flash_brownout_hook.c") 13 14 if(CONFIG_SOC_SPI_MEM_SUPPORT_OPI_MODE) 15 list(APPEND srcs "${target}/spi_flash_oct_flash_init.c") 16 endif() 17 18 if(CONFIG_SPI_FLASH_HPM_ON) 19 list(APPEND srcs 20 "spi_flash_hpm_enable.c") 21 endif() 22 23 # New implementation after IDF v4.0 24 list(APPEND srcs 25 "spi_flash_chip_drivers.c" 26 "spi_flash_chip_generic.c" 27 "spi_flash_chip_issi.c" 28 "spi_flash_chip_mxic.c" 29 "spi_flash_chip_gd.c" 30 "spi_flash_chip_winbond.c" 31 "spi_flash_chip_boya.c" 32 "spi_flash_chip_mxic_opi.c" 33 "spi_flash_chip_th.c" 34 "memspi_host_driver.c") 35 36 set(cache_srcs 37 "cache_utils.c" 38 "flash_mmap.c" 39 "flash_ops.c" 40 "spi_flash_wrap.c" 41 ) 42 43 list(APPEND cache_srcs 44 "esp_flash_api.c" 45 "esp_flash_spi_init.c" 46 "spi_flash_os_func_app.c" 47 "spi_flash_os_func_noos.c") 48 49 list(APPEND srcs ${cache_srcs}) 50 set(priv_requires bootloader_support app_update soc driver esp_mm) 51endif() 52 53idf_component_register(SRCS "${srcs}" 54 REQUIRES hal 55 PRIV_REQUIRES "${priv_requires}" 56 INCLUDE_DIRS include 57 PRIV_INCLUDE_DIRS include/spi_flash 58 LDFRAGMENTS linker.lf) 59 60# Avoid cache miss by unexpected inlineing when built by -Os 61set_source_files_properties(${cache_srcs} PROPERTIES COMPILE_FLAGS "-fno-inline-functions") 62if(CMAKE_C_COMPILER_ID MATCHES "GNU") 63 # These flags are GCC specific 64 set_property(SOURCE ${cache_srcs} APPEND_STRING PROPERTY COMPILE_FLAGS 65 " -fno-inline-small-functions -fno-inline-functions-called-once") 66endif() 67 68if(NOT BOOTLOADER_BUILD AND NOT CONFIG_APP_BUILD_TYPE_PURE_RAM_APP) 69 if(CONFIG_SPIRAM) 70 # [refactor-todo]: requires "esp_psram" for few MMU usages in `flash_mmap.c` 71 # will be replaced with MMU requirements 72 idf_component_optional_requires(PRIVATE esp_psram) 73 endif() 74 target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") 75endif() 76