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 micr ocontr oller that s upp orts th e DFU c apa bility i nclu ding the ST7 2F62, S T72F 63 an d
ST72F65x MCU families.
The DFU-DK can be downloaded from ST’s website.
Related Documentation:
ST7 USB Device Firmware Upgrade Demonstrator User M anual.
AN1603/02031/21
1
USING THE ST7 USB DEVICE FIRMWARE UPGRADE DEVELOPMENT KIT (DFU-DK)
USING THE ST7 USB DEVICE FIR MWARE UPGRADE DEVELOPMENT KIT (DFU-DK)
2 LIST OF INSTALLED FILE S
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 require-
ments 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
USING THE ST7 USB DEVICE FIRMWARE UPGRADE DEVELOPMENT KIT (DFU-DK)
(
g
3 SOFTWARE ARCHITECTURE
Figure 1. DFU-DK software layers
STMicro el ectr on i cs
referenc e so ftware
Firmware Im ag e
& suffix
Image.s19
e.dfu
Ima
STMicro el ectr on ics
binary module
ST7DFUPRT.DLL
Protocol DFU Interface
DFU Interface protocol
STTubeDeviceXXX.dll
DFU GUI
ST7DFU.DLL
Status and error reporting
4/21
Tube-Driver for the DFU Class
STTubXXX.SYS
Microsoft USB Driver Stack
USB Bus Interface
User Mode
Kernel Mode
USBD)
Hardwa re
USING THE ST7 USB DEVICE FIR MWARE 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 manage-
ment dynamic link library and a demonstration GUI).
This modula r architec ture was chose n so that the DFU-DK c an be used for any ap plication
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 follow ing table sum mariz e the DF U class-sp ecific requ ests us ed to acco mplish the upgrade operation.
Before creating o r customi sing the D FU inf file, you ha ve to obtain two l icence k eys fo r 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 (ST M icroelectronics 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 drive r. The one given in this package c an be customis ed 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 FIR MWARE UPGRADE DEVELOPMENT KIT (DFU-DK)
4.3 PROGRAMMING INTERFACE
This is the Application-programming interface of the ST7DFU.dll modu le. 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: