demo.html 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. <!DOCTYPE html>
  2. <html class="writer-html5" lang="en" data-content_root="../">
  3. <head>
  4. <meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <title>基于现有 demo 快速验证 &mdash; CherryUSB 1.6.0 documentation</title>
  7. <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=80d5e7a1" />
  8. <link rel="stylesheet" type="text/css" href="../_static/css/theme.css?v=9edc463e" />
  9. <script src="../_static/jquery.js?v=5d32c60e"></script>
  10. <script src="../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
  11. <script src="../_static/documentation_options.js?v=72d88caf"></script>
  12. <script src="../_static/doctools.js?v=9a2dae69"></script>
  13. <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
  14. <script src="../_static/js/theme.js"></script>
  15. <link rel="index" title="Index" href="../genindex.html" />
  16. <link rel="search" title="Search" href="../search.html" />
  17. <link rel="next" title="芯片通用移植指南" href="transplant.html" />
  18. <link rel="prev" title="入门必看" href="start.html" />
  19. </head>
  20. <body class="wy-body-for-nav">
  21. <div class="wy-grid-for-nav">
  22. <nav data-toggle="wy-nav-shift" class="wy-nav-side">
  23. <div class="wy-side-scroll">
  24. <div class="wy-side-nav-search" >
  25. <a href="../index.html" class="icon icon-home">
  26. CherryUSB
  27. </a>
  28. <div role="search">
  29. <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
  30. <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
  31. <input type="hidden" name="check_keywords" value="yes" />
  32. <input type="hidden" name="area" value="default" />
  33. </form>
  34. </div>
  35. </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
  36. <p class="caption" role="heading"><span class="caption-text">快速上手</span></p>
  37. <ul class="current">
  38. <li class="toctree-l1"><a class="reference internal" href="start.html">入门必看</a></li>
  39. <li class="toctree-l1 current"><a class="current reference internal" href="#">基于现有 demo 快速验证</a><ul>
  40. <li class="toctree-l2"><a class="reference internal" href="#bouffalolab-sdk">基于 bouffalolab 系列芯片(官方 SDK 支持)</a></li>
  41. <li class="toctree-l2"><a class="reference internal" href="#hpmicro-sdk">基于 HPMicro 系列芯片(官方 SDK 支持)</a></li>
  42. <li class="toctree-l2"><a class="reference internal" href="#esp32s2-s3-p4-sdk">基于 esp32s2/s3/p4 系列芯片(官方 SDK 支持)</a></li>
  43. <li class="toctree-l2"><a class="reference internal" href="#phytium-sdk">基于 Phytium 系列芯片(官方 SDK 支持)</a></li>
  44. <li class="toctree-l2"><a class="reference internal" href="#essemi-sdk">基于 Essemi 系列芯片(官方 SDK 支持)</a></li>
  45. <li class="toctree-l2"><a class="reference internal" href="#artinchip-sdk">基于 Artinchip 系列芯片(官方 SDK 支持)</a></li>
  46. <li class="toctree-l2"><a class="reference internal" href="#kendryte-canmv-k230-sdk">基于 Kendryte canmv-k230 系列(官方 SDK 支持)</a></li>
  47. <li class="toctree-l2"><a class="reference internal" href="#nxp-mcx">基于 NXP MCX 系列芯片</a></li>
  48. <li class="toctree-l2"><a class="reference internal" href="#sifli-sf32-sdk">基于 SiFli SF32 系列芯片(官方 SDK 支持)</a></li>
  49. <li class="toctree-l2"><a class="reference internal" href="#rp2040-rp2035-sdk">基于 RP2040/RP2035 芯片(官方 SDK 即将支持)</a></li>
  50. <li class="toctree-l2"><a class="reference internal" href="#actionstech-sdk">基于 Actionstech 系列芯片(官方 SDK 支持)</a></li>
  51. <li class="toctree-l2"><a class="reference internal" href="#st">基于 ST 系列芯片</a><ul>
  52. <li class="toctree-l3"><a class="reference internal" href="#usb-device">USB Device 移植要点</a></li>
  53. <li class="toctree-l3"><a class="reference internal" href="#usb-host">USB Host 移植要点</a></li>
  54. </ul>
  55. </li>
  56. </ul>
  57. </li>
  58. <li class="toctree-l1"><a class="reference internal" href="transplant.html">芯片通用移植指南</a></li>
  59. <li class="toctree-l1"><a class="reference internal" href="rtthread.html">基于 RT-Thread 软件包开发指南</a></li>
  60. <li class="toctree-l1"><a class="reference internal" href="q%26a.html">Q &amp; A</a></li>
  61. <li class="toctree-l1"><a class="reference internal" href="migration.html">部分改动迁移指南</a></li>
  62. <li class="toctree-l1"><a class="reference internal" href="share.html">开发者经验/开源项目分享</a></li>
  63. <li class="toctree-l1"><a class="reference internal" href="opensource.html">官方开源项目分享</a></li>
  64. </ul>
  65. <p class="caption" role="heading"><span class="caption-text">USB 基本知识点</span></p>
  66. <ul>
  67. <li class="toctree-l1"><a class="reference internal" href="../usb/usb2.0_basic.html">USB 基本概念(2.0 为主)</a></li>
  68. <li class="toctree-l1"><a class="reference internal" href="../usb/usb3.0_basic.html">USB 基本概念(3.0 为主)</a></li>
  69. <li class="toctree-l1"><a class="reference internal" href="../usb/usb_desc.html">USB 描述符</a></li>
  70. <li class="toctree-l1"><a class="reference internal" href="../usb/usb_request.html">USB 设备请求</a></li>
  71. <li class="toctree-l1"><a class="reference internal" href="../usb/usb_enum.html">USB 枚举</a></li>
  72. <li class="toctree-l1"><a class="reference internal" href="../usb/usb_ext.html">USB 知识点拓展</a></li>
  73. </ul>
  74. <p class="caption" role="heading"><span class="caption-text">API 手册</span></p>
  75. <ul>
  76. <li class="toctree-l1"><a class="reference internal" href="../api/api_device.html">设备协议栈</a></li>
  77. <li class="toctree-l1"><a class="reference internal" href="../api/api_host.html">主机协议栈</a></li>
  78. <li class="toctree-l1"><a class="reference internal" href="../api/api_port.html">主从驱动</a></li>
  79. <li class="toctree-l1"><a class="reference internal" href="../api/api_config.html">USB CONFIG 说明</a></li>
  80. </ul>
  81. <p class="caption" role="heading"><span class="caption-text">Class 指南</span></p>
  82. <ul>
  83. <li class="toctree-l1"><a class="reference internal" href="../class/class_cdc.html">CDC</a></li>
  84. <li class="toctree-l1"><a class="reference internal" href="../class/class_hid.html">HID</a></li>
  85. <li class="toctree-l1"><a class="reference internal" href="../class/class_msc.html">MSC</a></li>
  86. <li class="toctree-l1"><a class="reference internal" href="../class/class_audio.html">UAC</a></li>
  87. <li class="toctree-l1"><a class="reference internal" href="../class/class_video.html">UVC</a></li>
  88. <li class="toctree-l1"><a class="reference internal" href="../class/winusb.html">WINUSB</a></li>
  89. </ul>
  90. <p class="caption" role="heading"><span class="caption-text">例程</span></p>
  91. <ul>
  92. <li class="toctree-l1"><a class="reference internal" href="../demo/usbd_cdc_acm.html">CDC ACM Device</a></li>
  93. <li class="toctree-l1"><a class="reference internal" href="../demo/usbd_hid.html">HID Device</a></li>
  94. <li class="toctree-l1"><a class="reference internal" href="../demo/usbd_msc.html">MSC Device</a></li>
  95. <li class="toctree-l1"><a class="reference internal" href="../demo/usbd_audiov1.html">AudioV1 Device</a></li>
  96. <li class="toctree-l1"><a class="reference internal" href="../demo/usbd_audiov2.html">AudioV2 Device</a></li>
  97. <li class="toctree-l1"><a class="reference internal" href="../demo/usbd_video.html">USB Video Device</a></li>
  98. <li class="toctree-l1"><a class="reference internal" href="../demo/usbd_winusb.html">WinUSB Device</a></li>
  99. <li class="toctree-l1"><a class="reference internal" href="../demo/usbd_webusb.html">WebUSB Device</a></li>
  100. <li class="toctree-l1"><a class="reference internal" href="../demo/usbd_rndis.html">CDC RNDIS Device</a></li>
  101. <li class="toctree-l1"><a class="reference internal" href="../demo/usbd_ecm.html">CDC ECM Device</a></li>
  102. <li class="toctree-l1"><a class="reference internal" href="../demo/usbd_adb.html">ADB Device</a></li>
  103. <li class="toctree-l1"><a class="reference internal" href="../demo/usbd_mtp.html">MTP Device</a></li>
  104. <li class="toctree-l1"><a class="reference internal" href="../demo/usbh_serial.html">Serial Host</a></li>
  105. <li class="toctree-l1"><a class="reference internal" href="../demo/usbh_hid.html">HID Host</a></li>
  106. <li class="toctree-l1"><a class="reference internal" href="../demo/usbh_msc.html">MSC Host</a></li>
  107. <li class="toctree-l1"><a class="reference internal" href="../demo/usbh_net.html">Network Host</a></li>
  108. <li class="toctree-l1"><a class="reference internal" href="../demo/usbh_bluetooth.html">BTBLE Host</a></li>
  109. <li class="toctree-l1"><a class="reference internal" href="../demo/usbh_wifi.html">WIFI Host</a></li>
  110. <li class="toctree-l1"><a class="reference internal" href="../demo/usbh_audio.html">Audio Host</a></li>
  111. <li class="toctree-l1"><a class="reference internal" href="../demo/usbh_video.html">Video Host</a></li>
  112. <li class="toctree-l1"><a class="reference internal" href="../demo/usb_otg.html">USB OTG</a></li>
  113. <li class="toctree-l1"><a class="reference internal" href="../demo/usbd_vendor.html">Vendor Device 驱动编写</a></li>
  114. <li class="toctree-l1"><a class="reference internal" href="../demo/usbh_vendor.html">Vendor Host 驱动编写</a></li>
  115. </ul>
  116. <p class="caption" role="heading"><span class="caption-text">USBIP 介绍</span></p>
  117. <ul>
  118. <li class="toctree-l1"><a class="reference internal" href="../usbip/ohci.html">OHCI</a></li>
  119. <li class="toctree-l1"><a class="reference internal" href="../usbip/ehci.html">EHCI</a></li>
  120. <li class="toctree-l1"><a class="reference internal" href="../usbip/xhci.html">XHCI</a></li>
  121. <li class="toctree-l1"><a class="reference internal" href="../usbip/chipidea.html">CHIPIDEA</a></li>
  122. <li class="toctree-l1"><a class="reference internal" href="../usbip/dwc2.html">DWC2</a></li>
  123. <li class="toctree-l1"><a class="reference internal" href="../usbip/musb.html">MUSB</a></li>
  124. <li class="toctree-l1"><a class="reference internal" href="../usbip/fotg210.html">FOTG210</a></li>
  125. <li class="toctree-l1"><a class="reference internal" href="../usbip/cdns2.html">CDNS2</a></li>
  126. <li class="toctree-l1"><a class="reference internal" href="../usbip/cdns3.html">CDNS3</a></li>
  127. <li class="toctree-l1"><a class="reference internal" href="../usbip/dwc3.html">DWC3</a></li>
  128. </ul>
  129. <p class="caption" role="heading"><span class="caption-text">工具使用</span></p>
  130. <ul>
  131. <li class="toctree-l1"><a class="reference internal" href="../tools/index.html">chryusb_configurator</a></li>
  132. <li class="toctree-l1"><a class="reference internal" href="../tools/index.html#usb-protocol-suite">力科 USB Protocol Suite</a></li>
  133. <li class="toctree-l1"><a class="reference internal" href="../tools/index.html#wireshark">Wireshark</a></li>
  134. <li class="toctree-l1"><a class="reference internal" href="../tools/index.html#audacity">Audacity</a></li>
  135. </ul>
  136. <p class="caption" role="heading"><span class="caption-text">版本说明</span></p>
  137. <ul>
  138. <li class="toctree-l1"><a class="reference internal" href="../version.html">版本说明</a></li>
  139. </ul>
  140. <p class="caption" role="heading"><span class="caption-text">性能展示</span></p>
  141. <ul>
  142. <li class="toctree-l1"><a class="reference internal" href="../show/index.html">性能展示</a></li>
  143. </ul>
  144. <p class="caption" role="heading"><span class="caption-text">商业支持</span></p>
  145. <ul>
  146. <li class="toctree-l1"><a class="reference internal" href="../support/index.html">商业支持</a></li>
  147. </ul>
  148. </div>
  149. </div>
  150. </nav>
  151. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
  152. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  153. <a href="../index.html">CherryUSB</a>
  154. </nav>
  155. <div class="wy-nav-content">
  156. <div class="rst-content">
  157. <div role="navigation" aria-label="Page navigation">
  158. <ul class="wy-breadcrumbs">
  159. <li><a href="../index.html" class="icon icon-home" aria-label="Home"></a></li>
  160. <li class="breadcrumb-item active">基于现有 demo 快速验证</li>
  161. <li class="wy-breadcrumbs-aside">
  162. <a href="../_sources/quick_start/demo.rst.txt" rel="nofollow"> View page source</a>
  163. </li>
  164. </ul>
  165. <hr/>
  166. </div>
  167. <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
  168. <div itemprop="articleBody">
  169. <section id="demo">
  170. <h1>基于现有 demo 快速验证<a class="headerlink" href="#demo" title="Link to this heading"></a></h1>
  171. <p>在学习 USB 或者是学习 CherryUSB 代码之前,我们需要先基于现有的 demo 进行快速验证,为什么?是为了提升对 USB 的兴趣,能有信心进行下一步的动作,如果 demo 都跑不起来,或者自己摸索写代码,或者先看 USB 基本概念,结果看到最后,
  172. 发现一点都看不懂,概念好多,根本记不住,从而丧失对 USB 的兴趣。因此,先跑 demo 非常重要。下面我将给大家罗列目前支持的 demo 仓库。</p>
  173. <section id="bouffalolab-sdk">
  174. <h2>基于 bouffalolab 系列芯片(官方 SDK 支持)<a class="headerlink" href="#bouffalolab-sdk" title="Link to this heading"></a></h2>
  175. <table class="docutils align-default">
  176. <colgroup>
  177. <col style="width: 33.3%" />
  178. <col style="width: 33.3%" />
  179. <col style="width: 33.3%" />
  180. </colgroup>
  181. <thead>
  182. <tr class="row-odd"><th class="head"><p>Repo url</p></th>
  183. <th class="head"><p>USB IP</p></th>
  184. <th class="head"><p>Version</p></th>
  185. </tr>
  186. </thead>
  187. <tbody>
  188. <tr class="row-even"><td><p><a class="reference external" href="https://github.com/CherryUSB/cherryusb_bouffalolab">https://github.com/CherryUSB/cherryusb_bouffalolab</a></p></td>
  189. <td><p>FOTG210</p></td>
  190. <td><p>less than latest</p></td>
  191. </tr>
  192. </tbody>
  193. </table>
  194. </section>
  195. <section id="hpmicro-sdk">
  196. <h2>基于 HPMicro 系列芯片(官方 SDK 支持)<a class="headerlink" href="#hpmicro-sdk" title="Link to this heading"></a></h2>
  197. <table class="docutils align-default">
  198. <colgroup>
  199. <col style="width: 33.3%" />
  200. <col style="width: 33.3%" />
  201. <col style="width: 33.3%" />
  202. </colgroup>
  203. <thead>
  204. <tr class="row-odd"><th class="head"><p>Repo url</p></th>
  205. <th class="head"><p>USB IP</p></th>
  206. <th class="head"><p>Version</p></th>
  207. </tr>
  208. </thead>
  209. <tbody>
  210. <tr class="row-even"><td><p><a class="reference external" href="https://github.com/CherryUSB/cherryusb_hpmicro">https://github.com/CherryUSB/cherryusb_hpmicro</a></p></td>
  211. <td><p>CHIPIDEA</p></td>
  212. <td><p>less than latest</p></td>
  213. </tr>
  214. </tbody>
  215. </table>
  216. </section>
  217. <section id="esp32s2-s3-p4-sdk">
  218. <h2>基于 esp32s2/s3/p4 系列芯片(官方 SDK 支持)<a class="headerlink" href="#esp32s2-s3-p4-sdk" title="Link to this heading"></a></h2>
  219. <table class="docutils align-default">
  220. <colgroup>
  221. <col style="width: 33.3%" />
  222. <col style="width: 33.3%" />
  223. <col style="width: 33.3%" />
  224. </colgroup>
  225. <thead>
  226. <tr class="row-odd"><th class="head"><p>Repo url</p></th>
  227. <th class="head"><p>USB IP</p></th>
  228. <th class="head"><p>Version</p></th>
  229. </tr>
  230. </thead>
  231. <tbody>
  232. <tr class="row-even"><td><p><a class="reference external" href="https://github.com/CherryUSB/cherryusb_esp32">https://github.com/CherryUSB/cherryusb_esp32</a></p></td>
  233. <td><p>DWC2</p></td>
  234. <td><p>less than latest</p></td>
  235. </tr>
  236. </tbody>
  237. </table>
  238. <p>默认 demo 采用组件库安装的形式,在 <a class="reference external" href="https://components.espressif.com/">https://components.espressif.com/</a> 中搜索 cherryusb 即可。也可使用官方 idf 仓库下的 cherryusb demo。</p>
  239. <p>ESP-Registry 可以参考官方文档,推荐使用 vscode + esp-idf 的开发环境。</p>
  240. <ul class="simple">
  241. <li><p>ctrl + shift + p 选择 ESP-IDF 欢迎界面,然后选择 Component mananger</p></li>
  242. </ul>
  243. <figure class="align-default">
  244. <img alt="../_images/esp1.png" src="../_images/esp1.png" />
  245. </figure>
  246. <ul class="simple">
  247. <li><p>找到 cherryusb 并安装</p></li>
  248. </ul>
  249. <figure class="align-default">
  250. <img alt="../_images/esp2.png" src="../_images/esp2.png" />
  251. </figure>
  252. <ul class="simple">
  253. <li><p>打开 menuconfig,并打开 cherryusb 的配置,根据实际情况选择主机或者从机模式</p></li>
  254. </ul>
  255. <figure class="align-default">
  256. <img alt="../_images/esp3.png" src="../_images/esp3.png" />
  257. </figure>
  258. <figure class="align-default">
  259. <img alt="../_images/esp4.png" src="../_images/esp4.png" />
  260. </figure>
  261. </section>
  262. <section id="phytium-sdk">
  263. <h2>基于 Phytium 系列芯片(官方 SDK 支持)<a class="headerlink" href="#phytium-sdk" title="Link to this heading"></a></h2>
  264. <table class="docutils align-default">
  265. <colgroup>
  266. <col style="width: 33.3%" />
  267. <col style="width: 33.3%" />
  268. <col style="width: 33.3%" />
  269. </colgroup>
  270. <thead>
  271. <tr class="row-odd"><th class="head"><p>Repo url</p></th>
  272. <th class="head"><p>USB IP</p></th>
  273. <th class="head"><p>Version</p></th>
  274. </tr>
  275. </thead>
  276. <tbody>
  277. <tr class="row-even"><td><p><a class="reference external" href="https://gitee.com/phytium_embedded/phytium-free-rtos-sdk">https://gitee.com/phytium_embedded/phytium-free-rtos-sdk</a></p></td>
  278. <td><p>PUSB2/XHCI</p></td>
  279. <td><p>equal to v1.4.0</p></td>
  280. </tr>
  281. </tbody>
  282. </table>
  283. </section>
  284. <section id="essemi-sdk">
  285. <h2>基于 Essemi 系列芯片(官方 SDK 支持)<a class="headerlink" href="#essemi-sdk" title="Link to this heading"></a></h2>
  286. <table class="docutils align-default">
  287. <colgroup>
  288. <col style="width: 33.3%" />
  289. <col style="width: 33.3%" />
  290. <col style="width: 33.3%" />
  291. </colgroup>
  292. <thead>
  293. <tr class="row-odd"><th class="head"><p>Repo url</p></th>
  294. <th class="head"><p>USB IP</p></th>
  295. <th class="head"><p>Version</p></th>
  296. </tr>
  297. </thead>
  298. <tbody>
  299. <tr class="row-even"><td><p><a class="reference external" href="https://github.com/CherryUSB/cherryusb_es32">https://github.com/CherryUSB/cherryusb_es32</a></p></td>
  300. <td><p>MUSB</p></td>
  301. <td><p>less than latest</p></td>
  302. </tr>
  303. </tbody>
  304. </table>
  305. </section>
  306. <section id="artinchip-sdk">
  307. <h2>基于 Artinchip 系列芯片(官方 SDK 支持)<a class="headerlink" href="#artinchip-sdk" title="Link to this heading"></a></h2>
  308. <table class="docutils align-default">
  309. <colgroup>
  310. <col style="width: 33.3%" />
  311. <col style="width: 33.3%" />
  312. <col style="width: 33.3%" />
  313. </colgroup>
  314. <thead>
  315. <tr class="row-odd"><th class="head"><p>Repo url</p></th>
  316. <th class="head"><p>USB IP</p></th>
  317. <th class="head"><p>Version</p></th>
  318. </tr>
  319. </thead>
  320. <tbody>
  321. <tr class="row-even"><td><p><a class="reference external" href="https://gitee.com/artinchip/luban-lite">https://gitee.com/artinchip/luban-lite</a></p></td>
  322. <td><p>AIC/EHCI/OHCI</p></td>
  323. <td><p>less than latest</p></td>
  324. </tr>
  325. </tbody>
  326. </table>
  327. </section>
  328. <section id="kendryte-canmv-k230-sdk">
  329. <h2>基于 Kendryte canmv-k230 系列(官方 SDK 支持)<a class="headerlink" href="#kendryte-canmv-k230-sdk" title="Link to this heading"></a></h2>
  330. <table class="docutils align-default">
  331. <colgroup>
  332. <col style="width: 33.3%" />
  333. <col style="width: 33.3%" />
  334. <col style="width: 33.3%" />
  335. </colgroup>
  336. <thead>
  337. <tr class="row-odd"><th class="head"><p>Repo url</p></th>
  338. <th class="head"><p>USB IP</p></th>
  339. <th class="head"><p>Version</p></th>
  340. </tr>
  341. </thead>
  342. <tbody>
  343. <tr class="row-even"><td><p><a class="reference external" href="https://github.com/CherryUSB/k230_sdk">https://github.com/CherryUSB/k230_sdk</a></p></td>
  344. <td><p>DWC2</p></td>
  345. <td><p>less than latest</p></td>
  346. </tr>
  347. </tbody>
  348. </table>
  349. </section>
  350. <section id="nxp-mcx">
  351. <h2>基于 NXP MCX 系列芯片<a class="headerlink" href="#nxp-mcx" title="Link to this heading"></a></h2>
  352. <table class="docutils align-default">
  353. <colgroup>
  354. <col style="width: 33.3%" />
  355. <col style="width: 33.3%" />
  356. <col style="width: 33.3%" />
  357. </colgroup>
  358. <thead>
  359. <tr class="row-odd"><th class="head"><p>Repo url</p></th>
  360. <th class="head"><p>USB IP</p></th>
  361. <th class="head"><p>Version</p></th>
  362. </tr>
  363. </thead>
  364. <tbody>
  365. <tr class="row-even"><td><p><a class="reference external" href="https://github.com/CherryUSB/cherryusb_mcx">https://github.com/CherryUSB/cherryusb_mcx</a> <a class="reference external" href="https://github.com/RT-Thread/rt-thread/tree/master/bsp/nxp/mcx">https://github.com/RT-Thread/rt-thread/tree/master/bsp/nxp/mcx</a></p></td>
  366. <td><p>CHIPIDEA/kinetis</p></td>
  367. <td><p>less than latest</p></td>
  368. </tr>
  369. </tbody>
  370. </table>
  371. </section>
  372. <section id="sifli-sf32-sdk">
  373. <h2>基于 SiFli SF32 系列芯片(官方 SDK 支持)<a class="headerlink" href="#sifli-sf32-sdk" title="Link to this heading"></a></h2>
  374. <table class="docutils align-default">
  375. <colgroup>
  376. <col style="width: 33.3%" />
  377. <col style="width: 33.3%" />
  378. <col style="width: 33.3%" />
  379. </colgroup>
  380. <thead>
  381. <tr class="row-odd"><th class="head"><p>Repo url</p></th>
  382. <th class="head"><p>USB IP</p></th>
  383. <th class="head"><p>Version</p></th>
  384. </tr>
  385. </thead>
  386. <tbody>
  387. <tr class="row-even"><td><p><a class="reference external" href="https://github.com/OpenSiFli/SiFli-SDK">https://github.com/OpenSiFli/SiFli-SDK</a></p></td>
  388. <td><p>MUSB</p></td>
  389. <td><p>less than latest</p></td>
  390. </tr>
  391. </tbody>
  392. </table>
  393. </section>
  394. <section id="rp2040-rp2035-sdk">
  395. <h2>基于 RP2040/RP2035 芯片(官方 SDK 即将支持)<a class="headerlink" href="#rp2040-rp2035-sdk" title="Link to this heading"></a></h2>
  396. <table class="docutils align-default">
  397. <colgroup>
  398. <col style="width: 33.3%" />
  399. <col style="width: 33.3%" />
  400. <col style="width: 33.3%" />
  401. </colgroup>
  402. <thead>
  403. <tr class="row-odd"><th class="head"><p>Repo url</p></th>
  404. <th class="head"><p>USB IP</p></th>
  405. <th class="head"><p>Version</p></th>
  406. </tr>
  407. </thead>
  408. <tbody>
  409. <tr class="row-even"><td><p><a class="reference external" href="https://github.com/CherryUSB/pico-examples">https://github.com/CherryUSB/pico-examples</a> <a class="reference external" href="https://github.com/CherryUSB/pico-sdk">https://github.com/CherryUSB/pico-sdk</a></p></td>
  410. <td><p>RP2040</p></td>
  411. <td><p>less than latest</p></td>
  412. </tr>
  413. </tbody>
  414. </table>
  415. </section>
  416. <section id="actionstech-sdk">
  417. <h2>基于 Actionstech 系列芯片(官方 SDK 支持)<a class="headerlink" href="#actionstech-sdk" title="Link to this heading"></a></h2>
  418. <p>Not opensource, 请联系 Actionstech 官方</p>
  419. </section>
  420. <section id="st">
  421. <h2>基于 ST 系列芯片<a class="headerlink" href="#st" title="Link to this heading"></a></h2>
  422. <table class="docutils align-default">
  423. <colgroup>
  424. <col style="width: 33.3%" />
  425. <col style="width: 33.3%" />
  426. <col style="width: 33.3%" />
  427. </colgroup>
  428. <thead>
  429. <tr class="row-odd"><th class="head"><p>Repo url</p></th>
  430. <th class="head"><p>USB IP</p></th>
  431. <th class="head"><p>Version</p></th>
  432. </tr>
  433. </thead>
  434. <tbody>
  435. <tr class="row-even"><td><p><a class="reference external" href="https://github.com/CherryUSB/cherryusb_stm32">https://github.com/CherryUSB/cherryusb_stm32</a></p></td>
  436. <td><p>DWC2/FSDEV</p></td>
  437. <td><p>less than latest</p></td>
  438. </tr>
  439. </tbody>
  440. </table>
  441. <p>默认提供以下 demo 工程:</p>
  442. <ul class="simple">
  443. <li><p>F103 使用 fsdev ip</p></li>
  444. <li><p>F429 主从使用 USB1, 引脚 pb14/pb15, 默认从机没有开启 DMA 模式</p></li>
  445. <li><p>H7 设备使用 USB0, 引脚 pa11/pa12,没有开 DMA 模式。主机使用 USB1 ,引脚 pb14/pb15,并且需要做 nocache 处理</p></li>
  446. </ul>
  447. <p>demo 底下提供了 <strong>stm32xxx.ioc</strong> 文件,双击打开,点击 <strong>Generate Code</strong> 即可。</p>
  448. <div class="admonition caution">
  449. <p class="admonition-title">Caution</p>
  450. <p>生成完以后,请使用 git reset 功能将被覆盖的 <cite>main.c</cite> 和 <cite>stm32xxx_it.c</cite> 文件撤回,禁止被 cubemx 覆盖。</p>
  451. </div>
  452. <p>涵盖 F1/F4/H7,其余芯片基本类似,不再赘述,具体区别有:</p>
  453. <ul class="simple">
  454. <li><p>usb ip 区别:F1使用 fsdev,F4/H7使用 dwc2</p></li>
  455. <li><p>dwc2 ip 区别: USB0 (引脚是 PA11/PA12) 和 USB1 (引脚是 PB14/PB15), 其中 USB1 默认全速,可以接外部PHY 形成高速主机,并且带 dma 功能</p></li>
  456. <li><p>F4 无 cache,H7 有 cache</p></li>
  457. </ul>
  458. <p>如果是 STM32F7/STM32H7 这种带 cache 功能,需要将 usb 使用到的 ram 定位到 no cache ram 区域。举例如下</p>
  459. <div class="highlight-C notranslate"><div class="highlight"><pre><span></span><span class="n">cpu_mpu_config</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="n">MPU_Normal_NonCache</span><span class="p">,</span><span class="w"> </span><span class="mh">0x24070000</span><span class="p">,</span><span class="w"> </span><span class="n">MPU_REGION_SIZE_64KB</span><span class="p">);</span>
  460. </pre></div>
  461. </div>
  462. <p>对应 keil 中的 sct 脚本修改:</p>
  463. <div class="highlight-C notranslate"><div class="highlight"><pre><span></span><span class="n">LR_IROM1</span><span class="w"> </span><span class="mh">0x08000000</span><span class="w"> </span><span class="mh">0x00200000</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">;</span><span class="w"> </span><span class="n">load</span><span class="w"> </span><span class="n">region</span><span class="w"> </span><span class="n">size_region</span>
  464. <span class="n">ER_IROM1</span><span class="w"> </span><span class="mh">0x08000000</span><span class="w"> </span><span class="mh">0x00200000</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">;</span><span class="w"> </span><span class="n">load</span><span class="w"> </span><span class="n">address</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">execution</span><span class="w"> </span><span class="n">address</span>
  465. <span class="o">*</span><span class="p">.</span><span class="n">o</span><span class="w"> </span><span class="p">(</span><span class="n">RESET</span><span class="p">,</span><span class="w"> </span><span class="o">+</span><span class="n">First</span><span class="p">)</span>
  466. <span class="o">*</span><span class="p">(</span><span class="n">InRoot$$Sections</span><span class="p">)</span>
  467. <span class="p">.</span><span class="n">ANY</span><span class="w"> </span><span class="p">(</span><span class="o">+</span><span class="n">RO</span><span class="p">)</span>
  468. <span class="p">.</span><span class="n">ANY</span><span class="w"> </span><span class="p">(</span><span class="o">+</span><span class="n">XO</span><span class="p">)</span>
  469. <span class="p">}</span>
  470. <span class="n">RW_IRAM2</span><span class="w"> </span><span class="mh">0x24000000</span><span class="w"> </span><span class="mh">0x00070000</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">;</span><span class="w"> </span><span class="n">RW</span><span class="w"> </span><span class="n">data</span>
  471. <span class="p">.</span><span class="n">ANY</span><span class="w"> </span><span class="p">(</span><span class="o">+</span><span class="n">RW</span><span class="w"> </span><span class="o">+</span><span class="n">ZI</span><span class="p">)</span>
  472. <span class="p">}</span>
  473. <span class="n">USB_NOCACHERAM</span><span class="w"> </span><span class="mh">0x24070000</span><span class="w"> </span><span class="mh">0x00010000</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">;</span><span class="w"> </span><span class="n">RW</span><span class="w"> </span><span class="n">data</span>
  474. <span class="o">*</span><span class="p">(.</span><span class="n">noncacheable</span><span class="p">)</span>
  475. <span class="p">}</span>
  476. <span class="p">}</span>
  477. </pre></div>
  478. </div>
  479. <section id="usb-device">
  480. <h3>USB Device 移植要点<a class="headerlink" href="#usb-device" title="Link to this heading"></a></h3>
  481. <ul class="simple">
  482. <li><p>使用 <strong>stm32cubemx</strong> 创建工程,配置基本的 RCC、UART (作为log使用)</p></li>
  483. </ul>
  484. <figure class="align-default">
  485. <img alt="../_images/stm32_1.png" src="../_images/stm32_1.png" />
  486. </figure>
  487. <figure class="align-default">
  488. <img alt="../_images/stm32_2.png" src="../_images/stm32_2.png" />
  489. </figure>
  490. <ul class="simple">
  491. <li><p>如果使用 fsdev ip,勾选 <strong>USB</strong> 。如果使用 dwc2 ip,勾选 <strong>USB_OTG_FS</strong> 或者勾选 <strong>USB_OTG_HS</strong>。开启 USB 中断,其他配置对我们没用,代码中不会使用任何 st 的 usb 库。</p></li>
  492. </ul>
  493. <figure class="align-default">
  494. <img alt="../_images/stm32_3_1.png" src="../_images/stm32_3_1.png" />
  495. </figure>
  496. <figure class="align-default">
  497. <img alt="../_images/stm32_3_2.png" src="../_images/stm32_3_2.png" />
  498. </figure>
  499. <ul class="simple">
  500. <li><p>配置 usb clock 为 48M</p></li>
  501. </ul>
  502. <figure class="align-default">
  503. <img alt="../_images/stm32_4_1.png" src="../_images/stm32_4_1.png" />
  504. </figure>
  505. <figure class="align-default">
  506. <img alt="../_images/stm32_4_2.png" src="../_images/stm32_4_2.png" />
  507. </figure>
  508. <ul class="simple">
  509. <li><p>选择好工程,这里我们选择 keil,设置好 stack 和 heap,如果使用 msc 可以推荐设置大点,然后点击 <strong>Generate Code</strong>。</p></li>
  510. </ul>
  511. <figure class="align-default">
  512. <img alt="../_images/stm32_5.png" src="../_images/stm32_5.png" />
  513. </figure>
  514. <ul class="simple">
  515. <li><p>添加 CherryUSB 必须要的源码( <strong>usbd_core.c</strong> 、 <strong>dwc2/usb_dc_dwc2.c</strong> 或者是 <strong>fsdev/usb_dc_fsdev.c</strong> ),以及想要使用的 class 驱动,可以将对应的 class template 添加方便测试。</p></li>
  516. </ul>
  517. <figure class="align-default">
  518. <img alt="../_images/stm32_6.png" src="../_images/stm32_6.png" />
  519. </figure>
  520. <ul class="simple">
  521. <li><p>头文件该加的加</p></li>
  522. </ul>
  523. <figure class="align-default">
  524. <img alt="../_images/stm32_7.png" src="../_images/stm32_7.png" />
  525. </figure>
  526. <ul class="simple">
  527. <li><p>复制一份 <strong>cherryusb_config_template.h</strong>,放到 <cite>Core/Inc</cite> 目录下,并命名为 <cite>usb_config.h</cite></p></li>
  528. </ul>
  529. <figure class="align-default">
  530. <img alt="../_images/stm32_8.png" src="../_images/stm32_8.png" />
  531. </figure>
  532. <ul class="simple">
  533. <li><p>如果使用 fsdev ip,(V1.5.0 开始需要增加 <strong>fsdev/usb_glue_st.c</strong>) 在 <cite>usb_config.h</cite> 中实现以下宏,具体数值不同芯片不一样:</p></li>
  534. </ul>
  535. <div class="highlight-C notranslate"><div class="highlight"><pre><span></span><span class="cp">#define CONFIG_USBDEV_FSDEV_PMA_ACCESS 2</span>
  536. </pre></div>
  537. </div>
  538. <ul class="simple">
  539. <li><p>编译器推荐使用 <strong>AC6</strong>。勾选 <strong>Microlib</strong>,并实现 <strong>printf</strong> ,方便后续查看 log。</p></li>
  540. </ul>
  541. <figure class="align-default">
  542. <img alt="../_images/stm32_10.png" src="../_images/stm32_10.png" />
  543. </figure>
  544. <figure class="align-default">
  545. <img alt="../_images/stm32_11.png" src="../_images/stm32_11.png" />
  546. </figure>
  547. <div class="admonition note">
  548. <p class="admonition-title">Note</p>
  549. <p>以下两个步骤从 V1.5.0 开始不再需要,<strong>fsdev/usb_glue_st.c</strong>, <strong>dwc2/usb_glue_st.c</strong> 文件中已经实现</p>
  550. </div>
  551. <ul class="simple">
  552. <li><p>拷贝 <strong>xxx_msp.c</strong> 中的 <strong>HAL_PCD_MspInit</strong> 函数中的内容到 <strong>usb_dc_low_level_init</strong> 函数中,屏蔽 st 生成的 usb 初始化</p></li>
  553. </ul>
  554. <figure class="align-default">
  555. <img alt="../_images/stm32_12.png" src="../_images/stm32_12.png" />
  556. </figure>
  557. <figure class="align-default">
  558. <img alt="../_images/stm32_14.png" src="../_images/stm32_14.png" />
  559. </figure>
  560. <ul class="simple">
  561. <li><p>在中断函数中调用 <cite>USBD_IRQHandler</cite>,并传入 <cite>busid</cite></p></li>
  562. </ul>
  563. <figure class="align-default">
  564. <img alt="../_images/stm32_13.png" src="../_images/stm32_13.png" />
  565. </figure>
  566. <ul class="simple">
  567. <li><p>如果芯片带 cache,cache 修改参考 <a class="reference internal" href="transplant.html#usb-cache"><span class="std std-ref">cache 配置修改</span></a> 章节</p></li>
  568. <li><p>调用 template 的内容初始化,并填入 <cite>busid</cite> 和 USB IP 的 <cite>reg base</cite>, <cite>busid</cite> 从 0 开始,不能超过 <cite>CONFIG_USBDEV_MAX_BUS</cite></p></li>
  569. </ul>
  570. <figure class="align-default">
  571. <img alt="../_images/stm32_15.png" src="../_images/stm32_15.png" />
  572. </figure>
  573. </section>
  574. <section id="usb-host">
  575. <h3>USB Host 移植要点<a class="headerlink" href="#usb-host" title="Link to this heading"></a></h3>
  576. <p>前面 6 步与 Device 一样。需要注意,host 驱动只支持带 dma 的 hs port (引脚是 PB14/PB15),所以 fs port (引脚是 PA11/PA12)不做支持(没有 dma 你玩什么主机)。</p>
  577. <ul class="simple">
  578. <li><p>添加 CherryUSB 必须要的源码( <strong>usbh_core.c</strong> 、 <strong>usbh_hub.c</strong> 、 <strong>usb_hc_dwc2.c</strong> 、 <strong>usb_glue_st.c</strong> 以及 <strong>osal</strong> 目录下的适配层文件),以及想要使用的 class 驱动,并且可以将对应的 <strong>usb host.c</strong> 添加方便测试。</p></li>
  579. </ul>
  580. <figure class="align-default">
  581. <img alt="../_images/stm32_16.png" src="../_images/stm32_16.png" />
  582. </figure>
  583. <ul class="simple">
  584. <li><p>编译器推荐使用 <strong>AC6</strong>。勾选 <strong>Microlib</strong>,并实现 <strong>printf</strong> ,方便后续查看 log。</p></li>
  585. </ul>
  586. <figure class="align-default">
  587. <img alt="../_images/stm32_10.png" src="../_images/stm32_10.png" />
  588. </figure>
  589. <figure class="align-default">
  590. <img alt="../_images/stm32_11.png" src="../_images/stm32_11.png" />
  591. </figure>
  592. <ul class="simple">
  593. <li><p>复制一份 <strong>cherryusb_config_template.h</strong>,放到 <cite>Core/Inc</cite> 目录下,并命名为 <cite>usb_config.h</cite></p></li>
  594. </ul>
  595. <div class="admonition note">
  596. <p class="admonition-title">Note</p>
  597. <p>以下两个步骤从 V1.5.0 开始不再需要,<strong>fsdev/usb_glue_st.c</strong>, <strong>dwc2/usb_glue_st.c</strong> 文件中已经实现</p>
  598. </div>
  599. <ul class="simple">
  600. <li><p>拷贝 <strong>xxx_msp.c</strong> 中的 <cite>HAL_HCD_MspInit</cite> 函数中的内容到 <cite>usb_hc_low_level_init</cite> 函数中,屏蔽 st 生成的 usb 初始化</p></li>
  601. <li><p>在中断函数中调用 <cite>USBH_IRQHandler</cite>,并传入 <cite>busid</cite></p></li>
  602. </ul>
  603. <figure class="align-default">
  604. <img alt="../_images/stm32_19.png" src="../_images/stm32_19.png" />
  605. </figure>
  606. <ul class="simple">
  607. <li><p>链接脚本修改参考 <a class="reference internal" href="transplant.html#usbh-link-script"><span class="std std-ref">主机链接脚本修改</span></a> 章节</p></li>
  608. <li><p>如果芯片带 cache,cache 修改参考 <a class="reference internal" href="transplant.html#usb-cache"><span class="std std-ref">cache 配置修改</span></a> 章节</p></li>
  609. <li><p>调用 <cite>usbh_initialize</cite> 并填入 <cite>busid</cite> 和 USB IP 的 <cite>reg base</cite> 还有 <cite>event_handler</cite> 可缺省为NULL, <cite>busid</cite> 从 0 开始,不能超过 <cite>CONFIG_USBHOST_MAX_BUS</cite></p></li>
  610. <li><p>启动线程</p></li>
  611. </ul>
  612. <figure class="align-default">
  613. <img alt="../_images/stm32_18.png" src="../_images/stm32_18.png" />
  614. </figure>
  615. </section>
  616. </section>
  617. </section>
  618. </div>
  619. </div>
  620. <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
  621. <a href="start.html" class="btn btn-neutral float-left" title="入门必看" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
  622. <a href="transplant.html" class="btn btn-neutral float-right" title="芯片通用移植指南" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
  623. </div>
  624. <hr/>
  625. <div role="contentinfo">
  626. <p>&#169; Copyright 2022 ~ 2026, sakumisu.</p>
  627. </div>
  628. Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
  629. <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
  630. provided by <a href="https://readthedocs.org">Read the Docs</a>.
  631. </footer>
  632. </div>
  633. </div>
  634. </section>
  635. </div>
  636. <script>
  637. jQuery(function () {
  638. SphinxRtdTheme.Navigation.enable(true);
  639. });
  640. </script>
  641. </body>
  642. </html>