CMakeLists.txt 2.6 KB

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