AN4045 Application note

Similar documents
AN3965 Application note

AN2557 Application note

AN3354 Application note

STSW-STWBCFWDT. STWBC firmware downloader tool. Description. Features

AN5123 Application note

RN0084 Release note. ST-LINK/V2 firmware upgrade. About this release note

STSW-BLUENRG1-DK. BlueNRG-1, BlueNRG-2 DK SW package

AN4491 Application note

AN4872 Application note

AN4515 Application note

P-NUCLEO-USB001. STM32 Nucleo pack for USB Type-C and Power Delivery. Features. Description

NUCLEO-L496ZG. STM32 Nucleo-144 board. Features. Description

P-NUCLEO-USB001. STM32 Nucleo pack for USB Type-C and Power Delivery Data brief. Features. Description

NUCLEO-L433RC-P NUCLEO-L452RE-P

ST25DV-DISCOVERY. Discovery kit for the ST25DV04K dynamic NFC/RFID tag. Features

STSW-BNRGUI. BlueNRG GUI SW package. Data brief. Features. Description

AN2143 Application note

USB Type-C and Power Delivery Nucleo pack with NUCLEO-F072RB expansion board based on STUSB1602. Description

AN3281 Application note

AN4113 Application note

Using the GPIOs and interrupt controller to drive LEDs on STM8 Nucleo-64 boards

AN2792 Application note

UM2092 User manual. Basic metrology firmware for the STM32F103RD and the STPM32 devices. Introduction

L9958 Evaluation board for high current (8.6A) DC and Stepper Motors. Description

Dynamic Electro-Thermal simulator for VIPower products. Description

UM2343 Application note

AN5179. RS232 communications with a terminal using the STM8 Nucleo-64 boards. Application note. Introduction

UM2167 User manual. OrCAD PSpice model usage instructions

Bluetooth low energy profiles for the X-CUBE-BLE1 expansion for STM32Cube. Description

Getting started with MotionPM real-time pedometer library in X CUBE-MEMS1 expansion for STM32Cube

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

A scalable approach to your body, networking and security platforms. Description

TN1235 Technical note

P-NUCLEO-IKA02A1. STM32 Nucleo pack: electrochemical toxic gas sensor expansion board with CO sensor. Description. Features

UM2350. Getting started with MotionPW real-time pedometer for wrist library in X-CUBE-MEMS1 expansion for STM32Cube. User manual.

AN2667 Application note

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

USB Type-C and Power Delivery Nucleo pack with NUCLEO-F072RB expansion board based on the STUSB1602

UM2276. Getting started with MotionSD standing vs sitting desk detection library in X-CUBE-MEMS1 expansion for STM32Cube. User manual.

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

UM1844 User manual. EVAL-L9958 Graphical user interface (GUI) Introduction

X-NUCLEO-53L0A1. Ranging and gesture detection sensor expansion board based on VL53L0X for STM32 Nucleo. Description. Features

32F412GDISCOVERY. Discovery kit with STM32F412ZG MCU. Features. Description

TN1234 Technical note

UM2330 User manual. ST8500 boot. Introduction

AN4624 Application note

Description. January 2019 DB2381 Rev 3 1/5

Getting started with STEVAL-IDB007V1 and STEVAL-IDB008V1 evaluation boards

DT0095 Design tip. Datalogging the SensorTile through a PC. Purpose and benefits. Description

STM32L4R9I-EVAL. Evaluation board with STM32L4R9AI MCU. Features

Getting started with MotionPM real-time pedometer library in X-CUBE-MEMS1 expansion for STM32Cube

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

Getting started with the STM32 Nucleo pack for USB Type-C and Power Delivery with the Nucleo-F072RB board and the STUSB1602

STSW-BNRG-Mesh. Mesh over Bluetooth low energy. Features. Description. Applications

Motor control power board based on the SLLIMM-nano 2 nd series

EVALKITSTKNX. Miniature transceiver STKNX evaluation and development kit. Features

UM2194. Getting started with MotionAW activity recognition for wrist library in X-CUBE-MEMS1 expansion for STM32Cube. User manual.

AN4696 Application note

How to upgrade the firmware on the STEVAL-USBC2DP USB Type-C to DisplayPort adapter

AN4782 Application note

STM32H7x3I-EVAL. Evaluation board with STM32H7x3XI MCUs. Data brief. Features

AN4311 Application note

UM2495. High performance HF reader / NFC initiator IC software expansion for NUCLEO-8S208RB. User manual. Introduction

UM2216 User manual. Getting started with MotionFA fitness activity library in X CUBE MEMS1 expansion for STM32Cube. Introduction

AN5224. STM32 DMAMUX: the DMA request router. Application note. Introduction

X-NUCLEO-53L1A1. Long distance ranging Time-of-Flight sensor expansion board based on VL53L1X for STM32 Nucleo. Description.

UM2361. Getting started with the ST BlueNRG-Mesh ios application. User manual. Introduction

Getting started with the X-CUBE-IKA02A1 multifunctional software expansion for STM32Cube

AN3154 Application note

Getting started with X-CUBE-LED channel LED driver software expansion based on LED1642GW for STM32Cube

ST Payment Secure Solution Java Card platform with up to 100 Kbytes of user NVM for AMEX payment applications

Description. July 2016 DocID Rev 2 1/6

AN2261 APPLICATION NOTE

AN3155 Application note

300 ma triple DC-DC converter for powering AMOLED displays. Description. Table 1: Device summary Negative voltage. Auxiliary positive voltage

Getting started with the digital MEMS microphone expansion board based on MP34DT01-M for STM32 Nucleo

Table 1: Device summary Part numbers Device info (stored in register 0xF0 and 0xF1) Comment SPIRIT1QTR 0x0130 Cut 3.0

32F469IDISCOVERY. Discovery kit with STM32F469NI MCU. Features. Description

STEVAL-IPMnM2N. Motor control power board based on the SLLIMM-nano 2 nd series. Description. Features. RoHS compliant

32L476GDISCOVERY. Discovery kit with STM32L476VG MCU. Features. Description

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

SPC58EHx,SPC58NHx. A scalable approach for high-end body, networking and security platforms for Automotive. Description. Features

AN2430 Application note

UM2255 User manual. SPC58NG-DISP user manual. Introduction

AN2606 Application note

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

32F746GDISCOVERY. Discovery kit with STM32F746NG MCU. Features. Description

UM2045 User manual. Getting started with the X-CUBE-NFC3 near field communication transceiver software expansion for STM32Cube.

Getting started with osxmotiongc gyroscope calibration library for X-CUBE-MEMS1 expansion for STM32Cube

STSW-L9960, STSW-L9960T Graphical User Interface (GUI) for EVAL-L9960 & EVAL-L9960T

AN4749 Application note

External memory code execution on STM32F7x0 Value line and STM32H750 Value line MCUs

UM1641 User manual. Sampling rate conversion SRC236 library software expansion for STM32Cube. Introduction

P-NUCLEO-53L1A1. VL53L1X nucleo pack with X-NUCLEO-53L1A1 expansion board and STM32F401RE nucleo board. Description. Features

AN3279 Application Note

How to configure the BlueNRG-1 and BlueNRG-2 devices in network coprocessor mode. Main components Bluetooth Low Energy wireless system-on-chip

Description of STM8 LIN software package (STSW-STM8A-LIN) release 4.1. Table 1. Release information. STM8 LIN package

ST Payment Secure Solution - Java Card platform with up to 90 Kbytes of user NVM for Visa, MasterCard, AMEX, Discover and Interac applications

Getting started with MotionAR activity recognition library in X-CUBE-MEMS1 expansion for STM32Cube

UM1853 User manual. STM32CubeF1 Nucleo demonstration firmware. Introduction

Transcription:

Application note STM32F3 series in-application programming (IAP) using the USART Introduction An important requirement for most Flash-memory-based systems is the ability to update the 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 microcontrollers of the STM32F3 series can run user-specific firmware to perform the IAP of the microcontroller-embedded Flash memory. This feature allows the use of any type of communication protocol for the reprogramming process. The USART is the example used in this application note. This application note also presents two methods to calculate CRC (software and hardware). This possibility is new in the microcontrollers of the STM32F3 series. Table 1 presents the list of products to which this application note applies. Table 1. Applicable product and software Type Applicable product Software Microcontrollers STSW-STM32111 STM32F3 series January 2015 DocID022782 Rev 2 1/16 www.st.com 1

Contents AN4045 Contents 1 IAP overview............................................... 5 1.1 Principle................................................... 5 1.2 IAP driver description......................................... 5 2 Running the IAP driver....................................... 8 2.1 HyperTerminal configuration.................................... 8 2.2 Executing the IAP driver....................................... 8 3 IAP driver menu............................................. 9 3.1 Downloading an image to the internal Flash memory............... 10 3.2 Uploading an image from the internal Flash memory.................11 3.3 Executing the new program....................................11 3.4 Disabling the write protection...................................11 4 STM32F3xx IAP implementation summary...................... 13 5 User program conditions.................................... 14 6 Revision history........................................... 15 2/16 DocID022782 Rev 2

List of tables List of tables Table 1. Applicable product and software.............................................. 1 Table 2. STM32F3xx IAP implementation............................................ 13 Table 3. Revision history......................................................... 15 DocID022782 Rev 2 3/16 3

List of figures AN4045 List of figures Figure 1. Flowchart of the IAP driver.................................................. 7 Figure 2. COM port properties....................................................... 8 Figure 3. IAP driver menu when the STM32F3xx Flash memory is not protected................ 9 Figure 4. IAP driver menu when the STM32F3xx Flash memory is write-protected............. 11 Figure 5. Flash memory usage..................................................... 14 4/16 DocID022782 Rev 2

IAP overview 1 IAP overview The devices of the STM32F3 series, also named STM32F3xx in this document, are implemented in the STMicroelectronics evaluation boards. 1.1 Principle Users have to program the IAP driver to the Flash memory base address via the JTAG/SWD interface using the chosen development toolchain or the factory-embedded boot loader in the System memory area. The IAP driver uses the USART to: Download a binary file from the HyperTerminal to the STM32F3xx internal Flash memory. Upload the STM32F3xx internal Flash memory content (starting from the defined user application address) into a binary file. Execute the user program. 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 menu.c file. menu.c: contains the main menu routine. The main menu gives the options of downloading a new binary file, uploading internal Flash memory, 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). flash_if.c contains write, erase and disable write protection of the internal Flash memory. common.c: contains functions related to read/write from/to USART peripheral ymodem.c: It is used to receive/send the data from/to the HyperTerminal application using the YMODEM protocol (a). In case of data reception failure, 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. STM32F3xx Standard Peripherals Library. a. The Ymodem protocol sends data in 1024-byte blocks. An error check is performed in data blocks transmitted to the STM32F3xx internal RAM to compare the transmitted and received data. Blocks unsuccessfully received are acknowledged with an NAK (Negative Acknowledgment). For more details about the Ymodem protocol, refer to existing documentation. DocID022782 Rev 2 5/16 15

IAP overview AN4045 Users can choose to either go to the user application or to 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 2.: STM32F3xx IAP implementation for more details. The IAP flowchart is shown in Figure 1. 6/16 DocID022782 Rev 2

IAP overview Figure 1. Flowchart of the IAP driver DocID022782 Rev 2 7/16 15

Running the IAP driver AN4045 2 Running the IAP driver 2.1 HyperTerminal configuration To use the IAP, users must have a PC running HyperTerminal or other Terminal program that supports Ymodem protocol. In this document the HyperTerminal is used. The following figure shows the HyperTerminal configuration. 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 STM32F3xx 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 2: STM32F3xx IAP implementation. 8/16 DocID022782 Rev 2

IAP driver menu 3 IAP driver menu When running the provided IAP firmware on the HyperTerminal menu, the four application possibilities are displayed: Download image into the internal flash memory. Upload image from the internal flash memory. Execute the new program. Disable the write protection (in case flash memory pages are write protected). Figure 3. IAP driver menu when the STM32F3xx Flash memory is not protected DocID022782 Rev 2 9/16 15

IAP driver menu AN4045 3.1 Downloading an image to the internal Flash memory To download a binary file via HyperTerminal to the STM32F3xx internal Flash memory, proceed as follows: 1. Press 1 on the keyboard to select the Download Image To the STM32F3xx 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 STM32F3xx internal Flash memory from the defined base address and displays the binary file name and size in the HyperTerminal window. 10/16 DocID022782 Rev 2

IAP driver menu 3.2 Uploading an image from the internal Flash memory To upload a copy of the internal Flash memory started from the user application address, proceed as follows: 1. Press 2 on the keyboard to select Upload image from the STM32F3xx internal Flash menu. 2. Select Receive File in the Transfer menu. 3. Select the directory in which the binary file will be saved. 4. From the protocol list, select the Ymodem protocol. 5. Click on the Receive button. 3.3 Executing the new program Once the new program has been loaded, press 3 on the keyboard to select the Execute The New Program menu and execute the code. 3.4 Disabling the write protection When the IAP starts, a write protection check is performed on the Flash memory pages where the user program is to be loaded. In case of write protection, the menu option allowing to disable the protection is displayed on the HyperTerminal window, as shown in Figure 4. Figure 4. IAP driver menu when the STM32F3xx Flash memory is write-protected DocID022782 Rev 2 11/16 15

IAP driver menu AN4045 Note: Prior to downloading the new program, the write protection must be disabled. To do so, press 4 (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 if the key push-button is pressed. In this application, the read protection is not supported, so the user has to verify that the Flash memory is not read-protected. 12/16 DocID022782 Rev 2

STM32F3xx IAP implementation summary 4 STM32F3xx IAP implementation summary Table 2 provides a summary of the STM32F3xx IAP implementation. Table 2. STM32F3xx IAP implementation Firmware Hardware The IAP program is located at 0x8000000. The Flash routines (program/erase) are executed from the Flash memory. The size of this program is about 2Kbytes and programmed on: The user application (image to be downloaded with the IAP) will be programmed starting from address 0x8003000 (1) The maximum size of the image to be loaded is: The image is uploaded with the IAP from the STM32F3xx internal Flash. The size of the image to be uploaded is: Push-button (active level: high) USART used page 0 244 Kbytes (2) (page 1- page122) 244 Kbyte (2) (page 1- page122) Key push-button connected to pin PA2 USART2 1. User application location address is defined in the flash_if.h file as: #define APPLICATION_ADDRESS 0x8003000.To modify it, change the default value to the desired one. 2. 500 Kbyte for STM32F303xDxE microcontrollers that provide up to 512 Kbytes of Flash memory. The STM32F3xx IAP package comes with: Source files and pre-configured projects for the IAP program (under Project\STM32F3xx_IAP directory) Source files and pre-configured projects that build the application to be loaded into Flash memory using the IAP (under Project\STM32F3xx_IAP\binary_template directory). The readme.txt files provided within this package describes step by step how to execute this IAP application. DocID022782 Rev 2 13/16 15

User program conditions AN4045 5 User program conditions 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 at 0x08003000, using your toolchain linker file 2. Relocate the vector table at address 0x08003000, using the NVIC_SetVectorTable function from the stm32f3xx_misc.h/.c driver. An example application program to be loaded with the IAP application is provided with preconfigured projects. Figure 5. Flash memory usage 1. The Top flash memory default address is defined in the flash_if.h file as: #define USER_FLASH_END_ADDRESS 0x0803FFFF.To modify the address, change the default value to the desired one, for example 0x0807FFFF for STM32F303xDxE microcontrollers. 14/16 DocID022782 Rev 2

Revision history 6 Revision history Table 3. Revision history Date Revision Changes 04-Jan-2012 1 Initial release. 28-Jan-2015 2 Extended the applicability to STM32F303xDxE. Updated: Table 2: STM32F3xx IAP implementation The footnote to Figure 5: Flash memory usage DocID022782 Rev 2 15/16 15

IMPORTANT NOTICE PLEASE READ CAREFULLY STMicroelectronics NV and its subsidiaries ( ST ) reserve the right to make changes, corrections, enhancements, modifications, and improvements to ST products and/or to this document at any time without notice. Purchasers should obtain the latest relevant information on ST products before placing orders. ST products are sold pursuant to ST s terms and conditions of sale in place at the time of order acknowledgement. Purchasers are solely responsible for the choice, selection, and use of ST products and ST assumes no liability for application assistance or the design of Purchasers products. No license, express or implied, to any intellectual property right is granted by ST herein. Resale of ST products with provisions different from the information set forth herein shall void any warranty granted by ST for such product. ST and the ST logo are trademarks of ST. All other product or service names are the property of their respective owners. Information in this document supersedes and replaces information previously supplied in any prior versions of this document. 2015 STMicroelectronics All rights reserved 16/16 DocID022782 Rev 2