Home

ST AN3990 handbook

image

Contents

1. the binary file AA Set On blue LED and Read the BUFFER_SIZE bytes from the blink Red LED in infinite loop y Set On Orange LED and blink Red LED in infinite loop binary file and writing them in the FLASH memory Yes ee the remaining binary file size No Blue LED OFF and Green LED ON Download done Close file named DOWNLOAD_FILENAME END BUFFER_SIZE is a user defined variable in the usbh_usr h file that can be modified at compilation BUFFER_SIZE 512 x where x 1 128 limited by firmware The DOWNLOAD command perform the erase of the required flash memory space then perform the program of the defined binary file using the flash word programming mode The Erase operation is performed for the FLASH memory space starting from the user application start address until the end of the flash memory Doc ID 022318 Rev 1 AN3990 Firmware upgrade overview 1 3 2 Note 1 4 UPLOAD command Figure 3 shows how to upload a copy of the internal Flash memory Figure 3 UPLOAD command a ee Check Flash Read Out Yes protection On Protection Status No Protection Off Remove the defined file UPLOAD_FILENAME if exists Y Open a new file named UPLOAD_FILENAME y Blue LED ON Upload on going Lal Read BUFFER_SIZE
2. flash if c Provides a medium layer access to the STM32 embedded Flash driver usb bsp c Implements the board support package for the USB Host library usbh_usr c Includes the USB Host library user callbacks system _stm32f4xx c 2 14 Contains the system clock configuration for STM32 F4xx devices Doc ID 022318 Rev 1 ky AN3990 Firmware upgrade overview Note After the board reset and depending on the user button state 1 User button pressed The firmware upgrade application is executed 2 User button not pressed A test on the user application start address will be performed and one of the below processes is executed User vector table available User application is executed User vector table not available firmware upgrade application is executed During the firmware upgrade application execution there is a continuous check on the user button pressed state time Depending on the state time of the user button one of the following processes is executed Table 2 User button state time control User button state Time Process executed UPLOAD command will be executed immediately after completed execution of the DOWNLOAD command lt 3seconds Only the DOWNLOAD command is executed gt 3 seconds Pressed The UPLOAD command condition verification is signaled by the blinking state of the blue LED Doc ID 022318 Rev 1 3 14 Firmware upgrade over
3. Ti AN3990 YZ Application note Upgrading STM32F4DISCOVERY board firmware using a USB key Introduction An important requirement for most Flash memory based systems is the ability to update the firmware installed in the end product This document provides general guidelines for creating a firmware upgrade application based on the STM32F4DISCOVERY board The STM32F4 series microcontroller can run user specific applications to upgrade the firmware of the microcontroller embedded Flash memory This feature allows the use of any type of communication protocol for the reprogramming process for example CAN USART and USB USB Host mass storage is the example used in this application note The firmware upgrade using a USB Host is very advantageous because it is a standalone executed code in which the user does not need to use a host computer to perform the firmware upgrade The user only needs a Flash disk to upgrade the target STM32 device Document contents e Section 1 Firmware upgrade overview contains an overview of the firmware upgrade process and demonstrates how to run the firmware upgrade Section 2 How to use the firmware upgrade application describes the user program and system requirements for the software and hardware Reference documents STM382F4DISCOVERY STM32F4 high performance discovery board UM1472 STM32F405xx STM32F407xx STM32F415xx and STM32F417xx advanced ARM based 32 bit MCUs reference manual RM
4. bytes in the FLASH memory and write them into the defined file UPLOAD_FILENAME y y Increment the counterread Set On Orange LED and blink Red LED in infinite loop y counterread end of FLASH No Yes Blue LED OFF and Green LED ON Upload done Y Close file named UPLOAD_FILENAME END BUFFERSIZE is a user defined variable in the usbh_usr h file that can be modified at compilation BUFFERSIZE 512 x where x 1 128 limited by firmware When the user selects the UPLOAD command the old UPLOAD BIN file will be deleted and replaced by a new one that contains the new Flash memory data To execute the UPLOAD command the user button should be kept pressed 3s just after a board reset at firmware startup Doc ID 022318 Rev 1 7 14 Firmware upgrade overview AN3990 1 3 3 JUMP command Once the new program has been loaded you can use the JUMP command to execute this image which must be defined from this flash address 0x08008000 Otherwise the user must adapt the firmware to JUMP to another address Figure 4 illustrates the JUMP command flowchart Figure 4 JUMP Command MCU Software Reset END JUMP Note Once the previous command s are performed with success the user green LED is ON and the MCU waits until the user button is pressed before executing the JUMP c
5. target memory and run the project Another option is to use the embedded Bootloader or any in system programming tool to easily reprogram this application Use STM32F4 Discovery_FW_Upgrade_V1 0 0 hex with in system programming tool such as STM32 ST LINK Utility Use STM32F4 Discovery_FW_Upgrade_V1 0 0 dfu with DFUse DFUse Demonstration tool For more details please refer to the Binary images for reprogramming firmware applications section of UM1467 Plug the USB key into the STM32F4DISCOVERY board through USB micro A Male to A Female cable Follow the description provided in section Section 1 1 Implementing the firmware upgrade application on page 2 Doc ID 022318 Rev 1 ky AN3990 How to use the firmware upgrade application 2 3 User program condition The user application binary file to be loaded into the Flash memory using the firmware upgrade application is built by the following configuration settings 1 Set the program load address to APPLICATION_ADDRESS in the toolchain linker file 2 Relocate the vector table to address APPLICATION_ADDRESS using the NVIC_SetVectorTable function or the VECT_TAB_OFFSET definition inside the system stm32f4xx c file Figure 6 Flash memory usage Flash memory 0 x080F FFFF User code User application vector table 0x0800 8000 0x0800 7FFF USB Host firmware upgrade driver Firmware upgrade driver vector table 0x0800 0000 Note 1 Be sure that APPLICATION_ADDR
6. 0090 STM382F405xx STM32F407xx datasheet STM32F415xx STM32F417xx datasheet The above documents are available at www st com stm32f4 discovery October 2011 Doc ID 022318 Rev 1 1 14 www st com Firmware upgrade overview AN3990 1 Firmware upgrade overview To program the firmware upgrade application to the Flash memory use the STM32F4xx s embedded Bootloader or any in system programming tool to easily reprogram this application The firmware upgrade application uses the USB Host to e Download a binary file bin from a Flash disk thumb drive to the STM32F4xx s internal flash memory e Upload all the STM32F4xx s internal Flash memory content into a binary file e Execute the user program Note This application note is based on the STM32 USB On The Go OTG Host and device library For more details about the USB Host stack and a mass storage demonstration please refer to user manual UM1021 1 1 Implementing the firmware upgrade application The firmware upgrade application contains the source files in Table 1 Table 1 Source files File Contents main c Contains the USB initialization data The USB Host state machine is then executed if the user wants to execute the firmware upgrade application or the program will execute the user code stm32f4xx it c Contains the interrupt handlers for the application command c Contains the firmware upgrade commands DOWNLOAD UPLOAD and JUMP commands
7. ALFUNCTION 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 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 2011 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 Philippines Singapore Spain Sweden Switzerland United Kingdom United States of America www st com 14 14 Doc ID 022318 Rev 1 ky
8. ESS do not overlap with firmware upgrade application For example with all options enabled the total read only memory size using EWARM compiler v6 21 with high optimization for size is 17 936 bytes 17 744 bytes of read only code memory and 192 bytes of read only data memory With these results two sectors of 16 Kbytes each will be used to store the firmware upgrade application so the user application flash start address will start from Sector2 Doc ID 022318 Rev 1 11 14 Frequently asked questions FAQs AN3990 3 Note 12 14 Frequently asked questions FAQs How to change the name of the image to be loaded The name of the binary file to be loaded in the USB Key can be changed by personalizing the UPLOAD_FILENAME definition in the command file How to change the name of the image to be downloaded The name of the binary file to be downloaded in the internal flash memory at user application start address can be changed by personalizing the DOWNLOAD_FILENAME definition in the command c file How to change the user application start address The user application start address can be changed by personalizing the APPLICATION_ADDRESS definition in the flash _if h file By editing the user application start address make sure that the user program conditions defined in Section 2 How to use the firmware upgrade application on page 9 are respected How to modify the size of the Flash memory to be u
9. ed or file AA system writing error Error Occurred No Check the Upload Complet condition Yes Green LED ON Upload Done End of Program gt Waiting User Button Pressed in infinity loop MS19633V1 To execute the UPLOAD command the user button should be kept pressed 3s just after a board reset at firmware startup Doc ID 022318 Rev 1 AN3990 Firmware upgrade overview 1 2 LEDs status The following section describes the LEDs behaviors during the firmware upgrade application execution Red LED blinks in infinite loop Error USB key disconnected binary file not available or FATFS file system error e Red LED blinks in infinite loop and Blue LED ON Error No available Flash memory size to load the binary file e Red LED blinks in infinite loop Blue LED ON and Orange LED ON Flash erase error Blue LED ON DOWNLOAD ongoing Blue LED ON and Orange LED ON DOWNLOAD done UPLOAD ongoing e Blue LED blinks UPLOAD condition verified and the user should release the user button e Orange LED ON DOWNLOAD done Orange LED ON Blue LED ON and Red LED blinks in infinite loop USB key read out protection ON Green LED ON and Orange LED OFF DOWNLOAD done with success and the MCU waiting until you press the user button to execute the JUMP command Green LED ON and Orange LED ON DOWNLOAD and UPLOAD done with succes
10. ommand 8 14 Doc ID 022318 Rev 1 ky AN3990 How to use the firmware upgrade application 2 How to use the firmware upgrade application 2 1 System requirements Before running your application you should establish the connection with the STM32F4DISCOVERY board as following in Figure 5 Figure 5 Hardware environment To run the firmware upgrade application on your STM32F4DISCOVERY board the minimum requirements are as follows Microsoft Windows PC 2000 XP Vista 7 e USB type A to Mini B cable used to power the board through USB connector CN1 from host PC and connect to the embedded ST LINK V2 for debugging and programming e USB micro A Male to A Female cable used to connect the USB key through USB connector CN5 as USB Device to host STM32F4xx ky Doc ID 022318 Rev 1 9 14 How to use the firmware upgrade application AN3990 2 2 10 14 Running the firmware upgrade application To run the firmware upgrade application proceed as follows Load the binary image of the user program to the root directory of a USB key You can use the provided binary images STM32F4 Discovery_xxxx_0x08008000 bin under the Project FW_upgrade Binary folder The binary should be renamed to image bin Program the firmware upgrade application into the internal Flash memory 1 a b c Open the project under Project FW_upgrade with your preferred toolchain Compile and load the project into the
11. ploaded The size of the Flash memory to be uploaded can be changed by personalizing the FLASH_SIZE and the FLASH_STARTADDRESS definitions in the flash_if n file When using the CPU frequency 168MHz how much time does the DOWNLOAD command take When the user application start address 0x0800 8000 start from sector 2 the erase operation takes 7 76s With BUFFER_SIZE 512 64 32 Kbytes and image size 25 Kbytes the DOWNLOAD operation takes about 7 94 seconds 7 76s erase time 0 18s program time With BUFFER_SIZE 512 64 32 Kbytes and image size 990 Kbytes the DOWNLOAD operation takes about 12 7 seconds 7 76s erase time 4 94s program time When using the CPU frequency 168MHz how much time does the UPLOAD command take With BUFFERSIZE 512 64 32 Kbytes uploading of all Flash memory 1Mbytes takes about 1 5 seconds Doc ID 022318 Rev 1 ky AN3990 Revision history 4 Revision history Table 4 Document revision history Date Revision Changes 24 Oct 2011 1 Initial release Doc ID 022318 Rev 1 13 14 AN3990 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 product
12. s and the MCU waiting until you press the user button before execute the JUMP command 1 3 Commands description The firmware upgrade application commands are listed in Table 3 Table 3 Supported commands Command Description ae oan UPLOAD Reads the entire embedded Flash memory and saves the contents to the defined file name UPLOAD_FILENAME in the thumb drive JUMP Executes the user code at the defined user application start address APPLICATION_ADDRESS Note The maximum length for the file names DOWNLOAD_FILENAME UPLOAD_FILENAME should be 11 characters as the LFN feature on the FAT file system is a patent of Microsoft Corporation and when enabling it on commercial products a license from Microsoft may be required depending on the final destination Doc ID 022318 Rev 1 5 14 Firmware upgrade overview AN3990 1 3 1 Note 6 14 DOWNLOAD command To download a binary file from the flash thumb drive to the internal STM32F4xx s embedded flash memory the flowchart in Figure 2 DOWNLOAD command is applied Figure 2 DOWNLOAD command C Start DOWNLOAD gt ea Open a binary file named No Binary file not available lt DOWNLOAD_FILENAME saved on the Flash disk 4 y Yes No available Flash memory size to load the binary file heck the available Flash size to loa the binary image Blue LED ON Download on going Y Erase the necessary space to program
13. s 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 M
14. view AN3990 Note 4 14 Figure 1 illustrates the Firmware upgrade application flowchart Figure 1 Upgrade application flowchart Start Program Y Check if User Button No User Button Released Pressed Yes User Button Pressed Y USB Host Process to No Check if vector table enter state machine DOWNLOAD Command heck the availability of the AA image bin file Yes Blue LED ON Download on going Start Download the binary image at user application address Yes USB device protected or file system reading error g Error occurred Check if User Button Released After more than PS LEDON 3s Download On Going Blue LED Blink Download On Red LED blinks in infinite loop going and Upload condition verified A Check the Download Complet condition Yes Blue LED OFF and Orange LED ON Download Done No Green LED ON and Orange LED switched OFF Check Upload Condition User Button End of Program JUMP Command available at User Application Start Address Jump to User Application code User Button Pressed Released after more than 3s UPLOAD Command E Y Upload the image of the device internal flash memory to the upload bin file Yes Blue LED ON Upload On Going Yes Flah memory protected or USB Device protect

Download Pdf Manuals

image

Related Search

ST AN3990 handbook

Related Contents

  TOSHIBA TD6204 08AP handbook                  

Copyright © All rights reserved.
DMCA: DMCA_mwitty#outlook.com.