cancel
Showing results for 
Search instead for 
Did you mean: 

Guide to USB development resources on STM32

Gyessine
ST Employee

Introduction

This article gives you the key information you need to dive into USB development on STM32. It mentions various resources, including training (MOOCs), articles, and application notes, that can help understand USB theory and hardware implementation.

1. USB theory

1.1 Starting with the fundamentals

 If you’re new to the world of USB on STM32 products, we really recommend watching our USB MOOC and consult the course materials. This will help you dive deep into USB theory and understand the fundamentals like:

You can also read the ST Wiki: USB protocol basics from section 1.0 to 1.15.

For more technical information related to USB, see the USB specification and USB class specifications that can be downloaded from https://www.usb.org/developers

1.2 USB hardware implementation on an STM32

USB hardware implementation is and will always be one of the most delicate and always asked about topics. The AN4879 covers most of what you need to know in an advanced way like: 

  • Internal and external clocks 

Check the relevant datasheet for your product. For more information, check section 2.4 "Clock" in AN4879.

  • Internal and external PHYs required for HS and internal PHYs

For this point, you can check this article about ULPI compatibility or from section 3.3 to section 3.5 of AN4879.

  • ESDs and concept of VBUS sensing

Check this article for more specific overview or check section 2.6 “VBUS sensing detection point” and section 2.3 "Protection against ESD and EMI" in AN4879.

  • Hardware architecture for DEVICE and HOST mode

To see STM32 products USB specifications, you can refer to the section 2, “USB on STM32 products” in AN4879.

You can also refer to specific application notes and datasheets for detailed hardware implementation guidance like the application notes for H5F7H7R/S, and H72x/H73x.

These application notes are titled under the name: “Getting started with STM32Xx MCU hardware development”.

You can also always refer to each product’s datasheets, reference manual, application note, and schematics to see some ST hardware implementation (noted as MBxxxx example: MB997 for F407G-Disco, MB1364 for STM32H757-EVAL.)

1.3 Middlewares

ST uses majorly 2 middlewares through their range of product, which is ST USB middleware and Azure USBX middleware.

1.3.1 ST USB middleware

ST USB middleware provides libraries and tools to facilitate USB device and host functionality on STM32 microcontrollers. It’s composed mainly of the device library and host library.

1.3.1.1 Device mode

For a general understanding of device mode, watch the STM32 USB device library training, read the fifth section in the wiki, and view the STM32 USB device library PDF.

For more in-depth review, check UM1734, sixth point USB device library of UM1021 or UM0424 for USB-FS demos.

If you’re still searching for helpful resources on the subject, here are some extra links that might help:

  • DFU class: AN3156 for DFU basic commands explanation
  • Audio class: UM2195 
1.3.1.2 Host mode

You can watch the STM32 USB host library training, read the “USB host library overview” in the ST wiki, and explore the STM32 USB host library PDF.

For a deep explanation, check the section 7. "USB host library" in UM1021.

1.3.2 Azure USBX middleware

As a general start you can check our USBX overview MOOC

1.3.2.1 Device mode:

You can review the second section of this WIKI and check the "USBX device stack user guide” and “USBX device stack supplemental” of USBX GitHub documentation 

1.3.2.2 Host mode

You can review this Link and check the “USBX host stack user guide” and “USBX host stack supplemental” sections of USBX GitHub documentation 

2. USB Projects and applications

ST provides some USB applications examples in almost every product in their range
You can refer to them buy following your product firmware buy this path

C:\Users\xxxxxx\STM32Cube\Repository\STM32Cube_FW_xx_Vx.xx.x\Projects\xxxxxxxxx\Applications\

This is the default path, but it may change if you chose another location for installing the firmware.

Or in our GitHub: STMicroelectronics/STM32CubeXX
For example: STM32CubeH7/Projects at master · STMicroelectronics/STM32CubeH7
or visit stm32-usbx-examples.

2.1 ST USB middleware

Here are some USB application examples for some of our products (be aware that you can find the same application in other products just check our GitHub or your products firmware as we explained

Class

Mode

Details

HID

Device

HID mouse application.

CUSTOM HID standalone application or visit this project tutorial and check USB HID articles part 1 and part 2

HID LPM application

Host

HID mouse and keyboard application or visit this tutorial.

CDC

Device

CDC transmit application, or follow this tutorial

Host

CDC Host application.

DFU

Device

DFU mode application or follow the device mode tutorial

 How to modify DFU firmware examples check this article

 How to jump to system bootloader check this article

 Open bootloaders check this article

 Dual bank demos check this GitHub example

Host

Check STM32H743-EVAL firmware or follow the host mode tutorial

MSC

Device

Mass storage class application or follow the device mode tutorial

 Bootloader USB mass storages check this GitHub example

Host

Check your firmware or follow the device mode tutorial

  mass storage class application

  AUDIO

Device

STM32H747-EVAL firmware example

DUAL CORE

Device

CDC & HID class application

Host

MSC & HID application

Dual Role

Device/Host

HID host & CDC device article

Composite 

device

 HID & MSC article

DUAL CDC ACM article

 (HID + CDC) tutorial and project

(DFU + HID) article

2.2 USBX

Here are some USB application examples for some of our products (be aware that you can find the same application in other products just check our GitHub or your products firmware as we explained

Class

Mode

Details

HID

 

 

Device

 

 

HID mouse

HID mouse standalone application 

Host

 

HID mouse and keyboard 

HID mouse & keyboard standalone

CDC

 

Device

 

CDC ACM  

How to implement the USB device CDC class using the Azure article

 

CDC LAB tutorial 

 

Dual CDC project with USBX stack GitHub link

Host

CDC host project or check this article

DFU

 

Device

Enable DFU mode project

MSC

Device

Mass storage application

 

How to implement USB mass storage device standalone

Host

 Mass storage class host project

 

AUDIO

Device

Device_Audio_2.0 application

Device_Audio_2.0_Standalone application

HOST

Host_Audio_2.0 application

Video

Device

STM32N6 firmware example

CCID

Device

Ux_Device_CCID

PIMA

Device

Ux_Device_PIMA_MTP

Printer

Device

Ux_Device_Printer

RNDIS

Device

Ux_Device_RNDIS

 

Host

Host_VIDEO application

Dual Class

Host

USB Host Human Interface "HID" and Mass Storage “MSC"

Composite

DEVICE

MOOC - Azure RTOS workshop - USBX lab - composite device

 

 

How to implement the USB device composite class using the Azure article and associated project

 

HOST

Host_HID_CDC_ACM application

 Standalone

HID

 

Be also aware that some of our products are native STM32 classic middleware but also can use the USBX Azure package like H7H7RSL5WBG4G0F7F4WL, and L4 like we did in this article

And some of them are USBX stack natively but can also use the classic middleware accordingly. With them like STM32WBASTM32U3STM32U0STM32N6STM32C0, STM32U5, STM32H5.

However, you can implement STMicroelectronics classic USB device middleware with these families. Like we did in this article.

2.2 Other USB features

How to configure USB FIFO over USB OTG controller over STM32

How to configure the packet memory area in STM32 USB controller

Practical use cases on how to configure packet memory area

Practical use cases to manage FIFO in USB OTG controller

2.3 USB + Other peripherals

  • How to run Bluetooth® Low Energy P2P server with USB CDC on STM32WB article part 1 and part 2.

3. FAQ and common errors

Conclusion

Overall, the article provides a thorough guide for USB development on STM32. It includes various resources such as MOOCs, articles, and application notes.

All useful links are directly accessible.

Comments

Thank you so much for sharing this comprehensive guide to USB development resources on STM32! This is an invaluable resource for both beginners and experienced developers working with STM32 microcontrollers. The detailed breakdown of available documentation, example projects, and tools will definitely save many hours of searching across different sources. I particularly appreciate how well-organized the information is, making it easy to find exactly what's needed for specific USB implementations. This guide will be a great reference for my future STM32 projects.

Version history
Last update:
‎2025-12-22 1:06 AM
Updated by:
Contributors