Kaynağa Gözat

cmake_format (#305)

cmake: Format CMake files using cmake_format and add a .cmake_format.json file.

Co-authored-by: mlwang <mlwang@bouffalolab.com>
minlewang 8 ay önce
ebeveyn
işleme
4c8d448ca2
3 değiştirilmiş dosya ile 626 ekleme ve 299 silme
  1. 311 0
      .cmake-format.json
  2. 148 139
      CMakeLists.txt
  3. 167 160
      cherryusb.cmake

+ 311 - 0
.cmake-format.json

@@ -0,0 +1,311 @@
+{
+  "_help_parse": "Options affecting listfile parsing",
+  "parse": {
+    "_help_additional_commands": [
+      "Specify structure for custom cmake functions"
+    ],
+    "additional_commands": {
+      "foo": {
+        "flags": [
+          "BAR",
+          "BAZ"
+        ],
+        "kwargs": {
+          "HEADERS": "*",
+          "SOURCES": "*",
+          "DEPENDS": "*"
+        }
+      }
+    },
+    "_help_override_spec": [
+      "Override configurations per-command where available"
+    ],
+    "override_spec": {},
+    "_help_vartags": [
+      "Specify variable tags."
+    ],
+    "vartags": [],
+    "_help_proptags": [
+      "Specify property tags."
+    ],
+    "proptags": []
+  },
+  "_help_format": "Options affecting formatting.",
+  "format": {
+    "_help_disable": [
+      "Disable formatting entirely, making cmake-format a no-op"
+    ],
+    "disable": false,
+    "_help_line_width": [
+      "How wide to allow formatted cmake files"
+    ],
+    "line_width": 120,
+    "_help_tab_size": [
+      "How many spaces to tab for indent"
+    ],
+    "tab_size": 4,
+    "_help_use_tabchars": [
+      "If true, lines are indented using tab characters (utf-8",
+      "0x09) instead of <tab_size> space characters (utf-8 0x20).",
+      "In cases where the layout would require a fractional tab",
+      "character, the behavior of the  fractional indentation is",
+      "governed by <fractional_tab_policy>"
+    ],
+    "use_tabchars": false,
+    "_help_fractional_tab_policy": [
+      "If <use_tabchars> is True, then the value of this variable",
+      "indicates how fractional indentions are handled during",
+      "whitespace replacement. If set to 'use-space', fractional",
+      "indentation is left as spaces (utf-8 0x20). If set to",
+      "`round-up` fractional indentation is replaced with a single",
+      "tab character (utf-8 0x09) effectively shifting the column",
+      "to the next tabstop"
+    ],
+    "fractional_tab_policy": "use-space",
+    "_help_max_subgroups_hwrap": [
+      "If an argument group contains more than this many sub-groups",
+      "(parg or kwarg groups) then force it to a vertical layout."
+    ],
+    "max_subgroups_hwrap": 2,
+    "_help_max_pargs_hwrap": [
+      "If a positional argument group contains more than this many",
+      "arguments, then force it to a vertical layout."
+    ],
+    "max_pargs_hwrap": 6,
+    "_help_max_rows_cmdline": [
+      "If a cmdline positional group consumes more than this many",
+      "lines without nesting, then invalidate the layout (and nest)"
+    ],
+    "max_rows_cmdline": 2,
+    "_help_separate_ctrl_name_with_space": [
+      "If true, separate flow control names from their parentheses",
+      "with a space"
+    ],
+    "separate_ctrl_name_with_space": false,
+    "_help_separate_fn_name_with_space": [
+      "If true, separate function names from parentheses with a",
+      "space"
+    ],
+    "separate_fn_name_with_space": false,
+    "_help_dangle_parens": [
+      "If a statement is wrapped to more than one line, than dangle",
+      "the closing parenthesis on its own line."
+    ],
+    "dangle_parens": true,
+    "_help_dangle_align": [
+      "If the trailing parenthesis must be 'dangled' on its on",
+      "line, then align it to this reference: `prefix`: the start",
+      "of the statement,  `prefix-indent`: the start of the",
+      "statement, plus one indentation  level, `child`: align to",
+      "the column of the arguments"
+    ],
+    "dangle_align": "prefix",
+    "_help_min_prefix_chars": [
+      "If the statement spelling length (including space and",
+      "parenthesis) is smaller than this amount, then force reject",
+      "nested layouts."
+    ],
+    "min_prefix_chars": 4,
+    "_help_max_prefix_chars": [
+      "If the statement spelling length (including space and",
+      "parenthesis) is larger than the tab width by more than this",
+      "amount, then force reject un-nested layouts."
+    ],
+    "max_prefix_chars": 10,
+    "_help_max_lines_hwrap": [
+      "If a candidate layout is wrapped horizontally but it exceeds",
+      "this many lines, then reject the layout."
+    ],
+    "max_lines_hwrap": 2,
+    "_help_line_ending": [
+      "What style line endings to use in the output."
+    ],
+    "line_ending": "unix",
+    "_help_command_case": [
+      "Format command names consistently as 'lower' or 'upper' case"
+    ],
+    "command_case": "canonical",
+    "_help_keyword_case": [
+      "Format keywords consistently as 'lower' or 'upper' case"
+    ],
+    "keyword_case": "unchanged",
+    "_help_always_wrap": [
+      "A list of command names which should always be wrapped"
+    ],
+    "always_wrap": [],
+    "_help_enable_sort": [
+      "If true, the argument lists which are known to be sortable",
+      "will be sorted lexicographicall"
+    ],
+    "enable_sort": true,
+    "_help_autosort": [
+      "If true, the parsers may infer whether or not an argument",
+      "list is sortable (without annotation)."
+    ],
+    "autosort": false,
+    "_help_require_valid_layout": [
+      "By default, if cmake-format cannot successfully fit",
+      "everything into the desired linewidth it will apply the",
+      "last, most agressive attempt that it made. If this flag is",
+      "True, however, cmake-format will print error, exit with non-",
+      "zero status code, and write-out nothing"
+    ],
+    "require_valid_layout": false,
+    "_help_layout_passes": [
+      "A dictionary mapping layout nodes to a list of wrap",
+      "decisions. See the documentation for more information."
+    ],
+    "layout_passes": {}
+  },
+  "_help_markup": "Options affecting comment reflow and formatting.",
+  "markup": {
+    "_help_bullet_char": [
+      "What character to use for bulleted lists"
+    ],
+    "bullet_char": "*",
+    "_help_enum_char": [
+      "What character to use as punctuation after numerals in an",
+      "enumerated list"
+    ],
+    "enum_char": ".",
+    "_help_first_comment_is_literal": [
+      "If comment markup is enabled, don't reflow the first comment",
+      "block in each listfile. Use this to preserve formatting of",
+      "your copyright/license statements."
+    ],
+    "first_comment_is_literal": true,
+    "_help_literal_comment_pattern": [
+      "If comment markup is enabled, don't reflow any comment block",
+      "which matches this (regex) pattern. Default is `None`",
+      "(disabled)."
+    ],
+    "literal_comment_pattern": null,
+    "_help_fence_pattern": [
+      "Regular expression to match preformat fences in comments",
+      "default= ``r'^\\s*([`~]{3}[`~]*)(.*)$'``"
+    ],
+    "fence_pattern": "^\\s*([`~]{3}[`~]*)(.*)$",
+    "_help_ruler_pattern": [
+      "Regular expression to match rulers in comments default=",
+      "``r'^\\s*[^\\w\\s]{3}.*[^\\w\\s]{3}$'``"
+    ],
+    "ruler_pattern": "^\\s*[^\\w\\s]{3}.*[^\\w\\s]{3}$",
+    "_help_explicit_trailing_pattern": [
+      "If a comment line matches starts with this pattern then it",
+      "is explicitly a trailing comment for the preceeding",
+      "argument. Default is '#<'"
+    ],
+    "explicit_trailing_pattern": "#<",
+    "_help_hashruler_min_length": [
+      "If a comment line starts with at least this many consecutive",
+      "hash characters, then don't lstrip() them off. This allows",
+      "for lazy hash rulers where the first hash char is not",
+      "separated by space"
+    ],
+    "hashruler_min_length": 10,
+    "_help_canonicalize_hashrulers": [
+      "If true, then insert a space between the first hash char and",
+      "remaining hash chars in a hash ruler, and normalize its",
+      "length to fill the column"
+    ],
+    "canonicalize_hashrulers": true,
+    "_help_enable_markup": [
+      "enable comment markup parsing and reflow"
+    ],
+    "enable_markup": true
+  },
+  "_help_lint": "Options affecting the linter",
+  "lint": {
+    "_help_disabled_codes": [
+      "a list of lint codes to disable"
+    ],
+    "disabled_codes": [],
+    "_help_function_pattern": [
+      "regular expression pattern describing valid function names"
+    ],
+    "function_pattern": "[0-9a-z_]+",
+    "_help_macro_pattern": [
+      "regular expression pattern describing valid macro names"
+    ],
+    "macro_pattern": "[0-9A-Z_]+",
+    "_help_global_var_pattern": [
+      "regular expression pattern describing valid names for",
+      "variables with global (cache) scope"
+    ],
+    "global_var_pattern": "[A-Z][0-9A-Z_]+",
+    "_help_internal_var_pattern": [
+      "regular expression pattern describing valid names for",
+      "variables with global scope (but internal semantic)"
+    ],
+    "internal_var_pattern": "_[A-Z][0-9A-Z_]+",
+    "_help_local_var_pattern": [
+      "regular expression pattern describing valid names for",
+      "variables with local scope"
+    ],
+    "local_var_pattern": "[a-z][a-z0-9_]+",
+    "_help_private_var_pattern": [
+      "regular expression pattern describing valid names for",
+      "privatedirectory variables"
+    ],
+    "private_var_pattern": "_[0-9a-z_]+",
+    "_help_public_var_pattern": [
+      "regular expression pattern describing valid names for public",
+      "directory variables"
+    ],
+    "public_var_pattern": "[A-Z][0-9A-Z_]+",
+    "_help_argument_var_pattern": [
+      "regular expression pattern describing valid names for",
+      "function/macro arguments and loop variables."
+    ],
+    "argument_var_pattern": "[a-z][a-z0-9_]+",
+    "_help_keyword_pattern": [
+      "regular expression pattern describing valid names for",
+      "keywords used in functions or macros"
+    ],
+    "keyword_pattern": "[A-Z][0-9A-Z_]+",
+    "_help_max_conditionals_custom_parser": [
+      "In the heuristic for C0201, how many conditionals to match",
+      "within a loop in before considering the loop a parser."
+    ],
+    "max_conditionals_custom_parser": 2,
+    "_help_min_statement_spacing": [
+      "Require at least this many newlines between statements"
+    ],
+    "min_statement_spacing": 1,
+    "_help_max_statement_spacing": [
+      "Require no more than this many newlines between statements"
+    ],
+    "max_statement_spacing": 2,
+    "max_returns": 6,
+    "max_branches": 12,
+    "max_arguments": 5,
+    "max_localvars": 15,
+    "max_statements": 50
+  },
+  "_help_encode": "Options affecting file encoding",
+  "encode": {
+    "_help_emit_byteorder_mark": [
+      "If true, emit the unicode byte-order mark (BOM) at the start",
+      "of the file"
+    ],
+    "emit_byteorder_mark": false,
+    "_help_input_encoding": [
+      "Specify the encoding of the input file. Defaults to utf-8"
+    ],
+    "input_encoding": "utf-8",
+    "_help_output_encoding": [
+      "Specify the encoding of the output file. Defaults to utf-8.",
+      "Note that cmake only claims to support utf-8 so be careful",
+      "when using anything else"
+    ],
+    "output_encoding": "utf-8"
+  },
+  "_help_misc": "Miscellaneous configurations options.",
+  "misc": {
+    "_help_per_command": [
+      "A dictionary containing any per-command configuration",
+      "overrides. Currently only `command_case` is supported."
+    ],
+    "per_command": {}
+  }
+}

+ 148 - 139
CMakeLists.txt

@@ -1,155 +1,164 @@
 cmake_minimum_required(VERSION 3.15)
 
 if(BL_SDK_BASE)
-set(CONFIG_CHERRYUSB_DEVICE 1)
-set(CONFIG_CHERRYUSB_DEVICE_CDC_ACM 1)
-set(CONFIG_CHERRYUSB_DEVICE_HID 1)
-set(CONFIG_CHERRYUSB_DEVICE_MSC 1)
-set(CONFIG_CHERRYUSB_DEVICE_AUDIO 1)
-set(CONFIG_CHERRYUSB_DEVICE_VIDEO 1)
-set(CONFIG_CHERRYUSB_DEVICE_DCD "bl")
-
-set(CONFIG_CHERRYUSB_HOST 1)
-set(CONFIG_CHERRYUSB_HOST_CDC_ACM 1)
-set(CONFIG_CHERRYUSB_HOST_CDC_ECM 1)
-set(CONFIG_CHERRYUSB_HOST_CDC_NCM 1)
-set(CONFIG_CHERRYUSB_HOST_HID 1)
-set(CONFIG_CHERRYUSB_HOST_MSC 1)
-set(CONFIG_CHERRYUSB_HOST_VIDEO 1)
-set(CONFIG_CHERRYUSB_HOST_AUDIO 1)
-set(CONFIG_CHERRYUSB_HOST_CDC_RNDIS 1)
-set(CONFIG_CHERRYUSB_HOST_BLUETOOTH 1)
-set(CONFIG_CHERRYUSB_HOST_ASIX 1)
-set(CONFIG_CHERRYUSB_HOST_RTL8152 1)
-set(CONFIG_CHERRYUSB_HOST_CH34X 1)
-set(CONFIG_CHERRYUSB_HOST_CP210X 1)
-set(CONFIG_CHERRYUSB_HOST_FTDI 1)
-set(CONFIG_CHERRYUSB_HOST_PL2303 1)
-set(CONFIG_CHERRYUSB_OSAL "freertos")
-set(CONFIG_CHERRYUSB_HOST_HCD "ehci_bouffalo")
-
-include(${CMAKE_CURRENT_LIST_DIR}/cherryusb.cmake)
-
-sdk_generate_library(cherryusb)
-sdk_add_include_directories(${cherryusb_incs})
-sdk_library_add_sources(${cherryusb_srcs})
-
-sdk_library_add_sources(platform/none/usbh_lwip.c)
+    set(CONFIG_CHERRYUSB_DEVICE 1)
+    set(CONFIG_CHERRYUSB_DEVICE_CDC_ACM 1)
+    set(CONFIG_CHERRYUSB_DEVICE_HID 1)
+    set(CONFIG_CHERRYUSB_DEVICE_MSC 1)
+    set(CONFIG_CHERRYUSB_DEVICE_AUDIO 1)
+    set(CONFIG_CHERRYUSB_DEVICE_VIDEO 1)
+    set(CONFIG_CHERRYUSB_DEVICE_DCD "bl")
+
+    set(CONFIG_CHERRYUSB_HOST 1)
+    set(CONFIG_CHERRYUSB_HOST_CDC_ACM 1)
+    set(CONFIG_CHERRYUSB_HOST_CDC_ECM 1)
+    set(CONFIG_CHERRYUSB_HOST_CDC_NCM 1)
+    set(CONFIG_CHERRYUSB_HOST_HID 1)
+    set(CONFIG_CHERRYUSB_HOST_MSC 1)
+    set(CONFIG_CHERRYUSB_HOST_VIDEO 1)
+    set(CONFIG_CHERRYUSB_HOST_AUDIO 1)
+    set(CONFIG_CHERRYUSB_HOST_CDC_RNDIS 1)
+    set(CONFIG_CHERRYUSB_HOST_BLUETOOTH 1)
+    set(CONFIG_CHERRYUSB_HOST_ASIX 1)
+    set(CONFIG_CHERRYUSB_HOST_RTL8152 1)
+    set(CONFIG_CHERRYUSB_HOST_CH34X 1)
+    set(CONFIG_CHERRYUSB_HOST_CP210X 1)
+    set(CONFIG_CHERRYUSB_HOST_FTDI 1)
+    set(CONFIG_CHERRYUSB_HOST_PL2303 1)
+    set(CONFIG_CHERRYUSB_OSAL "freertos")
+    set(CONFIG_CHERRYUSB_HOST_HCD "ehci_bouffalo")
+
+    include(${CMAKE_CURRENT_LIST_DIR}/cherryusb.cmake)
+
+    sdk_generate_library(cherryusb)
+    sdk_add_include_directories(${cherryusb_incs})
+    sdk_library_add_sources(${cherryusb_srcs})
+
+    sdk_library_add_sources(platform/none/usbh_lwip.c)
 
 elseif(HPM_SDK_BASE)
-set(CONFIG_CHERRYUSB_HOST 1)
-set(CONFIG_CHERRYUSB_HOST_CDC_ACM 1)
-set(CONFIG_CHERRYUSB_HOST_CDC_ECM 1)
-set(CONFIG_CHERRYUSB_HOST_CDC_NCM 1)
-set(CONFIG_CHERRYUSB_HOST_HID 1)
-set(CONFIG_CHERRYUSB_HOST_MSC 1)
-set(CONFIG_CHERRYUSB_HOST_VIDEO 1)
-set(CONFIG_CHERRYUSB_HOST_AUDIO 1)
-set(CONFIG_CHERRYUSB_HOST_CDC_RNDIS 1)
-# set(CONFIG_CHERRYUSB_HOST_BLUETOOTH 1)
-set(CONFIG_CHERRYUSB_HOST_ASIX 1)
-set(CONFIG_CHERRYUSB_HOST_RTL8152 1)
-set(CONFIG_CHERRYUSB_HOST_CH34X 1)
-set(CONFIG_CHERRYUSB_HOST_CP210X 1)
-set(CONFIG_CHERRYUSB_HOST_FTDI 1)
-set(CONFIG_CHERRYUSB_HOST_PL2303 1)
-set(CONFIG_CHERRYUSB_HOST_BL616 1)
-set(CONFIG_CHERRYUSB_OSAL "freertos")
-set(CONFIG_CHERRYUSB_HOST_HCD "ehci_hpm")
-
-include(${CMAKE_CURRENT_LIST_DIR}/cherryusb.cmake)
-
-sdk_inc(${cherryusb_incs})
-sdk_src(${cherryusb_srcs})
-
-sdk_src(platform/none/usbh_lwip.c)
+    set(CONFIG_CHERRYUSB_HOST 1)
+    set(CONFIG_CHERRYUSB_HOST_CDC_ACM 1)
+    set(CONFIG_CHERRYUSB_HOST_CDC_ECM 1)
+    set(CONFIG_CHERRYUSB_HOST_CDC_NCM 1)
+    set(CONFIG_CHERRYUSB_HOST_HID 1)
+    set(CONFIG_CHERRYUSB_HOST_MSC 1)
+    set(CONFIG_CHERRYUSB_HOST_VIDEO 1)
+    set(CONFIG_CHERRYUSB_HOST_AUDIO 1)
+    set(CONFIG_CHERRYUSB_HOST_CDC_RNDIS 1)
+    # set(CONFIG_CHERRYUSB_HOST_BLUETOOTH 1)
+    set(CONFIG_CHERRYUSB_HOST_ASIX 1)
+    set(CONFIG_CHERRYUSB_HOST_RTL8152 1)
+    set(CONFIG_CHERRYUSB_HOST_CH34X 1)
+    set(CONFIG_CHERRYUSB_HOST_CP210X 1)
+    set(CONFIG_CHERRYUSB_HOST_FTDI 1)
+    set(CONFIG_CHERRYUSB_HOST_PL2303 1)
+    set(CONFIG_CHERRYUSB_HOST_BL616 1)
+    set(CONFIG_CHERRYUSB_OSAL "freertos")
+    set(CONFIG_CHERRYUSB_HOST_HCD "ehci_hpm")
+
+    include(${CMAKE_CURRENT_LIST_DIR}/cherryusb.cmake)
+
+    sdk_inc(${cherryusb_incs})
+    sdk_src(${cherryusb_srcs})
+
+    sdk_src(platform/none/usbh_lwip.c)
 
 elseif(ESP_PLATFORM)
 
-set(CONFIG_CHERRYUSB_DEVICE_DCD "dwc2_esp")
-set(CONFIG_CHERRYUSB_HOST_HCD "dwc2_esp")
-set(CONFIG_CHERRYUSB_OSAL "idf")
+    set(CONFIG_CHERRYUSB_DEVICE_DCD "dwc2_esp")
+    set(CONFIG_CHERRYUSB_HOST_HCD "dwc2_esp")
+    set(CONFIG_CHERRYUSB_OSAL "idf")
 
-include(${CMAKE_CURRENT_LIST_DIR}/cherryusb.cmake)
+    include(${CMAKE_CURRENT_LIST_DIR}/cherryusb.cmake)
 
-set(ldfragments "osal/idf/linker.lf")
+    set(ldfragments "osal/idf/linker.lf")
 
-if(CONFIG_CHERRYUSB_HOST_CDC_ECM OR CONFIG_CHERRYUSB_HOST_CDC_RNDIS OR CONFIG_CHERRYUSB_HOST_CDC_NCM
-OR CONFIG_CHERRYUSB_HOST_ASIX OR CONFIG_CHERRYUSB_HOST_RTL8152 OR CONFIG_CHERRYUSB_HOST_BL616)
-list(APPEND cherryusb_srcs platform/none/usbh_lwip.c)
-idf_component_get_property(lwip lwip COMPONENT_LIB)
-target_compile_definitions(${lwip} PRIVATE "-DPBUF_POOL_BUFSIZE=1600")
-endif()
-
-idf_component_get_property(freertos_include freertos ORIG_INCLUDE_PATH)
-
-idf_component_register(SRCS ${cherryusb_srcs}
-    INCLUDE_DIRS ${cherryusb_incs} ${freertos_include}
-    PRIV_REQUIRES usb
-    LDFRAGMENTS  ${ldfragments}
-)
-
-if(CONFIG_CHERRYUSB_HOST)
-    target_linker_script(${COMPONENT_LIB} INTERFACE "osal/idf/usbh_class_info.ld")
-
-    # 强制链接器不删除符号
-    if(CONFIG_CHERRYUSB_HOST_CDC_ACM)
-        target_link_libraries(${COMPONENT_LIB} INTERFACE "-u cdc_acm_class_info")
-        target_link_libraries(${COMPONENT_LIB} INTERFACE "-u cdc_data_class_info")
-    endif()
-    if(CONFIG_CHERRYUSB_HOST_HID)
-        target_link_libraries(${COMPONENT_LIB} INTERFACE "-u hid_custom_class_info")
-    endif()
-    if(CONFIG_CHERRYUSB_HOST_MSC)
-        target_link_libraries(${COMPONENT_LIB} INTERFACE "-u msc_class_info")
-    endif()
-    if(CONFIG_CHERRYUSB_HOST_CDC_ECM)
-        target_link_libraries(${COMPONENT_LIB} INTERFACE "-u cdc_ecm_class_info")
-    endif()
-    if(CONFIG_CHERRYUSB_HOST_CDC_RNDIS)
-        target_link_libraries(${COMPONENT_LIB} INTERFACE "-u rndis_class_info")
+    if(CONFIG_CHERRYUSB_HOST_CDC_ECM
+       OR CONFIG_CHERRYUSB_HOST_CDC_RNDIS
+       OR CONFIG_CHERRYUSB_HOST_CDC_NCM
+       OR CONFIG_CHERRYUSB_HOST_ASIX
+       OR CONFIG_CHERRYUSB_HOST_RTL8152
+       OR CONFIG_CHERRYUSB_HOST_BL616
+    )
+        list(APPEND cherryusb_srcs platform/none/usbh_lwip.c)
+        idf_component_get_property(lwip lwip COMPONENT_LIB)
+        target_compile_definitions(${lwip} PRIVATE "-DPBUF_POOL_BUFSIZE=1600")
     endif()
-    if(CONFIG_CHERRYUSB_HOST_CDC_NCM)
-        target_link_libraries(${COMPONENT_LIB} INTERFACE "-u cdc_ncm_class_info")
-    endif()
-    if(CONFIG_CHERRYUSB_HOST_VIDEO)
-        target_link_libraries(${COMPONENT_LIB} INTERFACE "-u video_ctrl_class_info")
-        target_link_libraries(${COMPONENT_LIB} INTERFACE "-u video_streaming_class_info")
-    endif()
-    if(CONFIG_CHERRYUSB_HOST_AUDIO)
-        target_link_libraries(${COMPONENT_LIB} INTERFACE "-u audio_ctrl_intf_class_info")
-        target_link_libraries(${COMPONENT_LIB} INTERFACE "-u audio_streaming_intf_class_info")
-    endif()
-    if(CONFIG_CHERRYUSB_HOST_BLUETOOTH)
-        if(CONFIG_USBHOST_BLUETOOTH_HCI_H4)
-            target_link_libraries(${COMPONENT_LIB} INTERFACE "-u bluetooth_h4_nrf_class_info")
-        else()
-            target_link_libraries(${COMPONENT_LIB} INTERFACE "-u bluetooth_class_info")
+
+    idf_component_get_property(freertos_include freertos ORIG_INCLUDE_PATH)
+
+    idf_component_register(
+        SRCS
+        ${cherryusb_srcs}
+        INCLUDE_DIRS
+        ${cherryusb_incs}
+        ${freertos_include}
+        PRIV_REQUIRES
+        usb
+        LDFRAGMENTS
+        ${ldfragments}
+    )
+
+    if(CONFIG_CHERRYUSB_HOST)
+        target_linker_script(${COMPONENT_LIB} INTERFACE "osal/idf/usbh_class_info.ld")
+
+        # 强制链接器不删除符号
+        if(CONFIG_CHERRYUSB_HOST_CDC_ACM)
+            target_link_libraries(${COMPONENT_LIB} INTERFACE "-u cdc_acm_class_info")
+            target_link_libraries(${COMPONENT_LIB} INTERFACE "-u cdc_data_class_info")
+        endif()
+        if(CONFIG_CHERRYUSB_HOST_HID)
+            target_link_libraries(${COMPONENT_LIB} INTERFACE "-u hid_custom_class_info")
+        endif()
+        if(CONFIG_CHERRYUSB_HOST_MSC)
+            target_link_libraries(${COMPONENT_LIB} INTERFACE "-u msc_class_info")
+        endif()
+        if(CONFIG_CHERRYUSB_HOST_CDC_ECM)
+            target_link_libraries(${COMPONENT_LIB} INTERFACE "-u cdc_ecm_class_info")
+        endif()
+        if(CONFIG_CHERRYUSB_HOST_CDC_RNDIS)
+            target_link_libraries(${COMPONENT_LIB} INTERFACE "-u rndis_class_info")
+        endif()
+        if(CONFIG_CHERRYUSB_HOST_CDC_NCM)
+            target_link_libraries(${COMPONENT_LIB} INTERFACE "-u cdc_ncm_class_info")
+        endif()
+        if(CONFIG_CHERRYUSB_HOST_VIDEO)
+            target_link_libraries(${COMPONENT_LIB} INTERFACE "-u video_ctrl_class_info")
+            target_link_libraries(${COMPONENT_LIB} INTERFACE "-u video_streaming_class_info")
+        endif()
+        if(CONFIG_CHERRYUSB_HOST_AUDIO)
+            target_link_libraries(${COMPONENT_LIB} INTERFACE "-u audio_ctrl_intf_class_info")
+            target_link_libraries(${COMPONENT_LIB} INTERFACE "-u audio_streaming_intf_class_info")
+        endif()
+        if(CONFIG_CHERRYUSB_HOST_BLUETOOTH)
+            if(CONFIG_USBHOST_BLUETOOTH_HCI_H4)
+                target_link_libraries(${COMPONENT_LIB} INTERFACE "-u bluetooth_h4_nrf_class_info")
+            else()
+                target_link_libraries(${COMPONENT_LIB} INTERFACE "-u bluetooth_class_info")
+            endif()
+        endif()
+        if(CONFIG_CHERRYUSB_HOST_ASIX)
+            target_link_libraries(${COMPONENT_LIB} INTERFACE "-u asix_class_info")
+        endif()
+        if(CONFIG_CHERRYUSB_HOST_RTL8152)
+            target_link_libraries(${COMPONENT_LIB} INTERFACE "-u rtl8152_class_info")
+        endif()
+        if(CONFIG_CHERRYUSB_HOST_FTDI)
+            target_link_libraries(${COMPONENT_LIB} INTERFACE "-u ftdi_class_info")
+        endif()
+        if(CONFIG_CHERRYUSB_HOST_CH34X)
+            target_link_libraries(${COMPONENT_LIB} INTERFACE "-u ch34x_class_info")
+        endif()
+        if(CONFIG_CHERRYUSB_HOST_CP210X)
+            target_link_libraries(${COMPONENT_LIB} INTERFACE "-u cp210x_class_info")
+        endif()
+        if(CONFIG_CHERRYUSB_HOST_PL2303)
+            target_link_libraries(${COMPONENT_LIB} INTERFACE "-u pl2303_class_info")
         endif()
     endif()
-    if(CONFIG_CHERRYUSB_HOST_ASIX)
-        target_link_libraries(${COMPONENT_LIB} INTERFACE "-u asix_class_info")
-    endif()
-    if(CONFIG_CHERRYUSB_HOST_RTL8152)
-        target_link_libraries(${COMPONENT_LIB} INTERFACE "-u rtl8152_class_info")
-    endif()
-    if(CONFIG_CHERRYUSB_HOST_FTDI)
-        target_link_libraries(${COMPONENT_LIB} INTERFACE "-u ftdi_class_info")
-    endif()
-    if(CONFIG_CHERRYUSB_HOST_CH34X)
-        target_link_libraries(${COMPONENT_LIB} INTERFACE "-u ch34x_class_info")
-    endif()
-    if(CONFIG_CHERRYUSB_HOST_CP210X)
-        target_link_libraries(${COMPONENT_LIB} INTERFACE "-u cp210x_class_info")
-    endif()
-    if(CONFIG_CHERRYUSB_HOST_PL2303)
-        target_link_libraries(${COMPONENT_LIB} INTERFACE "-u pl2303_class_info")
-    endif()
-endif()
 
-if(CONFIG_CHERRYUSB)
-    set_source_files_properties("class/audio/usbd_audio.c"
-        PROPERTIES COMPILE_FLAGS
-        -Wno-maybe-uninitialized)
+    if(CONFIG_CHERRYUSB)
+        set_source_files_properties("class/audio/usbd_audio.c" PROPERTIES COMPILE_FLAGS -Wno-maybe-uninitialized)
+    endif()
 endif()
-endif()

+ 167 - 160
cherryusb.cmake

@@ -4,6 +4,8 @@
 # SPDX-License-Identifier: Apache-2.0
 #
 
+# cmake-format: off
+
 # set(CONFIG_CHERRYUSB_DEVICE 1)
 # set(CONFIG_CHERRYUSB_DEVICE_CDC 1)
 # set(CONFIG_CHERRYUSB_DEVICE_HID 1)
@@ -25,257 +27,262 @@
 # set(CONFIG_CHERRYUSB_OSAL "freertos")
 # set(CONFIG_CHERRYUSB_HOST_HCD "ehci_xxx")
 
-list(APPEND cherryusb_incs
-${CMAKE_CURRENT_LIST_DIR}
-${CMAKE_CURRENT_LIST_DIR}/common
-${CMAKE_CURRENT_LIST_DIR}/core
-${CMAKE_CURRENT_LIST_DIR}/class/hub
-${CMAKE_CURRENT_LIST_DIR}/class/cdc
-${CMAKE_CURRENT_LIST_DIR}/class/hid
-${CMAKE_CURRENT_LIST_DIR}/class/msc
-${CMAKE_CURRENT_LIST_DIR}/class/audio
-${CMAKE_CURRENT_LIST_DIR}/class/video
-${CMAKE_CURRENT_LIST_DIR}/class/wireless
-${CMAKE_CURRENT_LIST_DIR}/class/midi
-${CMAKE_CURRENT_LIST_DIR}/class/adb
-${CMAKE_CURRENT_LIST_DIR}/class/dfu
-${CMAKE_CURRENT_LIST_DIR}/class/vendor/net
-${CMAKE_CURRENT_LIST_DIR}/class/vendor/serial
-${CMAKE_CURRENT_LIST_DIR}/class/vendor/wifi
-${CMAKE_CURRENT_LIST_DIR}/class/aoa
+# cmake-format: on
+
+list(
+    APPEND
+    cherryusb_incs
+    ${CMAKE_CURRENT_LIST_DIR}
+    ${CMAKE_CURRENT_LIST_DIR}/common
+    ${CMAKE_CURRENT_LIST_DIR}/core
+    ${CMAKE_CURRENT_LIST_DIR}/class/hub
+    ${CMAKE_CURRENT_LIST_DIR}/class/cdc
+    ${CMAKE_CURRENT_LIST_DIR}/class/hid
+    ${CMAKE_CURRENT_LIST_DIR}/class/msc
+    ${CMAKE_CURRENT_LIST_DIR}/class/audio
+    ${CMAKE_CURRENT_LIST_DIR}/class/video
+    ${CMAKE_CURRENT_LIST_DIR}/class/wireless
+    ${CMAKE_CURRENT_LIST_DIR}/class/midi
+    ${CMAKE_CURRENT_LIST_DIR}/class/adb
+    ${CMAKE_CURRENT_LIST_DIR}/class/dfu
+    ${CMAKE_CURRENT_LIST_DIR}/class/vendor/net
+    ${CMAKE_CURRENT_LIST_DIR}/class/vendor/serial
+    ${CMAKE_CURRENT_LIST_DIR}/class/vendor/wifi
+    ${CMAKE_CURRENT_LIST_DIR}/class/aoa
 )
 
 if(CONFIG_CHERRYUSB_DEVICE)
     list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/core/usbd_core.c)
     if(CONFIG_CHERRYUSB_DEVICE_CDC_ACM)
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/cdc/usbd_cdc_acm.c)
+        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/cdc/usbd_cdc_acm.c)
     endif()
     if(CONFIG_CHERRYUSB_DEVICE_HID)
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/hid/usbd_hid.c)
+        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/hid/usbd_hid.c)
     endif()
     if(CONFIG_CHERRYUSB_DEVICE_MSC)
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/msc/usbd_msc.c)
+        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/msc/usbd_msc.c)
     endif()
     if(CONFIG_CHERRYUSB_DEVICE_AUDIO)
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/audio/usbd_audio.c)
+        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/audio/usbd_audio.c)
     endif()
     if(CONFIG_CHERRYUSB_DEVICE_VIDEO)
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/video/usbd_video.c)
+        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/video/usbd_video.c)
     endif()
     if(CONFIG_CHERRYUSB_DEVICE_CDC_ECM)
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/cdc/usbd_cdc_ecm.c)
+        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/cdc/usbd_cdc_ecm.c)
     endif()
     if(CONFIG_CHERRYUSB_DEVICE_CDC_NCM)
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/cdc/usbd_cdc_ncm.c)
+        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/cdc/usbd_cdc_ncm.c)
     endif()
     if(CONFIG_CHERRYUSB_DEVICE_CDC_RNDIS)
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/wireless/usbd_rndis.c)
+        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/wireless/usbd_rndis.c)
     endif()
     if(CONFIG_CHERRYUSB_DEVICE_DFU)
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/dfu/usbd_dfu.c)
+        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/dfu/usbd_dfu.c)
     endif()
     if(CONFIG_CHERRYUSB_DEVICE_ADB)
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/adb/usbd_adb.c)
+        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/adb/usbd_adb.c)
     endif()
 
     if(DEFINED CONFIG_CHERRYUSB_DEVICE_DCD)
         if("${CONFIG_CHERRYUSB_DEVICE_DCD}" STREQUAL "fsdev")
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/fsdev/usb_dc_fsdev.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/fsdev/usb_dc_fsdev.c)
         elseif("${CONFIG_CHERRYUSB_DEVICE_DCD}" STREQUAL "dwc2_st")
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_dc_dwc2.c)
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_glue_st.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_dc_dwc2.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_glue_st.c)
         elseif("${CONFIG_CHERRYUSB_DEVICE_DCD}" STREQUAL "dwc2_esp")
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_dc_dwc2.c)
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_glue_esp.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_dc_dwc2.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_glue_esp.c)
         elseif("${CONFIG_CHERRYUSB_DEVICE_DCD}" STREQUAL "dwc2_at")
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_dc_dwc2.c)
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_glue_at.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_dc_dwc2.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_glue_at.c)
         elseif("${CONFIG_CHERRYUSB_DEVICE_DCD}" STREQUAL "dwc2_gd")
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_dc_dwc2.c)
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_glue_gd.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_dc_dwc2.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_glue_gd.c)
         elseif("${CONFIG_CHERRYUSB_DEVICE_DCD}" STREQUAL "dwc2_hc")
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_dc_dwc2.c)
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_glue_hc.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_dc_dwc2.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_glue_hc.c)
         elseif("${CONFIG_CHERRYUSB_DEVICE_DCD}" STREQUAL "musb_es")
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_dc_musb.c)
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_glue_es.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_dc_musb.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_glue_es.c)
         elseif("${CONFIG_CHERRYUSB_DEVICE_DCD}" STREQUAL "musb_sunxi")
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_dc_musb.c)
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_glue_sunxi.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_dc_musb.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_glue_sunxi.c)
         elseif("${CONFIG_CHERRYUSB_DEVICE_DCD}" STREQUAL "musb_bk")
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_dc_musb.c)
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_glue_bk.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_dc_musb.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_glue_bk.c)
         elseif("${CONFIG_CHERRYUSB_DEVICE_DCD}" STREQUAL "chipidea_mcx")
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/chipidea/usb_dc_chipidea.c)
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/chipidea/usb_glue_mcx.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/chipidea/usb_dc_chipidea.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/chipidea/usb_glue_mcx.c)
         elseif("${CONFIG_CHERRYUSB_DEVICE_DCD}" STREQUAL "kinetis_mcx")
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/kinetis/usb_dc_kinetis.c)
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/kinetis/usb_glue_mcx.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/kinetis/usb_dc_kinetis.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/kinetis/usb_glue_mcx.c)
         elseif("${CONFIG_CHERRYUSB_DEVICE_DCD}" STREQUAL "hpm")
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/hpm/usb_dc_hpm.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/hpm/usb_dc_hpm.c)
         elseif("${CONFIG_CHERRYUSB_DEVICE_DCD}" STREQUAL "bl")
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/bouffalolab/usb_dc_bl.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/bouffalolab/usb_dc_bl.c)
         elseif("${CONFIG_CHERRYUSB_DEVICE_DCD}" STREQUAL "aic")
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/aic/usb_dc_aic.c)
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/aic/usb_dc_aic_ll.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/aic/usb_dc_aic.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/aic/usb_dc_aic_ll.c)
         elseif("${CONFIG_CHERRYUSB_DEVICE_DCD}" STREQUAL "rp2040")
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/rp2040/usb_dc_rp2040.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/rp2040/usb_dc_rp2040.c)
         endif()
     endif()
 
 endif()
 
 if(CONFIG_CHERRYUSB_HOST)
-    list(APPEND cherryusb_srcs
-    ${CMAKE_CURRENT_LIST_DIR}/core/usbh_core.c
-    ${CMAKE_CURRENT_LIST_DIR}/class/hub/usbh_hub.c
+    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/core/usbh_core.c
+         ${CMAKE_CURRENT_LIST_DIR}/class/hub/usbh_hub.c
     )
 
     if(CONFIG_CHERRYUSB_HOST_CDC_ACM)
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/cdc/usbh_cdc_acm.c)
+        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/cdc/usbh_cdc_acm.c)
     endif()
     if(CONFIG_CHERRYUSB_HOST_CDC_ECM)
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/cdc/usbh_cdc_ecm.c)
+        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/cdc/usbh_cdc_ecm.c)
     endif()
     if(CONFIG_CHERRYUSB_HOST_CDC_RNDIS)
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/wireless/usbh_rndis.c)
+        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/wireless/usbh_rndis.c)
     endif()
     if(CONFIG_CHERRYUSB_HOST_CDC_NCM)
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/cdc/usbh_cdc_ncm.c)
+        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/cdc/usbh_cdc_ncm.c)
     endif()
     if(CONFIG_CHERRYUSB_HOST_HID)
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/hid/usbh_hid.c)
+        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/hid/usbh_hid.c)
     endif()
     if(CONFIG_CHERRYUSB_HOST_MSC)
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/msc/usbh_msc.c)
+        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/msc/usbh_msc.c)
 
-    if(CONFIG_CHERRYUSB_HOST_MSC_FATFS)
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/third_party/fatfs-0.14/source/port/fatfs_usbh.c)
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/third_party/fatfs-0.14/source/diskio.c)
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/third_party/fatfs-0.14/source/ff.c)
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/third_party/fatfs-0.14/source/ffsystem.c)
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/third_party/fatfs-0.14/source/ffunicode.c)
+        if(CONFIG_CHERRYUSB_HOST_MSC_FATFS)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/third_party/fatfs-0.14/source/port/fatfs_usbh.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/third_party/fatfs-0.14/source/diskio.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/third_party/fatfs-0.14/source/ff.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/third_party/fatfs-0.14/source/ffsystem.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/third_party/fatfs-0.14/source/ffunicode.c)
 
-    list(APPEND cherryusb_incs ${CMAKE_CURRENT_LIST_DIR}/third_party/fatfs-0.14/source)
-    endif()
+            list(APPEND cherryusb_incs ${CMAKE_CURRENT_LIST_DIR}/third_party/fatfs-0.14/source)
+        endif()
     endif()
     if(CONFIG_CHERRYUSB_HOST_VIDEO)
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/video/usbh_video.c)
+        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/video/usbh_video.c)
     endif()
     if(CONFIG_CHERRYUSB_HOST_AUDIO)
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/audio/usbh_audio.c)
+        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/audio/usbh_audio.c)
     endif()
     if(CONFIG_CHERRYUSB_HOST_BLUETOOTH)
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/wireless/usbh_bluetooth.c)
+        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/wireless/usbh_bluetooth.c)
 
-    set(BLUETOOTH_PATH ${CMAKE_CURRENT_LIST_DIR}/third_party/zephyr_bluetooth-2.7.5)
+        set(BLUETOOTH_PATH ${CMAKE_CURRENT_LIST_DIR}/third_party/zephyr_bluetooth-2.7.5)
 
-    list(APPEND cherryusb_srcs
-    ${BLUETOOTH_PATH}/ble_hci_usbh.c
-    ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/beacon/src/main.c
-    ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/central/src/main.c
-    ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/central_hr/src/main.c
-    ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/central_ht/src/main.c
-    ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/central_multilink/src/main.c
-    ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/central_multilink/src/central_multilink.c
-    # ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/handsfree/src/main.c
-    ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/ibeacon/src/main.c
-    ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/peripheral/src/main.c
-    ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/peripheral/src/cts.c
-    ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/peripheral_csc/src/main.c
-    ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/peripheral_dis/src/main.c
-    ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/peripheral_esp/src/main.c
-    ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/peripheral_hids/src/main.c
-    ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/peripheral_hids/src/hog.c
-    ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/peripheral_hr/src/main.c
-    # ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/peripheral_ht/src/main.c
-    # ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/peripheral_ht/src/hts.c
-    ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/peripheral_identity/src/main.c
-    ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/peripheral_identity/src/peripheral_identity.c
-    # ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/peripheral_ots/src/main.c
-    ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/peripheral_sc_only/src/main.c
-    ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/scan_adv/src/main.c
-    )
+        list(
+            APPEND
+            cherryusb_srcs
+            ${BLUETOOTH_PATH}/ble_hci_usbh.c
+            ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/beacon/src/main.c
+            ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/central/src/main.c
+            ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/central_hr/src/main.c
+            ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/central_ht/src/main.c
+            ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/central_multilink/src/main.c
+            ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/central_multilink/src/central_multilink.c
+            # ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/handsfree/src/main.c
+            ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/ibeacon/src/main.c
+            ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/peripheral/src/main.c
+            ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/peripheral/src/cts.c
+            ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/peripheral_csc/src/main.c
+            ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/peripheral_dis/src/main.c
+            ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/peripheral_esp/src/main.c
+            ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/peripheral_hids/src/main.c
+            ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/peripheral_hids/src/hog.c
+            ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/peripheral_hr/src/main.c
+            # ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/peripheral_ht/src/main.c
+            # ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/peripheral_ht/src/hts.c
+            ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/peripheral_identity/src/main.c
+            ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/peripheral_identity/src/peripheral_identity.c
+            # ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/peripheral_ots/src/main.c
+            ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/peripheral_sc_only/src/main.c
+            ${BLUETOOTH_PATH}/zephyr_bluetooth/examples/scan_adv/src/main.c
+        )
 
-    include(${BLUETOOTH_PATH}/zephyr_bluetooth/zephyr_bluetooth.cmake)
-    list(APPEND cherryusb_srcs ${zephyr_bluetooth_srcs})
-    list(APPEND cherryusb_incs ${zephyr_bluetooth_incs})
+        include(${BLUETOOTH_PATH}/zephyr_bluetooth/zephyr_bluetooth.cmake)
+        list(APPEND cherryusb_srcs ${zephyr_bluetooth_srcs})
+        list(APPEND cherryusb_incs ${zephyr_bluetooth_incs})
     endif()
 
     if(CONFIG_CHERRYUSB_HOST_ASIX)
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/vendor/net/usbh_asix.c)
+        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/vendor/net/usbh_asix.c)
     endif()
     if(CONFIG_CHERRYUSB_HOST_RTL8152)
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/vendor/net/usbh_rtl8152.c)
+        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/vendor/net/usbh_rtl8152.c)
     endif()
     if(CONFIG_CHERRYUSB_HOST_CH34X)
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/vendor/serial/usbh_ch34x.c)
+        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/vendor/serial/usbh_ch34x.c)
     endif()
     if(CONFIG_CHERRYUSB_HOST_CP210X)
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/vendor/serial/usbh_cp210x.c)
+        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/vendor/serial/usbh_cp210x.c)
     endif()
     if(CONFIG_CHERRYUSB_HOST_FTDI)
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/vendor/serial/usbh_ftdi.c)
+        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/vendor/serial/usbh_ftdi.c)
     endif()
     if(CONFIG_CHERRYUSB_HOST_PL2303)
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/vendor/serial/usbh_pl2303.c)
+        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/vendor/serial/usbh_pl2303.c)
     endif()
     if(CONFIG_CHERRYUSB_HOST_BL616)
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/vendor/wifi/usbh_bl616.c)
+        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/vendor/wifi/usbh_bl616.c)
     endif()
     if(CONFIG_CHERRYUSB_HOST_AOA)
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/aoa/usbh_aoa.c)
+        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/class/aoa/usbh_aoa.c)
     endif()
 
     if(DEFINED CONFIG_CHERRYUSB_HOST_HCD)
         if("${CONFIG_CHERRYUSB_HOST_HCD}" STREQUAL "ehci_bouffalo")
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_hc_ehci.c)
-        #list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_hc_ehci_iso.c)
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_glue_bouffalo.c)
-        list(APPEND cherryusb_incs ${CMAKE_CURRENT_LIST_DIR}/port/ehci)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_hc_ehci.c)
+            # list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_hc_ehci_iso.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_glue_bouffalo.c)
+            list(APPEND cherryusb_incs ${CMAKE_CURRENT_LIST_DIR}/port/ehci)
         elseif("${CONFIG_CHERRYUSB_HOST_HCD}" STREQUAL "ehci_hpm")
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_hc_ehci.c)
-        #list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_hc_ehci_iso.c)
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_glue_hpm.c)
-        list(APPEND cherryusb_incs ${CMAKE_CURRENT_LIST_DIR}/port/ehci)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_hc_ehci.c)
+            # list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_hc_ehci_iso.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_glue_hpm.c)
+            list(APPEND cherryusb_incs ${CMAKE_CURRENT_LIST_DIR}/port/ehci)
         elseif("${CONFIG_CHERRYUSB_HOST_HCD}" STREQUAL "ehci_aic")
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_hc_ehci.c)
-        #list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_hc_ehci_iso.c)
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_glue_aic.c)
-        list(APPEND cherryusb_incs ${CMAKE_CURRENT_LIST_DIR}/port/ehci)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_hc_ehci.c)
+            # list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_hc_ehci_iso.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_glue_aic.c)
+            list(APPEND cherryusb_incs ${CMAKE_CURRENT_LIST_DIR}/port/ehci)
         elseif("${CONFIG_CHERRYUSB_HOST_HCD}" STREQUAL "ehci_mcx")
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_hc_ehci.c)
-        #list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_hc_ehci_iso.c)
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_glue_mcx.c)
-        list(APPEND cherryusb_incs ${CMAKE_CURRENT_LIST_DIR}/port/ehci)
-        list(APPEND cherryusb_incs ${CMAKE_CURRENT_LIST_DIR}/port/chipidea)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_hc_ehci.c)
+            # list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_hc_ehci_iso.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_glue_mcx.c)
+            list(APPEND cherryusb_incs ${CMAKE_CURRENT_LIST_DIR}/port/ehci)
+            list(APPEND cherryusb_incs ${CMAKE_CURRENT_LIST_DIR}/port/chipidea)
         elseif("${CONFIG_CHERRYUSB_HOST_HCD}" STREQUAL "ehci_nuvoton")
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_hc_ehci.c)
-        #list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_hc_ehci_iso.c)
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_glue_nuvoton.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_hc_ehci.c)
+            # list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_hc_ehci_iso.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_glue_nuvoton.c)
         elseif("${CONFIG_CHERRYUSB_HOST_HCD}" STREQUAL "dwc2_st")
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_hc_dwc2.c)
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_glue_st.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_hc_dwc2.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_glue_st.c)
         elseif("${CONFIG_CHERRYUSB_HOST_HCD}" STREQUAL "dwc2_esp")
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_hc_dwc2.c)
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_glue_esp.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_hc_dwc2.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_glue_esp.c)
         elseif("${CONFIG_CHERRYUSB_HOST_HCD}" STREQUAL "dwc2_hc")
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_hc_dwc2.c)
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_glue_hc.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_hc_dwc2.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/dwc2/usb_glue_hc.c)
         elseif("${CONFIG_CHERRYUSB_HOST_HCD}" STREQUAL "musb_es")
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_hc_musb.c)
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_glue_es.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_hc_musb.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_glue_es.c)
         elseif("${CONFIG_CHERRYUSB_HOST_HCD}" STREQUAL "musb_sunxi")
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_hc_musb.c)
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_glue_sunxi.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_hc_musb.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_glue_sunxi.c)
         elseif("${CONFIG_CHERRYUSB_HOST_HCD}" STREQUAL "musb_bk")
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_hc_musb.c)
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_glue_bk.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_hc_musb.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/musb/usb_glue_bk.c)
         elseif("${CONFIG_CHERRYUSB_HOST_HCD}" STREQUAL "kinetis_mcx")
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/kinetis/usb_hc_kinetis.c)
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/kinetis/usb_glue_mcx.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/kinetis/usb_hc_kinetis.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/kinetis/usb_glue_mcx.c)
         elseif("${CONFIG_CHERRYUSB_HOST_HCD}" STREQUAL "rp2040")
-        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/rp2040/usb_hc_rp2040.c)
+            list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/rp2040/usb_hc_rp2040.c)
         endif()
     endif()
 
@@ -283,30 +290,30 @@ endif()
 
 if(DEFINED CONFIG_CHERRYUSB_OSAL)
     if("${CONFIG_CHERRYUSB_OSAL}" STREQUAL "freertos")
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/osal/usb_osal_freertos.c)
+        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/osal/usb_osal_freertos.c)
     elseif("${CONFIG_CHERRYUSB_OSAL}" STREQUAL "rtthread")
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/osal/usb_osal_rtthread.c)
+        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/osal/usb_osal_rtthread.c)
     elseif("${CONFIG_CHERRYUSB_OSAL}" STREQUAL "yoc")
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/osal/usb_osal_yoc.c)
+        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/osal/usb_osal_yoc.c)
     elseif("${CONFIG_CHERRYUSB_OSAL}" STREQUAL "idf")
-    list(APPEND cherryusb_incs ${CMAKE_CURRENT_LIST_DIR}/osal/idf)
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/osal/idf/usb_osal_idf.c)
+        list(APPEND cherryusb_incs ${CMAKE_CURRENT_LIST_DIR}/osal/idf)
+        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/osal/idf/usb_osal_idf.c)
     elseif("${CONFIG_CHERRYUSB_OSAL}" STREQUAL "threadx")
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/osal/usb_osal_threadx.c)
+        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/osal/usb_osal_threadx.c)
     endif()
 endif()
 
 if(CONFIG_CHERRYRB)
-list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/third_party/cherryrb/chry_ringbuffer.c)
-list(APPEND cherryusb_incs ${CMAKE_CURRENT_LIST_DIR}/third_party/cherryrb)
+    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/third_party/cherryrb/chry_ringbuffer.c)
+    list(APPEND cherryusb_incs ${CMAKE_CURRENT_LIST_DIR}/third_party/cherryrb)
 endif()
 
 if(CONFIG_CHERRYMP)
-list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/third_party/cherrymp/chry_mempool.c)
-list(APPEND cherryusb_incs ${CMAKE_CURRENT_LIST_DIR}/third_party/cherrymp)
+    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/third_party/cherrymp/chry_mempool.c)
+    list(APPEND cherryusb_incs ${CMAKE_CURRENT_LIST_DIR}/third_party/cherrymp)
     if("${CONFIG_CHERRYUSB_OSAL}" STREQUAL "freertos")
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/third_party/cherrymp/chry_mempool_osal_freertos.c)
+        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/third_party/cherrymp/chry_mempool_osal_freertos.c)
     elseif("${CONFIG_CHERRYUSB_OSAL}" STREQUAL "rtthread")
-    list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/third_party/cherrymp/chry_mempool_osal_rtthread.c)
+        list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/third_party/cherrymp/chry_mempool_osal_rtthread.c)
     endif()
-endif()
+endif()