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