AN3354 Application note

Similar documents
AN3965 Application note

STEVAL-PCC010V1. ST802RT1A Ethernet PHY demonstration board with STM32F107 controller add-on board. Features. Description

AN2667 Application note

STEVAL-CCM002V1. TFT-LCD panel demonstration board based on the STM32 as LCD controller. Features. Description

AN4113 Application note

AN2557 Application note

STEVAL-SPBT4ATV3. USB dongle for the Bluetooth class 1 SPBT2632C1A.AT2 module. Features. Description

STM3210B-SK/KEIL STR91X-SK/KEI, STR7-SK/KEIL

AN2676 Application note

STM32-SK/KEIL STR91X-SK/KEI, STR7-SK/KEIL

AN3996 Application Note

AN2672 Application note

STM3220G-SK/KEI. Keil starter kit for STM32F2 series microcontrollers (STM32F207IG MCU) Features. Description

AN2143 Application note

AN3279 Application Note

UM0693 User manual. 1 Introduction. STM8L101-EVAL demonstration firmware

STM32-MP3NL/DEC. STM32 audio engine MP3 decoder library. Description. Features

UM1572 User manual. STEVAL-IPE020V1: ST energy meter application based on the Android platform. Introduction

AN3980 Application note

STM32-SK/RAIS,STR91X-SK/RAI,STR7-SK/RAIS STM32-D/RAIS,STR9-D/RAIS,STR7-D/RAIS

AN626 Application note

AN3154 Application note

UM0792 User manual. Demonstration firmware for the DMX-512 communication protocol transmitter based on the STM32F103Zx.

OSPlus USB Extension. OSPlus USB 2.0 extension. Description. Features. Application. TCP/IP stack NexGenOS NexGenIP VFS. FAT Ext2 LVM Device layer

AN2470 Application note TS4871 low voltage audio power amplifier Evaluation board user guidelines Features Description

EV-VNQ5E050AK VNQ5E050AK evaluation board

AN2855 Application note

ST19WR08 Dual Contactless Smartcard MCU With RF UART, IART & 8 Kbytes EEPROM Features Contactless specific features

AN2737 Application note Basic in-application programming example using the STM8 I 2 C and SPI peripherals Introduction

STTS V memory module temperature sensor. Features

RN0046 Release note. 1 Introduction. SimpleMAC library for STM32W108xx kits. About this release note

AN2361 Application note

STM8 I 2 C optimized examples

ST33F1M. Smartcard MCU with 32-bit ARM SecurCore SC300 CPU and 1.25 Mbytes high-density Flash memory. Features. Hardware features.

AN2673 Application note

UM0401 User manual. User manual for eight bit port expander STMPE801 demonstration board. Introduction

AN2825 Application Note

STM8L-PRIMER STM32-PRIMER STMPRIMER

STM32 embedded target for MATLAB and Simulink release 3.1. Summary for STM32 embedded target for MATLAB and Simulink release 3.1:

AN2594 Application note

STICE CF/Stice_Connect AD/Stice_Connect AS/Stice_Connect

EVAL6235PD. L6235 three-phase brushless DC motor driver demonstration board. Features. Description

Description SPC564A-DISP. March 2014 DocID Rev 3 1/5

AN2734 Application note S-Touch design procedure Introduction

AN2261 APPLICATION NOTE

STEVAL-IHM028V1. 2 kw 3-phase motor control demonstration board featuring the IGBT intelligent power module STGIPS20K60. Features.

SOT23-6L ESDALCL6-2SC6

AN2240 Application note

UM1488 User manual. STPMC1 evaluation software. Introduction

Getting started with DfuSe USB device firmware upgrade STMicroelectronics extension

TN0189 Technical note

AN2474 Application note

STM8L-PRIMER STM32-PRIMER STMPRIMER

AN4321 Application note

UM1084 User manual. CR95HF development software user guide. Introduction. Reference documents

AN2792 Application note

STM8-SK/RAIS STM8-D/RAIS ST7-SK/RAIS ST7-D/RAIS

TN0132 Technical note

STA bit single chip baseband controller for GPS and telematic applications. Features

AN3250 Application note

STMicroelectronics. STxP70-4 assembler. User manual Rev A. October

AN2430 Application note

Main components USB charging controller with integrated power switch

AN3265 Application note

AN2592 Application note

Obsolete Product(s) - Obsolete Product(s)


AN3155 Application note

ST21NFCB. Near field communication controller. Features. RF communications. Hardware features. Communication interfaces. Electrical characteristics

ST33F1M, ST33F1M0, ST33F896, ST33F768, ST33F640, ST33F512

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

AN2202 Application note

AN3362 Application note

AN3226 Application note

STLC2500D. Bluetooth V2.1 "Lisbon" + EDR. Features. Description

EMIF01-SMIC01F2 IPAD. Single line EMI filter including ESD protection. Main application. Description. Benefits. Pin configuration (Bump side view)

Main components 1 A, high efficiency adjustable single inductor dual mode buckboost DC-DC converter

AN4464 Application note

EMIF02-SPK02F2. 2-line IPAD, EMI filter and ESD protection. Features. Application. Description. Complies with the following standards

AN4274 Application note

AN2408 Application note

SMP75. Trisil for telecom equipment protection. Features. Description. Applications. Benefits

AN3988 Application note

EMIF02-MIC01F2 2-line IPAD, EMI filter including ESD protection Features Application Description Complies with the standards:

The following table provides a general information of the considered toolchains. Toolchain Company Version Release date Hardware emulator

AN2781 Application note

AN3376 Application note

LD A very low drop adjustable positive voltage regulator. Description. Features

AN3174 Application note

STM8-SK/RAIS STM8-D/RAIS ST7-SK/RAIS ST7-D/RAIS

AN3001 Application note

AN3975 Application note

UM1677 User manual. Getting started with STM32F030 Value Line Discovery development tools. Introduction

AN4152 Application note

STM3240G-EVAL/STM3241G-EVAL demonstration firmware

ST10F271B/E, ST10F272B/E Errata sheet

AN4440 Application note

AN3099 Application note

AN2606 Application note

AN3140 Application note

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. 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. Note: 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