Giter Club home page Giter Club logo

tinyusb's Introduction

TinyUSB for RT-Thread

中文文档

tinyusb

Build Status Documentation Status License

TinyUSB is an open-source cross-platform USB Host/Device stack for embedded system, designed to be memory-safe with no dynamic allocation and thread-safe with all interrupt events are deferred then handled in the non-ISR task function.

Please take a look at the online documentation.

.
├── docs            # Documentation
├── examples        # Sample with Makefile build support
├── hw
│   ├── bsp         # Supported boards source files
│   └── mcu         # Low level mcu core & peripheral drivers
├── lib             # Sources from 3rd party such as freeRTOS, fatfs ...
├── src             # All sources files for TinyUSB stack itself.
├── test            # Unit tests for the stack
└── tools           # Files used internally

Supported MCUs

The stack supports the following MCUs:

  • Allwinner: F1C100s/F1C200s
  • Broadcom: BCM2837, BCM2711
  • Dialog: DA1469x
  • Espressif: ESP32-S2, ESP32-S3
  • GigaDevice: GD32VF103
  • Infineon: XMC4500
  • MicroChip: SAMD11, SAMD21, SAMD51, SAME5x, SAMG55, SAML21, SAML22, SAME7x
  • NordicSemi: nRF52833, nRF52840, nRF5340
  • Nuvoton: NUC120, NUC121/NUC125, NUC126, NUC505
  • NXP:
    • iMX RT Series: RT1011, RT1015, RT1021, RT1052, RT1062, RT1064
    • Kinetis: KL25, K32L2
    • LPC Series: 11u, 13, 15, 17, 18, 40, 43, 51u, 54, 55
  • Raspberry Pi: RP2040
  • Renesas: RX63N, RX65N, RX72N
  • Silabs: EFM32GG
  • Sony: CXD56
  • ST: STM32 series: F0, F1, F2, F3, F4, F7, H7, G4, L0, L1, L4, L4+
  • TI: MSP430, MSP432E4, TM4C123
  • ValentyUSB: eptri

Here is the list of Supported Devices that can be used with provided examples.

Device Stack

Supports multiple device configurations by dynamically changing USB descriptors, low power functions such like suspend, resume, and remote wakeup. The following device classes are supported:

  • Audio Class 2.0 (UAC2)
  • Bluetooth Host Controller Interface (BTH HCI)
  • Communication Device Class (CDC)
  • Device Firmware Update (DFU): DFU mode (WIP) and Runtime
  • Human Interface Device (HID): Generic (In & Out), Keyboard, Mouse, Gamepad etc ...
  • Mass Storage Class (MSC): with multiple LUNs
  • Musical Instrument Digital Interface (MIDI)
  • Network with RNDIS, Ethernet Control Model (ECM), Network Control Model (NCM)
  • Test and Measurement Class (USBTMC)
  • Video class 1.5 (UVC): work in progress
  • Vendor-specific class support with generic In & Out endpoints. Can be used with MS OS 2.0 compatible descriptor to load winUSB driver without INF file.
  • WebUSB with vendor-specific class

If you have a special requirement, usbd_app_driver_get_cb() can be used to write your own class driver without modifying the stack. Here is how the RPi team added their reset interface raspberrypi/pico-sdk#197

Host Stack

  • Human Interface Device (HID): Keyboard, Mouse, Generic
  • Mass Storage Class (MSC)
  • Hub currently only supports 1 level of hub (due to my laziness)

OS Abstraction layer

TinyUSB is completely thread-safe by pushing all Interrupt Service Request (ISR) events into a central queue, then processing them later in the non-ISR context task function. It also uses semaphore/mutex to access shared resources such as Communication Device Class (CDC) FIFO. Therefore the stack needs to use some of the OS's basic APIs. Following OSes are already supported out of the box.

  • No OS
  • FreeRTOS
  • RT-Thread: repo
  • Mynewt Due to the newt package build system, Mynewt examples are better to be on its own repo

Local Docs

License

All TinyUSB sources in the src folder are licensed under MIT license, the Full license is here. However, each file can be individually licensed especially those in lib and hw/mcu folder. Please make sure you understand all the license term for files you use in your project.

tinyusb's People

Contributors

brtchip-gdm avatar cr1901 avatar duempel avatar gsteiert avatar hathach avatar hifiphile avatar j4cbo avatar jgressmann avatar kamtom480 avatar karlk90 avatar kasjer avatar kilograham avatar kkitayam avatar majbthrd avatar mmosca avatar mysterywolf avatar nxf58843 avatar perigoso avatar pete-pjb avatar pigrew avatar ryzee119 avatar salkinium avatar t123yh avatar tannewt avatar tfx2001 avatar uwebonnes avatar wini-buh avatar xmos-jmccarthy avatar xobs avatar zlittell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

tinyusb's Issues

是否可以考虑在tusb_config.h之外再添加一个配置文件?

Related area

Kconfig

Hardware specification

stm32h750xbhx

Is your feature request related to a problem?

您好,最近在学习 TinyUSB,使用 RT-Thread 直接下载 TinyUSB 的软件包十分简便。
但是目前 RT-Thread 的 TinyUSB 只有 2 个 example,如果要实现例如 DFU、Audio 的设备类型就必须修改到 packages 里面的 tusb_config.h 文件,否则就得需要修改 Scons 脚本使得生成的工程使用自定义的 tusb_config.h。这样就导致了我必须在工程中保留一份用户自己的 TinyUSB packages 代码,如果后续需要更新版本将有导致修改丢失的威胁,而且也不利于使用 git 进行版本管理。

Describe the solution you'd like

那么,是否可以考虑在 TinyUSB 的 Kconfig 中添加一个扩展 config.h 文件?比如命名为 rt_tusb_config.h 文件,可以通过 KConfig 的宏进行控制,包含在 tusb_config.h 之前,默认情况下为关闭,开启后用户需要实现该文件就可以避免需要修改到 tusb_config.h 文件的问题。
或者提供一个选项支持用户自定义 tusb_config.h,默认情况下使用 packages 里 tinyusb 中提供的 tusb_config.h,开启后就让 Scons 不包含 tinyusb 中提供的 tusb_config.h,进而能够使用到用户自定义的 tusb_config.h。

I have checked existing issues, dicussion and documentation

  • I confirm I have checked existing issues, dicussion and documentation.

TinyUSB usb cable plugged and unlugged

Operating System

Windows 11

Board

STM32F407

Firmware

当我在STM32F407开发板上rt-thread 4.1.1软件平台下,rt-thread studio开发环境中,加入tinyUSB 软件包,如下
image
软件版本V0.13.0。使用板载SPI Flash 作为存储,挂载到USB上作为U盘,配置后运行,插上USB线缆,效果挺好,显示如下
image
但是这样做是我在没有将SPI flash分区挂载到嵌入式系统的前提下操作的。在实际工作中,当嵌入式系统检测到USB线插上时会自动卸载掉当前分区,然后让USB挂载,当USB线拔掉时,嵌入式系统再次自动挂载分区。从而时序SPI Flash分区在USB和嵌入式系统之间自动切换。

What happened ?

当我这样尝试做时,想利用DCD_EVENT_UNPLUGGED和DCD_EVENT_PLUGGED事件来解决此问题,在tud_task函数内代码如下:
image

但跟踪调试发现,程序根本就跳不进这两个分支下。然后又尝试到tud_msc_start_stop_cb函数下,代码如下:
image

发现程序也不会到达到这里

How to reproduce ?

阅读程序代码,根据理解,在插拔USB线后,程序应该会执行到这里的,请问是程序哪里设置的不对,还是其它什么原因?

Debug Log as txt file

No response

Screenshots

No response

I have checked existing issues, dicussion and documentation

  • I confirm I have checked existing issues, dicussion and documentation.

RTT usb驱动转换

建议增加一个转换层,以RTT中现有usb设备驱动为基础封装到tinyusb;
这样的话,现有的,已经写好的usb设备驱动,就能很方便的转换到tinyusb中。很多芯片的驱动就不用再写一遍了。

Roadmap

MCU 平台的移植

设备类的支持

  • HID
  • MSC
  • Audio
  • DFU

各个设备类的用例

  • CDC
  • HID

USB Host

  • Host 协议栈

rt-thread studio 添加 tunyUSB软件包后编译报错

Operating System

Windows 10

Board

STM32F103VET6

Firmware

RT-THREAD STUDIO V2.2.3

What happened ?

Uploading R5W~C}V@[U%G]H8I%OZEZBA.png…

How to reproduce ?

RT-THREAD STUDIO 中添加 tiny USB 软件包后进行编译

Debug Log as txt file

No response

Screenshots

No response

MDK5 TinyUSB Compile error --c99

Operating System

Windows 10

Board

stm32h7-armfly-v7

Firmware

  1. MDK5.36 ArmClang编译器
  2. bsp stm32h7-armfly-v7

What happened ?

不使用 TinyUSB 的时,基于V7开发板的仓库代码编译没有问题,添加了 TinyUSB 后会报下列错误:

1682326639538

上面的使用 ArmClang 编译的,改成 ARMCC 进行编译会出现下面的错误,有勾选GNU扩展选项,也配置了CubeMx的USB驱动:

image
image

How to reproduce ?

  1. 使用 stm32h743-armfly-v7 开发板
  2. menuconfig 设置使用 TinyUSB 配置 CubeMX 使能USB设备
  3. pkgs --update 下载TinyUSB
  4. 配置 AC6 或 AC5 + GNU Extensions
  5. 问题出现

Debug Log as txt file

#ifndef RT_CONFIG_H__
#define RT_CONFIG_H__

/* Automatically generated file; DO NOT EDIT. /
/
RT-Thread Configuration */

/* RT-Thread Kernel */

#define RT_NAME_MAX 8
#define RT_ALIGN_SIZE 8
#define RT_THREAD_PRIORITY_32
#define RT_THREAD_PRIORITY_MAX 32
#define RT_TICK_PER_SECOND 1000
#define RT_USING_OVERFLOW_CHECK
#define RT_USING_HOOK
#define RT_HOOK_USING_FUNC_PTR
#define RT_USING_IDLE_HOOK
#define RT_IDLE_HOOK_LIST_SIZE 4
#define IDLE_THREAD_STACK_SIZE 256
#define RT_USING_TIMER_SOFT
#define RT_TIMER_THREAD_PRIO 4
#define RT_TIMER_THREAD_STACK_SIZE 512

/* kservice optimization */

#define RT_KSERVICE_USING_STDLIB
#define RT_DEBUG

/* Inter-Thread communication */

#define RT_USING_SEMAPHORE
#define RT_USING_MUTEX
#define RT_USING_EVENT
#define RT_USING_MAILBOX
#define RT_USING_MESSAGEQUEUE

/* Memory Management */

#define RT_USING_MEMPOOL
#define RT_USING_SMALL_MEM
#define RT_USING_SMALL_MEM_AS_HEAP
#define RT_USING_HEAP

/* Kernel Device Object */

#define RT_USING_DEVICE
#define RT_USING_CONSOLE
#define RT_CONSOLEBUF_SIZE 128
#define RT_CONSOLE_DEVICE_NAME "uart"
#define RT_VER_NUM 0x50001
#define RT_USING_CACHE
#define RT_USING_HW_ATOMIC
#define RT_USING_CPU_FFS
#define ARCH_ARM
#define ARCH_ARM_CORTEX_M
#define ARCH_ARM_CORTEX_M7

/* RT-Thread Components */

#define RT_USING_COMPONENTS_INIT
#define RT_USING_USER_MAIN
#define RT_MAIN_THREAD_STACK_SIZE 2048
#define RT_MAIN_THREAD_PRIORITY 10
#define RT_USING_MSH
#define RT_USING_FINSH
#define FINSH_USING_MSH
#define FINSH_THREAD_NAME "tshell"
#define FINSH_THREAD_PRIORITY 20
#define FINSH_THREAD_STACK_SIZE 4096
#define FINSH_USING_HISTORY
#define FINSH_HISTORY_LINES 5
#define FINSH_USING_SYMTAB
#define FINSH_CMD_SIZE 80
#define MSH_USING_BUILT_IN_COMMANDS
#define FINSH_USING_DESCRIPTION
#define FINSH_ARG_MAX 10

/* DFS: device virtual file system */

#define RT_USING_DFS
#define DFS_USING_POSIX
#define DFS_USING_WORKDIR
#define DFS_FD_MAX 16
#define RT_USING_DFS_V1
#define DFS_FILESYSTEMS_MAX 4
#define DFS_FILESYSTEM_TYPES_MAX 4
#define RT_USING_DFS_DEVFS

/* Device Drivers */

#define RT_USING_DEVICE_IPC
#define RT_UNAMED_PIPE_NUMBER 64
#define RT_USING_SERIAL
#define RT_USING_SERIAL_V1
#define RT_SERIAL_USING_DMA
#define RT_SERIAL_RB_BUFSZ 64
#define RT_USING_PIN

/* Using USB */

#define RT_USING_USB

/* C/C++ and POSIX layer */

#define RT_LIBC_DEFAULT_TIMEZONE 8

/* POSIX (Portable Operating System Interface) layer */

/* Interprocess Communication (IPC) */

/* Socket is in the 'Network' category */

/* Network */

/* Utilities */

/* RT-Thread Utestcases */

/* RT-Thread online packages */

/* IoT - internet of things */

/* Wi-Fi */

/* Marvell WiFi */

/* Wiced WiFi */

/* IoT Cloud */

/* security packages */

/* language packages */

/* JSON: JavaScript Object Notation, a lightweight data-interchange format */

/* XML: Extensible Markup Language */

/* multimedia packages */

/* LVGL: powerful and easy-to-use embedded GUI library */

/* u8g2: a monochrome graphic library */

/* tools packages */

/* system packages */

/* enhanced kernel services */

/* acceleration: Assembly language or algorithmic acceleration packages */

/* CMSIS: ARM Cortex-M Microcontroller Software Interface Standard */

/* Micrium: Micrium software products porting for RT-Thread */

#define PKG_USING_TINYUSB
#define PKG_TINYUSB_STACK_SIZE 2048
#define PKG_TINYUSB_THREAD_PRIORITY 8
#define PKG_TINYUSB_MEM_SECTION ".data"
#define PKG_TINYUSB_MEM_ALIGN 4
#define PKG_TINYUSB_RHPORT_NUM_1
#define PKG_TINYUSB_RHPORT_NUM 0
#define PKG_TINYUSB_FULL_SPEED
#define PKG_TINYUSB_DEVICE_PORT_SPEED 0x00
#define PKG_TINYUSB_DEVICE_ENABLE
#define PKG_TINYUSB_DEVICE_VID 0xCAFE
#define PKG_TINYUSB_DEVICE_PID 0x4000
#define PKG_TINYUSB_DEVICE_MANUFACTURER "TinyUSB"
#define PKG_TINYUSB_DEVICE_PRODUCT "TinyUSB Device"
#define PKG_TINYUSB_EDPT0_SIZE 64
#define PKG_TINYUSB_DEVICE_CURRENT 100
#define PKG_TINYUSB_DEVICE_CDC
#define CFG_TUD_CDC 1
#define PKG_TINYUSB_DEVICE_CDC_STRING "TinyUSB CDC"
#define PKG_TINYUSB_DEVICE_CDC_EPNUM_NOTIF 1
#define PKG_TINYUSB_DEVICE_CDC_EPNUM 2
#define PKG_TINYUSB_DEVICE_CDC_RX_BUFSIZE 64
#define PKG_TINYUSB_DEVICE_CDC_TX_BUFSIZE 64
#define PKG_TINYUSB_DEBUG_NO
#define CFG_TUSB_DEBUG 0
#define PKG_USING_TINYUSB_V01400

/* peripheral libraries and drivers */

/* sensors drivers */

/* touch drivers */

/* Kendryte SDK */

/* AI packages */

/* Signal Processing and Control Algorithm Packages */

/* miscellaneous packages */

/* project laboratory */

/* samples: kernel and components samples */

/* entertainment: terminal games and other interesting software packages */

/* Arduino libraries */

/* Projects */

/* Sensors */

/* Display */

/* Timing */

/* Data Processing */

/* Data Storage */

/* Communication */

/* Device Control */

/* Other */

/* Signal IO */

/* Uncategorized */

#define SOC_FAMILY_STM32
#define SOC_SERIES_STM32H7

/* Hardware Drivers Config */

#define SOC_STM32H743XI

/* Onboard Peripheral Drivers */

/* On-chip Peripheral Drivers */

#define BSP_USING_GPIO
#define BSP_USING_UART
#define BSP_USING_UART1

/* Board extended module Drivers */

#endif

Screenshots

No response

I have checked existing issues, dicussion and documentation

  • I confirm I have checked existing issues, dicussion and documentation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.