October 2011 Doc ID 022104 Rev 1 1/13
AN3965
Application note
STM32F40x/STM32F41x in-application programming
using the USART
1 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 STM32F4xx 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. The USART is the example used in
this application note.
www.st.com
Contents AN3965
2/13 Doc ID 022104 Rev 1
Contents
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
2 IAP overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.1 Principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 IAP driver description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
3 Running the IAP driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1 HyperTerminal configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.2 Executing the IAP driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
4 IAP driver menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
4.1 Download image to the internal Flash memory . . . . . . . . . . . . . . . . . . . . . 7
4.2 Upload image from the internal Flash memory . . . . . . . . . . . . . . . . . . . . . 8
4.3 Execute the new program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4.4 Disabling the write protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
5 STM32F4xx IAP implementation summary . . . . . . . . . . . . . . . . . . . . . . 10
6 User program conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
7 Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12