AN1633
APPLICATION NOTE
DEVICE FIRMWARE UPGRADE (DFU) IMPLEMENTATION IN
NON-USB APPLICATIONS
by Microco nt rol l e r Divi s i on Ap pl ications
1 INTRODUCTION
This application note describes how to implement the Device Firmware Upgrade (DFU) capability using a ST7 USB microcontroller like the ST72F62 or ST72F63B in a general purpose or
‘non-USB’ application. The term ’non-USB’ is used here to contrast with ‘USB application’
which has a different DFU implementation (refer to AN1577). In the implementation described
here, the USB i nterfac e is not used in the applicati on. The appl ication board is self p owere d
and the on-chip USB interfac e is onl y used occasional ly, as a main tenance uti lity port to upgrade the MCU firmware.
The USB cell is only activated when the USB cable is plugged-in. At this time the application
is stopped and th e micro contro ller is seen as a USB de vice and ente rs the DF U proces s to
erase and program the new firmware in Sector 1 and/or Sector 2. When the user removes the
USB cable, the USB cell is switched-off and the main application is executed !
To illustrate this application note, a firmware example has been developed using a ST72F62
or a ST72F63B USB Low-Speed device. This firmware is based on the ST7 USB Low-Speed
DFU Demo firmware.
It is not necessary to know the USB cell to understand this application note. For more information about the USB DFU class, please refer to the Application Note AN1577.
AN1633/0303 1/9
1
2 DFU MECHANISM
2.1 OVERVIEW
As mentioned in the introduction, the m icrocontroller’s USB cell is onl y used du ring the DFU
upgrade process. This upgrade process takes place only when the US B ca ble is plugged-in.
When the USB cable is removed the non-USB application is executed and the USB cell is
switched off. The following figure explains this mechanism in detail.
Figure 1. DFU Flowchart in a non -USB application
Yes
SECTOR 0
MCU Reset
Main (DFU)
USB cable ?
Yes
DFU Process
USB cable ?
(jump table)
No
Flash
erasing &
programming
SECTORS 1 & 2
Main (Application)
USB cable ?
Yes
WDG Reset
No
No
WDG Reset
As you can see, two s eparat e firm ware appl ications r eside in diffe re nt flash sector s and are
selected by plugging a cable in the USB connector.
2/9
2
The first firmware application contains the USB Library, the DFU layer and the HDFlash driver.
This firmware application must be placed in Sector 0. It is executed only when the USB cable
is plugged-in. This firmware cannot be modified during the DFU process. When the Flash upgrade is finished, the firmware in Sector 0 continues execution until the USB cable is removed.
The second firm ware ap plica tion is the m ain appl ication. It m ust be pla ced in Se ctors 1 or 2
because it is modified during the DFU process. This firmware is executed only when the USB
cable is not plugged into the board.
The DFU layer also allows you to upgrade only one sector. You can use this feature, for example, to store common data or code for any firmware loaded in Sector 2.
2.2 USB CABLE DETECTION
The detection of the USB cable is made through an I/O port configured in Input mode. This
I/O is connected to the Vbus li ne on the USB connector. Detection can be done with i nterrupts
or by polling. In our example, the poll ing method i s us ed. This detec tion must be performed by
both applications (main application and DFU).
Figure 2. Connecting an I/O Port to the Vbus line
+5V
Vdd
Vss
I/O
USB connector
VbusUSB Vcc
3/9