CMakeLists.txt 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. cmake_minimum_required(VERSION 3.15)
  2. if(CONFIG_CHERRYUSB)
  3. if(BL_SDK_BASE)
  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_HOST_CDC_ACM 1)
  10. set(CONFIG_CHERRYUSB_HOST_CDC_ECM 1)
  11. set(CONFIG_CHERRYUSB_HOST_CDC_NCM 1)
  12. set(CONFIG_CHERRYUSB_HOST_HID 1)
  13. set(CONFIG_CHERRYUSB_HOST_MSC 1)
  14. set(CONFIG_CHERRYUSB_HOST_VIDEO 1)
  15. set(CONFIG_CHERRYUSB_HOST_AUDIO 1)
  16. set(CONFIG_CHERRYUSB_HOST_CDC_RNDIS 1)
  17. set(CONFIG_CHERRYUSB_HOST_BLUETOOTH 1)
  18. set(CONFIG_CHERRYUSB_HOST_ASIX 1)
  19. set(CONFIG_CHERRYUSB_HOST_RTL8152 1)
  20. set(CONFIG_CHERRYUSB_HOST_CH34X 1)
  21. set(CONFIG_CHERRYUSB_HOST_CP210X 1)
  22. set(CONFIG_CHERRYUSB_HOST_FTDI 1)
  23. set(CONFIG_CHERRYUSB_HOST_PL2303 1)
  24. set(CONFIG_CHERRYUSB_DEVICE_BL 1)
  25. set(CONFIG_CHERRYUSB_HOST_EHCI_BL 1)
  26. set(CONFIG_CHERRYUSB_OSAL "freertos")
  27. include(${CMAKE_CURRENT_LIST_DIR}/cherryusb.cmake)
  28. sdk_generate_library(cherryusb)
  29. sdk_add_include_directories(${cherryusb_incs})
  30. sdk_library_add_sources(${cherryusb_srcs})
  31. elseif(ESP_PLATFORM)
  32. set(CONFIG_CHERRYUSB_DEVICE_DWC2_ESP 1)
  33. set(CONFIG_CHERRYUSB_HOST_DWC2_ESP 1)
  34. set(CONFIG_CHERRYUSB_OSAL "idf")
  35. include(${CMAKE_CURRENT_LIST_DIR}/cherryusb.cmake)
  36. set(ldfragments "osal/idf/linker.lf")
  37. if(CONFIG_CHERRYUSB_HOST_CDC_ECM
  38. OR CONFIG_CHERRYUSB_HOST_CDC_RNDIS
  39. OR CONFIG_CHERRYUSB_HOST_CDC_NCM
  40. OR CONFIG_CHERRYUSB_HOST_ASIX
  41. OR CONFIG_CHERRYUSB_HOST_RTL8152
  42. OR CONFIG_CHERRYUSB_HOST_BL616
  43. )
  44. idf_component_get_property(lwip lwip COMPONENT_LIB)
  45. target_compile_definitions(${lwip} PRIVATE "-DPBUF_POOL_BUFSIZE=1600")
  46. endif()
  47. idf_component_get_property(freertos_include freertos ORIG_INCLUDE_PATH)
  48. idf_component_register(
  49. SRCS
  50. ${cherryusb_srcs}
  51. INCLUDE_DIRS
  52. ${cherryusb_incs}
  53. ${freertos_include}
  54. PRIV_REQUIRES
  55. usb
  56. LDFRAGMENTS
  57. ${ldfragments}
  58. )
  59. if(CONFIG_CHERRYUSB_HOST)
  60. target_linker_script(${COMPONENT_LIB} INTERFACE "osal/idf/usbh_class_info.ld")
  61. # 强制链接器不删除符号
  62. if(CONFIG_CHERRYUSB_HOST_CDC_ACM)
  63. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u cdc_acm_class_info")
  64. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u cdc_data_class_info")
  65. endif()
  66. if(CONFIG_CHERRYUSB_HOST_HID)
  67. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u hid_custom_class_info")
  68. endif()
  69. if(CONFIG_CHERRYUSB_HOST_MSC)
  70. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u msc_class_info")
  71. endif()
  72. if(CONFIG_CHERRYUSB_HOST_CDC_ECM)
  73. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u cdc_ecm_class_info")
  74. endif()
  75. if(CONFIG_CHERRYUSB_HOST_CDC_RNDIS)
  76. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u rndis_class_info")
  77. endif()
  78. if(CONFIG_CHERRYUSB_HOST_CDC_NCM)
  79. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u cdc_ncm_class_info")
  80. endif()
  81. if(CONFIG_CHERRYUSB_HOST_VIDEO)
  82. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u video_ctrl_class_info")
  83. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u video_streaming_class_info")
  84. endif()
  85. if(CONFIG_CHERRYUSB_HOST_AUDIO)
  86. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u audio_ctrl_intf_class_info")
  87. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u audio_streaming_intf_class_info")
  88. endif()
  89. if(CONFIG_CHERRYUSB_HOST_BLUETOOTH)
  90. if(CONFIG_USBHOST_BLUETOOTH_HCI_H4)
  91. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u bluetooth_h4_nrf_class_info")
  92. else()
  93. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u bluetooth_class_info")
  94. endif()
  95. endif()
  96. if(CONFIG_CHERRYUSB_HOST_ASIX)
  97. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u asix_class_info")
  98. endif()
  99. if(CONFIG_CHERRYUSB_HOST_RTL8152)
  100. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u rtl8152_class_info")
  101. endif()
  102. if(CONFIG_CHERRYUSB_HOST_FTDI)
  103. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u ftdi_class_info")
  104. endif()
  105. if(CONFIG_CHERRYUSB_HOST_CH34X)
  106. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u ch34x_class_info")
  107. endif()
  108. if(CONFIG_CHERRYUSB_HOST_CP210X)
  109. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u cp210x_class_info")
  110. endif()
  111. if(CONFIG_CHERRYUSB_HOST_PL2303)
  112. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u pl2303_class_info")
  113. endif()
  114. endif()
  115. if(CONFIG_CHERRYUSB)
  116. set_source_files_properties("class/audio/usbd_audio.c" PROPERTIES COMPILE_FLAGS -Wno-maybe-uninitialized)
  117. endif()
  118. elseif(ZEPHYR_BASE)
  119. set(CONFIG_CHERRYUSB_OSAL "zephyr")
  120. include(${CMAKE_CURRENT_LIST_DIR}/cherryusb.cmake)
  121. if (CONFIG_SHELL)
  122. list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/platform/zephyr/usb_cmd.c)
  123. endif ()
  124. zephyr_library()
  125. if(cherryusb_incs)
  126. zephyr_include_directories(${cherryusb_incs})
  127. endif()
  128. if(cherryusb_srcs)
  129. zephyr_library_sources(${cherryusb_srcs})
  130. endif()
  131. if (CONFIG_CHERRYUSB_HOST)
  132. zephyr_linker_sources(SECTIONS zephyr/usbh_class_info.ld)
  133. endif()
  134. elseif(HPM_SDK_BASE)
  135. set(CONFIG_CHERRYUSB_DEVICE_CDC_ACM 1)
  136. set(CONFIG_CHERRYUSB_DEVICE_HID 1)
  137. set(CONFIG_CHERRYUSB_DEVICE_MSC 1)
  138. set(CONFIG_CHERRYUSB_DEVICE_AUDIO 1)
  139. set(CONFIG_CHERRYUSB_DEVICE_VIDEO 1)
  140. set(CONFIG_CHERRYUSB_HOST_CDC_ACM 1)
  141. set(CONFIG_CHERRYUSB_HOST_CDC_ECM 1)
  142. set(CONFIG_CHERRYUSB_HOST_CDC_NCM 1)
  143. set(CONFIG_CHERRYUSB_HOST_HID 1)
  144. set(CONFIG_CHERRYUSB_HOST_MSC 1)
  145. set(CONFIG_CHERRYUSB_HOST_VIDEO 1)
  146. set(CONFIG_CHERRYUSB_HOST_AUDIO 1)
  147. set(CONFIG_CHERRYUSB_HOST_CDC_RNDIS 1)
  148. # set(CONFIG_CHERRYUSB_HOST_BLUETOOTH 1)
  149. set(CONFIG_CHERRYUSB_HOST_ASIX 1)
  150. set(CONFIG_CHERRYUSB_HOST_RTL8152 1)
  151. set(CONFIG_CHERRYUSB_HOST_CH34X 1)
  152. set(CONFIG_CHERRYUSB_HOST_CP210X 1)
  153. set(CONFIG_CHERRYUSB_HOST_FTDI 1)
  154. set(CONFIG_CHERRYUSB_HOST_PL2303 1)
  155. set(CONFIG_CHERRYUSB_HOST_BL616 1)
  156. set(CONFIG_CHERRYUSB_DEVICE_HPM 1)
  157. set(CONFIG_CHERRYUSB_HOST_EHCI_HPM 1)
  158. set(CONFIG_CHERRYUSB_OSAL "freertos")
  159. include(${CMAKE_CURRENT_LIST_DIR}/cherryusb.cmake)
  160. sdk_inc(${cherryusb_incs})
  161. sdk_src(${cherryusb_srcs})
  162. endif()
  163. endif()