demo.html 37 KB

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