CMakeLists.txt 2.4 KB

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