AN2557 Application note

Similar documents
AN2557 Application note

AN3354 Application note

UM0985 User manual. Developing your STM32VLDISCOVERY application using the IAR Embedded Workbench software. Introduction

AN3332 Application note

SPC5-FLASHER. Flash management tool for SPC56xx family. Description. Features

AN2824 Application note

How To Write To An Eeprom Memory On A Flash Memory On An Iphone Or Ipro Memory On Microsoft Flash Memory (Eeprom) On A Microsoft Microsoft Powerbook (Ai) 2.2.2

AN4108 Application note

UM1727 User manual. Getting started with STM32 Nucleo board software development tools. Introduction

AN3990 Application note

UM1790 User manual. Getting started with STM32L053 discovery kit software development tools. Introduction

AN2604 Application note

AN3265 Application note

Getting started with DfuSe USB device firmware upgrade STMicroelectronics extension

AN3998 Application note

UM1680 User manual. Getting started with STM32F429 Discovery software development tools. Introduction

UM1676 User manual. Getting started with.net Micro Framework on the STM32F429 Discovery kit. Introduction

AN2389 Application note

EVL185W-LEDTV. 185 W power supply with PFC and standby supply for LED TV based on the L6564, L6599A and Viper27L. Features.

TN0023 Technical note

AN4156 Application note

DDSL01. Secondary protection for DSL lines. Features. Description

BD238. Low voltage PNP power transistor. Features. Applications. Description. Low saturation voltage PNP transistor

AN2680 Application note

BD241A BD241C. NPN power transistors. Features. Applications. Description. NPN transistors. Audio, general purpose switching and amplifier transistors

Single LNB supply and control IC DiSEqC 1.X compliant with EXTM based on the LNBH29 in a QFN16 (4x4) Description

2STBN15D100. Low voltage NPN power Darlington transistor. Features. Application. Description

M24LRxx/CR95HF application software installation guide

STEVAL-IEG001V2. Smart real-time vehicle tracking system. Features

ULN2801A, ULN2802A, ULN2803A, ULN2804A

ST High voltage fast-switching NPN power transistor. Features. Applications. Description

BD135 - BD136 BD139 - BD140

AN3155 Application note

AN4128 Application note

AN3353 Application note

Description. Table 1. Device summary. Order code Temperature range Package Packaging Marking

AN3110 Application note

Order code Temperature range Package Packaging

EN: This Datasheet is presented by the m anufacturer. Please v isit our website for pricing and availability at ore.hu.

ULN2001, ULN2002 ULN2003, ULN2004

LM337. Three-terminal adjustable negative voltage regulators. Features. Description

DSL01-xxxSC5. Secondary protection for DSL lines. Features. Description. Applications. Benefits. Complies with the following standards

AN3270 Application note

UM1613 User manual. 16-pin smartcard interface ST8034P demonstration board. Introduction

ETP01-xx21. Protection for Ethernet lines. Features. Description. Applications. Benefits. Complies with the following standards

Description. IO and RF AGC. ASIC controller and power management. Carrier recovery loop. GPIO switch matrix. Lock indicator and monitoring DVBS2 FEC

ESDLIN1524BJ. Transil, transient voltage surge suppressor diode for ESD protection. Features. Description SOD323

AN3359 Application note

SPC5-CRYP-LIB. SPC5 Software Cryptography Library. Description. Features. SHA-512 Random engine based on DRBG-AES-128

UM0462 User manual. STM32 and STM8 Flash loader demonstrator. Introduction

ST19NP18-TPM-I2C. Trusted Platform Module (TPM) with I²C Interface. Features

AN3252 Application note

L78MxxAB L78MxxAC. Precision 500 ma regulators. Features. Description

LM135-LM235-LM335. Precision temperature sensors. Features. Description

LM134-LM234-LM334. Three terminal adjustable current sources. Features. Description

Description. Table 1. Device summary

STTH2R06. High efficiency ultrafast diode. Features. Description

BZW50. Transil, transient voltage surge suppressor (TVS) Features. Description

STN3NF06L. N-channel 60 V, 0.07 Ω, 4 A, SOT-223 STripFET II Power MOSFET. Features. Application. Description

AN2866 Application note

MC Low noise quad operational amplifier. Features. Description

AN3969 Application note

Table 1. Absolute maximum ratings (T amb = 25 C) Symbol Parameter Value Unit. ISO C = 330 pf, R = 330 Ω : Contact discharge Air discharge

UM0834 User manual. Developing and debugging your STM8S-DISCOVERY application code. Introduction. Reference documents

STTH1R04-Y. Automotive ultrafast recovery diode. Features. Description

AN974 APPLICATION NOTE

STP60NF06. N-channel 60V Ω - 60A TO-220 STripFET II Power MOSFET. General features. Description. Internal schematic diagram.

AN2146 APPLICATION NOTE

STP60NF06FP. N-channel 60V Ω - 30A TO-220FP STripFET II Power MOSFET. General features. Description. Internal schematic diagram.

AN2760 Application note

AN1754 APPLICATION NOTE

AN3997 Application note

AN2703 Application note

L6234. Three phase motor driver. Features. Description

UA741. General-purpose single operational amplifier. Features. Applications. Description. N DIP8 (plastic package)

TN0072 Technical note

Description. Table 1. Device summary. Order codes. TO-220 (single gauge) TO-220 (double gauge) D²PAK (tape and reel) TO-220FP

AN1819 APPLICATION NOTE Bad Block Management in Single Level Cell NAND Flash Memories

Description SO-8. series. Furthermore, in the 8-pin configuration Very low-dropout voltage (0.2 V typ.)

STDP2690. Advanced DisplayPort to DisplayPort (dual mode) converter. Features. Applications

TDA W CAR RADIO AUDIO AMPLIFIER

UM1075 User manual. ST-LINK/V2 in-circuit debugger/programmer for STM8 and STM32. Introduction

UM1727 User manual. Getting started with STM32 Nucleo board software development tools. Introduction

Obsolete Product(s) - Obsolete Product(s)

P6KE. Transil, transient voltage surge suppressor (TVS) Features. Description. Complies with the following standards

UM1969 User manual. Getting started with STM32F746G discovery software development tools. Introduction

STP55NF06L STB55NF06L - STB55NF06L-1

AN2328 Application note

STCS A max constant current LED driver. Features. Applications. Description

Figure 1. STM32F429 Discovery board: STM32F429I-DISCO

AN4368 Application note

32F072BDISCOVERY. Discovery kit for STM32F072xx microcontrollers. Features. Description

UM0109 USER MANUAL. Public Transport Ticketing Demo

Obsolete Product(s) - Obsolete Product(s)

STTH110. High voltage ultrafast rectifier. Description. Features

VN05N. High side smart power solid state relay PENTAWATT. Features. Description

STDP4328. DisplayPort 1.2a concentrator. Features. Applications

AN886 APPLICATION NOTE

STP10NK80ZFP STP10NK80Z - STW10NK80Z

TDA2004R W stereo amplifier for car radio. Features. Description

Transcription:

Application note STM32F10xxx in-application programming using the USART Introduction An important requirement for most Flash-memory-based systems is the ability to update firmware when installed in the end product. This ability is referred to as in-application programming (IAP). The purpose of this application note is to provide general guidelines for creating an IAP application. The STM3210B-EVAL/STM3210E-EVAL board was used to validate the IAP driver. The STM32F10xxx microcontroller can run user-specific firmware to perform IAP of the microcontroller-embedded Flash memory. This feature allows the use of any type of communication protocol for the reprogramming process (such as CAN, USART, USB). USART is the example used in this application note. June 2008 Rev 4 1/13 www.st.com

Contents AN2557 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 Executing the IAP driver....................................... 5 3 IAP driver menu............................................. 6 3.1 Download image to the internal Flash memory..................... 6 3.2 Execute the new program...................................... 6 3.3 Disabling the write protection................................... 7 4 STM32F10xxx IAP implementation summary..................... 8 5 User program conditions..................................... 9 6 IAP restrictions............................................. 9 7 How to use the IAP driver.................................... 10 8 Revision history........................................... 12 2/13

IAP overview 1 IAP overview Medium-density devices are STM32F101xx and STM32F103xx microcontrollers where the Flash memory density ranges between 32 and 128 Kbytes. Medium-density devices are implemented in the STMicroelectronics STM3210B-EVAL evaluation board. High-density devices are STM32F101xx and STM32F103xx microcontrollers where the Flash memory density ranges between 256 and 512 Kbytes. High-density devices are implemented in the STMicroelectronics STM3210E-EVAL evaluation board. 1.1 Principle The IAP driver must be programmed from the Flash memory base address via the JTAG or SWD interface using the development toolchain chosen by the user. This driver uses the USART to load a binary file from the HyperTerminal to the STM32F10xxx s internal Flash memory, and then executes it. 1.2 IAP driver description The IAP driver contains the following set of source files: main.c: where the USART initialization and RCC configuration are set. A main menu is then executed from the common.c file. common.c: contains display functions and the main menu routine. The main menu gives the options of loading a new binary file, executing the binary file already loaded and disabling the write protection of the pages where the user loads his binary file (if they are write-protected). ymodem.c and download.c: they are used to receive the data from the HyperTerminal application (using the YMODEM protocol (a), and then to load them into the STM32F10xxx s internal RAM. In the event of a failure when receiving the data, the Failed to receive the file error message is displayed. If the data is received successfully, it is programmed into the internal Flash memory from the appropriate address. A comparison between internal RAM contents and internal Flash memory contents is performed to check the data integrity. If there is any data discrepancy, the Verification failed error message is displayed. Other error messages are also displayed when the image file size is greater than the allowed memory space and when the user aborts the task. STM32F10xxx firmware library To specify the device (High-density or Medium-density) on which the software is to be run, uncomment the relative definition line in the platform_config.h header file: //#define USE_STM3210B_EVAL //#define USE_STM3210E_EVAL a. The Ymodem protocol sends data in 1024-byte blocks. An error check is performed in data blocks transmitted to the STM32F10xxx s internal RAM to compare the transmitted and received data. Blocks unsuccessfully received are acknowledged with an NAK (Negative Acknowledgement). For more details about the Ymodem protocol, refer to existing documentation. 3/13

IAP overview AN2557 The user can choose to either go to the user application or execute the IAP for reprogramming purposes by pressing a push-button connected to a pin. Not pressing the push-button at reset switches to the user application Pressing the push-button at reset displays the IAP main menu Refer to Table 1.: STM32F10xxx IAP implementation for more details about the STM3210B- EVAL/STM3210E-EVAL board push-button used to enter the IAP mode. The IAP flowchart is represented in Figure 1. Figure 1. Flowchart of the IAP driver Start Push-button is pressed? No Yes Initialize the STM32F10xxx USART Display the IAP main menu Download Receive a binary file Download or switch or disable writeprotection? Switch to user program No Success Disable the writeprotection Yes Program the Flash System reset generation Switch to user program No All data programmed successfully? Yes User application software Display the name and size of received file Display the error message "Verification failed" Display the error message "Failed to receive the file" ai14402b 4/13

Running the IAP driver 2 Running the IAP driver The IAP driver is programmed in Flash memory: from page 0 to page 7 on Medium-density devices from page 0 to page 3 on High-density devices The user application occupies the remaining memory space. 2.1 HyperTerminal configuration To use the IAP, the user must have a PC running HyperTerminal and configured as shown in Figure 2. Figure 2. COM port properties Note: The baud rate value of 115200 bps is used as an example. Care must be taken when selecting the system clock frequency. To guarantee successful communication via the USART, the system clock frequency in the end application must be such that a baud rate equal to 115200 bps can be generated. 2.2 Executing the IAP driver As an example in this application note, pressing the pin connected to the push-button allows the IAP driver to run. By pressing the push-button at reset, the user can run the IAP driver to reprogram the STM32F10xxx s internal Flash memory. It is not mandatory to use the push-button; the user can apply a signal to this pin with respect to its active level. Refer to Table 1: STM32F10xxx IAP implementation on page 8. 5/13

IAP driver menu AN2557 3 IAP driver menu Running the IAP displays the following menu in the HyperTerminal window. Figure 3. IAP Driver menu when the STM32F10xxx Flash memory is not protected 3.1 Download image to the internal Flash memory To download a binary file via HyperTerminal to the STM32F10xxx s internal Flash memory, do as follows: 1. Press 1 on the keyboard to select the Download Image To the STM32F10x Internal Flash menu 2. Select Send File in the Transfer menu 3. In the Filename field, type the name and the path of the binary file you want to download 4. From the protocol list, select the Ymodem protocol 5. Click on the Send button As a result, the IAP driver loads the binary file into the STM32F10xxx s internal Flash memory from the defined base address and displays the binary file name and size in the HyperTerminal window. 3.2 Execute the new program Once the new program has been loaded, press 2 on the keyboard to select the Execute The New Program menu and execute the code. 6/13

IAP driver menu 3.3 Disabling the write protection When the IAP starts, it checks the Flash memory pages where the user program is to be loaded to see if any are write-protected. If it is the case, the menu shown in Figure 4 appears. Figure 4. IAP driver menu when the STM32F10xxx Flash memory is write-protected Note: Prior to downloading the new program, the write protection must be disabled. To do so, press 3 (Disable the write protection) on the keyboard. The write protection is disabled and a system reset is generated to reload the new option byte values. After resuming from reset, the menu shown in Figure 3 is displayed. In this application, the read protection is not supported, so the user has to verify that the Flash memory is not read-protected. 7/13

STM32F10xxx IAP implementation summary AN2557 4 STM32F10xxx IAP implementation summary Note: Table 1 provides a summary of the STM32F10xxx IAP implementation. The information is identical for Medium-density (STM3210B-EVAL) and High-density devices (STM3210E-EVAL) unless otherwise specified. Table 1. STM32F10xxx IAP implementation STM32F10xxx IAP application Location Number of Flash memory pages used STM3210B-EVAL board 0x8000000 8 (page size: 1 KByte) STM3210E-EVAL board 4 (page size: 2 KByte) User application location 0x8002000 (1) Push-button Assigned pin STM3210E-EVAL board PG.08 (KEY push-button) STM3210B-EVAL board PB.09 (KEY push-button) Flash routines USART used Active level 1. User application location address is defined in the common.h file as: #define ApplicationAddress 0x8002000.To modify it, change the default value to the desired one. Low For STM32F10xxx devices, Flash routines (program/erase) are executed from the Flash memory USART1 8/13

User program conditions 5 User program conditions On STM32F10xxx microcontrollers, the user must program the IAP application from the Flash memory base address (0x0800 0000), and the user application from address 0x8002000. As shown in Figure 5, the user application vector table must be located at address 0x8002000. An example application program to be loaded with the IAP application is provided with preconfigured projects. Refer to Section 7: How to use the IAP driver for more details. Figure 5. Flash memory usage Top Flash memory address (1) Flash memory User code 0x800 2000 0x800 1FFF Vector table IAP code 0x800 0000 Vector table AI14403b 1. Top Flash memory address is equal to 0x0801 FFFF for Medium-density devices, and to 0x0807 FFFF for High-density devices. 6 IAP restrictions The STM32F10xxx IAP driver code is downloaded: from page 0 to page 7 for Medium-density devices from page 0 to page 3 for High-density devices Therefore, the maximum size of the image to be loaded is: 120 Kbytes (page 8 - page 127) for Medium-density devices. 504 Kbytes (page 4 - page 255) for High-density devices. 9/13

How to use the IAP driver AN2557 7 How to use the IAP driver The IAP package is supplied in a single zip file. The extraction of the zip file generates a folder that contains the subfolders shown in Figure 6. FWLib folder The FWlib folder contains all the subdirectories and files that make up the core of the STM32F10xxx firmware library: inc subfolder contains the firmware library header files src subfolder contains the firmware library source files IAP_AN folder The IAP_AN folder contains all the subdirectories and files that make up the core of the IAP: binary subfolder contains a set of sources files and preconfigured projects, that describe how to build an application to be loaded into Flash memory using IAP. A readme.txt file is provided, describes how to use the directory contents. include subfolder contains the IAP firmware header files source subfolder contains the IAP firmware source files project subfolder contains three projects that compile all the IAP files: EWARMv5: contains the project for the EWARM version 5 toolchain HiTOP: contains the project for the HiTOP toolchain RIDE: contains the project for the RIDE toolchain RVMDK: contains the project for the RVMDK toolchain 10/13

How to use the IAP driver Figure 6. IAP driver directory structure To efficiently use the IAP drive: 1. Download the IAP driver into the STM32F10xxx s internal Flash memory via the JTAG or SWD interface using the desired development toolchain. 2. Open a HyperTerminal window using the settings already defined in Section 2.1. 3. To run the IAP driver, keep the push-button (Key push-button on STM3210B- EVAL/STM3210E-EVAL board) pressed at Reset. The IAP main menu is then displayed on the HyperTerminal window. 4. To download an application, press 1 and use the Ymodem protocol as described in Figure 3: IAP Driver menu when the STM32F10xxx Flash memory is not protected. 11/13

Revision history AN2557 8 Revision history Table 2. Revision history Date Revision Changes 05-Jun-2007 1 Initial release. 05-Oct-2007 2 30-May-2008 3 The IAP driver can also be programmed from the SWD interface (see Section 1.1: Principle). Modified: Figure 3: IAP Driver menu when the STM32F10xxx Flash memory is not protected Figure 4: IAP driver menu when the STM32F10xxx Flash memory is write-protected Figure 6: IAP driver directory structure. Flash routines modified in Table 1: STM32F10xxx IAP implementation. Section 5: User program conditions updated. Section 7: How to use the IAP driver modified, RIDE project added. Application note updated to apply to High-density devices (implemented on the STM3210E-EVAL evaluation board). Small text changes. Figure 1: Flowchart of the IAP driver on page 4 corrected. 13-Jun-2008 4 Figure 6: IAP driver directory structure modified. 12/13

Please Read Carefully: Information in this document is provided solely in connection with ST products. STMicroelectronics NV and its subsidiaries ( ST ) reserve the right to make changes, corrections, modifications or improvements, to this document, and the products and services described herein at any time, without notice. All ST products are sold pursuant to ST s terms and conditions of sale. Purchasers are solely responsible for the choice, selection and use of the ST products and services described herein, and ST assumes no liability whatsoever relating to the choice, selection or use of the ST products and services described herein. No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. If any part of this document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such third party products or services or any intellectual property contained therein. UNLESS OTHERWISE SET FORTH IN ST S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY WITH RESPECT TO THE USE AND/OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE (AND THEIR EQUIVALENTS UNDER THE LAWS OF ANY JURISDICTION), OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT. UNLESS EXPRESSLY APPROVED IN WRITING BY AN AUTHORIZED ST REPRESENTATIVE, ST PRODUCTS ARE NOT RECOMMENDED, AUTHORIZED OR WARRANTED FOR USE IN MILITARY, AIR CRAFT, SPACE, LIFE SAVING, OR LIFE SUSTAINING APPLICATIONS, NOR IN PRODUCTS OR SYSTEMS WHERE FAILURE OR MALFUNCTION MAY RESULT IN PERSONAL INJURY, DEATH, OR SEVERE PROPERTY OR ENVIRONMENTAL DAMAGE. ST PRODUCTS WHICH ARE NOT SPECIFIED AS "AUTOMOTIVE GRADE" MAY ONLY BE USED IN AUTOMOTIVE APPLICATIONS AT USER S OWN RISK. Resale of ST products with provisions different from the statements and/or technical features set forth in this document shall immediately void any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever, any liability of ST. ST and the ST logo are trademarks or registered trademarks of ST in various countries. Information in this document supersedes and replaces all information previously supplied. The ST logo is a registered trademark of STMicroelectronics. All other names are the property of their respective owners. 2008 STMicroelectronics - All rights reserved STMicroelectronics group of companies Australia - Belgium - Brazil - Canada - China - Czech Republic - Finland - France - Germany - Hong Kong - India - Israel - Italy - Japan - Malaysia - Malta - Morocco - Singapore - Spain - Sweden - Switzerland - United Kingdom - United States of America www.st.com 13/13