CMakeLists.txt 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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 "esp_system.c"
  5. "port/soc/linux/reset_reason.c"
  6. "port/soc/linux/system_internal.c"
  7. "port/esp_system_linux.c"
  8. INCLUDE_DIRS "include")
  9. return()
  10. endif()
  11. set(srcs "esp_err.c")
  12. if(CONFIG_IDF_ENV_FPGA OR CONFIG_ESP_BRINGUP_BYPASS_CPU_CLK_SETTING)
  13. list(APPEND srcs "fpga_overrides.c")
  14. endif()
  15. if(BOOTLOADER_BUILD)
  16. # "_esp_error_check_failed()" requires spi_flash module
  17. # Bootloader relies on some Kconfig options defined in esp_system.
  18. idf_component_register(SRCS "${srcs}" REQUIRES spi_flash)
  19. else()
  20. list(APPEND srcs "crosscore_int.c"
  21. "esp_ipc.c"
  22. "esp_err.c"
  23. "freertos_hooks.c"
  24. "int_wdt.c"
  25. "panic.c"
  26. "esp_system.c"
  27. "startup.c"
  28. "system_time.c"
  29. "stack_check.c"
  30. "ubsan.c"
  31. "xt_wdt.c"
  32. "debug_stubs.c")
  33. if(CONFIG_ESP_TASK_WDT_EN)
  34. list(APPEND srcs "task_wdt/task_wdt.c")
  35. if(CONFIG_ESP_TASK_WDT_USE_ESP_TIMER)
  36. list(APPEND srcs "task_wdt/task_wdt_impl_esp_timer.c")
  37. else()
  38. list(APPEND srcs "task_wdt/task_wdt_impl_timergroup.c")
  39. endif()
  40. endif()
  41. if(CONFIG_ESP_SYSTEM_USE_EH_FRAME)
  42. list(APPEND srcs "eh_frame_parser.c")
  43. endif()
  44. if(CONFIG_SOC_SYSTIMER_SUPPORT_ETM)
  45. list(APPEND srcs "systick_etm.c")
  46. endif()
  47. if(CONFIG_ESP_SYSTEM_HW_STACK_GUARD)
  48. list(APPEND srcs "hw_stack_guard.c")
  49. endif()
  50. idf_component_register(SRCS "${srcs}"
  51. INCLUDE_DIRS include
  52. PRIV_REQUIRES spi_flash esp_timer esp_mm
  53. # [refactor-todo] requirements due to init code,
  54. # should be removable once using component init functions
  55. # link-time registration is used.
  56. # [refactor-todo] requires "esp_driver_spi" for headers:
  57. # - spi_common_internal.h
  58. # [refactor-todo] esp_partition required for virtual efuse
  59. # init code. Move to esp_efuse component.
  60. pthread bootloader_support efuse esp_driver_spi esp_partition
  61. LDFRAGMENTS "linker.lf" "app.lf")
  62. add_subdirectory(port)
  63. # After system initialization, `start_app` (and its other cores variant) is called.
  64. # This is provided by the user or from another component. Since we can't establish
  65. # dependency on what we don't know, force linker to not drop the symbol regardless
  66. # of link line order.
  67. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u start_app")
  68. if(NOT CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE)
  69. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u start_app_other_cores")
  70. endif()
  71. # Disable stack protection in files which are involved in initialization of that feature
  72. set_source_files_properties(
  73. "startup.c" "stack_check.c"
  74. PROPERTIES COMPILE_FLAGS
  75. -fno-stack-protector)
  76. include(${CMAKE_CURRENT_LIST_DIR}/ld/ld.cmake)
  77. endif()
  78. if(CONFIG_IDF_ENV_FPGA OR CONFIG_ESP_BRINGUP_BYPASS_CPU_CLK_SETTING)
  79. # Forces the linker to include fpga stubs from this component
  80. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u esp_common_include_fpga_overrides")
  81. endif()
  82. # Force linking UBSAN hooks. If UBSAN is not enabled, the hooks will ultimately be removed
  83. # due to -ffunction-sections -Wl,--gc-sections options.
  84. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u __ubsan_include")
  85. # [refactor-todo] requirements due to init code, should be removable
  86. # once link-time registration of component init functions is used.
  87. if(CONFIG_APPTRACE_ENABLE)
  88. idf_component_optional_requires(PRIVATE app_trace)
  89. endif()
  90. if(CONFIG_ESP_COREDUMP_ENABLE)
  91. idf_component_optional_requires(PRIVATE espcoredump)
  92. endif()
  93. # [refactor-todo] requirement from the panic handler,
  94. # need to introduce panic "event" concept to remove this dependency (IDF-2194)
  95. idf_component_optional_requires(PRIVATE esp_gdbstub)
  96. if(NOT CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT)
  97. idf_component_optional_requires(PRIVATE esp_app_format)
  98. endif()
  99. if(CONFIG_PM_ENABLE)
  100. idf_component_optional_requires(PRIVATE pm)
  101. endif()
  102. if(CONFIG_VFS_SUPPORT_IO)
  103. idf_component_optional_requires(PRIVATE vfs)
  104. endif()
  105. if(CONFIG_SW_COEXIST_ENABLE OR CONFIG_EXTERNAL_COEX_ENABLE)
  106. idf_component_optional_requires(PRIVATE esp_coex)
  107. endif()
  108. if(NOT BOOTLOADER_BUILD)
  109. if(CONFIG_SPIRAM)
  110. idf_component_optional_requires(PRIVATE esp_psram)
  111. endif()
  112. endif()