CMakeLists.txt 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. idf_build_get_property(target IDF_TARGET)
  2. # On Linux, there is currently no HAL, hence this simple component registration
  3. if(${target} STREQUAL "linux")
  4. idf_component_register()
  5. return()
  6. endif()
  7. set(srcs "mpu_hal.c"
  8. "efuse_hal.c"
  9. "${target}/efuse_hal.c")
  10. set(includes "${target}/include" "include" "platform_port/include")
  11. if(NOT CONFIG_HAL_WDT_USE_ROM_IMPL)
  12. list(APPEND srcs "wdt_hal_iram.c")
  13. endif()
  14. if(NOT CONFIG_APP_BUILD_TYPE_PURE_RAM_APP)
  15. list(APPEND srcs "mmu_hal.c")
  16. # We wrap Cache ROM APIs as Cache HAL APIs for: 1. internal ram ; 2. unified APIs
  17. # ESP32 cache structure / ROM APIs are different and we have a patch `cache_hal_esp32.c` for it.
  18. if(${target} STREQUAL "esp32")
  19. list(APPEND srcs "esp32/cache_hal_esp32.c")
  20. else()
  21. list(APPEND srcs "cache_hal.c")
  22. endif()
  23. endif()
  24. if(CONFIG_SOC_LP_TIMER_SUPPORTED)
  25. list(APPEND srcs "lp_timer_hal.c")
  26. endif()
  27. if(NOT BOOTLOADER_BUILD)
  28. list(APPEND srcs
  29. "rtc_io_hal.c"
  30. "gpio_hal.c"
  31. "uart_hal.c"
  32. "uart_hal_iram.c")
  33. if(NOT CONFIG_APP_BUILD_TYPE_PURE_RAM_APP)
  34. list(APPEND srcs
  35. "spi_flash_hal.c"
  36. "spi_flash_hal_iram.c"
  37. )
  38. if(CONFIG_SOC_FLASH_ENC_SUPPORTED)
  39. list(APPEND srcs "spi_flash_encrypt_hal_iram.c")
  40. endif()
  41. endif()
  42. if(CONFIG_SOC_CLK_TREE_SUPPORTED)
  43. list(APPEND srcs "${target}/clk_tree_hal.c")
  44. endif()
  45. if(CONFIG_SOC_SYSTIMER_SUPPORTED AND NOT CONFIG_HAL_SYSTIMER_USE_ROM_IMPL)
  46. list(APPEND srcs "systimer_hal.c")
  47. endif()
  48. if(CONFIG_SOC_GPTIMER_SUPPORTED)
  49. list(APPEND srcs "timer_hal.c")
  50. endif()
  51. if(CONFIG_SOC_LEDC_SUPPORTED)
  52. list(APPEND srcs "ledc_hal.c" "ledc_hal_iram.c")
  53. endif()
  54. if(CONFIG_SOC_I2C_SUPPORTED)
  55. list(APPEND srcs "i2c_hal.c" "i2c_hal_iram.c")
  56. endif()
  57. if(CONFIG_SOC_RMT_SUPPORTED)
  58. list(APPEND srcs "rmt_hal.c")
  59. endif()
  60. if(CONFIG_SOC_PCNT_SUPPORTED)
  61. list(APPEND srcs "pcnt_hal.c")
  62. endif()
  63. if(CONFIG_SOC_MCPWM_SUPPORTED)
  64. list(APPEND srcs "mcpwm_hal.c")
  65. endif()
  66. if(CONFIG_SOC_TWAI_SUPPORTED)
  67. list(APPEND srcs "twai_hal.c" "twai_hal_iram.c")
  68. endif()
  69. if(CONFIG_SOC_GDMA_SUPPORTED)
  70. list(APPEND srcs "gdma_hal_top.c")
  71. endif()
  72. if(CONFIG_SOC_AHB_GDMA_VERSION EQUAL 1)
  73. list(APPEND srcs "gdma_hal_ahb_v1.c")
  74. endif()
  75. if(CONFIG_SOC_AHB_GDMA_VERSION EQUAL 2)
  76. list(APPEND srcs "gdma_hal_ahb_v2.c")
  77. endif()
  78. if(CONFIG_SOC_AXI_GDMA_SUPPORTED)
  79. list(APPEND srcs "gdma_hal_axi.c")
  80. endif()
  81. if(CONFIG_SOC_I2S_SUPPORTED)
  82. list(APPEND srcs "i2s_hal.c")
  83. endif()
  84. if(CONFIG_SOC_SDM_SUPPORTED)
  85. list(APPEND srcs "sdm_hal.c")
  86. endif()
  87. if(CONFIG_ETH_USE_ESP32_EMAC)
  88. list(APPEND srcs "emac_hal.c")
  89. endif()
  90. if(CONFIG_SOC_ETM_SUPPORTED)
  91. list(APPEND srcs "etm_hal.c")
  92. endif()
  93. if(CONFIG_SOC_PARLIO_SUPPORTED)
  94. list(APPEND srcs "parlio_hal.c")
  95. endif()
  96. if(CONFIG_SOC_ADC_SUPPORTED)
  97. list(APPEND srcs "adc_hal_common.c" "adc_oneshot_hal.c")
  98. endif()
  99. if(CONFIG_SOC_ADC_DMA_SUPPORTED)
  100. list(APPEND srcs "adc_hal.c")
  101. endif()
  102. if(CONFIG_SOC_LCDCAM_SUPPORTED)
  103. list(APPEND srcs "lcd_hal.c")
  104. endif()
  105. if(CONFIG_SOC_ECC_SUPPORTED)
  106. list(APPEND srcs "ecc_hal.c")
  107. endif()
  108. if(CONFIG_SOC_ECDSA_SUPPORTED)
  109. list(APPEND srcs "ecdsa_hal.c")
  110. endif()
  111. if(CONFIG_SOC_MPI_SUPPORTED)
  112. list(APPEND srcs "mpi_hal.c")
  113. endif()
  114. if(CONFIG_SOC_SHA_SUPPORTED)
  115. list(APPEND srcs "sha_hal.c")
  116. endif()
  117. if(CONFIG_SOC_AES_SUPPORTED)
  118. list(APPEND srcs "aes_hal.c")
  119. endif()
  120. if(CONFIG_SOC_MODEM_CLOCK_IS_INDEPENDENT)
  121. list(APPEND srcs "${target}/modem_clock_hal.c")
  122. endif()
  123. if(CONFIG_SOC_PAU_SUPPORTED)
  124. list(APPEND srcs "${target}/pau_hal.c")
  125. endif()
  126. if(CONFIG_SOC_BOD_SUPPORTED)
  127. list(APPEND srcs "brownout_hal.c")
  128. endif()
  129. if(CONFIG_SOC_GPSPI_SUPPORTED)
  130. list(APPEND srcs
  131. "spi_hal.c"
  132. "spi_hal_iram.c"
  133. "spi_slave_hal.c"
  134. "spi_slave_hal_iram.c")
  135. endif()
  136. if(CONFIG_SOC_SPI_SUPPORT_SLAVE_HD_VER2)
  137. list(APPEND srcs "spi_slave_hd_hal.c")
  138. endif()
  139. if(CONFIG_SOC_GPSPI_SUPPORTED AND NOT CONFIG_IDF_TARGET_ESP32)
  140. list(APPEND srcs "spi_flash_hal_gpspi.c")
  141. endif()
  142. if(CONFIG_SOC_SDIO_SLAVE_SUPPORTED)
  143. list(APPEND srcs "sdio_slave_hal.c")
  144. endif()
  145. if(CONFIG_SOC_PMU_SUPPORTED)
  146. list(APPEND srcs "${target}/pmu_hal.c")
  147. endif()
  148. if(CONFIG_SOC_APM_SUPPORTED)
  149. list(APPEND srcs "apm_hal.c")
  150. endif()
  151. if(CONFIG_SOC_HMAC_SUPPORTED AND NOT CONFIG_IDF_TARGET_ESP32S2)
  152. # For ESP32-S2 we do not have HMAC HAL layer implementation yet
  153. list(APPEND srcs "hmac_hal.c")
  154. endif()
  155. if(CONFIG_SOC_DIG_SIGN_SUPPORTED AND NOT CONFIG_IDF_TARGET_ESP32S2)
  156. # For ESP32-S2 we do not have DS HAL layer implementation yet
  157. list(APPEND srcs "ds_hal.c")
  158. endif()
  159. if(${target} STREQUAL "esp32")
  160. list(APPEND srcs
  161. "touch_sensor_hal.c"
  162. "esp32/touch_sensor_hal.c"
  163. "esp32/gpio_hal_workaround.c")
  164. endif()
  165. if(${target} STREQUAL "esp32s2")
  166. list(APPEND srcs
  167. "touch_sensor_hal.c"
  168. "usb_hal.c"
  169. "usb_phy_hal.c"
  170. "xt_wdt_hal.c"
  171. "esp32s2/cp_dma_hal.c"
  172. "esp32s2/touch_sensor_hal.c"
  173. "usb_dwc_hal.c")
  174. endif()
  175. if(${target} STREQUAL "esp32s3")
  176. list(APPEND srcs
  177. "touch_sensor_hal.c"
  178. "usb_hal.c"
  179. "usb_phy_hal.c"
  180. "xt_wdt_hal.c"
  181. "esp32s3/touch_sensor_hal.c"
  182. "esp32s3/rtc_cntl_hal.c"
  183. "usb_dwc_hal.c")
  184. endif()
  185. if(${target} STREQUAL "esp32c3")
  186. list(APPEND srcs
  187. "xt_wdt_hal.c"
  188. "esp32c3/rtc_cntl_hal.c")
  189. endif()
  190. if(${target} STREQUAL "esp32c2")
  191. list(APPEND srcs
  192. "esp32c2/rtc_cntl_hal.c")
  193. endif()
  194. if(${target} STREQUAL "esp32h2")
  195. list(REMOVE_ITEM srcs
  196. "esp32h2/rtc_cntl_hal.c"
  197. )
  198. endif()
  199. endif()
  200. idf_component_register(SRCS ${srcs}
  201. INCLUDE_DIRS ${includes}
  202. PRIV_INCLUDE_DIRS ${priv_include}
  203. REQUIRES soc esp_rom
  204. LDFRAGMENTS linker.lf)
  205. target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
  206. if(CONFIG_HAL_DEFAULT_ASSERTION_LEVEL EQUAL 1)
  207. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u abort")
  208. elseif(CONFIG_HAL_DEFAULT_ASSERTION_LEVEL EQUAL 2)
  209. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u __assert_func")
  210. endif()