ST AN1633 Application note

AN1633

APPLICATION NOTE

DEVICE FIRMWARE UPGRADE (DFU) IMPLEMENTATION IN NON-USB APPLICATIONS

by Microcontroller Division Applications

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 interface is not used in the application. The application board is self powered and the on-chip USB interface is only used occasionally, as a maintenance utility 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 the microcontroller is seen as a USB device and enters the DFU process 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

ST AN1633 Application note

2 DFU MECHANISM

2.1 OVERVIEW

As mentioned in the introduction, the microcontroller’s USB cell is only used during the DFU upgrade process. This upgrade process takes place only when the USB cable 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

SECTOR 0

 

SECTORS 1 & 2

 

MCU Reset

(jump table)

 

 

 

 

 

Main (DFU)

 

Main (Application)

 

 

 

 

USB cable ?

No

USB cable ?

No

 

 

Yes

 

Yes

 

 

 

 

DFU Process

Flash

WDG Reset

 

 

erasing &

 

 

 

programming

 

 

Yes

 

 

 

USB cable ?

 

 

 

No

 

 

 

WDG Reset

 

 

 

As you can see, two separate firmware applications reside in different flash sectors 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 firmware application is the main application. It must be placed in Sectors 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 line on the USB connector. Detection can be done with interrupts or by polling. In our example, the polling method is used. This detection must be performed by both applications (main application and DFU).

Figure 2. Connecting an I/O Port to the Vbus line

+5V

Vdd

I/O

 

USB connector

USB Vcc

 

Vbus

 

 

 

 

 

 

 

Vss

3/9

Loading...
+ 6 hidden pages