AN4872 Application note

Similar documents
AN5123 Application note

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

AN3155 Application note

AN3154 Application note

AN3155 Application note

AN2606 Application note

AN4820 Application note

AN4491 Application note

AN2430 Application note

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

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

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

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

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

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

AN4869 Application note

AN4045 Application note

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

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

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

UM2330 User manual. ST8500 boot. Introduction

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

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

UM2167 User manual. OrCAD PSpice model usage instructions

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

TN1234 Technical note

EVALKITSTKNX. Miniature transceiver STKNX evaluation and development kit. Features

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

Dynamic Electro-Thermal simulator for VIPower products. Description

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

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

Getting started with the X-CUBE-IKA02A1 multifunctional software expansion for STM32Cube

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

UM2255 User manual. SPC58NG-DISP user manual. Introduction

SPC58NE84E7, SPC58NE84C3

AN5153 Application note

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

AN4515 Application note

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

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

Description. July 2016 DocID Rev 2 1/6

AN4274 Application note

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

AN4113 Application note

UM0792 User manual. Demonstration firmware for the DMX-512 communication protocol transmitter based on the STM32F103Zx.

AN2606 Application note

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

AN3965 Application note

AN2792 Application note

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

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

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

DT0095 Design tip. Datalogging the SensorTile through a PC. Purpose and benefits. Description

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

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

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

AN2143 Application note

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

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

AN4696 Application note

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

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

NUCLEO-L433RC-P NUCLEO-L452RE-P

AN3281 Application note

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

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

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

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

TN1235 Technical note

AN3354 Application note

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

AN4311 Application note

TN0189 Technical note

AN2781 Application note

AN2667 Application note

STA bit single chip baseband controller for GPS and telematic applications. Features

AN2261 APPLICATION NOTE

Getting started with X-CUBE-LED channel LED driver software expansion based on LED1642GW for STM32Cube

UM2343 Application note

AN2676 Application note

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

ST19WR08 Dual Contactless Smartcard MCU With RF UART, IART & 8 Kbytes EEPROM Features Contactless specific features

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

DT0063 Design tip. Bluetooth Low Energy network: time-stamping and sample-rate-conversion. Purpose and benefits. BLE wireless link overview

Power line communication expansion board based on ST7580 for STM32 Nucleo. Description

SPC584Cx, SPC58ECx. 32-bit Power Architecture microcontroller for automotive ASIL-B applications. Features

Getting started with the FP-NET-6LPBLE1 function pack for 6LoWPAN IoT node connection to a smartphone via BLE interface

AN4749 Application note

AN5115 Application note

EV-AUTO-LDOS. L5150GJ-L5300AH7-L4995AK Evaluation Board. Applications. Features. Description

Description. January 2019 DB2381 Rev 3 1/5

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

UM2084 User manual. Getting started with the ultra-low-power STM32 and LoRa Nucleo pack. Introduction

STM32H7x3I-EVAL. Evaluation board with STM32H7x3XI MCUs. Data brief. Features

AN2061 APPLICATION NOTE

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

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

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

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

Getting started with the FP-SNS-ALLMEMS1 Bluetooth low energy and sensors software expansion for STM32Cube

Transcription:

Application note BlueNRG-1 and BlueNRG-2 UART bootloader protocol Introduction The BlueNRG-1 and BlueNRG-2 are very low power Bluetooth low energy (BLE) single-mode systemson-chip, compliant with Bluetooth specification. The architecture core is a Cortex-M0 32-bit. This application note contains the specifications of the BlueNRG-1 and BlueNRG-2 UART bootloader. Note: The contents of this document are valid for both BlueNRG-1 and BlueNRG-2 devices. Therefore, any reference to the BlueNRG-1 device is also valid for the BlueNRG-2 device. Specific differences have been highlighted whenever needed. July 2017 DocID029329 Rev 2 1/29 www.st.com

Contents AN4872 Contents 1 UART bootloader configuration... 5 2 UART bootloader activation... 6 3 UART bootloader commands... 7 3.1 Get List command... 7 3.2 Get Version command... 10 3.3 Get ID command... 11 3.4 Read Memory command... 14 3.5 Go command... 16 3.6 Write Memory command... 19 3.7 Erase Memory command... 22 3.8 Readout Protect command... 25 3.9 Readout Unprotect command... 26 4 Revision history... 28 2/29 DocID029329 Rev 2

List of tables List of tables Table 1: BlueNRG-1 and BlueNRG-2 UART bootloader commands... 7 Table 2: Document revision history... 28 DocID029329 Rev 2 3/29

List of figures List of figures AN4872 Figure 1: UART bootloader for BlueNRG-1 and BlueNRG-2 (device side)... 6 Figure 2: Get List command: host side... 8 Figure 3: Get list command: device side... 9 Figure 4: Get Version command: host side... 10 Figure 5: Get Version command: device side... 11 Figure 6: Get ID command: host side... 12 Figure 7: Get ID command: device side... 13 Figure 8: Read Memory command: host side... 14 Figure 9: Read Memory command: device side... 15 Figure 10: Go command: host side... 17 Figure 11: Go command: device side... 18 Figure 12: Write Memory command: host side... 20 Figure 13: Write Memory command: device side... 21 Figure 14: Erase Memory command: host side... 23 Figure 15: Erase Memory command: device side... 24 Figure 16: Readout Protect command: host side... 25 Figure 17: Readout Protect command: device side... 26 Figure 18: Readout Unprotect command: host side... 27 Figure 19: Readout Unprotect command: device side... 27 4/29 DocID029329 Rev 2

UART bootloader configuration 1 UART bootloader configuration To communicate with the BlueNRG-1 and BlueNRG-2 bootloader the host UART has to be configured as follows: UART data 8 bit NO parity Stop bit 1 NO flow control Baud rate range [500 460800] The bootloader is configured to use the UART pin: UART RX = DIO11 UART TX = DIO8 DocID029329 Rev 2 5/29

UART bootloader activation AN4872 2 UART bootloader activation The BlueNRG-1 and BlueNRG-2 bootloader is activated by hardware forcing high DIO7 at device reset. Once the bootloader is activated, the code starts a procedure to auto-detect the host UART baud rate and begins to scan the USART RX line pin, waiting for the 0x7F data frame from the host: one start bit, 0x7F data bits, no parity bit and one stop bit. The duration of this data frame is measured using the Systick timer. The timer count value is then used to calculate the corresponding baud rate factor with respect to the current system clock. Once the baud rate is calculated, the firmware initializes the BlueNRG-1 or BlueNRG-2 serial interface accordingly, using this calculated baud rate. An acknowledge byte (0x79) is returned to the host, which signals that the BlueNRG-1 or BlueNRG-2 is ready to receive commands. Figure 1: UART bootloader for BlueNRG-1 and BlueNRG-2 devices 6/29 DocID029329 Rev 2

UART bootloader commands 3 UART bootloader commands The table below lists the supported commands, fully detailed in the following subsections. Command Get List Command Table 1: BlueNRG-1 and BlueNRG-2 UART bootloader commands Command code 0x00 Command description Get Version 0x01 Gets the bootloader version Get ID 0x02 Gets the chip ID Read Memory Go Write Memory 0x11 0x21 0x31 Gets the version and the allowed commands supported by the current version of the bootloader Reads up to 256 bytes of memory starting from an address specified by the application Jumps to user application code located in the internal Flash memory or in RAM Writes up to 256 bytes to the RAM or Flash memory starting from an address specified by the application Erase 0x43 Erases from one to all the Flash memory pages Readout Protect Readout Unprotect 0x82 0x92 Enables the read protection Disables the read protection All communications from the host to the BlueNRG-1 or BlueNRG-2 device are safe because they are verified by: Checksum: received blocks of data bytes are XORed. A byte containing the computed XOR of all previous bytes is added to the end of each communication (checksum byte). By XORing all received bytes, data + checksum, the result at the end of the packet must be 0x00 For each bootloader command, the host sends a byte and its complement Each packet is either accepted (ACK answer) or discarded (NACK answer): ACK = 0x79 NACK = 0x1F 3.1 Get List command The Get List command allows getting the version of the bootloader and the supported commands. When the BlueNRG-1 or BlueNRG-2 bootloader receives the Get List command, it transmits the bootloader version and the supported command codes to the host. DocID029329 Rev 2 7/29

UART bootloader commands Figure 2: Get List command: host side AN4872 8/29 DocID029329 Rev 2

Figure 3: Get list command: device side UART bootloader commands The BlueNRG-1 or BlueNRG-2 sends the bytes as follows: Byte 1: ACK Byte 2: N = 9 = the number of bytes to follow -1 except current and ACKs. Byte 3: Bootloader version (0 < Version <= 255), example: 0x01 = Version 1.0 Byte 4: 0x00 Get List command Byte 5: 0x01 Get Version command Byte 6: 0x02 Get ID command Byte 7: 0x11 Read Memory command Byte 8: 0x21 Go command Byte 9: 0x31 Write Memory command Byte 10: 0x43 Erase command Byte 11: 0x82 Readout Protect command DocID029329 Rev 2 9/29

UART bootloader commands Byte 12: 0x92 Readout Unprotect command AN4872 Byte 13: ACK. This is the last byte 3.2 Get Version command The Get Version command is used to get the bootloader version. When the bootloader receives the command, it transmits the information shown below to the host. Figure 4: Get Version command: host side 10/29 DocID029329 Rev 2

Figure 5: Get Version command: device side UART bootloader commands The BlueNRG-1 or BlueNRG-2 device sends the bytes as follows: Byte 1: ACK Byte 2: Bootloader version (0 < Version <= 255), example: 0x01 = Version 1.0 Byte 3: Option byte 1: 0x00 Byte 4: Option byte 2: 0x00 Byte 5: ACK 3.3 Get ID command The Get IDcommand is used to get the version of the chip ID (identification). When the bootloader receives the command, it transmits the product ID to the host. DocID029329 Rev 2 11/29

UART bootloader commands Figure 6: Get ID command: host side AN4872 12/29 DocID029329 Rev 2

Figure 7: Get ID command: device side UART bootloader commands The BlueNRG-1 or BlueNRG-2 device sends the bytes as follows: Byte 1: ACK Byte 2: 0x02: the number of bytes -1, except for current byte and ACKs Byte 3-5: PID Byte 6: ACK The Get ID command format returns three bytes: BYTE1: Metal fix version (e.g. cut 1.0 will be 0) BYTE2: Mask set version (e.g cut 1.0 will be 1) BYTE3: is split in two nibbles: 0xHL: H is the product ID: 2 means BlueNRG-2 0 means BlueNRG-1 L is the flash size code: 3: 160 KB (for BlueNRG-1) F: 256 KB (for BlueNRG-2) DocID029329 Rev 2 13/29

UART bootloader commands 3.4 Read Memory command AN4872 The Read Memory command is used to read data from any valid memory address in RAM and Flash memory. When the bootloader receives the Read Memory command, it transmits the ACK byte to the application. Afterwards, the bootloader waits for an address (4 bytes, byte 1 is the address MSB and byte 4 is the LSB) and a checksum byte. If the received address is valid and the checksum is correct, the bootloader transmits an ACK byte, otherwise it transmits a NACK byte and aborts the command. When the address is valid and the checksum is correct, the bootloader waits for N that is the number of bytes to be transmitted 1 and for its complemented byte (checksum). If the checksum is correct it transmits the needed data ((N + 1) bytes) to the application, starting from the received address. If the checksum is not correct, it sends a NACK before aborting the command. If the readout protection is active, a NACK byte is sent to the host when the Read Memory command is received. Figure 8: Read Memory command: host side 14/29 DocID029329 Rev 2

Figure 9: Read Memory command: device side UART bootloader commands DocID029329 Rev 2 15/29

UART bootloader commands The host sends bytes to the BlueNRG-1 or BlueNRG-2 as follows: Byte 1: 0x11 Byte 2: 0xEE Wait for ACK Byte 3 to 6: start address Byte 3: MSB Byte 6: LSB Byte 7: Checksum: XOR of address bytes Wait for ACK Byte 8: Number of bytes to read -1 (0 < N <= 255) Byte 9: Checksum: XOR byte 8 (complement of byte 8) AN4872 3.5 Go command The Go command is used to execute the downloaded code or any other code by jumping to an address specified by the application. When the bootloader receives the Go command, it transmits the ACK byte to the application. Afterwards, the bootloader waits for an address (4 bytes, byte 1 is the address MSB and byte 4 is LSB) and a checksum byte. If the address is valid and the checksum is correct, the bootloader transmits an ACK byte, otherwise it transmits a NACK byte and aborts the command. When the address is valid and the checksum is correct, the bootloader firmware performs the following actions: initializes the registers of the peripherals used by the bootloader to their default reset values initializes the user application main stack pointer jumps to the memory location programmed in the received address + 4 (which corresponds to the address of the application reset handler). For example, if the received address is 0x10040000, the bootloader jumps to the memory location programmed at address 0x10040004. 16/29 DocID029329 Rev 2

Figure 10: Go command: host side UART bootloader commands DocID029329 Rev 2 17/29

UART bootloader commands Figure 11: Go command: device side AN4872 The host sends bytes to the BlueNRG-1 or BlueNRG-2 as follows: Byte 1: 0x21 Byte 2: 0xDE Wait for ACK Byte 3 6: start application address Byte 3: MSB Byte 6: LSB Byte 7: checksum: XOR of address bytes Wait for ACK 18/29 DocID029329 Rev 2

3.6 Write Memory command UART bootloader commands The Write Memory command is used to write data to any valid memory address RAM or Flash memory. When the bootloader receives the Write Memory command, it transmits the ACK byte to the application. Afterwards, the bootloader waits for an address (4 bytes, byte 1 is the address MSB and byte 4 is the LSB) and a checksum byte. If the received address is valid and the checksum is correct, the bootloader transmits an ACK byte, otherwise it transmits a NACK byte and aborts the command. When the address is valid and the checksum is correct, the bootloader performs these actions: gets a byte, N, which contains the number of data bytes to be received receives the user data ((N + 1) bytes) and the checksum (XOR of N and of all data bytes) programs the user data to memory starting from the received address At the end of the command, if the write operation is successful, the bootloader transmits the ACK byte; otherwise it transmits a NACK byte to the application and aborts the command The maximum length of the block to be written for the BlueNRG-1 or BlueNRG-2 is 256 bytes. If the readout protection is active, a NACK byte is sent to the host when the Write Memory command is received. DocID029329 Rev 2 19/29

UART bootloader commands Figure 12: Write Memory command: host side AN4872 20/29 DocID029329 Rev 2

Figure 13: Write Memory command: device side UART bootloader commands The host sends the bytes to the BlueNRG-1 or BlueNRG-2 as follows: Byte 1: 0x31 Byte 2: 0xCE Wait for ACK Byte 3 to byte 6: start address Byte 3: MSB Byte 6: LSB DocID029329 Rev 2 21/29

UART bootloader commands Byte 7: Checksum: XOR (Byte 3, Byte 4, Byte 5, Byte 6) AN4872 Wait for ACK Byte 8: Number of bytes to be received (0< N <= 255) N + 1 data bytes: (Max 256 bytes) Checksum byte: XOR (N, N+1 data bytes) Wait for ACK 3.7 Erase Memory command The Erase Memory command allows the host to erase Flash memory pages. When the bootloader receives the Erase Memory command, it transmits the ACK byte to the host. Afterwards, the bootloader receives one byte (number of pages to be erased), the Flash memory page codes and a checksum byte. If the checksum is correct then the bootloader erases the memory and sends an ACK byte to the host, otherwise it sends a NACK byte to the host and the command is aborted. Erase Memory command specifications are: 1. the bootloader receives one byte that contains N, the number of pages to be erased 1. N= 255 is reserved for mass erase request. For 0 < N <= 79, N + 1 pages are erased. 2. the bootloader receives (N + 1) bytes, each byte containing a page number 22/29 DocID029329 Rev 2

Figure 14: Erase Memory command: host side UART bootloader commands DocID029329 Rev 2 23/29

UART bootloader commands Figure 15: Erase Memory command: device side AN4872 The host sends bytes to the BlueNRG-1 or BlueNRG-2 as follows: Byte 1: 0x43 Byte 2: 0xBC Wait for ACK Byte 3: 0xFF or number of pages to be erased 1 (0 <= N <= maximum number of pages) Byte 4: 0x00 (in case of mass erase) or ((N+1 bytes (page numbers) and then checksum XOR(N, N+1 bytes)) Wait for ACK 24/29 DocID029329 Rev 2

3.8 Readout Protect command UART bootloader commands The Readout Protect command is used to enable the Flash memory read protection. When the bootloader receives the Readout Protect command, it transmits the ACK byte to the host. Afterwards, the bootloader enables the read protection for the Flash memory. At the end of the Readout Protect command, the bootloader transmits the ACK byte and generates a system Reset to take into account the new configuration of the BlueNRG-1 or BlueNRG-2. Figure 16: Readout Protect command: host side DocID029329 Rev 2 25/29

UART bootloader commands Figure 17: Readout Protect command: device side AN4872 3.9 Readout Unprotect command The Readout Unprotect command is used to disable the Flash memory read protection. When the bootloader receives the Readout Unprotect command, it transmits the ACK byte to the host. Afterwards, the bootloader erases all the Flash memory sectors and it disables the read protection for the entire Flash memory. If the erase operation is successful, the bootloader deactivates the Readout Protection. If the erase operation is unsuccessful, the bootloader transmits a NACK and the read protection remains active. At the end of the Readout Unprotect command, the bootloader transmits an ACK and generates a system Reset. 26/29 DocID029329 Rev 2

Figure 18: Readout Unprotect command: host side UART bootloader commands Figure 19: Readout Unprotect command: device side DocID029329 Rev 2 27/29

Revision history AN4872 4 Revision history Table 2: Document revision history Date Version Changes 06-Jul-2016 1 Initial release. 12-Jul-2017 2 Throughout text added references to BlueNRG-2. Minor text edits. 28/29 DocID029329 Rev 2

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. 2017 STMicroelectronics All rights reserved DocID029329 Rev 2 29/29