ST AN2078 Application note

AN2078
Application note
STR7 In-Application Programming using UART
Introduction
An important requirement for most Flash-based systems is the ability to update firmware while the system is installed in the end product. This is referred to as In-Application Programming (IAP).
This application note outlines general guidelines for creating an IAP application. The STR7xx Eval Boards were used to validate the IAP driver.
Software is provided and is available on http://www.st.com/mcu
January 2007 Rev 3 1/13
www.st.com
Contents AN2078
Contents
1 IAP overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1 Principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 IAP driver description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 Running the IAP driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.1 HyperTerminal configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2 Triggering execution of the IAP driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3 IAP driver menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1 Download image to internal Flash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.2 Execute the new program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
4 STR7xx IAP implementation Summary . . . . . . . . . . . . . . . . . . . . . . . . . . 7
5 User program conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
6 IAP restrictions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
7 How to use the IAP driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
8 Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2/13
AN2078 IAP overview

1 IAP overview

1.1 Principle

The IAP driver must be programmed by the user in the Flash base address (0x00) via JTAG using a flasher toolset.
Using the UART, the IAP driver loads a binary file from the HyperTerminal to the STR7xx internal Flash, and then jumps to execute it.

1.2 IAP driver description

The following table shows the IAP driver code size for each STR7xx MCU.
STR71x STR73x STR75x
7.2 Kbytes 8.3 Kbytes 5.8 Kbytes
The IAP driver contains a set of source files:
main.c: where the UART initialization and PLL configuration are set. Then, a main
menu is executed from the common.c file.
common.c: contains display functions and the main menu routine. The main menu
gives the choice between loading a new binary file and executing the binary file already loaded.
ymodem.c and download.c: they allow all data to be received from the HyperTerminal
application (using the YMODEM protocol the event of a failure in data receival, the ‘Failed to receive the file’ error message is displayed on the HyperTerminal window. However, if successful, the data is then programmed into internal Flash at the appropriate address. A comparison between internal RAM and internal Flash contents is performed to check the data intergrity. If there is any discrepency, the ‘Verification failed’ error message is displayed on HyperTerminal window. Other error messages are also displayed when the image size is higher than the allowed space memory and when there is an abort by the user.
1)
), then loaded into STR7 internal RAM. In
Note: 1 Ymodem protocol sends data in 1024-byte blocks. A check for errors in data blocks
transmitted to the STR7xx Internal RAM is applied: A comparison between the transmitted and received data is achieved. Blocks received unsuccessfully are acknowledged with a NAK (Negative Acknowledgement). For more details about the Ymodem protocol, refer to existing documentation.
Some STR7xx Standard library and Flash library files.
A pin connected to a push button is used to select between jumping to the user application and executing the IAP for reprogramming purpose:
Push button is not pressed at reset: jump to the user application
Push button is pressed at reset: the IAP main menu is displayed
Figure 1 shows the IAP flowchart.
3/13
IAP overview AN2078
Figure 1. FlowChart of the IAP Driver
Start
Initialize the STR7 UART & PLL
Display the IAP Main Menu
Download
Receive a binary file
No
Success
Yes
Program the internal Flash
Push button is
pressed?
Yes
Download or
Jump?
No
Jump to User Program
Jump to the User Program
Display the error message ‘Failed
to receive the
file’
No
All data
programmed
successfully?
Yes
Display the name and the size of
the received file
Display the error message ‘Verfification failed’
User Application
Software
4/13
Loading...
+ 9 hidden pages