CMakeLists.txt 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. idf_build_get_property(target IDF_TARGET)
  2. # On Linux, we only support a few features, hence this simple component registration
  3. if(${target} STREQUAL "linux")
  4. idf_component_register(SRCS "port/linux/esp_random.c"
  5. "port/linux/chip_info.c"
  6. INCLUDE_DIRS "include")
  7. return()
  8. endif()
  9. set(requires soc)
  10. # only esp_hw_support/adc_share_hw_ctrl.c requires efuse component
  11. set(priv_requires efuse spi_flash bootloader_support)
  12. if(${target} STREQUAL "esp32c6")
  13. list(APPEND priv_requires hal)
  14. endif()
  15. set(srcs "cpu.c" "esp_memory_utils.c" "port/${IDF_TARGET}/cpu_region_protect.c")
  16. if(NOT BOOTLOADER_BUILD)
  17. list(APPEND srcs "esp_clk.c"
  18. "clk_ctrl_os.c"
  19. "hw_random.c"
  20. "intr_alloc.c"
  21. "mac_addr.c"
  22. "periph_ctrl.c"
  23. "revision.c"
  24. "rtc_module.c"
  25. "sleep_modes.c"
  26. "sleep_console.c"
  27. "sleep_gpio.c"
  28. "sleep_event.c"
  29. "sleep_modem.c"
  30. "regi2c_ctrl.c"
  31. "esp_gpio_reserve.c"
  32. "sar_periph_ctrl_common.c"
  33. "port/${target}/io_mux.c"
  34. "port/${target}/esp_clk_tree.c"
  35. "port/esp_clk_tree_common.c"
  36. "dma/esp_dma_utils.c")
  37. if(CONFIG_SOC_ADC_SUPPORTED)
  38. list(APPEND srcs "adc_share_hw_ctrl.c")
  39. endif()
  40. if(CONFIG_SOC_PM_SUPPORT_CPU_PD)
  41. list(APPEND srcs "sleep_cpu.c")
  42. endif()
  43. if(CONFIG_SOC_PAU_SUPPORTED)
  44. list(APPEND srcs "sleep_retention.c" "sleep_system_peripheral.c" "sleep_clock.c")
  45. endif()
  46. # [refactor-todo]
  47. list(APPEND priv_requires esp_driver_gpio # for GPIO and RTC (by sleep_gpio and sleep_modes)
  48. esp_timer
  49. esp_pm)
  50. list(APPEND priv_requires esp_mm)
  51. if(CONFIG_IDF_TARGET_ESP32 OR CONFIG_IDF_TARGET_ESP32S2)
  52. list(APPEND srcs "rtc_wdt.c")
  53. endif()
  54. if(CONFIG_SOC_GDMA_SUPPORTED)
  55. list(APPEND srcs "dma/gdma.c")
  56. endif()
  57. if(CONFIG_SOC_ASYNC_MEMCPY_SUPPORTED)
  58. list(APPEND srcs "dma/esp_async_memcpy.c")
  59. if(CONFIG_SOC_GDMA_SUPPORTED)
  60. list(APPEND srcs "dma/async_memcpy_gdma.c")
  61. endif() # CONFIG_SOC_GDMA_SUPPORTED
  62. if(CONFIG_SOC_CP_DMA_SUPPORTED)
  63. list(APPEND srcs "dma/async_memcpy_cp_dma.c")
  64. endif() # CONFIG_SOC_CP_DMA_SUPPORTED
  65. endif() # CONFIG_SOC_ASYNC_MEMCPY_SUPPORTED
  66. if(CONFIG_SOC_GDMA_SUPPORT_ETM)
  67. list(APPEND srcs "dma/gdma_etm.c")
  68. endif()
  69. if(CONFIG_SOC_SYSTIMER_SUPPORTED)
  70. list(APPEND srcs "port/${target}/systimer.c")
  71. endif()
  72. if(CONFIG_SOC_HMAC_SUPPORTED)
  73. list(APPEND srcs "esp_hmac.c")
  74. endif()
  75. if(CONFIG_SOC_ETM_SUPPORTED)
  76. list(APPEND srcs "esp_etm.c")
  77. endif()
  78. if(CONFIG_SOC_CRYPTO_DPA_PROTECTION_SUPPORTED)
  79. list(APPEND srcs "esp_dpa_protection.c")
  80. endif()
  81. if(CONFIG_SOC_DIG_SIGN_SUPPORTED)
  82. list(APPEND srcs "esp_ds.c")
  83. endif()
  84. if(CONFIG_SOC_PAU_SUPPORTED)
  85. list(APPEND srcs "port/pau_regdma.c"
  86. "port/regdma_link.c")
  87. endif()
  88. if(CONFIG_SOC_PM_CPU_RETENTION_BY_SW)
  89. list(APPEND srcs "sleep_cpu_asm.S")
  90. set_property(TARGET ${COMPONENT_LIB}
  91. APPEND PROPERTY INTERFACE_LINK_LIBRARIES "-u rv_core_critical_regs_save")
  92. set_property(TARGET ${COMPONENT_LIB}
  93. APPEND PROPERTY INTERFACE_LINK_LIBRARIES "-u rv_core_critical_regs_restore")
  94. endif()
  95. if(CONFIG_SOC_MODEM_CLOCK_IS_INDEPENDENT)
  96. list(APPEND srcs "modem_clock.c")
  97. endif()
  98. if(NOT CONFIG_APP_BUILD_TYPE_PURE_RAM_APP)
  99. list(APPEND srcs "mspi_timing_tuning.c" "mspi_timing_config.c")
  100. if(CONFIG_SOC_MEMSPI_TIMING_TUNING_BY_MSPI_DELAY)
  101. list(APPEND srcs "mspi_timing_by_mspi_delay.c")
  102. endif()
  103. endif()
  104. if(CONFIG_SOC_RTC_FAST_MEM_SUPPORTED)
  105. list(APPEND srcs "sleep_wake_stub.c")
  106. endif()
  107. if(CONFIG_SOC_GPIO_CLOCKOUT_BY_GPIO_MATRIX OR CONFIG_SOC_GPIO_CLOCKOUT_BY_IO_MUX)
  108. list(APPEND srcs "esp_clock_output.c")
  109. endif()
  110. if(CONFIG_IDF_TARGET_ESP32P4)
  111. list(REMOVE_ITEM srcs
  112. "sleep_cpu.c" # TODO: IDF-7528, IDF-7529
  113. "sleep_modes.c" # TODO: IDF-7528, IDF-7529
  114. "sleep_wake_stub.c" # TODO: IDF-7529
  115. "sleep_gpio.c" # TODO: IDF-7528, IDF-7529
  116. "port/esp_clk_tree_common.c" # TODO: IDF-7526
  117. )
  118. endif()
  119. else()
  120. # Requires "_esp_error_check_failed()" function
  121. list(APPEND priv_requires "esp_system")
  122. endif()
  123. idf_component_register(SRCS ${srcs}
  124. INCLUDE_DIRS include include/soc include/soc/${target}
  125. PRIV_INCLUDE_DIRS port/include include/esp_private
  126. REQUIRES ${requires}
  127. PRIV_REQUIRES "${priv_requires}"
  128. LDFRAGMENTS linker.lf dma/linker.lf)
  129. idf_build_get_property(target IDF_TARGET)
  130. add_subdirectory(port/${target})
  131. if(NOT BOOTLOADER_BUILD)
  132. if(CONFIG_SPIRAM)
  133. idf_component_optional_requires(PRIVATE esp_psram)
  134. endif()
  135. if(CONFIG_SOC_CRYPTO_DPA_PROTECTION_SUPPORTED)
  136. target_link_libraries(${COMPONENT_LIB} PRIVATE "-u esp_crypto_dpa_prot_include_impl")
  137. endif()
  138. endif()