AN4491 Application note

Similar documents
AN4872 Application note

STSW-BLUENRG1-DK. BlueNRG-1, BlueNRG-2 DK SW package

STSW-BNRGUI. BlueNRG GUI SW package. Data brief. Features. Description

AN5123 Application note

UM2330 User manual. ST8500 boot. Introduction

AN4045 Application note

TN1234 Technical note

STSW-STWBCFWDT. STWBC firmware downloader tool. Description. Features

UM2167 User manual. OrCAD PSpice model usage instructions

RN0084 Release note. ST-LINK/V2 firmware upgrade. About this release note

Dynamic Electro-Thermal simulator for VIPower products. Description

AN4869 Application note

AN4820 Application note

L9958 Evaluation board for high current (8.6A) DC and Stepper Motors. Description

How to configure the BlueNRG-1 and BlueNRG-2 devices in network coprocessor mode. Main components Bluetooth Low Energy wireless system-on-chip

Table 1: Device summary Part numbers Device info (stored in register 0xF0 and 0xF1) Comment SPIRIT1QTR 0x0130 Cut 3.0

UM1844 User manual. EVAL-L9958 Graphical user interface (GUI) Introduction

AN3154 Application note

Description. January 2019 DB2381 Rev 3 1/5

Description. July 2016 DocID Rev 2 1/6

The BlueNRG-1, BlueNRG-2 BLE OTA (over-the-air) firmware upgrade

AN5153 Application note

ST25DV-DISCOVERY. Discovery kit for the ST25DV04K dynamic NFC/RFID tag. Features

Getting started with STEVAL-IDB007V1 and STEVAL-IDB008V1 evaluation boards

AN2430 Application note

X-NUCLEO-53L0A1. Ranging and gesture detection sensor expansion board based on VL53L0X for STM32 Nucleo. Description. Features

P-NUCLEO-USB001. STM32 Nucleo pack for USB Type-C and Power Delivery. Features. Description

Bluetooth low energy profiles for the X-CUBE-BLE1 expansion for STM32Cube. Description

STSW-BNRG-Mesh. Mesh over Bluetooth low energy. Features. Description. Applications

P-NUCLEO-USB001. STM32 Nucleo pack for USB Type-C and Power Delivery Data brief. Features. Description

AN5115 Application note

UM2361. Getting started with the ST BlueNRG-Mesh ios application. User manual. Introduction

P-NUCLEO-IKA02A1. STM32 Nucleo pack: electrochemical toxic gas sensor expansion board with CO sensor. Description. Features

ST Payment Secure Solution Java Card platform with up to 100 Kbytes of user NVM for AMEX payment applications

A scalable approach to your body, networking and security platforms. Description

X-NUCLEO-53L1A1. Long distance ranging Time-of-Flight sensor expansion board based on VL53L1X for STM32 Nucleo. Description.

STSW-L9960, STSW-L9960T Graphical User Interface (GUI) for EVAL-L9960 & EVAL-L9960T

Kinetis Bootloader to Update Multiple Devices in a Field Bus Network

ST Payment Secure Solution - Java Card platform with up to 90 Kbytes of user NVM for Visa, MasterCard, AMEX, Discover and Interac applications

EVALKITSTKNX. Miniature transceiver STKNX evaluation and development kit. Features

AN3354 Application note

AN3281 Application note

AN3965 Application note

Using the GPIOs and interrupt controller to drive LEDs on STM8 Nucleo-64 boards

Motor control power board based on the SLLIMM-nano 2 nd series

UM2119 User manual. Graphical user interface (GUI) for EVAL-L9907-H. Introduction

AN2261 APPLICATION NOTE

AN4838. Managing memory protection unit (MPU) in STM32 MCUs. Application note. Introduction

300 ma triple DC-DC converter for powering AMOLED displays. Description. Table 1: Device summary Negative voltage. Auxiliary positive voltage

UM1641 User manual. Sampling rate conversion SRC236 library software expansion for STM32Cube. Introduction

NUCLEO-L496ZG. STM32 Nucleo-144 board. Features. Description

NUCLEO-L433RC-P NUCLEO-L452RE-P

TN0189 Technical note

STEVAL-SPBT4ATV3. USB dongle for the Bluetooth class 1 SPBT2632C1A.AT2 module. Features. Description

UM2092 User manual. Basic metrology firmware for the STM32F103RD and the STPM32 devices. Introduction

Getting started with the digital MEMS microphone expansion board based on MP34DT01-M for STM32 Nucleo

USB Type-C and Power Delivery Nucleo pack with NUCLEO-F072RB expansion board based on STUSB1602. Description

STEVAL-IPMnM2N. Motor control power board based on the SLLIMM-nano 2 nd series. Description. Features. RoHS compliant

AN2667 Application note

Getting started with MotionPM real-time pedometer library in X CUBE-MEMS1 expansion for STM32Cube

UM2255 User manual. SPC58NG-DISP user manual. Introduction

ST33F1M. Smartcard MCU with 32-bit ARM SecurCore SC300 CPU and 1.25 Mbytes high-density Flash memory. Features. Hardware features.

UM2051 User manual. Getting started with the STM32 Nucleo pack for USB Type-C and Power Delivery. Introduction

AN2676 Application note

AN2061 APPLICATION NOTE

UM2343 Application note

AN2792 Application note

SPC58EHx,SPC58NHx. A scalable approach for high-end body, networking and security platforms for Automotive. Description. Features

EVAL6494L. Demonstration board for L6494L gate driver. Description. Features

TN1235 Technical note

STM32 Trusted Package Creator tool software description

AN4696 Application note

UM0693 User manual. 1 Introduction. STM8L101-EVAL demonstration firmware

UM2379. The BlueNRG-1, BlueNRG-2 radio driver. User manual. Introduction

AN4749 Application note

AN2143 Application note

Interpreting humidity and temperature readings in the HTS221 digital humidity sensor

AN3188 Application note

Description SPC564A-DISP. March 2014 DocID Rev 3 1/5

External memory code execution on STM32F7x0 Value line and STM32H750 Value line MCUs

AN4782 Application note

UM2356 User manual. VL53L1X API user manual. Introduction

Software GUI user guide for STEVAL-ISV021V1, STEVAL- IDS002V1 and STEVAL-IDS003V1 evaluation boards

EVALSTGAP1AS. Demonstration board for STGAP1AS galvanically isolated single gate driver. Description. Features

AN4777 Application note

How to upgrade the firmware on the STEVAL-USBC2DP USB Type-C to DisplayPort adapter

AN2606 Application note

32F412GDISCOVERY. Discovery kit with STM32F412ZG MCU. Features. Description

TN1251 Technical note

UM2216 User manual. Getting started with MotionFA fitness activity library in X CUBE MEMS1 expansion for STM32Cube. Introduction

AN2594 Application note

EVLKSTCOMET10-1. STCOMET smart meter system-on-chip development kit. Features

32L476GDISCOVERY. Discovery kit with STM32L476VG MCU. Features. Description

AN3155 Application note

ST21NFCB. Near field communication controller. Features. RF communications. Hardware features. Communication interfaces. Electrical characteristics

Getting started with the STM32 Nucleo pack for USB Type-C and Power Delivery with the Nucleo-F072RB board and the STUSB1602

STEVAL-PCC010V1. ST802RT1A Ethernet PHY demonstration board with STM32F107 controller add-on board. Features. Description

UM2350. Getting started with MotionPW real-time pedometer for wrist library in X-CUBE-MEMS1 expansion for STM32Cube. User manual.

Sub-1 GHz RF expansion board based on the SPSGRF-868 module for STM32 Nucleo. Description

EMIF06-USD14F3. 6-line low capacitance IPAD for micro-sd card with EMI filtering and ESD protection. Applications. Description. Features.

Transcription:

Application note BlueNRG, BlueNRG-MS updater Introduction Note: This document describes the updater functionality of BlueNRG and BlueNRG-MS devices. The document content is valid for both BlueNRG and BlueNRG-MS devices. Any specific difference is highlighted whenever it is needed. December 2016 DocID026337 Rev 3 1/ www.st.com

Contents AN4491 Contents 1 Description................................................. 3 2 CRC....................................................... 4 3 Updater BLUE flag........................................... 5 4 Entering updater mode....................................... 6 5 Evt_BlueBlue_Initialized...................................... 7 6 Updater commands.......................................... 8 6.1 aci_updater_start............................................ 8 6.2 aci_updater_reboot.......................................... 9 6.3 aci_get_updater_version...................................... 9 6.4 aci_get_updater_buffer_size.................................. 10 6.5 aci_erase_blue_flag......................................... 10 6.6 aci_reset_blue_flag..........................................11 6.7 aci_updater_erase_sector.....................................11 6.8 aci_updater_program_data_block.............................. 12 6.9 aci_updater_read_data_block................................. 13 6.10 aci_updater_calc_crc........................................ 14 7 Firmware update algorithm.................................. 16 8 IFR update algorithm....................................... 17 9 Revision history........................................... 18 2/ DocID026337 Rev 3

Description 1 Description The updater is an independent program that resides within the BlueNRG device. It allows changing of the BlueNRG firmware, by receiving a new version via serial port (SPI), and reprogramming the Flash memory. The updater cannot change itself. The updater is allocated in a section of the NVM (non-volatile-memory) of the device (Flash or ROM). When the updater is in Flash, the first sector is used, i.e. 2 KB. Figure 1 and Figure 2 below show the Flash layouts of the BlueNRG and BlueNRG-MS devices. Specific software such as the IFR, and the BlueNRG and BlueNRG-MS firmware stacks are indicated in addition to the area where the Updater is stored. On BlueNRG-MS Updater is stored on device ROM. Figure 1. BlueNRG Flash layout Updater (in FLASH1, 2 Kbytes) BlueNRG firmware stack (in FLASH1, 62 Kbytes) BlueNRG firmware stack + IFR data (in FLASH2, 2 Kbytes) Figure 2. BlueNRG-MS Flash layout BlueNRG-MS firmware stack (in FLASH1, 64 Kbytes) BlueNRG-MS IFR data (in FLASH2, last 2 bytes) On BlueNRG, as a separate program, the updater is able to work without the BlueNRG firmware. Even if the BlueNRG firmware is corrupted, or if the 62 KB firmware region and/or 2 KB IFR Flash are empty, the updater is still able to turn on the system, wait to receive new firmware, and then update the Flash. So it can safeguard the system and bring it back to a known working state. DocID026337 Rev 3 3/

CRC AN4491 2 CRC The updater can perform 32-bit CRC calculation to verify the data stored inside the Flash. This is done by an updater command. The command returns the CRC result and the user can compare it with the previously calculated values. If it does not match, it means the Flash data is corrupted. The common IEEE CRC 32 polynomial is used: x 32 + x 26 + x 23 + x 22 + x 16 + x 12 + x 11 + x 10 + x 8 + x 7 + x 5 + x 4 + x 2 + x + 1 The user must choose at least 1 Flash sector (2 KB) to do the CRC calculation. It is also allowed to do CRC calculation for more continuous FLASH sectors. 4/ DocID026337 Rev 3

Updater BLUE flag 3 Updater BLUE flag Note: There are 4 bytes of data stored in the firmware region as a flag (called BLUE flag). When the flag is set to a particular known value, it indicates that there is a valid firmware stored in the Flash. When new firmware programming is started, a special command should first be called to erase the BLUE flag. The flag should be set only at the end of the programming phase, if the firmware is correctly updated. So, if the firmware update procedure is not properly done, the flag is not set and the updater will be forced to stay in the program mode. This mechanism prevents BlueNRG from running a corrupted firmware that will cause unexpected malfunctioning. The BlueFlag word is stored at the 0x100108C0 location. DocID026337 Rev 3 5/

Entering updater mode AN4491 4 Entering updater mode The updater can be started in two different ways: Through the ACI command, when in normal operation (see Section 6.1: aci_updater_start). Using the IRQ pin during hardware reset. If the IRQ pin is detected high during BlueNRG startup (power-up or hardware reset), BlueNRG enters updater mode. The startup phase of BlueNRG (hardware and firmware) takes about 3 ms. To be sure that IRQ is detected high during startup, it is recommended to keep it high for at least 4 ms after Reset has been released. 6/ DocID026337 Rev 3

Evt_BlueBlue_Initialized 5 Evt_BlueBlue_Initialized When the BlueNRG firmware is started normally, it gives a Evt_Blue_Initialized event to the user to indicate the system has started. The Evt_Blue_Initialized event is an ACI event with the same format as the other events. Figure 3. ACI event It is a vendor specific HCI event (event code 0xFF). In Table 1 all the fields are described. Table 1. Evt_Blue_Initialized event BlueNRG Event Code 1 byte 0x0001 - The event code for Evt_Blue_Initialized event Reason code 1 byte 0x01 Application started properly 0x02 Updater mode entered because of Updater_Start command 0x03 - Updater mode entered because of a bad BLUE flag 0x04 - Updater mode entered because of IRQ pin high DocID026337 Rev 3 7/

Updater commands AN4491 6 Updater commands Once updater mode is entered, the updater first reports a Evt_Blue_Initialized event, as described in the previous section. Then it continues checking the SPI interface to receive commands. The updater only responds to certain updater commands, listed below. The updater supports no other commands. Once entered, the updater stays in this mode unless clearly asked to exit by a command (aci_updater_reboot) or a HW reset. For each command, the updater acknowledges with standard Command Complete event. The commands and events are in the format as the same as other ACI commands. The updater supports only the following commands: aci_updater_start aci_updater_reboot aci_get_updater_version aci_get_updater_buffer_size aci_erase_blue_flag aci_reset_blue_flag aci_updater_erase_sector aci_updater_program_data_block aci_updater_read_data_block aci_updater_calc_crc aci_updater_hw_version 6.1 aci_updater_start Table 2. aci_updater_start Command name Parameters Return aci_updater_start (0xFC20) This command is only implemented together with the normal application. The updater does not support this command. If this command is called, the system reboots and enters updater mode. Table 3. aci_updater_start return parameters 1 byte 0x00: BLE_STATUS_SUCCESS Event(s) generated: The controller will generate a command complete event. 8/ DocID026337 Rev 3

Updater commands 6.2 aci_updater_reboot Table 4. aci_updater_reboot Command name Parameters Return aci_updater_reboot (0xFC21) This command reboots the system. This command does not set the BLUE flag, which must be done by another command. Table 5. aci_updater_reboot return parameters 1 byte 0x00: BLE_STATUS_SUCCESS Event(s) generated: The controller will generate a command complete event. 6.3 aci_get_updater_version Table 6. aci_get_updater_version Command name Parameters Return aci_get_updater_version (0xFC22) Version This command returns the version of the Updater. Table 7. aci_get_updater_version return parameters 1 byte 0x00: BLE_STATUS_SUCCESS Version 1 byte 0x00: If an error occurred 0xXX: Updater Version ID Event(s) generated: The controller will generate a command complete event. DocID026337 Rev 3 9/

Updater commands AN4491 6.4 aci_get_updater_buffer_size Table 8. aci_get_updater_buffer_size Command name Parameters Return aci_get_updater_buffer_size (0xFC23) Buffer Size Return the maximum buffer size. This value limits the size of the data blocks that could be used on the command aci_updater_program_data_block. Table 9. aci_get_updater_buffer_size return parameters 1 byte 0x00: BLE_STATUS_SUCCESS Buffer Size 2 bytes Size of the buffer, unit in bytes Event(s) generated: The controller will generate a command complete event. 6.5 aci_erase_blue_flag Table 10. aci_erase_blue_flag Command name Parameters Return aci_erase_blue_flag (0xFC24) This command erases the BLUE flag in the Flash. After this operation, the updater cannot jump to the firmware until the BLUE flag is set to a valid value with aci_reset_blue_flag. This command is strongly recommended when the updater wants to upgrade the firmware application. Table 11. aci_erase_blue_flag return parameters 1 byte 0x00: BLE_STATUS_SUCCESS Event(s) Generated: The controller will generate a command complete event. 10/ DocID026337 Rev 3

Updater commands 6.6 aci_reset_blue_flag Table 12. aci_reset_blue_flag Command name Parameter Return aci_reset_blue_flag (0xFC25) Reset the BLUE flag to its proper value. This command must be called when the firmware upgrade is finished. So that after reboot, the update may jump to the firmware application. Table 13. aci_reset_blue_flag return parameters 1 byte 0x00: BLE_STATUS_SUCCESS 0x4A: Blue Flag failed to be set The reason of failure is normally because the Flash sector is not erased before using the ResetBlueFlag command. Event(s) generated: The controller will generate a command complete event. 6.7 aci_updater_erase_sector Table 14. aci_updater_erase_sector Command name Parameters Return aci_updater_erase_sector (0xFC26) Sector Base Address This command erases one sector of the Flash memory. One sector is 2 KB. After erasing, the sector will be all 0xFF. DocID026337 Rev 3 11/

Updater commands AN4491 Table 15. aci_updater_erase_sector command parameters Address 4 bytes Base address of the sector to be erased Sector 0: 0x10010000 (Updater sector, forbidden) Sector 1: 0x10010800 Sector 2: 0x10011000 Sector 3: 0x10011800 Sector 4: 0x10012000 Sector 5: 0x10012800... Sector 30: 0x1001F000 Sector 31: 0x1001F800 Sector 32: 0x10020000 (IFR sector) Only the based address listed here from Sector 1-32 are allowed. Other values will be rejected Note: Don't erase sector 0. Table 16. aci_updater_erase_sector return parameters 1 byte 0x00: BLE_STATUS_SUCCESS 0x12: Invalid HCI parameter If the base address given in the command is not the one listed. Event(s) generated: The controller will generate a command complete event. 6.8 aci_updater_program_data_block Table 17. aci_updater_program_data_block Command name Parameters Return aci_updater_program_data_block (0xFC27) Base Address Data Length Data This command writes a block of data to the Flash, starting from the given base address. 12/ DocID026337 Rev 3

Updater commands Table 18. aci_updater_program_data_block command parameters Address 4 bytes Initial address to start the writing of the data Data Length 2 bytes Length of the data (unit in bytes) Data 0-N bytes Data to be programmed Table. aci_updater_program_data_block return parameters 1 byte 0x00: BLE_STATUS_SUCCESS 0x12: Invalid HCI parameters This may happen if there is an attempt to write outside the allowed range. Event(s) generated: The controller will generate a command complete event went the data has been programmed. 6.9 aci_updater_read_data_block Table 20. aci_updater_read_data_block Command name Parameters Return aci_updater_read_data_block (0xFC28) Base Address Data Length Data Note: This command reads a block of data from the Flash, starting from the given base address. For it is only allowed to read from the IFR flash. So the Base Address must be bigger than 0x10020000. Table 21. aci_updater_read_data_block command parameters Address 4 bytes Initial address Data 2 bytes Length of the data (unit in bytes) DocID026337 Rev 3 13/

Updater commands AN4491 Table 22. aci_updater_read_data_block return parameters 1 byte 0x00: BLE_STATUS_SUCCESS 0x12: Invalid HCI parameters This may happen if there is an attempt to read outside the allowed range Data 0-N bytes Data read Event(s) generated: The controller will generate a command complete event. 6.10 aci_updater_calc_crc Table 23. aci_updater_calc_crc Command name Parameters Return aci_updater_calc_crc (0xFC29) Base Address Number of Sectors CRC Value It calculates the CRC32 of one or more Flash sectors. One Flash sector is 2 KB (see also Section 2). Table 24. aci_updater_calc_crc command parameters Address Number of sectors 4 bytes 1 byte Base address of the sector to calculate CRC Sector 0: 0x10010000 Sector 1: 0x10010800 Sector 2: 0x10011000 Sector 3: 0x10011800 Sector 4: 0x10012000 Sector 5: 0x10012800... Sector 30: 0x1001F000 Sector 31: 0x1001F800 Sector 32: 0x10020000 (IFR sector) Only the values listed here are allowed. Other values will be rejected. Number of continuous Flash sectors to be calculated. Should be between 1 and 32. E.g. if the base address is 0x10011000, and the number of sectors is 3, it will calculate the 6 KB address starting from 0x10011000 14/ DocID026337 Rev 3

Updater commands Table 25. aci_updater_calc_crc return parameters 1 byte 0x00: BLE_STATUS_SUCCESS 0x12: Invalid HCI parameters This may happen if there is an attempt to read outside the allowed range CRC Value 4 bytes CRC32 value calculated for the region Event(s) generated: The controller will generate a command complete event. DocID026337 Rev 3 15/

Firmware update algorithm AN4491 7 Firmware update algorithm Note: The updater client should adhere to the following procedure when updating the firmware stack: 1. Enter updater mode with IRQ pin or aci_updater_start command 2. Wait for the Evt_Blue_Initialized and check the reason code to be sure that the device has booted in updater mode 3. Read updater version (optional). 4. Read updater buffer size to know the maximum data block that can be written in a single aci_updater_program_data_block command. 5. Clear BLUE flag. 6. Erase sectors containing the firmware: a) Sectors from 1 to 32 on BlueNRG (sector 0 contains bootloader and it is forbidden to erase or write into it). Sector 32 must be erased since it also contains firmware code. b) Sectors from 0 to 31 on BlueNRG-MS. Erase also sector 32 if IFR configuration is programmed during firmware update phase. 7. Write new firmware data with aci_updater_program_data_block command and IFR configuration if sector 32 has been erased. 8. Run aci_updater_calc_crc command, which generates the CRC calculation based on the loaded firmware. 9. If the CRC is OK, reset the BLUE flag. Otherwise notify the application or retry the whole procedure. 10. Reset the device or send aci_updater_reboot command to reboot the system. If IFR is changed during the update, a hardware reset is mandatory. It is also possible to switch off the power. This algorithm assumes that the firmware image has the BLUE flag at offset 0x08C0 set to 0xFFFFFFFF. 16/ DocID026337 Rev 3

IFR update algorithm 8 IFR update algorithm The updater client should adhere to the following procedure when updating the IFR configuration: 1. Enter updater mode with IRQ pin or aci_updater_start command 2. Wait for the Evt_Blue_Initialized and check the reason code to be sure that the device has booted in updater mode 3. Read updater version (optional). 4. Read updater buffer size to know the maximum data block that can be written in a single aci_updater_program_data_block command. 5. For BlueNRG only, dump the IFR sector using aci_updater_read_data_block command 6. Erase IFR sector 32 7. For BlueNRG only, write the dumped IFR sector except for the last 2 bytes, where IFR configuration is stored. 8. Write IFR configuration in the last 2 bytes of IFR sector by using aci_updater_program_data_block command. 9. Verify that the sector has been correctly programmed. aci_updater_read_data_block command can be used to read sector content. 10. Reset the device to reboot the system. It is also possible to switch off the power. DocID026337 Rev 3 17/

Revision history AN4491 9 Revision history Table 26. Document revision history Date Revision Changes 29-May-2014 1 Initial release. 18-Jan-2016 2 Added reference to BlueNRG-MS device. -Dec-2016 3 Updated Section 7: Firmware update algorithm, added new Section 8: IFR update algorithm and BlueFlag address location. 18/ DocID026337 Rev 3

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. 2016 STMicroelectronics All rights reserved DocID026337 Rev 3 /