使用STM32F2x7系列的以太网模块实现IAP

AN3376
Application note STM32F2x7 In-Application Programming (IAP) over Ethernet
Introduction
This application note is intended for developers using the STM32F2x7 microcontroller. It
provides implementation solutions for In-Application Programming (IAP) using the
STM32F2x7 Ethernet communications interface.
Two possible solutions are provided on top of the LwIP TCP/IP stack:
●IAP using TFTP (T rivial File Transfer Protocol)
●IAP using HTTP (Hypertext Transfer Protocol)
October 2011Doc ID 018642 Rev 21/19
www.st
Contents AN3376
Contents
1IAP overview  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.1Theory of operation  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2IAP using the MCU Ethernet interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.3Implementing IAP over the Ethernet on the STM32F2x7 . . . . . . . . . . . . . . 6
1.3.1IAP method using TFTP  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.3.2IAP method using HTTP  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2IAP using TFTP  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1TFTP overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2Implementing IAP for the STM32F2x7 using TFTP  . . . . . . . . . . . . . . . . . . 7
2.3Using the software  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3IAP using HTTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.1HTTP file upload overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.2Implementing IAP using HTTP on the STM32F2x7 . . . . . . . . . . . . . . . . . 12
3.3Using the software  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.4Known limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.4.1Extra bytes added to binary file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4.1MAC and IP address settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4.2Jumper settings on the STM322xG-EVAL board . . . . . . . . . . . . . . . . . . . 15
4.3Software file organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.4Code size measurements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.5Building an image for IAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 5Revision history  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2/19Doc ID 018642 Rev 2
AN3376List of tables List of tables
Table 1.TFTP opcodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Table 2.Jumper configurations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Table 3.File organization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Table 4.Code size vs. configuration options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Table 5.Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Doc ID 018642 Rev 23/19
List of figures AN3376 List of figures
Figure 1.IAP operation flow. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Figure 2.TFTP packets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Figure 3.Flowchart of IAP using TFTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Figure 4.TFTPD32 dialog box. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Figure 5.Browser view of the file upload HTML form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Figure 6.IE8 HTTP header format. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Figure 7.Mozilla Firefox HTTP header format. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Figure 8.Login web page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Figure 9.File upload done web page. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Figure 10.Flowchart of IAP using HTTP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 4/19Doc ID 018642 Rev 2
jumper2
AN3376IAP overview Doc ID 018642 Rev 25/19
1 IAP overview
1.1 Theory of operation
In-Application Programming (IAP) is a means of upgrading firmware in the field using the
MCU communication interfaces such as UART, USB, CAN, Ethernet.
When you boot the microcontroller, you can choose to put it in IAP mode in order to execute
the IAP code or, in normal mode, start to execute the application code. Both the IAP code
and the application code are in the embedded Flash memory of the microcontroller. The IAP
code is usually stored in the first pages of the MCU Flash, and the user application code
occupies the remaining Flash area.
Figure 1 illustrates the IAP operation flow:
1.2 IAP using the MCU Ethernet interface
When it is available, Ethernet is often the preferred interface for implementing IAP capability
in an embedded application. The advantages are:
High speed communication interface (10/100 Mbit/s)●
Remote programming through the network (LAN or WAN)●Standardized application protocols such as FTP , TFTP , HTTP on top of the TCP/IP stack that can be used for implementing the IAP
IAP overview AN3376
1.3 Implementing IAP over the Ethernet on the STM32F2x7
This application note describes two solutions that implement IAP for the STM32F2x7 using
the Ethernet communication peripheral:
●IAP using TFTP (T rivial File Transfer Protocol)
●IAP using HTTP (Hypertext Transfer Protocol)
Both solutions run on top of the LwIP stack (v1.3.2), which is a light-weight implementation
of the TCP/IP protocol suite.
1.3.1 IAP method using TFTP
The IAP method using TFTP is widely used in embedded applications that require a
firmware upgrade capability (for example, in embedded Linux bootloaders).
TFTP is a simple file transfer protocol that works on top of the UDP transport layer. It is
intended to be used on a LAN environment. It is based on a client/server architecture, where
a client requests a file transfer (read or write operation) from a file server.
In this case the server only processes write requests from a PC TFTP client, so a simple
TFTP server is implemented on top of the LwIP stack.
1.3.2 IAP method using HTTP
A firmware upgrade using the HTTP protocol is less common than with TFTP, but it can be a
useful solution when remote programming over the Internet is needed. In this case, the TCP
transport protocol is needed to ensure optimum operation.
HTTP works on top of TCP, and offers a way of sending a binary file from a Web client
(Mozilla Firefox or Microsoft Internet Explorer) using HTML Forms. This is called HTTP File-
upload (RFC 1867).
The following sections of this document provide details about the implementation of both
IAP methods, and an explanation of how to use the software.
6/19Doc ID 018642 Rev 2

本文发布于:2024-09-21 08:30:27,感谢您对本站的认可!

本文链接:https://www.17tex.com/tex/1/351990.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2024 Comsenz Inc.Powered by © 易纺专利技术学习网 豫ICP备2022007602号 豫公网安备41160202000603 站长QQ:729038198 关于我们 投诉建议