CMSIS-DAP: Configure USB Peripheral

| CMSIS-DAP Version 2.0.0 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 an USB interface to host computer. More...

CMSIS-DAP Firmware communicates via an USB interface to host computer.

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

The CMSIS-DAP Firmware is able to communicate with the host computer using one of the following USB classes:

- Communication via USB HID (Human Interface Device) does not require any USB driver installation.
- Communication via WinUSB provides higher speed communication but may require an *.inf file for USB installation.

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 HID

CMSIS-DAP with V1 configuration uses USB HID and is therefore compatible with previous versions of CMSIS-DAP.There is no modification at the debugger required as all the additions are fully upward compatible. To configure CMSIS-DAP for V1 interface, add to the compiler options the #define DAP_FW_V1 as shown below:
Compiler CMSIS-DAP Firmware for USB HID interface

The CMSIS-DAP Firmware can be also part of a USB composite device. If this case, the HID Interface String must contain the sub-string CMSIS-DAP. The HID Interface String is configured in the file USBD_Config_HID_0.h under the category Human Interface Device Class Settings.

Adapt CMSIS-DAP to the USB HID class

### Communication via WinUSB

CMSIS-DAP with default V2 configuration uses WinUSB and is therefore faster.Optionally support for streaming SWO trace is provided via an additional USB endpoint.The WinUSB configuration requires custom class support with the interface setting – Class Code: 0xFF (Vendor specific), Subclass: 0x00, Protocol code: 0x00. 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).

To identify a CMSIS-DAP V2 configuration by debuggers the following WinUSB GUID must be used:
{CDB3B5AD-293B-4663-AA36-1AAE46463776}

The picture below shows the configuration of the USB custom class.

Adapt CMSIS-DAP to the WinUSB class

USB Driver and *.inf file
Windows 8 and Windows 10 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 PC is connected to the Internet and Device Installation Settings of PC are set to automatically download and install drivers for devices. Automatically installed device will be seen in Device Manager under Universal Serial Bus devices as WinUsb Device
If no Internet connection is available or you want device to show with different name under 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"