CMSIS-DAP: Configure USB peripheral

| CMSIS-DAP Version 2.1.1 Interface Firmware for CoreSight Debug Access Port

- Main Page
- Usage and Description
- Reference

All Functions Groups Pages
Configure USB peripheral
Firmware configuration

CMSIS-DAP firmware communicates via USB with the host computer. More...

CMSIS-DAP firmware communicates via USB with the host computer.

The USB communication is implemented via MDK-Middleware components that access the USB peripheral of the microcontroller.

The CMSIS-DAP v2 firmware uses USB bulk endpoints that provide high-speed communication. In addition, Communication Device Class is used to enable USB COM port.

For the USB interface it is important to provide correct configuration information for the USB peripheral as described in this section.

The following steps describe how to change and configure the USB peripheral in the CMSIS-DAP firmware project:

1. In the Project Window, the group USB contains USB interface with the relevant configuration files.
2. Open the file usb_config_0.c in the editor and select Configuration Wizard as edit mode; then change the following settings:
   - USB Device 0 - High-speed: enable this option only for a high-speed USB peripheral; disable for full-speed USB.
   - Update Device Settings - Vendor ID which is provided by the USB Implementers Forum.
   - Update Device Settings - Product ID to provide a unique identification for the debug unit.
   - Update Device Settings - Device Release Number to indicate the revision of the adaptation.
   - Update String Settings - Manufacturer String to reflect the vendor of the debug unit. This setting should match the Vendor ID.
   - Update String Settings - Product String to indicate the debug unit. Note that "CMSIS-DAP" must be part of that string to allow identification by debuggers (or part of interface string for USB composite device).
   - Optionally each debug unit may provide a unique Serial Number String. If the String Settings - Serial Number String is not provided, only one debug unit can be connected at the same time to a host computer since it is impossible to identify multiple debug units.

Note
  - The USB Device setting high-speed / full-speed USB must be reflected in the DAP_config.h file as described under Firmware configuration.
  - The String Settings - Product String must contain "CMSIS-DAP" somewhere in the string. This is used by the debuggers to identify a CMSIS-DAP compliant debug unit that is connected to a host computer.

Adapt the USB Peripheral to the microcontroller

### Communication via USB bulk endpoints

CMSIS-DAP v2 uses USB bulk endpoints and is therefore faster than the deprecated v1.Optionally, support for streaming SWO trace is provided via an additional USB endpoint.This configuration requires custom class support with the interface setting:

- Class Code: 0xFF (Vendor specific)
- Subclass: 0x00
- Protocol code: 0x00

Note
  This interface enables also WebUSB technology that is used in web browsers to connect to a debug adapter connected to your PC.

Depending on the configuration, it uses the following USB endpoints which should be configured in the interface descriptor in this order:

- Endpoint 1: Bulk Out – used for commands received from host PC.
- Endpoint 2: Bulk In – used for responses send to host PC.
- Endpoint 3: Bulk In (optional) – used for streaming SWO trace (if enabled with SWO_STREAM).

Configuration settings for the USB custom class

Note
  These settings allow support in Windows (8 and above), Mac OS, and Linux without further drivers. Some additional settings are required to automatically install CMSIS-DAP enabled debug adapters in these operating systems.

Additional settings for Microsoft Windows
For automatic installation of a CMSIS-DAP v2 enabled debug adapter in Windows, use the following WinUSB GUID in the USB custom class:

{CDB3B5AD-293B-4663-AA36-1AAE46463776}
The picture below shows the WinUSB GIUD configuration of the USB custom class:
Adapt CMSIS-DAP to the WinUSB class

USB Driver and *.inf file
Windows 8 and above does not require a WinUSB driver provided that the USB firmware stack supports Microsoft descriptors. CMSIS-DAP v2 device should be configured as WCID (Windows Compatible ID) device which provides extra information to a Windows system to facilitate automated driver installation.
For Windows 7, the CMSIS-DAP v2 device will install automatically if the PC is connected to the Internet and device installation settings are set to automatically download and install drivers for devices. The installed device will be seen in the Device Manager under Universal Serial Bus devices as a WinUSB Device.
If no Internet connection is available or you want the device to show with a different name in the Device Manager, you should provide an .inf file and sign it to generate .cat files. More information is available from Microsoft under the topic Steps for Signing a Device Driver Package.
The following CMSIS_DAP_v2.inf file should be provided for an Windows 7 host PC.

    [Version]
    Signature = "$Windows NT$"
    Class     = USBDevice
    ClassGUID = {88BAE032-5A81-49f0-BC3D-A4FF138216D6}
    Provider  = %ManufacturerName%
    DriverVer = 04/13/2016, 1.0.0.0
    CatalogFile.nt      = CMSIS_DAP_v2_x86.cat
    CatalogFile.ntx86   = CMSIS_DAP_v2_x86.cat
    CatalogFile.ntamd64 = CMSIS_DAP_v2_amd64.cat

    ; ========== Manufacturer/Models sections ===========

    [Manufacturer]
    %ManufacturerName% = Devices, NTx86, NTamd64

    [Devices.NTx86]
    %DeviceName% = USB_Install, USB\VID_c251&PID_f000

    [Devices.NTamd64]
    %DeviceName% = USB_Install, USB\VID_c251&PID_f000

    ; ========== Class definition ===========

    [ClassInstall32]
    AddReg = ClassInstall_AddReg

    [ClassInstall_AddReg]
    HKR,,,,%ClassName%
    HKR,,NoInstallClass,,1
    HKR,,IconPath,0x10000,"%%SystemRoot%%\System32\setupapi.dll,-20"
    HKR,,LowerLogoVersion,,5.2

    ; =================== Installation ===================

    [USB_Install]
    Include = winusb.inf
    Needs   = WINUSB.NT

    [USB_Install.Services]
    Include = winusb.inf
    Needs   = WINUSB.NT.Services

    [USB_Install.HW]
    AddReg  = Dev_AddReg

    [Dev_AddReg]
    HKR,,DeviceInterfaceGUIDs,0x10000,"{CDB3B5AD-293B-4663-AA36-1AAE46463776}"

    ; =================== Strings ===================

    [Strings]
    ClassName        = "Universal Serial Bus devices"
    ManufacturerName = "KEIL - Tools By ARM"
    DeviceName       = "CMSIS-DAP v2"

### Communication Device Class

CMSIS-DAP v2 supports also a UART communication port optionally routed to a USB COM port which is implemented by a USB Communication Device Class (CDC) device.
The picture below shows the configuration of the USB CDC class.
Configuration of USB CDC class