ST AN1603 Application note

AN1603

APPLICATION NOTE

USING THE ST7 USB DEVICE FIRMWARE UPGRADE DEVELOPMENT KIT (DFU-DK)

by Microcontroller Division Applications

1 INTRODUCTION

This Application Note describes how to use the ST7 USB DFU PC development kit (DFU-DK). It begins with a presentation of the software architecture. It then gives a full description of the DFU-DK programming interface and all the features. Finally, an example is given of a vendor upgrade package developed with the DFU-DK.

The objective of the DFU-DK is to provide you with a simple means of upgrading the firmware of a USB device. It runs under Microsoft Windows and works with any STMicroelectronics USB microcontroller that supports the DFU capability including the ST72F62, ST72F63 and ST72F65x MCU families.

The DFU-DK can be downloaded from ST’s website.

Related Documentation:

ST7 USB Device Firmware Upgrade Demonstrator User Manual.

AN1603/0203

1/21

1

USING THE ST7 USB DEVICE FIRMWARE UPGRADE DEVELOPMENT KIT (DFU-DK)

1 INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 LIST OF INSTALLED FILES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2.1 DEVELOPMENT MODULES FOR BUILDING YOUR OWN PC SOFTWARE . . 3 2.2 DOCUMENTATION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2.3 DFU DRIVER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2.4 EXAMPLE VENDOR UPGRADE SOFTWARE FILES . . . . . . . . . . . . . . . . . . . . 3 3 SOFTWARE ARCHITECTURE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

4 DFU-DK PROGRAMMING INTERFACE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 4.1 OVERVIEW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 4.2 DRIVER INSTALLATION FILE (.INF) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 4.3 PROGRAMMING INTERFACE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

4.3.1 STDFU_EnumGETNBDevices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 4.3.2 STDFU_GetDeviceDescriptor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 4.3.3 STDFU_GetDFUDescriptor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 4.3.4 STDFU_GetStringDescriptor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 4.3.5 STDFU_GetNbOfConfigurations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 4.3.6 STDFU_GetConfigurationDescriptor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 4.3.7 STDFU_GetNbOfInterfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 4.3.8 STDFU_GetNbOfAlternates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 4.3.9 STDFU_GetInterfaceDescriptor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 4.3.10STDFU_Open . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 4.3.11STDFU_Close . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 4.3.12STDFU_Detach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 4.3.13STDFU_Dnload . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 4.3.14STDFU_UPload . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 4.3.15STDFU_Getstatus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 4.3.16STDFU_Clrstatus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 4.3.17STDFU_Getstate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 4.3.18STDFU_Abort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 4.3.19STDFU_HandleDeviceChange . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

5 EXAMPLE VENDOR UPGRADE SOFTWARE (DFU DEMONSTRATOR) . . . . . . . . 17 5.1 ST7DFUPRT PROGRAMMING INTERFACE . . . . . . . . . . . . . . . . . . . . . . . . . . 17

5.1.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

5.1.2 Programming Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

5.2 DFU DEMONSTRATOR GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

2/21

2

USING THE ST7 USB DEVICE FIRMWARE UPGRADE DEVELOPMENT KIT (DFU-DK)

2 LIST OF INSTALLED FILES

This section provides a list of all the DFU-DK files referred to in this application note.

2.1 DEVELOPMENT MODULES FOR BUILDING YOUR OWN PC SOFTWARE

In the Dev subdirectory, you will find the following items :

– Bin subdirectory -ST7DFU.dll : interface dll

-STTubeDevice203.dll : driver dll used by the ST7DFU dll

– Inc subdirectory

-ST7DFU.h : C header containining all prototypes exported by ST7DFU.dll -USB100.h : Microsoft header for USB.

– Lib subdirectory -ST7DFU.lib : static lib file

2.2 DOCUMENTATION

In the Doc subdirectory, you will find the following items :

– Application note AN1603: this file.

2.3 DFU DRIVER

In the Driver subdirectory, you will find the following items :

STDFU.inf: installation file for the DFU driver that can be customised to meet the requirements of your application

STTub203.sys: STMicroelectronics tube driver used as a DFU class driver

2.4 EXAMPLE VENDOR UPGRADE SOFTWARE FILES

In the Sources subdirectory, you will find the following items :

Binary subdirectory inludes binary modules: debug and release

DFUDEMO subdirectory includes GUI sources

ST7DFUPRT subdirectory includes DFU protocol dll sources

3/21

ST AN1603 Application note

USING THE ST7 USB DEVICE FIRMWARE UPGRADE DEVELOPMENT KIT (DFU-DK)

3 SOFTWARE ARCHITECTURE

Figure 1. DFU-DK software layers

STMicroelectronics

 

 

 

reference software

 

DFU GUI

 

 

 

 

Firmware Image

 

ST7DFUPRT.DLL

 

& suffix

 

 

Image.s19

 

 

reporting

Image.dfu

DFUProtocolInterfaceDFUprotocolInterface

 

 

 

 

STMicroelectronics

 

 

error

binary module

 

 

 

 

and

 

 

ST7DFU.DLL

 

 

Status

 

 

 

 

 

STTubeDeviceXXX.dll

 

 

 

 

User Mode

 

 

 

Kernel Mode

Tube-Driver for the DFU Class

STTubXXX.SYS

 

 

 

 

 

 

Microsoft USB Driver Stack (USBD)

 

 

 

 

Hardware

 

 

USB Bus Interface

 

4/21

 

 

 

USING THE ST7 USB DEVICE FIRMWARE UPGRADE DEVELOPMENT KIT (DFU-DK)

As shown in Figure 1, we can see that the DFU software is divided into four distinct layers:

The hardware layer (USB bus interface),

The kernel layer (Microsoft USB stack and STMicroelectronics tube driver)

and a user application layer that is also divided into two other layers:

A generic one that manages all DFU requests and is provided as ready binary modules (ST7DFU and STTubeDevice203 dynamic link libraries).

A vendor-specific one that is provided as an example reference software (protocol management dynamic link library and a demonstration GUI).

This modular architecture was chosen so that the DFU-DK can be used for any application that needs to implement DFU features. Moreover, this will make it easier to add features anytime in the future and manage changes.

Note: The DFU-DK is compatible with Windows 98, 98SE, Me, 2000 and XP and is compliant with the Device Class specification for DFU version1.0 as detailed by the USB-IF.

5/21

USING THE ST7 USB DEVICE FIRMWARE UPGRADE DEVELOPMENT KIT (DFU-DK)

4 DFU-DK PROGRAMMING INTERFACE

4.1 OVERVIEW

This module is used to allow the application to access the low level USB protocol, such as receiving descriptor information, configuring a device etc, and also for managing all DFU requests that are implemented in this module and are not linked to the application layer.

The following table summarize the DFU class-specific requests used to accomplish the upgrade operation.

Table 1. DFU Class specific requests

bmRequetType

bRequest

wValue

wIndex

wLength

Data

 

 

 

 

 

 

00100001b

DFU_DETACH

wTimeout

Interface

Zero

None

 

 

 

 

 

 

00100001b

DFU_DNLOAD

wBlockNum

Interface

Length

Firmware

 

 

 

 

 

 

10100001b

DFU_UPLOAD

wBlockNum

Interface

Length

Firmware

 

 

 

 

 

 

10100001b

DFU_GETSTATUS

Zero

Interface

6

Status

 

 

 

 

 

 

00100001b

DFU_CLRSTATUS

Zero

Interface

Zero

None

 

 

 

 

 

 

10100001b

DFU_GETSTATE

Zero

Interface

1

State

 

 

 

 

 

 

00100001b

DFU_ABORT

Zero

Interface

Zero

None

 

 

 

 

 

 

4.2 DRIVER INSTALLATION FILE (.INF)

Before creating or customising the DFU inf file, you have to obtain two licence keys for your vendor ID and product IDs, in order to use the DFU driver : One for the product ID of your composite device (Functional mode + DFU mode) and one for the only DFU mode device.

In our example we have two distinct keys, one for the PID=0xDF11 (STMicroelectronics DFU devices) which is “6f72a98be4e1edad” and another one for a composite device, PID= 0xFF03 (STMicroelectronics EvalKit and DFU) which is “d083fc290a34aa18”.

Once you have your licence keys, you need to make your own inf file. The inf file is a text file used by Windows to install a driver. The one given in this package can be customised to fit your needs. Anyway, you have to choose your own name for the inf file, and you shouldn’t use the one given in the package.

After a successful driver installation the correct values in this inf file will be entered in the registery.

6/21

USING THE ST7 USB DEVICE FIRMWARE UPGRADE DEVELOPMENT KIT (DFU-DK)

4.3 PROGRAMMING INTERFACE

This is the Application-programming interface of the ST7DFU.dll module. The documentation describes the interface in C language.

4.3.1 STDFU_EnumGETNBDevices

4.3.1.1 Prototype

DWORD STDFU_EnumGetNbDevices( PDWORD pNb,

HWND hWnd,

DWORD Message);

4.3.1.2 Description

Browses all DFU devices connected to the PC.

4.3.1.3 Parameters

pNb: pointer to the number of DFU devices hWnd :window handle

Message: notifies an application of a change to the hardware configuration of a DFU-device.

4.3.1.4 Returned value

STDFU_NOERROR in case of success, otherwise (Error Code)

4.3.1.5 Remarks

For more details about hWnd and Message parameters please refer to Section 4.3.19 The following section provides all error codes that can be returned by any function:

STDFU_ERROR_OFFSET

STDFU_NOERROR

STDFU_MEMORY

STDFU_BADPARAMETER

STDFU_NOTIMPLEMENTED

STDFU_ENUMFINISHED

STDFU_OPENDRIVERERROR STDFU_ERRORDESCRIPTORBUILDING STDFU_PIPECREATIONERROR STDFU_PIPERESETERROR STDFU_PIPEABORTERROR STDFU_STRINGDESCRIPTORERROR STDFU_DRIVERISCLOSED STDFU_VENDOR_RQ_PB STDFU_ERRORWHILEREADING STDFU_ERRORBEFOREREADING STDFU_ERRORWHILEWRITING

0x12340000 STDFU_ERROR_OFFSET (STDFU_ERROR_OFFSET+1) (STDFU_ERROR_OFFSET+2) (STDFU_ERROR_OFFSET+3) (STDFU_ERROR_OFFSET+4)

(STDFU_ERROR_OFFSET+5) (STDFU_ERROR_OFFSET+6) (STDFU_ERROR_OFFSET+7) (STDFU_ERROR_OFFSET+8) (STDFU_ERROR_OFFSET+9)

(STDFU_ERROR_OFFSET+0xA) (STDFU_ERROR_OFFSET+0xB) (STDFU_ERROR_OFFSET+0xC) (STDFU_ERROR_OFFSET+0xD) (STDFU_ERROR_OFFSET+0xE) (STDFU_ERROR_OFFSET+0xF)

7/21

Loading...
+ 14 hidden pages