CMakeLists.txt 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. idf_build_get_property(idf_target IDF_TARGET)
  2. if(CONFIG_ESP32_NO_BLOBS OR CONFIG_ESP32S2_NO_BLOBS)
  3. set(link_binary_libs 0)
  4. set(ldfragments)
  5. else()
  6. set(link_binary_libs 1)
  7. set(ldfragments "linker.lf")
  8. endif()
  9. if(IDF_TARGET_ESP32)
  10. # dport workaround headers are in esp32 component
  11. set(extra_priv_requires esp32)
  12. else()
  13. set(extra_priv_requires)
  14. endif()
  15. idf_component_register(SRCS "src/coexist.c"
  16. "src/lib_printf.c"
  17. "src/mesh_event.c"
  18. "src/phy_init.c"
  19. "src/smartconfig.c"
  20. "src/smartconfig_ack.c"
  21. "src/wifi_init.c"
  22. "src/wifi_default.c"
  23. "src/wifi_netif.c"
  24. "${idf_target}/esp_adapter.c"
  25. INCLUDE_DIRS "include" "${idf_target}/include"
  26. PRIV_REQUIRES wpa_supplicant nvs_flash esp_netif driver ${extra_priv_requires}
  27. REQUIRES esp_event
  28. LDFRAGMENTS "${ldfragments}")
  29. idf_build_get_property(build_dir BUILD_DIR)
  30. # ToDo: Rename esp32s2beta to esp32s2 next time update wifi lib
  31. set(target_name "${idf_target}")
  32. target_link_libraries(${COMPONENT_LIB} PUBLIC "-L ${CMAKE_CURRENT_SOURCE_DIR}/lib/${target_name}")
  33. if(link_binary_libs)
  34. set(phy phy)
  35. set(blobs coexist core espnow mesh net80211 pp rtc smartconfig ${phy})
  36. foreach(blob ${blobs})
  37. add_library(${blob} STATIC IMPORTED)
  38. set_property(TARGET ${blob} PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/lib/${target_name}/lib${blob}.a)
  39. target_link_libraries(${COMPONENT_LIB} PUBLIC ${blob})
  40. foreach(_blob ${blobs})
  41. if(NOT _blob STREQUAL ${blob})
  42. set_property(TARGET ${blob} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${_blob})
  43. endif()
  44. endforeach()
  45. set_property(TARGET ${blob} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${COMPONENT_LIB})
  46. endforeach()
  47. endif()
  48. if(CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION)
  49. idf_component_get_property(esp_common_dir esp_common COMPONENT_DIR)
  50. partition_table_get_partition_info(phy_partition_offset "--partition-type data --partition-subtype phy" "offset")
  51. if(CONFIG_ESP32_SUPPORT_MULTIPLE_PHY_INIT_DATA_BIN)
  52. set(phy_init_data_bin "${CMAKE_CURRENT_SOURCE_DIR}/phy_multiple_init_data.bin")
  53. else()
  54. set(phy_init_data_bin "${build_dir}/phy_init_data.bin")
  55. # To get the phy_init_data.bin file, compile phy_init_data.h as a C file and then objcopy
  56. # the object file to a raw binary
  57. idf_build_get_property(config_dir CONFIG_DIR)
  58. add_custom_command(
  59. OUTPUT ${phy_init_data_bin}
  60. DEPENDS ${CMAKE_CURRENT_LIST_DIR}/${idf_target}/include/phy_init_data.h
  61. COMMAND ${CMAKE_C_COMPILER} -x c -c
  62. -I ${esp_common_dir}/include -I ${CMAKE_CURRENT_LIST_DIR}/include -I ${config_dir}
  63. -o phy_init_data.obj
  64. ${CMAKE_CURRENT_LIST_DIR}/${idf_target}/include/phy_init_data.h
  65. COMMAND ${CMAKE_OBJCOPY} -O binary phy_init_data.obj ${phy_init_data_bin}
  66. )
  67. add_custom_target(phy_init_data ALL DEPENDS ${phy_init_data_bin})
  68. add_dependencies(flash phy_init_data)
  69. idf_component_get_property(main_args esptool_py FLASH_ARGS)
  70. idf_component_get_property(sub_args esptool_py FLASH_SUB_ARGS)
  71. endif()
  72. set(phy_name "phy")
  73. esptool_py_flash_target(${phy_name}-flash "${main_args}" "${sub_args}")
  74. esptool_py_flash_target_image(${phy_name}-flash ${phy_name} "${phy_partition_offset}" "${phy_init_data_bin}")
  75. esptool_py_flash_target_image(flash ${phy_name} "${phy_partition_offset}" "${phy_init_data_bin}")
  76. endif()