CMakeLists.txt 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. idf_build_get_property(target IDF_TARGET)
  2. set(include_dirs "include" "include/${target}")
  3. set(private_required_comp "")
  4. set(sources "")
  5. if(target STREQUAL "linux")
  6. list(APPEND sources "${target}/esp_rom_sys.c"
  7. "${target}/esp_rom_crc.c"
  8. "${target}/esp_rom_md5.c"
  9. "${target}/esp_rom_efuse.c")
  10. else()
  11. list(APPEND include_dirs "${target}")
  12. list(APPEND sources "patches/esp_rom_crc.c"
  13. "patches/esp_rom_sys.c"
  14. "patches/esp_rom_uart.c"
  15. "patches/esp_rom_tjpgd.c")
  16. list(APPEND private_required_comp soc hal)
  17. endif()
  18. if(CONFIG_IDF_TARGET_ARCH_XTENSA)
  19. list(APPEND sources "patches/esp_rom_longjmp.S")
  20. endif()
  21. idf_component_register(SRCS ${sources}
  22. INCLUDE_DIRS ${include_dirs}
  23. PRIV_REQUIRES ${private_required_comp})
  24. # Append a target linker script at the target-specific path,
  25. # only the 'name' part is different for each script
  26. function(rom_linker_script name)
  27. target_linker_script(${COMPONENT_LIB} INTERFACE "${target}/ld/${target}.rom.${name}.ld")
  28. endfunction()
  29. if(target STREQUAL "linux")
  30. # We need to disable some warnings due to the ROM code's printf implementation
  31. if(${CMAKE_CXX_COMPILER_VERSION} GREATER "7.0.0") # TODO: clang compatibility
  32. target_compile_options(${COMPONENT_LIB} PUBLIC -Wimplicit-fallthrough=0 -Wno-shift-count-overflow)
  33. endif()
  34. else()
  35. target_linker_script(${COMPONENT_LIB} INTERFACE "${target}/ld/${target}.rom.ld")
  36. rom_linker_script("api")
  37. rom_linker_script("libgcc")
  38. endif()
  39. if(BOOTLOADER_BUILD)
  40. if(target STREQUAL "esp32")
  41. rom_linker_script("newlib-funcs")
  42. if(NOT CONFIG_SPI_FLASH_ROM_DRIVER_PATCH)
  43. rom_linker_script("spiflash")
  44. endif()
  45. if(CONFIG_ESP32_REV_MIN_3)
  46. rom_linker_script("eco3")
  47. endif()
  48. elseif(target STREQUAL "esp32s2")
  49. rom_linker_script("newlib-funcs")
  50. rom_linker_script("spiflash")
  51. elseif(target STREQUAL "esp32s3")
  52. rom_linker_script("newlib")
  53. elseif(target STREQUAL "esp32c3")
  54. rom_linker_script("newlib")
  55. elseif(target STREQUAL "esp32h2")
  56. rom_linker_script("newlib")
  57. endif()
  58. else() # Regular app build
  59. if(target STREQUAL "esp32")
  60. rom_linker_script("newlib-data")
  61. rom_linker_script("syscalls")
  62. if(NOT CONFIG_SPIRAM_CACHE_WORKAROUND)
  63. rom_linker_script("newlib-funcs")
  64. if(NOT CONFIG_SDK_TOOLCHAIN_SUPPORTS_TIME_WIDE_64_BITS)
  65. # If SDK_TOOLCHAIN_SUPPORTS_TIME_WIDE_64_BITS option is defined
  66. # then all time functions from the ROM memory will not be linked.
  67. # Instead, those functions can be used from the toolchain by ESP-IDF.
  68. rom_linker_script("newlib-time")
  69. endif()
  70. # Include in newlib nano from ROM only if SPIRAM cache workaround is disabled
  71. if(CONFIG_NEWLIB_NANO_FORMAT)
  72. rom_linker_script("newlib-nano")
  73. endif()
  74. endif()
  75. if(NOT CONFIG_SPI_FLASH_ROM_DRIVER_PATCH)
  76. rom_linker_script("spiflash")
  77. endif()
  78. if(CONFIG_ESP32_REV_MIN_3)
  79. rom_linker_script("eco3")
  80. endif()
  81. elseif(target STREQUAL "esp32s2")
  82. rom_linker_script("newlib-funcs")
  83. rom_linker_script("newlib-data")
  84. rom_linker_script("spiflash")
  85. if(CONFIG_NEWLIB_NANO_FORMAT)
  86. rom_linker_script("newlib-nano")
  87. endif()
  88. # descirptors used by ROM code
  89. target_sources(${COMPONENT_LIB} PRIVATE "esp32s2/usb_descriptors.c")
  90. elseif(target STREQUAL "esp32s3")
  91. rom_linker_script("newlib")
  92. rom_linker_script("version")
  93. if(CONFIG_NEWLIB_NANO_FORMAT)
  94. rom_linker_script("newlib-nano")
  95. endif()
  96. elseif(target STREQUAL "esp32c3")
  97. rom_linker_script("newlib")
  98. rom_linker_script("version")
  99. if(CONFIG_NEWLIB_NANO_FORMAT)
  100. rom_linker_script("newlib-nano")
  101. endif()
  102. if(CONFIG_ESP32C3_REV_MIN_3)
  103. rom_linker_script("eco3")
  104. endif()
  105. elseif(target STREQUAL "esp32h2")
  106. rom_linker_script("newlib")
  107. rom_linker_script("version")
  108. if(CONFIG_NEWLIB_NANO_FORMAT)
  109. rom_linker_script("newlib-nano")
  110. endif()
  111. endif()
  112. if(CONFIG_IDF_TARGET_ARCH_XTENSA)
  113. target_link_libraries(${COMPONENT_LIB} INTERFACE "-Wl,--wrap=longjmp")
  114. endif()
  115. endif()
  116. if(target STREQUAL "esp32s2")
  117. target_sources(${COMPONENT_LIB} PRIVATE "esp32s2/usb_descriptors.c")
  118. endif()