USB DFU protocol, STM32

[ Pobierz całość w formacie PDF ]
AN3156
Application note
USB DFU protocol used in
the STM32™ bootloader
Introduction
This application note describes the USB DFU protocol used in STM32 microcontroller
bootloader. It details each supported command. For more information about the USB
hardware resources and requirements for your device bootloader, please refer to the
“STM32 system memory boot mode” application note (AN2606).
Related documents
Available from www.st.com:
AN2606 “STM32 system memory boot mode”
April 2011
Doc ID 17068 Rev 2
1/26
Contents
AN3156
Contents
1
Bootloader code sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2
USB DFU bootloader requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3
DFU bootloader commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.1
Device-dependent bootloader parameters . . . . . . . . . . . . . . . . . . . . . . . . 11
4
DFU_UPLOAD request commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.1
Read memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.2
Get command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
5
DFU_DNLOAD request commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
5.1
Write memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
5.2
Set Address Pointer command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
5.3
Erase command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
5.4
Read Unprotect command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
5.5
Leave DFU mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
6
Bootloader protocol version evolution . . . . . . . . . . . . . . . . . . . . . . . . . 24
7
Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2/26
Doc ID 17068 Rev 2
AN3156
List of tables
List of tables
Table 1.
DFU class requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Table 2.
Summary of DFU class-specific requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Table 3.
DFU bootloader commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Table 4.
Bootloader protocol versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Table 5.
Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Doc ID 17068 Rev 2
3/26
List of figures
AN3156
List of figures
4/26
Doc ID 17068 Rev 2
AN3156
Bootloader code sequence
1
Bootloader code sequence
Two versions of USB DFU bootloader are implemented depending on the STM32 device:
V2.0 and V2.1 (refer to AN2606 for more details). The main differences between these two
versions are the following:

Detection and connection mechanism (refer to
and

Memory descriptors and features (refer to AN2606 for more details).
The is no difference in terms of protocol (requests and commands).
Once the system memory boot mode is entered and the STM32 device has been configured
(for more details refer to AN2606), the bootloader code configures the USB and its
interrupts, and waits for the “enumeration done” interrupt.
Once this interrupt is detected (a host is present, has connected to the device and
enumerated it), the system is configured in External oscillator mode and the USB device is
re-initialized.
For USB DFU bootloader V2.0, the device first tries the 25 MHz configuration, then, if it fails,
the 14.7456 MHz configuration, and finally, if it fails, the 8 MHz configuration. If it still fails,
this operation is repeated with a large timeout value (the three configurations are tested
again). If the second trial also fails, a system reset is generated.
For the V2.1 USB DFU bootloader version, once the USB is detected, the system clock is
configured to 60 MHz. If no external clock is detected, a system reset is generated. The
external clock is detected and its value is computed using HSI clock and a timer (refer to
AN2606 for more details).
The USB enumeration is performed as soon as the USB cable is plugged (or immediately if
the cable is already plugged). If you do not want the STM32 to enter the USB DFU
bootloader application, the USB cable has to be unplugged before reset.
The bootloader version is returned in the device descriptor in the MSB of the bcd Device
field (example: 0x2000 = Version 2.0).
Doc ID 17068 Rev 2
5/26
   [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • emaginacja.xlx.pl
  •