CMakeLists.txt 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. if(BOOTLOADER_BUILD)
  2. # bootloader only needs FreeRTOS for config, not for anything else
  3. idf_component_register()
  4. return()
  5. endif()
  6. idf_build_get_property(target IDF_TARGET)
  7. if(CONFIG_IDF_TARGET_ARCH_XTENSA)
  8. set(srcs
  9. "port/xtensa/port.c"
  10. "port/xtensa/portasm.S"
  11. "port/xtensa/xtensa_context.S"
  12. "port/xtensa/xtensa_init.c"
  13. "port/xtensa/xtensa_overlay_os_hook.c"
  14. "port/xtensa/xtensa_vector_defaults.S"
  15. "port/xtensa/xtensa_vectors.S")
  16. set(include_dirs
  17. include
  18. include/esp_additions/freertos # For files with #include "FreeRTOSConfig.h"
  19. port/xtensa/include # For including arch-specific FreeRTOSConfig_arch.h in port/<arch>/include
  20. include/esp_additions) # For files with #include "freertos/FreeRTOSConfig.h"
  21. set(private_include_dirs
  22. port/xtensa/include/freertos
  23. port/xtensa
  24. port/priv_include
  25. .)
  26. elseif(CONFIG_IDF_TARGET_ARCH_RISCV)
  27. set(srcs
  28. "port/riscv/port.c"
  29. "port/riscv/portasm.S")
  30. set(include_dirs
  31. include
  32. include/esp_additions/freertos # For files with #include "FreeRTOSConfig.h"
  33. port/riscv/include # For including arch-specific FreeRTOSConfig_arch.h in port/<arch>/include
  34. include/esp_additions) # For files with #include "freertos/FreeRTOSConfig.h"
  35. set(private_include_dirs
  36. port/riscv/include/freertos
  37. port/riscv
  38. port/priv_include
  39. .)
  40. endif()
  41. list(APPEND srcs
  42. "esp_additions/task_snapshot.c"
  43. "port/port_common.c"
  44. "port/port_systick.c"
  45. "croutine.c"
  46. "event_groups.c"
  47. "list.c"
  48. "queue.c"
  49. "tasks.c"
  50. "timers.c"
  51. "stream_buffer.c"
  52. "FreeRTOS-openocd.c"
  53. "freertos_v8_compat.c")
  54. list(APPEND private_include_dirs
  55. "include/freertos")
  56. if(CONFIG_ESP32_IRAM_AS_8BIT_ACCESSIBLE_MEMORY)
  57. list(APPEND srcs "port/xtensa/xtensa_loadstore_handler.S")
  58. endif()
  59. # esp_timer is required by FreeRTOS because we use esp_tiemr_get_time() to do profiling
  60. # app_trace is required by FreeRTOS headers only when CONFIG_APPTRACE_SV_ENABLE=y,
  61. # REQUIRES can't depend on config options, so always require it.
  62. set(required_components app_trace esp_timer)
  63. idf_component_register(SRCS "${srcs}"
  64. INCLUDE_DIRS ${include_dirs}
  65. PRIV_INCLUDE_DIRS ${private_include_dirs}
  66. LDFRAGMENTS linker.lf
  67. REQUIRES ${required_components}
  68. PRIV_REQUIRES soc esp_pm)
  69. idf_component_get_property(COMPONENT_DIR freertos COMPONENT_DIR)
  70. idf_component_set_property(freertos ORIG_INCLUDE_PATH "${COMPONENT_DIR}/include/freertos/")
  71. if(CONFIG_FREERTOS_DEBUG_OCDAWARE)
  72. target_link_libraries(${COMPONENT_LIB} INTERFACE "-Wl,--undefined=uxTopUsedPriority")
  73. endif()
  74. set_source_files_properties(
  75. tasks.c
  76. event_groups.c
  77. timers.c
  78. queue.c
  79. stream_buffer.c
  80. PROPERTIES COMPILE_DEFINITIONS
  81. _ESP_FREERTOS_INTERNAL
  82. )
  83. # The freertos component provides the `start_app` and `start_app_other_cores`
  84. # if it is included in the build. It then calls `app_main`
  85. # from the main task created, which must be provided by the user.
  86. # Like for `start_app` and `start_app_other_cores`,
  87. # we can't establish dependency on what we don't yet know, so we force the
  88. # linker to not drop this symbol.
  89. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u app_main")