USB Behind the Scenes Handson HID Firmware Development
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
Have you ever wanted to develop your own device that can be connected to a computer using USB? Are you familiar with using USB <-> UART adapters but want to take your USB knowledge and understanding to the next ultimate level? If yes, then this course is absolutely for you!I made the whole content of slides and code by myself after a lot of preparation and fine-tuning to give you the best experience you can find today online to learn and understand USB protocol and framework in theory and in practice.Your journey with me in this course should save you from any frustration that could happen when you try to learn or understand USB from any other online source. USB is for most a mystery and a very complex protocol, and most engineers try to avoid it or at least try to convert it to other simpler protocols. However, after taking this course, you will be able to be a confident native USB engineer, and you will be able to develop your first bare-metal USB device with me without using any library, which will give you full control over the powers of USB. Even if you want in your career to use a USB library, taking this course will give you a full understanding of what is going on behind the scenes, and will allow you to be able to develop and fine-tune and USB device you want, because, after the end of this course, I would expect from you to have a full understanding of the concept of USB and how it works.In this course, we will:- Start with some theoretical information about USB.- Understand the essential details of USB protocol.- Take our time to understand how to configure the clock of any embedded system correctly.- Implement a bare-metal USB firmware for ARM Cortex M4 based microcontroller (STM32F4xx family).- Implement a bare-metal USB framework.- Develop our own USB HID mouse from zero to fully functional!Of course, the source code of the project we are going to develop together in this course will be available for you to download. You may use it as a template (fully or partially) for your projects in the future.This course is in its early stages and some new additional content will be added or enhanced if necessary frequently. Nevertheless, the current content is full and sufficient to get a fully functional USB human interface device.Happy engineering! See you inside the course!
Overview
Section 1: Welcome to the Course
Lecture 1 Introduction
Lecture 2 How to Get the Most of This Course?
Lecture 3 Discord Server for Student Communication
Lecture 4 Why STM32F429ZI (ARM Cortex-M4 Based) Microcontroller?
Lecture 5 Udemy Review
Section 2: Introduction to USB
Lecture 6 Definition and Motivation
Lecture 7 History
Lecture 8 Cables and Connectors
Lecture 9 USB 2.0 Cable Structure
Lecture 10 Main Features
Lecture 11 Bus Topology and Functions
Lecture 12 VBUS
Lecture 13 Power Delivery Specification
Lecture 14 Smart Charger
Section 3: USB Protocol
Lecture 15 Differential States
Lecture 16 Bus States
Lecture 17 Timing Tolerance
Lecture 18 USB 2.0 Speed Identification
Lecture 19 Bit Stuffing
Lecture 20 Non-Return-to-Zero Inverted (NRZI)
Lecture 21 Host Controllers
Lecture 22 Frames
Lecture 23 Endpoints
Lecture 24 (PDF) Packet and Transaction Types
Lecture 25 Packets
Lecture 26 Packet Types and Packet Fields
Lecture 27 Transaction
Lecture 28 Packet Identifiers
Lecture 29 Token Packets
Lecture 30 Data Packets
Lecture 31 Handshake Packets
Lecture 32 Device Address
Lecture 33 Bus Polling
Lecture 34 USB is Host Driver
Lecture 35 USB is Host Driver Demonstration
Lecture 36 Endpoint Types (Transfer Types)
Lecture 37 Interrupt Transfer
Lecture 38 Bulk Transfer
Lecture 39 Isochronous Transfer
Lecture 40 Control Transfer
Lecture 41 Control Transfer Stages
Lecture 42 Bus Bandwidth Allocation
Section 4: Preparing the Workspace
Lecture 43 Installing STM32CubeIDE
Lecture 44 Creating a New Project
Lecture 45 Including ARM CMSIS
Lecture 46 Removing Sysmem and Syscalls
Lecture 47 Log to Debugger Using SWO
Lecture 48 Logging Helper
Lecture 49 Configuring Debugger and SVW for Logging
Lecture 50 Project source code
Section 5: Configuring the Clock
Lecture 51 NO CODE GENERATION IN STM32CubeMX
Lecture 52 My Method to Explain Clocking
Lecture 53 Creating Temporary STM32CubeMX Project
Lecture 54 USB Module Requires 48 MHz Signal
Lecture 55 Understanding Clock Frequency Requirements
Lecture 56 Understanding PLL, Prescalers, SYSCLK, and HCLK
Lecture 57 Understanding MCO Divider
Lecture 58 Initial Steps to Configure the Clock
Lecture 59 CMSIS Bit Operations
Lecture 60 Configuring Flash Latency
Lecture 61 CMSIS Fld2Val and Val2Fld Macros
Lecture 62 Enabling HSE
Lecture 63 Enabling and Configuring PLL
Lecture 64 Configuring APB-Prescaler
Lecture 65 Disabling HSI
Lecture 66 Correction of PLL Configuration Trap
Lecture 67 Testing Clock Configuration
Lecture 68 Configuring MCO
Lecture 69 Verifying the Clock Frequency Using Oscilloscope
Lecture 70 Reconfiguring SWO Clock Frequency
Section 6: Preparing USB Testing and Debugging Linux Environment
Lecture 71 Installing Wireshark on Linux
Lecture 72 Viewing Linux System Log
Section 7: USB Device Driver – Initialization
Lecture 73 Firmware Architecture We Will Be Using
Lecture 74 Creating Driver Source and Header Files and Accessing USB Regions
Lecture 75 Configuring GPIOs as USB Pins
Lecture 76 Tips to Get the Most Benefits
Lecture 77 Skimming Core and Device Configuration
Lecture 78 USB Core Initialization
Lecture 79 Initializing USB Core Interrupts
Lecture 80 Connecting the USB Device to the Bus (Using Firmware)
Lecture 81 Testing Connecting the USB Device to the Host
Section 8: USB Device Driver – Polling Loop
Lecture 82 USB Core Global Interrupts
Lecture 83 USB Global Interrupt Handler
Lecture 84 Steps of Handling USB Reset Signal
Lecture 85 USB Reset Handler
Lecture 86 Configuring Endpoint 0
Lecture 87 Configuring IN Endpoints
Lecture 88 NOTICE about “Deconfiguring Endpoint” lecture
Lecture 89 Deconfiguring Endpoint
Lecture 90 NOTE: Parameters Validation and Code Documentation
Lecture 91 Understanding FIFO Dedicated Memory
Lecture 92 Configuring FIFO Size
Lecture 93 Configuring FIFO Offset
Lecture 94 Configuring FIFOs While Configuring Endpoints
Lecture 95 Flushing FIFOs
Lecture 96 Accessing the FIFOs
Lecture 97 Transfer Completed Interrupts
Lecture 98 USB Speed Enumeration Done Handler
Lecture 99 Implementing RxFIFO Not Empty Interrupt Handler
Lecture 100 SETUP and OUT Transfer Completed Status Data
Lecture 101 Popping Data from the RxFIFO (From an OUT endpoint)
Lecture 102 Pushing Data into a TxFIFO (To an IN endpoint)
Lecture 103 Fixing Compilaiton Error (Reorder Some Functions)
Lecture 104 Defining USB Driver Type
Section 9: USB Device Framework
Lecture 105 Polling on Interrupt Level
Lecture 106 Defining USB Events Type
Lecture 107 Defining USB Device States
Lecture 108 Defining USB Control Transfer Stages
Lecture 109 Defining USB Device Instance Structure
Lecture 110 Starting to Configure the USB Device Instance
Lecture 111 Implementing USB Reset Handler
Lecture 112 [DRIVER] Implementing USB Set Address
Lecture 113 Triggering USB Reset Event (Calling the Handler)
Lecture 114 Reading the Received Requests
Lecture 115 Understanding USB Request Structure
Lecture 116 Understanding USB Standard Device Requests
Lecture 117 Defining the Structure of USB Requests
Lecture 118 Starting Processing the Requests
Lecture 119 Investigating the First Request
Lecture 120 Defining Descriptor Structure
Lecture 121 Writing the Device Descriptor
Lecture 122 Defining the Standard Request Macros (wValue)
Lecture 123 Defining a Variable after a Switch Case Error
Lecture 124 Write a Packet ONLY when the Endpoint is Empty
Lecture 125 Starting Implementing Control Stage Processor
Lecture 126 Handling GET DEVICE Descriptor Request
Lecture 127 Processing IN-DATA Stage
Lecture 128 Handling IN and OUT Endpoint Interrupts
Lecture 129 Handling IN and OUT Transfer Completed
Lecture 130 Sending the Last Packet of Transactions
Lecture 131 Processing OUT-STATUS Stage
Lecture 132 Processing IN-DATA Zero Sub-Stage
Lecture 133 Call the Implemented Functions Before Testing
Lecture 134 Viewing the First Successful Communication in SysLog
Lecture 135 Viewing the First Successful Communication in Wireshark
Lecture 136 Processing SET ADDRESS Request
Lecture 137 Setting Device Address after transaction completion
Lecture 138 Processing IN-STATUS Stage
Lecture 139 Viewing no SET ADDRESS Error in SysLog
Lecture 140 Viewing SET ADDRESS Request and Response in Wireshark
Lecture 141 Viewing full GET DEVICE DESCRIPTOR response in Wireshark
Lecture 142 Viewing GET CONFIGURATION request in Wireshark
Lecture 143 Understanding the idea of combining descriptors
Lecture 144 Defining CONFIGURATION descriptor placeholder
Lecture 145 Merging the CONFIG-Combination into one definition
Lecture 146 Handling GET CONFIGURATION DESCRIPTOR request
Lecture 147 Understanding the size of CONFIG-Combination
Lecture 148 Processing SET CONFIGURATION request
Lecture 149 Defining use-case-specific configuration function
Section 10: USB Mouse
Lecture 150 Simple USB Mouse specifications
Lecture 151 Writing CONFIGURATION descriptor
Lecture 152 Writing INTERFACE descriptor
Lecture 153 Writing ENDPOINT descriptor
Lecture 154 Writing HID descriptor
Lecture 155 Introducing HID Report descriptor / HID report structure
Lecture 156 Describing HID buttons
Lecture 157 Describing HID axes
Lecture 158 Compacting HID report descriptor
Lecture 159 Packing data encapsulations (no word alignment)
Lecture 160 Introducing Set Idle and Get HID Report descriptor requests
Lecture 161 Handling SET IDLE request
Lecture 162 Handling GET HID REPORT descriptor request
Lecture 163 Responding to INTERRUPT IN tokens
Lecture 164 Testing the USB HID Mouse
Lecture 165 Changing descriptors order (Windows compatibility)
Section 11: Conclusion, Next Steps and Thank you!
Lecture 166 Conclusion, Next Steps and Thank you!
Anyone who wants to understand how the complex USB systems work behind the scenes.,Embedded engineers who want to develop USB devices.,Engineers who want to enrich their knowledge in embedded systems in general.,Engineers who want to write modular and maintainable firmware.
Course Information:
Udemy | English | 14h 28m | 5.61 GB
Created by: Mohammed Noureldin
You Can See More Courses in the IT & Software >> Greetings from CourseDown.com