AN3968 Application Note: STM32F407/STM32F417 In-Application Programming (IAP) Over Ethernet
AN3968 Application Note: STM32F407/STM32F417 In-Application Programming (IAP) Over Ethernet
AN3968 Application Note: STM32F407/STM32F417 In-Application Programming (IAP) Over Ethernet
Application note
STM32F407/STM32F417
in-application programming (IAP) over Ethernet
1 Introduction
Contents
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
2 IAP overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.1 Theory of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2 IAP using the MCU Ethernet interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.3 Implementing IAP over the Ethernet on the STM32F407/STM32F417 . . . 6
2.3.1 IAP method using TFTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3.2 IAP method using HTTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
5 Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.1 MAC and IP address settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.2 Jumper settings on the STM324xG-EVAL board . . . . . . . . . . . . . . . . . . . 15
5.3 Software file organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
5.4 Code size measurements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
5.5 Building an image for IAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
6 Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
List of tables
List of figures
2 IAP overview
-#5 RESET
.O
%NTER )!0 MODE %XECUTE APPLICATION CODE
)!0 INITIALIZATION
.O
)!0 REQUEST
9ES
2ECEIVE BINARY IMAGE AND
PROGRAM IT INTO USER &LASH AREA
-36
BYTES BYTES
!#+ PACKET /PCODE "LOCK
%NTER )!0 MODE
4&40 SERVER INITIALIZATION
4&40 7RITE .O
REQUEST
%RASE THE TOTAL USER &LASH AREA
3END !CK
$ATA 0ACKET .O
RECEIVED
7RITE $ATA BLOCK TO &LASH
3END !CK
,AST $ATA 0ACKET .O
SIZE BYTES
%ND OF FILE TRANSFER
Browse to select a binary file to upload, and then press the Upload button to send it.
Depending on the file size, the data is sent in consecutive TCP segments to the web server.
Note: Before sending the file data, the web client sends HTTP header data that contains
information such as the file name and the content length, some of which must be parsed by
the web server.
Web clients do not always have the same HTTP header format. Figure 6 shows Internet
Explorer HTTP header formatting for a POST request. Figure 7 shows the Mozilla Firefox
HTTP header formatting.
The http web server must handle these different formats.
Enter a correct User ID and Password (pre-defined in main.h file) and click the Login
button. A file upload web page is then loaded (see Figure 5).
Note: 1 The default User ID is: user and Password is stm32.
2 If the User ID or Password is incorrect, the login web page is reloaded.
After a successful login, browse to select the binary file to be loaded into the STM32 Flash.
Note: Make sure the binary file size does not exceed the total size of the STM32 user Flash area.
When clicking the Upload button (see Figure 5), a POST request is sent to the server. At this
moment the server starts erasing all the user Flash area and waits for the binary file raw
data. The received data is then written into the user Flash area.
Note that the total length of the data to be received is extracted from the HTTP header data
sent at the beginning of the transfer.
At the end of IAP operation, a web page indicates the success of IAP operation, displaying a
button which allows you to reset the MCU.
%NTER )!0 MODE
(440 SERVER INITIALIZATION
)NDEX PAGE .O
REQUEST
)NDEX PAGE SENT TO WEB CLIENT
#ORRECT
5SER )$ 07 .O
SUBMITTED
&ILE UPLOAD PAGE SENT TO WEB CLIENT
(4-, 0/34 .O
REQUEST RECEIVED FOR
FILE UPLOAD
%RASE THE TOTAL USER &LASH AREA
2AW DATA .O
RECEIVED
7RITE DATA INTO &LASH MEMORY
!LL DATA .O
RECEIVED
5PLOAD?DONE PAGE SENT TO WEB CLIENT
5 Environment
Note: The table does not show files used from the standard firmware library and the LwIP stack.
19796 X
22956 X X
28500 X X X
31484 X
33884 X X
39820 X X X
41196 X X X X
Note: The software is compiled using IAR EWARM v6.21.3, with high optimization for code size.
6 Revision history
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 TWO AUTHORIZED ST REPRESENTATIVES, 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.
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.