1idf_build_get_property(idf_target IDF_TARGET) 2 3set(srcs "src/phy_override.c" "src/lib_printf.c" "src/phy_common.c") 4 5if(CONFIG_APP_NO_BLOBS) 6 set(link_binary_libs 0) 7 set(ldfragments) 8else() 9 set(link_binary_libs 1) 10 set(ldfragments "linker.lf") 11endif() 12 13if(CONFIG_SOC_IEEE802154_BLE_ONLY) 14 list(APPEND srcs "src/phy_init_esp32hxx.c") 15else() 16 list(APPEND srcs "src/phy_init.c") 17endif() 18 19if(CONFIG_SOC_BT_SUPPORTED OR CONFIG_SOC_IEEE802154_SUPPORTED OR CONFIG_SOC_IEEE802154_BLE_ONLY) 20 list(APPEND srcs "src/btbb_init.c") 21endif() 22 23if(CONFIG_ESP_PHY_ENABLE_CERT_TEST) 24 list(APPEND srcs "src/phy_callback.c") 25endif() 26 27idf_build_get_property(build_dir BUILD_DIR) 28 29if(CONFIG_SOC_WIFI_SUPPORTED) 30if(CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN) 31 if(NOT EXISTS "${build_dir}/phy_multiple_init_data.bin") 32 file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/${idf_target}/phy_multiple_init_data.bin DESTINATION "${build_dir}") 33 endif() 34endif() 35 36if(CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN_EMBED) 37 set(embed_files "${build_dir}/phy_multiple_init_data.bin") 38endif() 39endif() 40 41# [refactor-todo]: requires "driver" component for periph_ctrl header file 42idf_component_register(SRCS "${srcs}" 43 INCLUDE_DIRS "include" "${idf_target}/include" 44 PRIV_REQUIRES nvs_flash driver efuse esp_timer esp_wifi 45 LDFRAGMENTS "${ldfragments}" 46 EMBED_FILES ${embed_files} 47 ) 48 49set(target_name "${idf_target}") 50target_link_directories(${COMPONENT_LIB} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/lib/${target_name}") 51 52# Override functions in PHY lib with the functions in 'phy_override.c' 53target_link_libraries(${COMPONENT_LIB} INTERFACE "-u include_esp_phy_override") 54 55if(link_binary_libs) 56 target_link_libraries(${COMPONENT_LIB} PUBLIC phy) 57 58 idf_component_get_property(esp_phy_lib esp_phy COMPONENT_LIB) 59 60 if(CONFIG_IDF_TARGET_ESP32) 61 target_link_libraries(${COMPONENT_LIB} PUBLIC rtc) 62 target_link_libraries(${COMPONENT_LIB} INTERFACE $<TARGET_FILE:${esp_phy_lib}> libphy.a librtc.a 63 $<TARGET_FILE:${esp_phy_lib}>) 64 elseif(CONFIG_IDF_TARGET_ESP32S2) 65 target_link_libraries(${COMPONENT_LIB} INTERFACE $<TARGET_FILE:${esp_phy_lib}> libphy.a 66 $<TARGET_FILE:${esp_phy_lib}>) 67 elseif(CONFIG_SOC_BT_SUPPORTED OR CONFIG_SOC_IEEE802154_SUPPORTED) 68 target_link_libraries(${COMPONENT_LIB} PUBLIC btbb) 69 target_link_libraries(${COMPONENT_LIB} INTERFACE $<TARGET_FILE:${esp_phy_lib}> libphy.a libbtbb.a 70 $<TARGET_FILE:${esp_phy_lib}>) 71 endif() 72 73 if(CONFIG_ESP_PHY_ENABLE_CERT_TEST) 74 target_link_libraries(${COMPONENT_LIB} INTERFACE $<TARGET_FILE:${esp_phy_lib}> libbttestmode.a 75 librfate.a librftest.a $<TARGET_FILE:${esp_phy_lib}>) 76 endif() 77endif() 78 79if(CONFIG_ESP_PHY_INIT_DATA_IN_PARTITION) 80 idf_component_get_property(esp_common_dir esp_common COMPONENT_DIR) 81 partition_table_get_partition_info(phy_partition_offset "--partition-type data --partition-subtype phy" "offset") 82 83 if(CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN) 84 set(phy_init_data_bin "${build_dir}/phy_multiple_init_data.bin") 85 if(CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN_EMBED) 86 set(COMPONENT_EMBED_FILES "${build_dir}/phy_multiple_init_data.bin") 87 endif() 88 else() 89 set(phy_init_data_bin "${build_dir}/phy_init_data.bin") 90 91 # To get the phy_init_data.bin file, compile phy_init_data.h as a C file and then objcopy 92 # the object file to a raw binary 93 idf_build_get_property(config_dir CONFIG_DIR) 94 add_custom_command( 95 OUTPUT ${phy_init_data_bin} 96 DEPENDS ${CMAKE_CURRENT_LIST_DIR}/${idf_target}/include/phy_init_data.h 97 COMMAND ${CMAKE_C_COMPILER} -x c -c 98 -I ${esp_common_dir}/include -I ${CMAKE_CURRENT_LIST_DIR}/include -I ${config_dir} 99 -o phy_init_data.obj 100 ${CMAKE_CURRENT_LIST_DIR}/${idf_target}/include/phy_init_data.h 101 COMMAND ${CMAKE_OBJCOPY} -O binary phy_init_data.obj ${phy_init_data_bin} 102 ) 103 add_custom_target(phy_init_data ALL DEPENDS ${phy_init_data_bin}) 104 add_dependencies(flash phy_init_data) 105 106 idf_component_get_property(main_args esptool_py FLASH_ARGS) 107 idf_component_get_property(sub_args esptool_py FLASH_SUB_ARGS) 108 endif() 109 110 set(phy_name "phy") 111 112 esptool_py_flash_target(${phy_name}-flash "${main_args}" "${sub_args}") 113 esptool_py_flash_target_image(${phy_name}-flash ${phy_name} "${phy_partition_offset}" "${phy_init_data_bin}") 114 esptool_py_flash_target_image(flash ${phy_name} "${phy_partition_offset}" "${phy_init_data_bin}") 115endif() 116