CMakeLists.txt 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. cmake_minimum_required(VERSION 3.15)
  2. if(BL_SDK_BASE)
  3. set(CONFIG_CHERRYUSB_DEVICE 1)
  4. set(CONFIG_CHERRYUSB_DEVICE_CDC_ACM 1)
  5. set(CONFIG_CHERRYUSB_DEVICE_HID 1)
  6. set(CONFIG_CHERRYUSB_DEVICE_MSC 1)
  7. set(CONFIG_CHERRYUSB_DEVICE_AUDIO 1)
  8. set(CONFIG_CHERRYUSB_DEVICE_VIDEO 1)
  9. set(CONFIG_CHERRYUSB_DEVICE_DCD "bl")
  10. set(CONFIG_CHERRYUSB_HOST 1)
  11. set(CONFIG_CHERRYUSB_HOST_CDC_ACM 1)
  12. set(CONFIG_CHERRYUSB_HOST_CDC_ECM 1)
  13. set(CONFIG_CHERRYUSB_HOST_CDC_NCM 1)
  14. set(CONFIG_CHERRYUSB_HOST_HID 1)
  15. set(CONFIG_CHERRYUSB_HOST_MSC 1)
  16. set(CONFIG_CHERRYUSB_HOST_VIDEO 1)
  17. set(CONFIG_CHERRYUSB_HOST_AUDIO 1)
  18. set(CONFIG_CHERRYUSB_HOST_CDC_RNDIS 1)
  19. set(CONFIG_CHERRYUSB_HOST_BLUETOOTH 1)
  20. set(CONFIG_CHERRYUSB_HOST_ASIX 1)
  21. set(CONFIG_CHERRYUSB_HOST_RTL8152 1)
  22. set(CONFIG_CHERRYUSB_HOST_CH34X 1)
  23. set(CONFIG_CHERRYUSB_HOST_CP210X 1)
  24. set(CONFIG_CHERRYUSB_HOST_FTDI 1)
  25. set(CONFIG_CHERRYUSB_HOST_PL2303 1)
  26. set(CONFIG_CHERRYUSB_OSAL "freertos")
  27. set(CONFIG_CHERRYUSB_HOST_HCD "ehci_bouffalo")
  28. include(${CMAKE_CURRENT_LIST_DIR}/cherryusb.cmake)
  29. sdk_generate_library(cherryusb)
  30. sdk_add_include_directories(${cherryusb_incs})
  31. sdk_library_add_sources(${cherryusb_srcs})
  32. sdk_library_add_sources(platform/none/usbh_lwip.c)
  33. elseif(HPM_SDK_BASE)
  34. set(CONFIG_CHERRYUSB_HOST 1)
  35. set(CONFIG_CHERRYUSB_HOST_CDC_ACM 1)
  36. set(CONFIG_CHERRYUSB_HOST_CDC_ECM 1)
  37. set(CONFIG_CHERRYUSB_HOST_CDC_NCM 1)
  38. set(CONFIG_CHERRYUSB_HOST_HID 1)
  39. set(CONFIG_CHERRYUSB_HOST_MSC 1)
  40. set(CONFIG_CHERRYUSB_HOST_VIDEO 1)
  41. set(CONFIG_CHERRYUSB_HOST_AUDIO 1)
  42. set(CONFIG_CHERRYUSB_HOST_CDC_RNDIS 1)
  43. # set(CONFIG_CHERRYUSB_HOST_BLUETOOTH 1)
  44. set(CONFIG_CHERRYUSB_HOST_ASIX 1)
  45. set(CONFIG_CHERRYUSB_HOST_RTL8152 1)
  46. set(CONFIG_CHERRYUSB_HOST_CH34X 1)
  47. set(CONFIG_CHERRYUSB_HOST_CP210X 1)
  48. set(CONFIG_CHERRYUSB_HOST_FTDI 1)
  49. set(CONFIG_CHERRYUSB_HOST_PL2303 1)
  50. set(CONFIG_CHERRYUSB_HOST_BL616 1)
  51. set(CONFIG_CHERRYUSB_OSAL "freertos")
  52. set(CONFIG_CHERRYUSB_HOST_HCD "ehci_hpm")
  53. include(${CMAKE_CURRENT_LIST_DIR}/cherryusb.cmake)
  54. sdk_inc(${cherryusb_incs})
  55. sdk_src(${cherryusb_srcs})
  56. sdk_src(platform/none/usbh_lwip.c)
  57. elseif(ESP_PLATFORM)
  58. set(CONFIG_CHERRYUSB_DEVICE_DCD "dwc2_esp")
  59. set(CONFIG_CHERRYUSB_HOST_HCD "dwc2_esp")
  60. set(CONFIG_CHERRYUSB_OSAL "idf")
  61. include(${CMAKE_CURRENT_LIST_DIR}/cherryusb.cmake)
  62. set(ldfragments "osal/idf/linker.lf")
  63. if(CONFIG_CHERRYUSB_HOST_CDC_ECM OR CONFIG_CHERRYUSB_HOST_CDC_RNDIS OR CONFIG_CHERRYUSB_HOST_CDC_NCM
  64. OR CONFIG_CHERRYUSB_HOST_ASIX OR CONFIG_CHERRYUSB_HOST_RTL8152 OR CONFIG_CHERRYUSB_HOST_BL616)
  65. list(APPEND cherryusb_srcs platform/none/usbh_lwip.c)
  66. idf_component_get_property(lwip lwip COMPONENT_LIB)
  67. target_compile_definitions(${lwip} PRIVATE "-DPBUF_POOL_BUFSIZE=1600")
  68. endif()
  69. idf_component_get_property(freertos_include freertos ORIG_INCLUDE_PATH)
  70. idf_component_register(SRCS ${cherryusb_srcs}
  71. INCLUDE_DIRS ${cherryusb_incs} ${freertos_include}
  72. PRIV_REQUIRES usb
  73. LDFRAGMENTS ${ldfragments}
  74. )
  75. if(CONFIG_CHERRYUSB_HOST)
  76. target_linker_script(${COMPONENT_LIB} INTERFACE "osal/idf/usbh_class_info.ld")
  77. # 强制链接器不删除符号
  78. if(CONFIG_CHERRYUSB_HOST_CDC_ACM)
  79. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u cdc_acm_class_info")
  80. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u cdc_data_class_info")
  81. endif()
  82. if(CONFIG_CHERRYUSB_HOST_HID)
  83. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u hid_custom_class_info")
  84. endif()
  85. if(CONFIG_CHERRYUSB_HOST_MSC)
  86. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u msc_class_info")
  87. endif()
  88. if(CONFIG_CHERRYUSB_HOST_CDC_ECM)
  89. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u cdc_ecm_class_info")
  90. endif()
  91. if(CONFIG_CHERRYUSB_HOST_CDC_RNDIS)
  92. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u rndis_class_info")
  93. endif()
  94. if(CONFIG_CHERRYUSB_HOST_CDC_NCM)
  95. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u cdc_ncm_class_info")
  96. endif()
  97. if(CONFIG_CHERRYUSB_HOST_VIDEO)
  98. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u video_ctrl_class_info")
  99. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u video_streaming_class_info")
  100. endif()
  101. if(CONFIG_CHERRYUSB_HOST_AUDIO)
  102. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u audio_ctrl_intf_class_info")
  103. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u audio_streaming_intf_class_info")
  104. endif()
  105. if(CONFIG_CHERRYUSB_HOST_BLUETOOTH)
  106. if(CONFIG_USBHOST_BLUETOOTH_HCI_H4)
  107. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u bluetooth_h4_nrf_class_info")
  108. else()
  109. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u bluetooth_class_info")
  110. endif()
  111. endif()
  112. if(CONFIG_CHERRYUSB_HOST_ASIX)
  113. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u asix_class_info")
  114. endif()
  115. if(CONFIG_CHERRYUSB_HOST_RTL8152)
  116. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u rtl8152_class_info")
  117. endif()
  118. if(CONFIG_CHERRYUSB_HOST_FTDI)
  119. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u ftdi_class_info")
  120. endif()
  121. if(CONFIG_CHERRYUSB_HOST_CH34X)
  122. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u ch34x_class_info")
  123. endif()
  124. if(CONFIG_CHERRYUSB_HOST_CP210X)
  125. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u cp210x_class_info")
  126. endif()
  127. if(CONFIG_CHERRYUSB_HOST_PL2303)
  128. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u pl2303_class_info")
  129. endif()
  130. endif()
  131. if(CONFIG_CHERRYUSB)
  132. set_source_files_properties("class/audio/usbd_audio.c"
  133. PROPERTIES COMPILE_FLAGS
  134. -Wno-maybe-uninitialized)
  135. endif()
  136. endif()