Usb Behind The Scenes Hands On Hid Firmware Development

The #1 video course that explains programming bare-metal firmware for USB human interface devices (HID) step by step.

Last updated 2022-01-10 | 4.8

- Write a bare-metal firmware for USB 2.0 human interface devices (HID) without using any third-party libraries or code generators.
- Implement USB device driver and USB 2.0 protocol framework.
- Program a fully functional USB mouse from zero.

What you'll learn

Write a bare-metal firmware for USB 2.0 human interface devices (HID) without using any third-party libraries or code generators.
Implement USB device driver and USB 2.0 protocol framework.
Program a fully functional USB mouse from zero.
Understand the generic USB descriptors and the descriptors specific to human interface device (HID) class.
Deal with native USB (WITHOUT any conversion to UART)
Use ARM Cortex-M4 based microcontroller (STM32F4xx)
one of the most developed and famous MCU in the world.
Debug USB communication using Wireshark and Linux SysLog.
Read different parts of ARM Cortex-M4 reference manual and extract the important information efficiently.
Understanding how USB 2.0 protocol works in full speed mode.
Understand USB endpoints
pipes
transfer types
packets
transactions
frames
power supply
topology
and many more.
Learn the basic mechanical and electrical specifications of the USB (connectors
cables
speed enumeration resistors
and many more).
Know the history and motivation behind developing the universal serial bus (USB).
Learn using Single Wire Output (SWO) to send logs to the debugging host.
Increase your productivity and code portability by using ARM CMSIS.
Document your code using Doxygen syntax.

* Requirements

* Basic knowledge of C programming language (recommended).
* Basic knowledge of designing embedded systems.
* Any STM32F4 Microcontroller (ARM Coretx-M4 based) on Discovery or Nucleo board to apply the knowledge.

Description

  • Write a bare-metal firmware for USB 2.0 human interface devices (HID) without using any third-party libraries or code generators.
  • Implement USB device driver and USB 2.0 protocol framework.
  • Program a fully functional USB mouse from zero.
  • Understand the generic USB descriptors and the descriptors specific to human interface device (HID) class.
  • Deal with native USB (WITHOUT any conversion to UART)
  • Use ARM Cortex-M4 based microcontroller (STM32F4xx), one of the most developed and famous MCU in the world.
  • Debug USB communication using Wireshark and Linux SysLog.
  • Read different parts of ARM Cortex-M4 reference manual and extract the important information efficiently.
  • Understanding how USB 2.0 protocol works in full speed mode.
  • Understand USB endpoints, pipes, transfer types, packets, transactions, frames, power supply, topology, and many more.
  • Learn the basic mechanical and electrical specifications of the USB (connectors, cables, speed enumeration resistors, and many more).
  • Know the history and motivation behind developing the universal serial bus (USB).
  • Learn using Single Wire Output (SWO) to send logs to the debugging host.
  • Increase your productivity and code portability by using ARM CMSIS.
  • Document your code using Doxygen syntax.

Course content

11 sections • 166 lectures

Introduction Preview 04:38

Credits:

Optimistic / Inspirational by Mixaund | https://mixaund.bandcamp.com

Music promoted by https://www.free-stock-music.com

How to Get the Most of This Course? Preview 00:37

Discord Server for Student Communication Preview 00:09

Why STM32F429ZI (ARM Cortex-M4 Based) Microcontroller? Preview 00:09

Udemy Review Preview 01:37

Credits:

Five stars: http://www.pngall.com/?p=39082

Definition and Motivation Preview 05:37

The definition of universal serial bus (USB) and the motivation behind USB development.

History Preview 05:48

The history of USB development and USB versions.

Cables and Connectors Preview 02:55

The most common USB cables and connectors.

USB 2.0 Cable Structure Preview 01:23

A quick look on the inner-structure of the specified cable in USB 2.0.

Main Features Preview 05:58

The main features of USB protocol regardless of the USB version.

Bus Topology and Functions Preview 09:10

Demonstration of the USB star topology and the meaning of USB function.

VBUS Preview 00:29

Power Delivery Specification Preview 10:18

Explanation about the history of different power supply specifications for USB devices.

Smart Charger Preview 01:40

Explanation about the principle of smart chargers.

Differential States Preview 05:27

Bus States Preview 10:09

Timing Tolerance Preview 01:21

USB 2.0 Speed Identification Preview 02:33

Bit Stuffing Preview 01:21

Non-Return-to-Zero Inverted (NRZI) Preview 04:24

Host Controllers Preview 05:11

Frames Preview 01:52

Endpoints Preview 11:57

(PDF) Packet and Transaction Types Preview 00:11

Here you can find a PDF file that contains the slides of some of the important upcoming lectures that you may need frequently to be opened next to you while watching the videos (e.g. to be able to compare the transaction types without switching between the videos).

Packets Preview 03:59

Packet Types and Packet Fields Preview 12:12

Transaction Preview 02:27

Packet Identifiers Preview 01:56

Token Packets Preview 06:03

Data Packets Preview 01:47

Handshake Packets Preview 02:58

Device Address Preview 01:56

Bus Polling Preview 03:20

USB is Host Driver Preview 05:54

USB is Host Driver Demonstration Preview 05:47

Endpoint Types (Transfer Types) Preview 02:58

Interrupt Transfer Preview 07:40

Bulk Transfer Preview 02:59

Isochronous Transfer Preview 03:34

Control Transfer Preview 06:42

Control Transfer Stages Preview 11:19

Bus Bandwidth Allocation Preview 03:23

Installing STM32CubeIDE Preview 03:35

Creating a New Project Preview 04:01

Including ARM CMSIS Preview 19:48

Removing Sysmem and Syscalls Preview 00:47

Log to Debugger Using SWO Preview 06:54

Logging Helper Preview 08:16

Configuring Debugger and SVW for Logging Preview 06:30

Project source code Preview 00:10

NO CODE GENERATION IN STM32CubeMX Preview 00:17

My Method to Explain Clocking Preview 03:44

Creating Temporary STM32CubeMX Project Preview 08:33

USB Module Requires 48 MHz Signal Preview 00:07

Understanding Clock Frequency Requirements Preview 04:49

Understanding PLL, Prescalers, SYSCLK, and HCLK Preview 04:26

Understanding MCO Divider Preview 02:17

Initial Steps to Configure the Clock Preview 05:10

CMSIS Bit Operations Preview 01:54

Configuring Flash Latency Preview 10:22

CMSIS Fld2Val and Val2Fld Macros Preview 01:21

Enabling HSE Preview 02:56

Enabling and Configuring PLL Preview 06:38

Configuring APB-Prescaler Preview 02:45

Disabling HSI Preview 00:31

Correction of PLL Configuration Trap Preview 04:38

Testing Clock Configuration Preview 02:59

Configuring MCO Preview 04:02

Verifying the Clock Frequency Using Oscilloscope Preview 03:29

Reconfiguring SWO Clock Frequency Preview 00:09

Firmware Architecture We Will Be Using Preview 07:04

Creating Driver Source and Header Files and Accessing USB Regions Preview 07:48

Configuring GPIOs as USB Pins Preview 05:56

Tips to Get the Most Benefits Preview 04:53

Skimming Core and Device Configuration Preview 07:37

USB Core Initialization Preview 06:49

Initializing USB Core Interrupts Preview 02:20

Connecting the USB Device to the Bus (Using Firmware) Preview 01:57

Testing Connecting the USB Device to the Host Preview 04:42

USB Core Global Interrupts Preview 00:44

USB Global Interrupt Handler Preview 05:25

Steps of Handling USB Reset Signal Preview 03:46

USB Reset Handler Preview 03:10

Configuring Endpoint 0 Preview 12:13

Configuring IN Endpoints Preview 06:52

NOTICE about "Deconfiguring Endpoint" lecture Preview 00:09

Deconfiguring Endpoint Preview 03:54

NOTE: Parameters Validation and Code Documentation Preview 01:33

Understanding FIFO Dedicated Memory Preview 11:16

Configuring FIFO Size Preview 06:01

Configuring FIFO Offset Preview 04:41

Configuring FIFOs While Configuring Endpoints Preview 05:25

Flushing FIFOs Preview 03:09

Accessing the FIFOs Preview 04:45

Transfer Completed Interrupts Preview 04:32

USB Speed Enumeration Done Handler Preview 02:48

Implementing RxFIFO Not Empty Interrupt Handler Preview 10:27

SETUP and OUT Transfer Completed Status Data Preview 09:50

Popping Data from the RxFIFO (From an OUT endpoint) Preview 13:50

Pushing Data into a TxFIFO (To an IN endpoint) Preview 05:53

Fixing Compilaiton Error (Reorder Some Functions) Preview 02:29

Defining USB Driver Type Preview 07:18

Polling on Interrupt Level Preview 06:55

Defining USB Events Type Preview 08:12

Defining USB Device States Preview 01:52

Defining USB Control Transfer Stages Preview 04:41

Defining USB Device Instance Structure Preview 04:47

Starting to Configure the USB Device Instance Preview 04:53

Implementing USB Reset Handler Preview 03:03

[DRIVER] Implementing USB Set Address Preview 01:54

Triggering USB Reset Event (Calling the Handler) Preview 03:58

Reading the Received Requests Preview 10:59

Understanding USB Request Structure Preview 09:16

Understanding USB Standard Device Requests Preview 14:38

Defining the Structure of USB Requests Preview 07:21

Starting Processing the Requests Preview 07:43

Investigating the First Request Preview 15:27

Defining Descriptor Structure Preview 05:10

Writing the Device Descriptor Preview 13:16

Defining the Standard Request Macros (wValue) Preview 06:05

Defining a Variable after a Switch Case Error Preview 03:02

Write a Packet ONLY when the Endpoint is Empty Preview 04:08

Starting Implementing Control Stage Processor Preview 08:09

Handling GET DEVICE Descriptor Request Preview 05:27

Processing IN-DATA Stage Preview 12:13

Handling IN and OUT Endpoint Interrupts Preview 15:08

Handling IN and OUT Transfer Completed Preview 07:53

Sending the Last Packet of Transactions Preview 12:13

Processing OUT-STATUS Stage Preview 01:58

Processing IN-DATA Zero Sub-Stage Preview 05:35

Call the Implemented Functions Before Testing Preview 03:29

Viewing the First Successful Communication in SysLog Preview 03:35

Viewing the First Successful Communication in Wireshark Preview 08:34

Processing SET ADDRESS Request Preview 03:57

Setting Device Address after transaction completion Preview 00:21

Processing IN-STATUS Stage Preview 02:10

Viewing no SET ADDRESS Error in SysLog Preview 01:38

Viewing SET ADDRESS Request and Response in Wireshark Preview 01:35

Viewing full GET DEVICE DESCRIPTOR response in Wireshark Preview 01:24

Viewing GET CONFIGURATION request in Wireshark Preview 01:55

Understanding the idea of combining descriptors Preview 03:20

Defining CONFIGURATION descriptor placeholder Preview 05:43

Merging the CONFIG-Combination into one definition Preview 01:36

Handling GET CONFIGURATION DESCRIPTOR request Preview 05:50

Understanding the size of CONFIG-Combination Preview 05:59

Processing SET CONFIGURATION request Preview 04:39

Defining use-case-specific configuration function Preview 06:10

Simple USB Mouse specifications Preview 01:45

Writing CONFIGURATION descriptor Preview 07:26

Writing INTERFACE descriptor Preview 06:16

Writing ENDPOINT descriptor Preview 07:13

Writing HID descriptor Preview 07:59

Introducing HID Report descriptor / HID report structure Preview 06:48

Describing HID buttons Preview 06:56

Describing HID axes Preview 05:48

Compacting HID report descriptor Preview 10:16

Packing data encapsulations (no word alignment) Preview 13:27

Introducing Set Idle and Get HID Report descriptor requests Preview 06:20

Handling SET IDLE request Preview 05:15

Handling GET HID REPORT descriptor request Preview 07:10

Responding to INTERRUPT IN tokens Preview 12:54

Testing the USB HID Mouse Preview 02:31

Changing descriptors order (Windows compatibility) Preview 09:42