Home
        STM32Cube Ethernet IAP example
         Contents
1.      13     Note     a    Make sure the jumpers on the evaluation board are set correctly  see Section 4 2      In the main h file  uncomment the option USE TAP HTTP  also depending on your  needs you can uncomment comment other options like USE DHCP or USE LCD   Recompile the firmware  Using the generated map file  make sure there is no overlap  between the IAP code area  starting from address 0x0  and the user Flash area starting  from address  USER FLASH FIRST PAGE ADDRESS  defined in main h     Program the firmware into STM32F4xx Flash and run it     To enter IAP mode  press then release the Reset button while keeping the Key button  pressed    If USE LCD is defined in main h file then the LCD screen displays a message  indicating that IAP mode has been entered  Also in the case of using DHCP    USE DHCP defined in main h   a message is displayed on the LCD screen indicating  the success or failure of DHCP IP address allocation    After IP address assignment  either static or dynamic address   the user can start the  IAP process    Open a web client  Mozilla Firefox or Microsoft Internet Explorer  and enter the STM32  IP address    A login web page will be shown  In the User ID field enter  user  and in the Password  field enter    stm32    then press the Login button    The fileupload html web page is then loaded  Browse for a binary image to be loaded  into STM32 Flash then press the Upload button in order to start the IAP process     If LCD is enabled  the progress of 
2.     ccc eee 11  Figure 7  File upload done           0    cee eee 11  Figure 8  Flowchart of IAP using HTTP           0 0    cece tees 12    d    4 19 DoclD025701 Rev 3       UM1709    IAP overview       1 1    d    IAP overview    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 and Ethernet     When you boot the microcontroller  you can choose to put it in either   e IAP mode in order to execute the IAP code   e Normal mode in order 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     Figure 1  IAP operation flow    MCU Reset    Enter IAP  mode      IAP initialization  T     IAP request                 Execute application  code            Receive binary image  and program it into  user Flash area   MS34111V1             DoclD025701 Rev 3 5 19       IAP overview UM1709       1 2    1 3    1 3 1    1 3 2    6 19    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     e High speed communication interface  10 100 Mbit s   e Remote programming through the network  LAN 
3.    Cor UM1709  WI life  augmented User manual       STM32Cube Ethernet IAP example       Note     May 2015    Introduction    The STMCube    initiative was originated by STMicroelectronics to ease developers    life by  reducing development efforts  time and cost  STM32Cube covers the STM32 portfolio   STM32Cube Version 1 x includes     e The STM32CubeMX  a graphical software configuration tool that allows the generation  of C initialization code using graphical wizards     e A comprehensive embedded software platform  delivered per series  such as  STM32CubeF4 for STM32F4 series         The STM32Cube HAL  an STM32 abstraction layer embedded software  ensuring  maximized portability across STM32 portfolio        A consistent set of middleware components such as RTOS  USB  STMTouch   FatFS and Graphics        A All embedded software utilities coming with a full set of examples   The In Application Programming  IAP  is a way to program the flash memory while code    execution from the same flash  It provides the possibility to load an application code using  high speed communication protocols     This user manual is intended for developers who use STM32Cube firmware on STM32  microcontrollers  It provides a full description of how to implement In Application  Programming  IAP  using Ethernet communication    Two possible solutions are provided on top of the LwIP TCP IP stack    e   AP using TFTP  Trivial File Transfer Protocol    e   AP using HTTP  Hypertext Transfer Protocol  
4.   This document is applicable to all STM32 series featuring an Ethernet peripheral  However     for simplicity reason  STM32F4xx microcontrollers and STM32CubeF4 are used as  reference platform     The same description  file names and screenshot are applicable as well to other series  offering Ethernet connectivity  such as STM32F107xx  STM32F2x7xx and STM32F7xx  To  know more about the Ethernet IAP example implementation on your STM32 Series  refer to  the documentation provided within the associated STM32Cube firmware package     G  Q    DoclD025701 Rev 3 1 19       www st com    Contents UM1709       Contents  1 IAP overview 65 05 peas Wosbee Na See EER eee 55 AKA NA MEER RR ACA 5  1 1 Theory of operation axes aquesta ra RN a oe due Ak Uns 5  1 2 IAP using the MCU Ethernet interface                 00 0 eee eee 6  1 3 Implementing IAP over the Ethernet             0 0 02 eee eee eee 6  1 3 1 IAP method using TFTP          ce cece eee 6  1 3 2 IAP method using HTTP     22  0    cee eee 6  2 IAP USING TFTP sisse a kA KABA RR Ei mE EX ER ER degen sawed 7  2 1 TFTP overview     2    2    ccc eee eens 7  2 2 Implementing IAP using TFTP for STM32F4xx                200055 8  2 3 Using the firmware         2 rh 9  3 IAP using HTTP Lian ERES KABA cae pees ces AG REG ARE RR RO E 10  3 1 HTTP file upload overview            2 000 c eee 10  3 2 Implementing IAP using HTTP for STM32F4xx              aa 10  3 3 Using the firmware anceps e otio ede ee ASA GD ADARNA de dcus 13  4 Environ
5.  7 9       IAP using TFTP    UM1709       2 2    8 19    Implementing IAP using TFTP for STM32F4xx    This IAP implementation consists of a TFTP server on top of the LwIP TCP IP stack     This server responds to file write requests received from a remote TFTP client  PC      TFTP read requests are ignored     Instead of writing received files to a file system  which is normally what TFTP is used for  the    server writes the received data blocks into the MCU Flash  in the user Flash area      Note  In this implementation  the data block size is fixed to 512 bytes     Figure 3 provides an overview of the IAP operation using TFTP     Figure 3  Flowchart of IAP using TFTP       Enter IAP mode    TFTP server    Initialization  FTP  request    Erase the total  user Flash area  Send Ack    Data packe  eceived                          Write data block to  Flash    Send Ack        End of file  transfer           MS34113V1       DoclD025701 Rev 3    Ly           UM1709    IAP using TFTP       2 3    d    Using the firmware    In order to test the IAP through TFTP  follow these steps     1  Make sure the jumper settings in the evaluation board are set correctly  see  Section 4 2    2  Inthe main h file  uncomment the option  define USE IAP TFTP  Also  depending  on your needs  you can uncomment comment other options such as  define  USE DHCP Or  define USE LCD    3  Recompile the firmware  Using the generated map file  be sure that there is no overlap  between the IAP code area  starti
6.  settings    Updated Section 4 3  Firmware file organization  introduction        DoclD025701 Rev 3    d          UM1709       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    d    DoclD025701 Rev 3 19 19       
7.  the user  Flash area  this address should be the same address as the one defined by  USER FLASH FIRST PAGE ADDRESS in main h         2  The vector table start address is configured as the start address of the user Flash area   The vector table base offset is configured by modifying the value of the constant  VECT TAB OFFSET defined in system stm32f4xx c file  For example  to set the  vector table base location at 0x08020000   define VECT TAB OFFSET 0x20000    3  The compiled software size does not exceed the total user Flash area     DoclD025701 Rev 3 15 19       Conclusion UM1709       5 Conclusion    The aim of this user manual is to explain the Ethernet In Application Programming  IAP   using the STM32Cube HAL drivers for the STM32F4xx microcontrollers     Two solutions are provided to support HTTP and TFTP protocols  both of them are based on  the LwIP stack as a middleware component for TCP IP communication     3    16 19 DoclD025701 Rev 3       UM1709    FAQ       Appendix A FAQ    A 1    A 2    A 3    d    How to choose between static or dynamic  DHCP  IP address  allocation  When the macro  define USE DHCP located in  main h  is commented  a static IP    address is assigned to the STM32 microcontroller  by default 192 168 0 10  this value can  be modified from  main h  file         If the macro  define USE DHCP is uncommented  the DHCP protocol is enabled  and the  STM32 will act as a DHCP client       How the application behaves when the Ethernet cable is  disconnec
8. 168 0 10  To change this address  modify the six bytes  defined in the main h file     Evaluation boards settings    Before running the Ethernet IAP example  read the corresponding readme file to know how  to configure the board jumper to ensure correct operation     Firmware file organization    The Ethernet IAP example sources are available under  Projects STM324xx_EVAL Applications LwIP LwIP_IAP   where STM324xx_EVAL refers to  STM32F4xx EVAL board  e g  STM324xG EVAL for STM32F407 417 line   Table 2  describes the example source files     Table 2  Files organization                      File name Description  main c Main application file  main h Main configuration file  httpserver c   h HTTP server implementation  tftpserver c   h TFTP server implementation  flash if c   h High level Flash access functions  stm32f4xx_it c   h Interrupt handler  fsdata c HTML files as a ROM file system                DoclD025701 Rev 3    a       Environment                            UM1709  Table 2  Files organization  File name Description  Iwipopts h LwIP configuration options  ethernetif c  h interface between LwIP and Ethernet driver  stm32f4xx hal conf HAL configuration file  Note  The table does not show files used from the STM32Cube HAL and BSP libraries and the  LwIP stack   4 4 Building an image for IAP    d    In order to build an image for IAP  to be loaded using the IAP software   make sure that   1  The firmware is compiled and linked to run starting from the start address of
9. al File Ic  Slwipdemos  bin      Remote File    Block  512  gt     See 01512   block  98 Get   Break    gH SEBBEED                DoclD025701 Rev 3 9 19       IAP using HTTP UM1709       3 IAP using HTTP    3 1 HTTP file upload overview    File upload using HTTP is defined in RFC1867  This method of uploading files is based on  HTML forms  To send raw binary data  the HTML Post method is used instead of GET   The following is an example of HTML code for implementing form based file upload     form action    upload cgi  enctype  multipart form data  method  post  gt    lt p gt Specify a binary file to upload into STM32F4xx Flash     br      input type  file  name  datafile  size  40  gt      p      div      input type  submit  value  Upload  gt      lt  div gt  lt  form gt     Figure 5  Browser view of the file upload HTML form       STM32F4xx IAP using HTTP   Windows Internet Explorer provid    DAR   e        httpiI192 169 0 10  v    47    X   4    File Edit View Favorites Tools Help    We de     sTM32F4xx IAP using HTTP a  E       Please specify a binary file to upload into STM32F4xx flash      CASysTick bin i Browse    J  Upload       4   internet  amp  10095               Press Browse button to select a binary file to upload  and then 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 fil
10. e 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  The http web server must  handle these differences     3 2 Implementing IAP using HTTP for STM32F4xx    This IAP implementation consists of an HTTP Web server on top of the LwIP stack     When typing the STM32 IP address in a browser  a login web page is shown  Figure 6   This  login web page restricts access to the IAP file upload to authorized users     10 19 DocID025701 Rev 3 Ly        UM1709    IAP using HTTP       Note     d    Figure 6  Login web page       STM32F4xx IAP using HTTP   Windows Internet Explorer provid    DER     j     jhtp  192 168 0 10  w    4    X    Fie Edit View Favorites Tools Help    Be Be   sTM32F4xx IAP using HTTP     Thco OE  am v   ep Page      Login    Enter user ID and password   User ID Password       Ca   Internet R 10095               Enter a correct User ID and Password  predefined in main h file  and click the Login  button  A file upload web page is then loaded  see Figure 5      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     3  Make sure the binary file size does not exceed the total size of the STM32 user Flash  area     4  When clicking the Upload button  see Figure 5   a POST request is sent to the server   At t
11. his 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     5  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     6  Atthe end of IAP operation  a web page indicates the success of IAP operation   displaying a button which allows you to reset the MCU     Figure 7  File upload done    7 STM32 IAP using HTTP   Windows Internet Explorer provided b     ym           e       ig httpir192 168 0 10 v    9    X  File Edit View Favorites Tools Help    Se fe    sTM321AP using HTTP   fay   E    de    Pas         File Upload Done     Reset MCU          CLE   internet 100                Figure 8 summarizes the IAP method using HTTP     DoclD025701 Rev 3 11 19       IAP using HTTP UM1709       Figure 8  Flowchart of IAP using HTTP       Enter IAP mode    HTTP server Initialization       Index page  request     Index page sent to web  client  orrect User ID aM     PW submitted     File upload page sent to  web client    HTML POST  request received  or file upload    Erase the total Flash area  Raw EN    received     Write data into flash  memory    All data  received     End of file transfer  MS34110V1                                12 19 DocID025701 Rev 3 Ly        UM1709    IAP using HTTP       3 3 Using the firmware    In order to test the IAP using HTTP  follow these steps     1   2     10     11   12
12. ment I                     ee 14  4 1 Application settings            2 0 0 0 eee 14  4 1 1 PHY interface configuration    0    0 0    saaana aaea 14  4 1 2 MAC and IP address settings            0c eee eee eee 14  4 2 Evaluation boards settings    i35 dea ae sede eae eR ERE eR eRe ats 14  4 3 Firmware file organization            0 cee eee 14  4 4 Building an image for IAP                660 ee es 15  5 jdn PED 16  Appendix A gite                  mrT 17    A 1 How to choose between static or dynamic  DHCP  IP address allocation 17  A 2 How the application behaves when the Ethernet cable is disconnected    17    A 3 How to port the application on a different hardware                   17    6 Revision history side dn cede ees itetsscs Seis te PAWANG ERE LENG 18    2 19 DoclD025701 Rev 3 Ly        UM1709 List of tables       List of tables   Table 1  TETP ODCOUG crees aer eere ur ERN heehee dae BS Ged 7  Table 2  Files organization     20    0 0 0 ccc et ne tae 14  Table 3  Document revision history           0    cece eee 18    DoclD025701 Rev 3 3 19    d       List of figures UM1709       List of figures    Figure 1  IAP operation TOW  emule ae BANAT Rena Rr jan ver ha aac iy daa Goa ees 5  Figure 2  TRIP packets     2 0 2 ee NP NG NG Rees eee ee ee 7  Figure 3  Flowchart of IAP using TRIP           0    8  Figure 4    TFTPD32 dialog box           00  ccc eens 9  Figure 5  Browser view of the file upload HTML form             0 000 eee ee 10  Figure 6  Login webpage        
13. ng from address 0x0  and the user Flash area starting  from address  USER  FLASH  FIRST PAGE ADDRESS defined in main h    4  Program the firmware in the STM32F4xx Flash and run it     5  To enter IAP mode  press and then release the Reset button while keeping the Key  button pressed    6  If USE_LCD is defined in main h file then the LCD screen displays a message indicating  that IAP mode has been entered  Also if DHCP is used  USE DHCP defined in main h    a message is displayed on the LCD screen indicating the success or failure of DHCP IP  address allocation    7  After IP address assignment  either static or dynamic address   the user can start the  IAP process    8  Onthe PC side  open the TFTP client  for example TFTPD32   and configure the TFTP  server address  host address in TFTPD32     9  Browse for a binary image to load in the STM32F4xx Flash  a binary image is provided  as examples in the  project binary folder     10  Start a file write request by clicking the Put button in the TFTPD32 utility    11  When LCD is enabled  the progress of the IAP operation is shown on the LCD     12  Atthe end of IAP operation  you can reset the evaluation board and run the application  that you have just programmed in the STM32F4xx Flash                                            Figure 4  TFTPD32 dialog box    Tftpd32 by Ph  Jounin    Current Directory   C         Server interfaces  192 1680 1    Titp Server Tftp Client   DHCP server   Syslog se    Host E 92 168 0 11 Port    Loc
14. or WAN     e Standardized application protocols such as FTP  TFTP  HTTP on top of the TCP IP  stack that can be used for implementing the IAP    Implementing IAP over the Ethernet    This user manual describes two solutions that implement IAP for the STM32F4xx using the  Ethernet communication peripheral     e IAP using TFTP  Trivial File Transfer Protocol   e IAP using HTTP  Hypertext Transfer Protocol     Both solutions run on top of the LwIP stack  which is a light weight implementation of the  TCP IP protocol suite     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 in 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     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 Firefo
15. ted    When the cable is disconnected the Ethernet peripheral stops both transmission and  reception traffics  also the network interface will be set down  If an LCD controller is used a  message is displayed to inform user that the cable is not connected  else the Red LED of  the evaluation board will turn on     When the user re connects the cable  the Ethernet traffic will resume and network interface  will be set up  If an LCD controller is used a message is displayed to inform user the new IP  address either with static or dynamic allocation  else the Yellow LED of the evaluation board  will turn on     How to port the application on a different hardware    When another hardware platform is used  you have to check the GPIO configuration into the  HAL ETH Msplnit   function for the Ethernet peripheral  also HAL PPP Msplnit   or  HAL_Msplnit   if the application needs more PPP peripheral     DoclD025701 Rev 3 17 19       Revision history    UM1709       6    18 19    Revision history    Table 3  Document revision history                Date Revision Changes   28 Mar 2014 1 Initial release   05 Feb 2015 2 Updated Section   Introduction and Section 1  IAP  overview  Section   Introduction updated and merged with  section STM32Cube overview   Removed note related to RMII mode and added note  concerning supported boards in Section 4 1 1  PHY   27 May 2015 3 interface configuration           Removed dedicated evaluation board settings sections  in Section 4 2  Evaluation boards
16. the IAP operation is shown on LCD    Atthe end of the IAP operation  a new web page is loaded indicating the success of the  file upload operation    Press the RESET MCU button to reset the MCU and run the application just  programmed in the STM32F4xx Flash                                         If there is a connection issue when LCD is enabled  an error message displays on the  LCD screen indicating the connection failure     The software was tested with the following Web clients  Microsoft Internet Explorer 8  and Mozilla Firefox 24     DoclD025701 Rev 3 13 19       Environment UM1709       4    4 1    Note     4 2    4 3    14 19    Environment    Application settings    PHY interface configuration    The Ethernet peripheral is interfaced with an external PHY to provide physical layer  communication  The PHY registers definition and defines are located under the HAL  configuration file    stm32f4xx hal conf h      The PHY operates following two modes MII and RMII  to select the required mode user has  to fill the    Medialnterface    parameter of  Init  structure when initializing the Ethernet  peripheral     Refer to the readme file provided within your device Ethernet IAP example to know more  about the available PHY interface modes on the supported boards   MAC and IP address settings    The default MAC address is set to  00 00 00 00 00 02  To change this address  modify the  six bytes defined in the stm32f4xx hal conf h file     The default IP address is set to  192 
17. x 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     d    DoclD025701 Rev 3       UM1709    IAP using TFTP       2    2 1    d    IAP using TFTP    TFTP overview    TFTP is a simple file transfer protocol that works on top of UDP  A file transfer is initiated  from a TFTP client  that sends a Read or Write request to a TFTP server  When the server  acknowledges the request  the file data transfer starts  The data is sent in fixed size blocks   for example in blocks of 512 bytes      Each transferred data block must be acknowledged by the recipient before the next block  can be sent  The acknowledge mechanism is based on the block number sent with each  data block  A data block with less than the fixed block size indicates the termination of the  file transfer     Figure 2 describes the format of the various TFTP packets     Figure 2  TFTP packets    2 bytes String 1 byte String 1 byte    wom ie  em   o   a TO    2 bytes n bytes    Data packet   Opcode Data    2 byt 2 bytes  ACK packet   Opcode    2 bytes String     byte    Error packet   Opcode Error Message gn    Table 1 lists the TFTP opcodes        Table 1  TFTP opcode                            Opcodes Operation  0x1 Read request  RRQ   0x2 Write request  WRQ   0x3 Data  0x4 Acknowledgment  ACK   0x5 Error  DoclD025701 Rev 3
    
Download Pdf Manuals
 
 
    
Related Search
    
Related Contents
USER MANUAL  LG Electronics 32LB9R Flat Panel Television User Manual  Algebra Lineal - Facultad de Ciencias Exactas y Tecnologías  ASP user manual    Arat 1277.2 holder  Pompa di calore XHP per piscine LIBRETTO DI ISTRUZIONI PER L  PureLink PureInstall PI045  EW-FA23 - Panasonic  "取扱説明書"    Copyright © All rights reserved. 
   Failed to retrieve file