1idf_build_get_property(target IDF_TARGET) 2 3set(includes "include") 4 5set(priv_requires heap spi_flash esp_mm) 6if(${target} STREQUAL "esp32") 7 list(APPEND priv_requires bootloader_support) 8 # [refactor-todo]: requires "driver" for `spicommon_periph_claim` 9 list(APPEND priv_requires driver) 10endif() 11 12set(srcs) 13 14if(CONFIG_SPIRAM) 15 list(APPEND srcs "esp_psram.c" 16 "mmu_psram_flash.c") 17 18 if(${target} STREQUAL "esp32") 19 list(APPEND srcs "esp32/esp_psram_extram_cache.c" 20 "esp32/esp_himem.c") 21 endif() 22 23 if(CONFIG_SPIRAM_MODE_QUAD) 24 list(APPEND srcs "${target}/esp_psram_impl_quad.c") 25 elseif(CONFIG_SPIRAM_MODE_OCT) 26 list(APPEND srcs "${target}/esp_psram_impl_octal.c") 27 endif() 28endif() 29 30idf_component_register(SRCS ${srcs} 31 INCLUDE_DIRS ${includes} 32 PRIV_REQUIRES ${priv_requires} 33 LDFRAGMENTS linker.lf) 34 35if(CONFIG_IDF_TARGET_ESP32 AND CONFIG_SPIRAM_CACHE_WORKAROUND AND NOT BOOTLOADER_BUILD) 36 # Note: Adding as a PUBLIC compile option here causes this option to propagate to all 37 # components that depend on esp_psram. 38 # 39 # To handle some corner cases, the same flag is set in project_include.cmake 40 target_compile_options(${COMPONENT_LIB} PUBLIC -mfix-esp32-psram-cache-issue) 41 # also, make sure we link with this option so correct toolchain libs are pulled in 42 target_link_libraries(${COMPONENT_LIB} PUBLIC -mfix-esp32-psram-cache-issue) 43 # set strategy selected 44 # note that we don't need to set link options as the library linked is independent of this 45 if(CONFIG_SPIRAM_CACHE_WORKAROUND_STRATEGY_DUPLDST) 46 target_compile_options(${COMPONENT_LIB} PUBLIC -mfix-esp32-psram-cache-strategy=dupldst) 47 target_link_libraries(${COMPONENT_LIB} PUBLIC -mfix-esp32-psram-cache-strategy=dupldst) 48 endif() 49 if(CONFIG_SPIRAM_CACHE_WORKAROUND_STRATEGY_MEMW) 50 target_compile_options(${COMPONENT_LIB} PUBLIC -mfix-esp32-psram-cache-strategy=memw) 51 target_link_libraries(${COMPONENT_LIB} PUBLIC -mfix-esp32-psram-cache-strategy=memw) 52 endif() 53 if(CONFIG_SPIRAM_CACHE_WORKAROUND_STRATEGY_NOPS) 54 target_compile_options(${COMPONENT_LIB} PUBLIC -mfix-esp32-psram-cache-strategy=nops) 55 target_link_libraries(${COMPONENT_LIB} PUBLIC -mfix-esp32-psram-cache-strategy=nops) 56 endif() 57endif() 58