CMakeLists.txt 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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
  64. OR CONFIG_CHERRYUSB_HOST_CDC_RNDIS
  65. OR CONFIG_CHERRYUSB_HOST_CDC_NCM
  66. OR CONFIG_CHERRYUSB_HOST_ASIX
  67. OR CONFIG_CHERRYUSB_HOST_RTL8152
  68. OR CONFIG_CHERRYUSB_HOST_BL616
  69. )
  70. list(APPEND cherryusb_srcs platform/none/usbh_lwip.c)
  71. idf_component_get_property(lwip lwip COMPONENT_LIB)
  72. target_compile_definitions(${lwip} PRIVATE "-DPBUF_POOL_BUFSIZE=1600")
  73. endif()
  74. idf_component_get_property(freertos_include freertos ORIG_INCLUDE_PATH)
  75. idf_component_register(
  76. SRCS
  77. ${cherryusb_srcs}
  78. INCLUDE_DIRS
  79. ${cherryusb_incs}
  80. ${freertos_include}
  81. PRIV_REQUIRES
  82. usb
  83. LDFRAGMENTS
  84. ${ldfragments}
  85. )
  86. if(CONFIG_CHERRYUSB_HOST)
  87. target_linker_script(${COMPONENT_LIB} INTERFACE "osal/idf/usbh_class_info.ld")
  88. # 强制链接器不删除符号
  89. if(CONFIG_CHERRYUSB_HOST_CDC_ACM)
  90. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u cdc_acm_class_info")
  91. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u cdc_data_class_info")
  92. endif()
  93. if(CONFIG_CHERRYUSB_HOST_HID)
  94. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u hid_custom_class_info")
  95. endif()
  96. if(CONFIG_CHERRYUSB_HOST_MSC)
  97. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u msc_class_info")
  98. endif()
  99. if(CONFIG_CHERRYUSB_HOST_CDC_ECM)
  100. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u cdc_ecm_class_info")
  101. endif()
  102. if(CONFIG_CHERRYUSB_HOST_CDC_RNDIS)
  103. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u rndis_class_info")
  104. endif()
  105. if(CONFIG_CHERRYUSB_HOST_CDC_NCM)
  106. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u cdc_ncm_class_info")
  107. endif()
  108. if(CONFIG_CHERRYUSB_HOST_VIDEO)
  109. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u video_ctrl_class_info")
  110. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u video_streaming_class_info")
  111. endif()
  112. if(CONFIG_CHERRYUSB_HOST_AUDIO)
  113. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u audio_ctrl_intf_class_info")
  114. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u audio_streaming_intf_class_info")
  115. endif()
  116. if(CONFIG_CHERRYUSB_HOST_BLUETOOTH)
  117. if(CONFIG_USBHOST_BLUETOOTH_HCI_H4)
  118. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u bluetooth_h4_nrf_class_info")
  119. else()
  120. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u bluetooth_class_info")
  121. endif()
  122. endif()
  123. if(CONFIG_CHERRYUSB_HOST_ASIX)
  124. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u asix_class_info")
  125. endif()
  126. if(CONFIG_CHERRYUSB_HOST_RTL8152)
  127. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u rtl8152_class_info")
  128. endif()
  129. if(CONFIG_CHERRYUSB_HOST_FTDI)
  130. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u ftdi_class_info")
  131. endif()
  132. if(CONFIG_CHERRYUSB_HOST_CH34X)
  133. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u ch34x_class_info")
  134. endif()
  135. if(CONFIG_CHERRYUSB_HOST_CP210X)
  136. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u cp210x_class_info")
  137. endif()
  138. if(CONFIG_CHERRYUSB_HOST_PL2303)
  139. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u pl2303_class_info")
  140. endif()
  141. endif()
  142. if(CONFIG_CHERRYUSB)
  143. set_source_files_properties("class/audio/usbd_audio.c" PROPERTIES COMPILE_FLAGS -Wno-maybe-uninitialized)
  144. endif()
  145. endif()