AN3354 Application note



Similar documents
AN3990 Application note

AN2557 Application note

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

AN4108 Application note

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

AN3332 Application note

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

DDSL01. Secondary protection for DSL lines. Features. Description

AN3265 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

TN0023 Technical note

AN3998 Application note

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

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

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

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

AN4156 Application note

Getting started with DfuSe USB device firmware upgrade STMicroelectronics extension

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

AN2824 Application note

ULN2801A, ULN2802A, ULN2803A, ULN2804A

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

AN2604 Application note

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

AN2389 Application note

M24LRxx/CR95HF application software installation guide

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

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

AN4128 Application note

AN3155 Application note

BD135 - BD136 BD139 - BD140

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

AN3353 Application note

AN3110 Application note

AN2680 Application note

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

ULN2001, ULN2002 ULN2003, ULN2004

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

AN3270 Application note

Order code Temperature range Package Packaging

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

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

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

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

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

AN3359 Application note

L78MxxAB L78MxxAC. Precision 500 ma regulators. Features. Description

AN3252 Application note

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

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

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

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

STTH2R06. High efficiency ultrafast diode. Features. Description

MC Low noise quad operational amplifier. Features. Description

Description. Table 1. Device summary

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

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

AN2866 Application note

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

AN3997 Application note

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

AN2146 APPLICATION NOTE

L6234. Three phase motor driver. Features. Description

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

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

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

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

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

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

AN2703 Application note

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

TN0072 Technical note

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

AN3969 Application note

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

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

AN3211 Application note

AN2760 Application note

AN2328 Application note

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

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

AN1754 APPLICATION NOTE

TDA W CAR RADIO AUDIO AMPLIFIER

STGB10NB37LZ STGP10NB37LZ

Figure 1. STM32F429 Discovery board: STM32F429I-DISCO

AN886 APPLICATION NOTE

STP55NF06L STB55NF06L - STB55NF06L-1

AN4368 Application note

TDA2004R W stereo amplifier for car radio. Features. Description

STP10NK80ZFP STP10NK80Z - STW10NK80Z

STTH110. High voltage ultrafast rectifier. Description. Features

Obsolete Product(s) - Obsolete Product(s)

Getting started with software and firmware environments for the STM32F0DISCOVERY kit

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

AN974 APPLICATION NOTE

MC34063AB, MC34063AC, MC34063EB, MC34063EC

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

AN820 APPLICATION NOTE INPUT/OUTPUT PROTECTION FOR AUTOMOTIVE COMPUTER

Transcription:

Application note STM32F105/107 in-application programming using a USB host 1 Introduction An important requirement for most Flash-memory-based systems is the ability to update firmware 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 STM32F105/107 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). USB Host Mass storage is the example used in this application note. This kind of IAP using USB Host is very interesting because it is a standalone IAP in which the user does not need to use a host computer to perform the firmware upgrade. The user only needs a Flash disk to upgrade the target STM32 device. Table 1. Glossary Term CAN IAP ICP JTAG SWD USART USB Controller area network in-application programming In-circuit programming Meaning Joint Test Action Group (JTAG) debugger Serial wire debugging. Universal synchronous/asynchronous receiver/transmitter Universal serial bus March 2011 Doc ID 018530 Rev 1 1/10 www.st.com

IAP overview AN3354 2 IAP overview 2.1 Principle To program the IAP driver to the Flash memory base address, use in-circuit programming (ICP) either with the JTAG/SWD interface using the development toolchain of your choice or the factory-embedded bootloader in the System memory area. Note: The IAP driver uses the USB Host to: Download a binary file (.bin) from a Flash disk (thumb drive) to the STM32F105/107's internal Flash memory. Upload all the STM32F105/107's internal Flash memory content into a binary file. Execute the user program. This application note is based on the STM32F105/107xx USB Host library. For more details about the USB Host stack and a mass storage demonstration, please refer to the STM32F105/107xx USB Host library user manual (UM1021). 2.2 IAP driver description The IAP driver contains the following set of source files: main.c: contains the USB initialization data. The USB Host state machine is then executed if the user wants to enter IAP mode or the program will execute the user code. stm32f10x_it.c: contains the interrupt handlers for the application. command.c: contains the IAP commands (download, upload and jump commands). flash_layer.c: provides a medium layer access to the STM32 embedded Flash driver. usb_bsp.c: implements the board support package for the USB host library. usbh_usr.c: includes the USB host library user callbacks and LCD control data. The user can choose to either go to the user application or execute the IAP for reprogramming purposes by pressing a Key-button connected to a pin: If the Key-button is not pressed at reset, the device switches to the user application. If the Key-button is pressed at reset, the device displays the IAP main menu. Figure 1 illustrates the IAP flowchart. 2/10 Doc ID 018530 Rev 1

IAP overview Figure 1. Flowchart of the IAP driver Doc ID 018530 Rev 1 3/10

IAP driver menu AN3354 3 IAP driver menu After pressing the Key-button at reset, the user can run the IAP driver to reprogram the STM32F device s internal Flash memory. At this stage, the LCD displays the following text. Figure 2. LCD IAP initialization STM32 IAP thru USB Host > DEVICE ATTACHED > DEVICE IS FULL SPEED > ENUMERATION COMPLETED To see IAP menu: Press Key B3... To display the IAP menu, press the Key-button. The LCD displays the following text. Figure 3. LCD IAP menu STM32 IAP thru USB Host Use Joystick to select and Key to validate Upload Download Jump To select an IAP menu option, use the Joystick UP/DOWN button. To validate the selection, press the Key button. Table 2. Option Menu options Description Upload Download Reads the entire embedded Flash memory and saves the contents in an upload.bin file in the thumb drive. Reads the selected.bin image from the thumb drive and writes it to the embedded Flash memory. Jump Executes the user code at address 0x08008000. 4/10 Doc ID 018530 Rev 1

IAP driver menu 3.1 Upload command Figure 4 illustrates how to upload a copy of the internal Flash memory. Figure 4. Upload command flowchart Note: 1 BUFFERSIZE is a user-defined variable in the usbh_usr.h file that can be modified at compilation. BUFFERSIZE = 4 * x; where x = [1,8192] limited by firmware. 2 With BUFFERSIZE = 4 * 8192 = 32 Kbytes, uploading of all Flash memory takes about 2 seconds. 3 When the user selects the Upload command, the old UPLOAD.BIN file will be deleted and replaced by a new one that contains the new Flash memory data. Doc ID 018530 Rev 1 5/10

IAP driver menu AN3354 3.2 Download command To download a binary file from the flash pen drive to the internal STM32F105/107 s embedded flash memory the following flowchart is applied: Figure 5. Download command flowchart 6/10 Doc ID 018530 Rev 1

IAP driver menu Note: 1 BUFFERSIZE is a user-defined variable in the usbh_usr.h file that can be modified at compilation. BUFFERSIZE = 4 * x; where x = [1,8192] limited by firmware. 2 With BUFFERSIZE = 4 * 8192 = 32 Kbytes and image size = 14.6 Kbytes, the download operation takes about 0.5 seconds (erase time included). 3 With BUFFERSIZE = 4 * 8192 = 32 Kbytes and image size = 190 Kbytes, the download operation takes about 7.8 seconds (erase time included). 3.3 Jump command Once the new program has been loaded, user can jump to execute this image which must be defined from this flash address: 0x08008000. Other wise, user must adapt the firmware to jump to an other address. The flowchart of this command is: Figure 6. Jump command flowchart Note: After selecting the Jump command, the Key button should not be pressed. Doc ID 018530 Rev 1 7/10

User program condition AN3354 4 User program condition Note: The user application to be loaded into the Flash memory using IAP should be built with these configuration settings: 1. Set the program load address to 0x0800 8000 in the toolchain linker file. 2. Relocate the vector table to address 0x0800 8000 using the NVIC_SetVectorTable function or the VECT_TAB_OFFSET definition inside the system_stm32f10x.c file. An example application program to be loaded with the IAP application is provided with preconfigured projects. Figure 7. Flash memory usage Note: The user must use high code optimization and verify that the IAP driver size is less than 32 Kbytes. 8/10 Doc ID 018530 Rev 1

Revision history 5 Revision history Table 3. Document revision history Date Revision Changes 31-Mar-2011 1 Initial release. Doc ID 018530 Rev 1 9/10

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. 2011 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 - Philippines - Singapore - Spain - Sweden - Switzerland - United Kingdom - United States of America www.st.com 10/10 Doc ID 018530 Rev 1