Home
STR91xFA in-application programming (IAP)
Contents
1. Figure 16 IAP using HTTP end of transmission page STR9Ix LAP over Ethernet demo v1 0 kyy OBack O Jump 21 24 IAP using HTTP AN2675 3 6 22 24 Driver description The IAP using HTTP application is a mini web server that offers possibility to upload files It is based on the ulP stack that manages all TCP IP traffic ulP is a free TCP IP stack designed originally for 8 bit 16 bit microcontrollers For more details about the ulP stack please refer to www sics se adam uip The Application Layer is controlled by functions included in the httpd c file In addition there are some configuration and control functions included in the file util c the ENET FWLib folder which is the driver of the STR91xFA ENET and some files from the STR91xFA Standard library AN2675 Revision history 4 Revision history Table 4 Document revision history Date Revision Changes 04 Feb 2008 1 Initial release 23 24 AN2675 Please Read Carefully 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 s
2. Ti AN2675 3 Application note STR91xFA in application programming IAP over Ethernet Introduction The STR912 is an ideal microcontroller for applications running on a network With its Ethernet MAC interface and the capability to operate at 96 MHz it provides a high performance solution for network embedded applications This application note demonstrates how to use In Application Programming IAP through the Ethernet interface Two solutions are provided the first using the TFTP protocol and the second using the HTTP protocol February 2008 Rev 1 1 24 www st com Contents AN2675 Contents 1 Theory of operation anima hh hh nem mm m mnm a a a 3 1 1 TAP OVOIVIBW spp DE are M VO AUR AN eaa ER RR aa ONDE Era DS 3 1 2 IAP using Ethernet on STRO 0 ee ee 3 1 2 1 Ethernet interface 0 000 eee 3 1 2 2 IAP using Ethernet 0000 ra 3 1 2 3 Application layer x se RERO ected dee peal dav LER RES 4 2 IAP USING TFTP susana ud ak y Odi RC CR RC RO Oc C ae 6 2 1 TFTP protocol overview as iiie ias ede ap a rb IS A is o 6 2 2 DHCP protocol overview saranen 7 2 3 IAP method spanish sa es A PS EE ada Seba RE ee Re 8 24 Running the IAP application l l 11 2 4 1 User project configuration 0 0 cee ee eee 11 2 4 2 PC configuration s c2skesgiaa eek beak ele sebo Pee Eee eS 11 2 4 3 How to start IAP operation 0 0 llle 13 2 5 Driver description ins E ss patio on wa
3. types of packets all of which have been mentioned above Table 1 TFTP opcode packet Opcode Operation 1 Read request RRQ 2 Write request WRQ 3 Data 4 Acknowledgment ACk 5 Error The TFTP header of a packet contains the opcode associated with that packet AN2675 IAP using TFTP Figure 4 TFTP packets 2 bytes String 1 byte String 1 byte RRQ WRQ packet Opcode File name 0 Mode 0 2bytes 2 bytes n bytes Data packet Opcode Block Data 2bytes 2 bytes ACK packet Opcode Blocks 2bytes 2 bytes String 1 byte Error packet pcoaal PUO Error r code message The mode field contains the string netascii octet or mail that are the modes defined in the protocol Octet mode is used to transfer a file that is in the 8 bit format of the machine from which the file is being transferred 2 2 DHCP protocol overview DHCP is a protocol used by networked computers clients to obtain IP addresses and other parameters such as the default gateway subnet mask and a name of a boot file from a DHCP server It facilitates access to a network because these settings would otherwise have to be made manually for the client to participate in the network DHCP operations fall into four basic phases These phases are DHCP Discovery DHCP Offers DHCP Requests and DHCP Acknowledgment The Client Server DHCP interaction is described below e The clie
4. 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 ST and the ST logo are trademarks or registered trademarks of ST in various countries 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 2008 STMicroelectronics All rights reserved STMicroelectronics group of companies Australia Belgium Brazil Canada China Czech Republic Finland France Germany Hong Kong India Israel Italy Japan Malaysia Malta Morocco Singapore Spain Sweden Switzerland United Kingdom United States of America www st com 24 24
5. Protocol TFTP which is a very simple file transfer protocol This protocol transfers files from a server following a request Therefore you must have TFTP server on the network to perform file loading ky AN2675 Theory of operation Another way to load data without using a server is to use the HyperText Transfer Protocol HTTP HTTP provides file uploading solutions using HTML forms Both IAP methods using the TFTP and HTTP protocols are described in the next sections SZA 5 24 IAP using TFTP AN2675 2 2 1 6 24 IAP using TFTP This method uses dynamic IP address assignment A DHCP server is needed for this purpose The following sections give an introduction to the TFTP and DHCP protocols TFTP protocol overview Trivial File Transfer Protocol TFTP is a very simple file transfer protocol with the functionality of a very basic form of FTP Since it is so simple it is easy to implement in a very small amount of memory an important consideration for embedded applications A transfer begins with a request to read a file which also serves to request a connection If the server grants the request the connection is opened and the file is sent in fixed length blocks of 512 bytes Each data packet contains one block of data and must be acknowledged by an acknowledgment packet before the next packet can be sent A data packet of less than 512 bytes signals the termination of a transfer TFTP supports five
6. are package copyrighted 1998 2006 by Philippe Jounin and downloadable from the website http tftpd32 jounin net The presence of more than one DHCP server causes incorrect behavior in the application So make sure that you have only one DHCP server on the network AN2675 IAP using TFTP Figure 6 IAP communication state diagram DHCP No offer Discover DHCP Offer Timeout DHCP DHCP ACK Request Timeout Timeout SZA 9 24 IAP using TFTP AN2675 10 24 Figure 7 Flowchart of IAP using TFTP No Joystick position in IAP initialization No DHCP communication success Yes Erase needed sectors TFTP Request Load Data into Flash memory No Data received No TFTP ERROR Send ACK Data received lt 512B Jump to user application AN2675 IAP using TFTP 2 4 2 4 1 2 4 2 Running the IAP application User project configuration e The user application to be loaded must be built at address 0x80000 which is the location of Banko if it has been remapped There is no need to remap BankO and Bank1 as this has already been done in the IAP software e Inthe file 91x fmi h uncomment the line define Remap Bank 1 to be compatible with the bank remapping An example is provided with this appl
7. e IAP driver Table 2 IAP driver description File name Description main c A framework of the IAP application Contains functions that configure and control the joystick the delay and util c the Flash erase tasks Icd c LCD driver tftp c Implementation of the TFTP protocol with function for load in Flash P memory dhcp c Implementation of the DHCP protocol udp c Implementation of the UDP protocol ip c Implementation of the IP protocol arp c Implementation of the ARP protocol Includes the functions that interface the Physical Layer and the TCP IP ether c stack In addition the driver includes the ENET FWLib which is the driver of the STR91xFA ENET and some files of the STR91xFA standard library Figure 11 Implementation of TCP IP layers Application DHCP dhcp c TFTP tftp c Transport UDP udp c Internet IP ip c ARP arp c Network Interface Ethernet ether c amp ENET FWLib 15 24 IAP using HTTP AN2675 3 3 1 3 2 3 3 16 24 IAP using HTTP HTTP overview HyperText Transfer Protocol is the underlying protocol used by the World Wide Web HTTP defines how messages are formatted and transmitted and what actions Web servers and browsers should take in response to various commands The HTTP protocol is a request response protocol Most HTTP communication is initiated by a user agent and consists of a request to be applied to a resource on the origi
8. e sap d sonia ee wee 15 3 IAP using HTTP assa sas auk RE deco en E sees 16 3 1 HTTP OVGIVIOW stc2008se2 gas pda UR ORA EG Ea Skee d RU EO ES eee 16 3 2 Request methods uescet oe Fe Geese hee hehe euteteeey REPE RES 16 3 3 Uploading files with HTTP esseri 16 3 4 IAP method TTD 17 3 5 Running the IAP application 0000 ee ee 20 3 5 1 User project configuration 0 0 cece ee 20 3 5 2 How to start IAP operation 0 0 llle eere 20 3 6 Driver description spe neec ced renas CT MOO EES Kee ee ad 22 4 REVISION history use ee ae ewe ma oe we 8 RR 23 2 24 ky AN2675 Theory of operation 1 Theory of operation 1 1 IAP overview In Application Programming IAP is used to update the contents of the Flash memory in the field without the use of any special hardware tool To update firmware the user must run the IAP application that downloads the new firmware to the Flash memory The flowchart of the IAP driver is given below Figure 1 Flowchart of the IAP driver Yes IAP initialization Jump to user application 1 2 IAP using Ethernet on STR9 1 2 1 Ethernet interface STR91xFA devices in 128 pin and 144 pin packages provide an IEEE 802 3 2002 compliant Media Access Controller MAC for Ethernet LAN communications through an industry standard Medium Independent Interface MII The STR91xFA requires an external Ethernet physical interface device PHY to connect to the physical LAN bus t
9. election 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 AN AUTHORIZED ST REPRESENTATIVE 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
10. est Then it submits the file to upload The communication between the HTTP server in this case the IAP application and the HTTP client a PC is shown in Figure 13 17 24 IAP using HTTP AN2675 18 24 Figure 13 IAP using HTTP transfers Server GET Request POST Request Start receiving the file GET HTTP data POST HTTP data TCP ACK V HTTP data TCP ACK Client Home page receiving File submission End of file transmission AN2675 IAP using HTTP Figure 14 Flowchart of the IAP using HTTP No Joystick position in Yes IAP initialization No Client connected Display a home page POST message Yes Erase needed Flash memory sectors c Receiving and loading data No Yes p Jump to user application 19 24 IAP using HTTP AN2675 3 5 3 5 1 3 5 2 20 24 Running the IAP application User project configuration e The user application to be loaded must be built at address 0x80000 which is the location of Banko if it has been remapped There is no need to remap BankO and Bank1 as this has already been done in the IAP software e Inthe file 91x fmi h uncomment the line define Remap Bank 1 to be compatible with the bank remapping An example is provided with this application to show the project settings of a user progra
11. f the Flash memory like this Bank 1 at 0x00 and make it the boot bank at power up Bank O at 0x80000 Using JTAG load the IAP driver into Bank1 On the host PC start TFTPD32 and make sure that the configuration is as described in Section 2 4 2 PC configuration Place the binary file of the new firmware to be loaded in the Base Directory selected in the TFTPD32 and make sure that the project configuration described Section 2 4 2 PC configuration was respected Enter the size of the file in number of 512bytes in the option field of the dialog box Connect the STR912 board to a PC using a crossover Ethernet cable or through an Ethernet switch If you are using a firewall application you will need to disable it Press the reset button while holding the joystick button pressed in to start the IAP process Finally if you want to reset your application you have just to press the reset button AN2675 IAP using TFTP 2 5 Driver description IAP using the TFTP driver is built with the same architecture as the TCP IP model The interface Network Application is composed of layers which are managed by files taken from the Ethernut software Ethernut is an open source hardware and software project for building tiny embedded Ethernet devices For more information please refer to www ethernut de The framework of the whole application is implemented in the main file Table 2 describes the various files that make up th
12. ication to show the project settings of a user program which can be loaded in the STR91xFA internal Flash using IAP PC configuration If your local network already supports DHCP and TFTP you can skip this part and use your existing installation To implement both DHCP and TFTP servers we will use the Philippe Jounin s TFTPD32 software e Install and start the TFTPD32 It should look like this Figure 8 Tftd32 main dialog box Tftpd32 by Ph Jounin loj xj Current Directory CAST Abin Server interfaces 164 1 30 62 96 Show pi Titp Server DHCP server Loa viewer start time About Settings Help e Click on the button labeled Settings This will open a new dialog box e The Base Directory is the subdirectory of the file to upload Select your own subdirectory using the browser 11 24 IAP using TFTP AN2675 12 24 Figure 9 Tftpd32 Settings Tftpd32 Settings iv im m Kc oie ie ie m NM NM MSE MM CAST n n E mi AN2675 IAP using TFTP 2 4 3 Figure 10 DHCP Server configuration Tftpd32 by Ph Jounin loj x Current Directory CAST Server interfaces 164 130 62 96 Show Di Titp Server DHCP server Log viewer IP pool starting address 192 168 0 1 _ Size of pool E Boot File GPIObn WINS DNS Server 0000 Default router 0000 Mask 2552552550 mm Domain Name Additional Opt
13. ion h 3 E wrt on allocated at IP MAC e The IAP application has to request an IP address from the DHCP pool Enter the IP pool starting address and the number of available addresses in the pool The sample above offers IP addresses from 192 168 0 01 up to and including 192 168 0 07 e The boot file is the name of the raw binary image of the application you want to upload to the STR912 Flash memory e There s no need to specify a WINS DNS server address or default router unless your IAP application requires direct Internet access Make sure that the network mask and the IP pool addresses fit your local network configuration e Additional Option is used to define the size of the file to download For this put 13 in the first blank that is the number of the size file option and insert the size of the file in term of 512 bytes in the second i e if the file size is 4 Kbytes you will put 8 e Finally press Save to let TFTPD32 store the values in the Windows registry and select the TFTP Server tab to return to the initial window How to start IAP operation At reset the position of the joystick button selects if IAP operation is started or not e Ifthe joystick button is pressed in the IAP starts e Else the system jumps to the user application stored in Banko To use the IAP driver efficiently please use the following procedure 13 24 IAP using TFTP AN2675 14 24 1 1 Using the CAPS tool remap the banks o
14. m which can be loaded in the STR91xFA internal Flash using IAP How to start IAP operation At reset the position of the joystick button selects if IAP operation is started or not e Ifthe joystick button is pressed in the IAP starts e Else the system jumps to the user application stored in Banko To use the IAP driver efficiently please use the following procedure 1 1 Using the CAPS tool remap the banks of the Flash memory like this Bank 1 at 0x00 and make it the boot bank at power up Bank O at 0x80000 2 Using JTAG load the IAP driver into Bank1 3 Connect the STR912 board to a PC using a crossover Ethernet cable or through an Ethernet switch 4 f you are using a firewall application you will need to disable it 5 Press the reset button while holding the joystick button pressed in to start the IAP process 6 With an internet browser connect to the board using the following address 192 168 0 1 The page shown in Figure 15 should appear on the browser 7 Select the directory of the binary file of the new firmware to upload and press the Send File button 8 When the transfer is terminated the page in Figure 16 is displayed 9 If you want to execute the uploaded code select Jump and validate Or if you want to upload another file select Back and validate AN2675 IAP using HTTP Figure 15 IAP using HTTP Home Page STR9Ix LAP over Ethernet demo v1 0 y Select a file to upload
15. n server In the simplest case this may be accomplished via a single connection between the user agent and the origin server Request methods HTTP Requests are primarily requests sent by the client browser to the web server software These requests are coded into the packet as plain text They inform the Web server what the client is looking for and indicate how the server should go about delivering the content or service requested A request message from a client to a server includes within the first line of that message the method to be applied to the resource the identifier of the resource and the protocol version in use HTTP defines eight methods indicating the desired action to be performed on the identified resource Table 3 HTTP request methods Method Description GET Requests a representation of the specified resource Asks for the response identical to the one that would correspond to a GET HEAD request but without the response body POST Submits data to be processed e g from an HTML form to the identified resource PUT Uploads a representation of the specified resource DELETE Deletes the specified resource Echoes back the received request so that a client can see what intermediate TRACE i T servers are adding or changing in the request Returns the HTTP methods that the server supports This can be used OPTIONS to check the functionality of a web server CONNECT For use with a proxy tha
16. nt broadcasts a DHCP DISCOVER message on its local physical subnet e When a DHCP server receives a DHCP DISCOVER it reserves an IP address for the client and send a DHCP OFFER message across the network to the client e When the client in our case it is the STR912 board receives a DHCP OFFER it must tell all the other DHCP servers that it has accepted an offer To do this the client broadcasts a DHCP REQUEST message that could contain the call for extra information e When the DHCP server receives the DHCP REQUEST message from the client it initiates the final phase of the configuration process This acknowledgement phase involves sending a DHCP ACK packet to the client 7 24 IAP using TFTP AN2675 2 3 Note 8 24 Figure 5 DHCP header Hardware Addr Hop Count Length Transaction ID Opcode Hardware Type Number of seconds Flags Client IP Address Your IP Address Server IP Address Gateway IP Address Client Hardware Address 16 Bytes Server Hostname 64 Bytes Boot Filename 128 Bytes Vendor specific information 64 Bytes IAP method The STR912 client must connect to a TFTP server and request a binary file of the new firmware To connect to a server a client must have an IP address on the network The DHCP provides to a client an IP address and a file path To implement DHCP and TFTP servers in the PC we have chosen the Tftpd32 which is a freew
17. t can change to being an SSL tunnel Uploading files with HTTP The HTTP protocol offers the possibility to upload files using HTML forms that allow the producer of the form to submit files of data requested from the user reading the form ky AN2675 IAP using HTTP 3 4 The HTML code to include in the web page in order to request a file from a user is as fol lows lt FORM action URL METHOD POST ENCTYPE multipart form data gt lt h2 gt Select a file to upload lt h2 gt lt INPUT type file name userfile gt lt BR gt lt BR gt lt INPUT type Submit value Send File name button lt FORM gt That will give the form below Figure 12 Upload File Form Select a file to upload Browse send Selecting the Browse button would cause the browser to enter into a file selection mode appropriate for the platform When the user completes the form and selects the SUBMIT element the browser should send the form data and the content of the selected files IAP method With this method the file upload user interface uses an HTML form The client in this case a PC that contains the binary file of the new firmware must connect to the STR912 board which include an embedded Web server and ask for the directory containing the file to be uploaded The client first asks for the home page that contains a file upload form by sending a GET Requ
18. wisted pair fiber etc 1 2 2 IAP using Ethernet The principle of the IAP over Ethernet consists of loading the new firmware from a PC via network The IAP application over Ethernet should be built on top of a TCP IP suite protocol 3 24 Theory of operation AN2675 1 2 3 4 24 Figure 2 IAP using Ethernet Binary file of the new firmware TCP IP STR912F board PC The full TCP IP suite consists of numerous protocols ranging from the low level protocol to the application level protocol The TCP IP suite uses encapsulation to provide abstraction of protocols and services Generally a protocol at a higher level uses a protocol at a lower level to help it fulfil its purpose Figure 3 Example of TCP IP encapsulation Application Data Application Data TCP Segment TCP UDP g header IP Datagram IP header Ethernet i F Physical headet CS Encapsulation q Ethernet frame p The control of the physical layer is performed by the ENET FWLib which is the Ethernet driver developed by STMicroelectronics for the STR91xFA MAC DMA controller ENET For more information please refer to STR91xFA ENET Firmware Library User Manual UMO248 Application layer The Application Layer is in charge of loading the file The TCP IP stack provides dedicated solutions for file loading over network such as the Trivial File Transfer
Download Pdf Manuals
Related Search
Related Contents
HDB Infrared Remote 120754_Bedanleitung RESQ user manual user manual - Universidad Carlos III de Madrid USER MANUAL Samsung DVD-1080PK Manual de Usuario AS16-ES-2010-04-15 Cambia vincite Manuale Operativo Copyright © All rights reserved.
Failed to retrieve file