ST AN3154 Application Note
ST AN3154 Application Note

ST AN3154 Application Note

Can protocol used in the stm32 bootloader
Table of Contents

Advertisement

AN3154
Application note
CAN protocol used
in the STM32™ bootloader
Introduction
This application note describes the CAN protocol used in the STM32 microcontroller
bootloader. It details each supported command. For more information about the CAN
hardware resources and requirements for your device bootloader, please refer to the
"STM32 system memory boot mode" application note (AN2606).
Related documents
Available from www.st.com:
AN2606 "STM32 system memory boot mode"
March 2010
Doc ID 17063 Rev 1
1/34
www.st.com

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the AN3154 and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Summary of Contents for ST AN3154

  • Page 1 It details each supported command. For more information about the CAN hardware resources and requirements for your device bootloader, please refer to the “STM32 system memory boot mode” application note (AN2606). Related documents Available from www.st.com: AN2606 “STM32 system memory boot mode” March 2010 Doc ID 17063 Rev 1 1/34 www.st.com...
  • Page 2: Table Of Contents

    Contents AN3154 Contents Bootloader code sequence ........5 CAN settings .
  • Page 3 AN3154 List of tables List of tables Table 1. CAN bootloader commands ..........8 Table 2.
  • Page 4 List of figures AN3154 List of figures Figure 1. Bootloader for STM32 with CAN..........5 Figure 2.
  • Page 5: Bootloader Code Sequence

    AN3154 Bootloader code sequence Bootloader code sequence Figure 1. Bootloader for STM32 with CAN Once the system memory boot mode is entered and the STM32 device has been configured (for more details refer to application note AN2606 “STM32 system memory boot mode”), the bootloader code waits for a frame on the CANx_Rx pin.
  • Page 6: Figure 2. Check Hse Frequency

    Bootloader code sequence AN3154 Figure 2. Check HSE frequency Next, the code initializes the serial interface accordingly. Using this calculated baud rate, an acknowledge byte (0x79) is returned to the host, which signals that the STM32 is ready to receive commands.
  • Page 7: Can Settings

    AN3154 CAN settings CAN settings The STM32 CAN is compliant with the 2.0A and B (active) specifications with a bitrate up to 1 Mbit/s. It can receive and transmit standard frames with 11-bit identifiers as well as extended frames with 29-bit identifiers.
  • Page 8: Bootloader Command Set

    Bootloader command set AN3154 Bootloader command set The supported commands are listed in Table 1 below. Each command is further described in this section. Table 1. CAN bootloader commands Command Command Command description code Gets the version and the allowed commands...
  • Page 9: Device-Dependent Bootloader Parameters

    AN3154 Bootloader command set Device-dependent bootloader parameters While the CAN bootloader protocol’s command set and sequences are the same for all STM32 devices, some parameters are device-dependent. For a few commands, the value of some parameters may depend on the device used. The concerned parameters are listed below: ●...
  • Page 10: Figure 4. Get Command: Host Side

    Bootloader command set AN3154 Figure 4. Get command: host side 10/34 Doc ID 17063 Rev 1...
  • Page 11: Figure 5. Get Command: Device Side

    AN3154 Bootloader command set The host sends messages as follows: Command message: Std ID = 0x00, data length code (DLC) = ‘not important’. Figure 5. Get command: device side The STM32 sends messages as follows: Message 1: Std ID = 0x00, DLC = 1, data = 0x79...
  • Page 12: Get Version & Read Protection Status Command

    Bootloader command set AN3154 Message 12: Std ID = 0x00, DLC = 1, data = 0x63 - Write Protect command Message 13: Std ID = 0x00, DLC = 1, data = 0x73 - Write Unprotect command Message 14: Std ID = 0x00, DLC = 1, data = 82h...
  • Page 13: Figure 7. Get Version & Read Protection Status Command: Device Side

    AN3154 Bootloader command set Figure 7. Get Version & Read Protection Status command: device side 1. GV = Get Version & Read Protection Status. The STM32 sends messages as follows: Message 1: Std ID = 0x01, DLC = 1, data = ACK Message 2: Std ID = 0x01, DLC = 1, data[0] = bootloader version (0 <...
  • Page 14: Get Id Command

    Bootloader command set AN3154 Get ID command The Get ID command 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. Figure 8. Get ID command: host side 1.
  • Page 15: Figure 9. Get Id Command: Device Side

    AN3154 Bootloader command set Figure 9. Get ID command: device side 1. GID = Get ID. 2. PID stands for product ID. Byte 1 is the MSB and byte 2 is LSB of the address. The STM32 sends the bytes as follows:...
  • Page 16: Speed Command

    Bootloader command set AN3154 Speed command The speed command allows the baud rate for CAN run-time to be changed. It can be used only if CAN is the peripheral being used. A system reset is generated if the CAN receives the correct message but the operation to set the new baudrate fails, which prevents it from entering or leaving initialization mode.
  • Page 17: Figure 11. Speed Command: Device Side

    AN3154 Bootloader command set Figure 11. Speed command: device side The STM32 sends the bytes as follows: Message 1: Std ID = 0x03, DLC = 1, data[0] = ACK= 0x79: with old baudrate if the receive message is correct else data[0] = NACK= 0x1F...
  • Page 18: Read Memory Command

    Bootloader command set AN3154 Read Memory command The Read Memory command is used to read data from any valid memory address (see note) in RAM, Flash memory and in the information block (System memory or option byte areas). Note: Refer to Section 3.1: Device-dependent bootloader parameters...
  • Page 19: Go Command

    AN3154 Bootloader command set Figure 13. Read memory command: device side The STM32 sends messages as follows: ACK message: Std ID = 0x11, DLC = 1, data[0] = ACK if content of the command is correct else data[0] = NACK Data message (N+1) / 8: Std ID = 0x11, DLC = Number of Byte, data[0] = 0xXX...
  • Page 20: Figure 14. Go Command: Host Side

    Bootloader command set AN3154 After sending an ACK message to the application, the bootloader firmware performs the following: ● it initializes the registers of the peripherals used by the bootloader to their default reset values ● it initializes the user application’s main stack pointer ●...
  • Page 21: Write Memory Command

    AN3154 Bootloader command set Figure 15. Go command: device side The STM32 send the messages as follows: ACK message: Std ID = 0x21, DLC = 1, data[0] = ACK if content of the command is correct else data[0] = NACK...
  • Page 22: Figure 16. Write Memory Command: Host Side

    Bootloader command set AN3154 Note: When writing to the RAM, you should take care not to overlap the first RAM memory used by the bootloader firmware. No error is returned when performing write operations on write protected sectors. Write operations to Flash memory/SRAM must be word aligned, if less data are written the remaining bytes must be filled with 0xFF.
  • Page 23: Figure 17. Write Memory Command: Device Side

    AN3154 Bootloader command set Figure 17. Write memory command: device side Start write memory Received message with stdID = 0x31? ROP inactive? Address valid? Send ACK message Receive the ’data messages’ and If a message is corrupted temporarily write the data to RAM...
  • Page 24: Erase Memory Command

    Bootloader command set AN3154 Erase Memory command The Erase Memory command allows the host to erase Flash memory pages. When the bootloader receives the Erase Memory command and ROP is disabled, it transmits the ACK message to the host. After the transmission of the ACK message, the bootloader checks if the message that contain data[0].
  • Page 25: Figure 19. Erase Memory Command: Device Side

    AN3154 Bootloader command set Figure 19. Erase Memory command: device side The STM32 sends messages as follows: ACK message: Std ID = 0x43, DLC = 1, data[0] = ACK if content of the command is correct and ROP is not active else data[0] = NACK...
  • Page 26: Write Protect Command

    Bootloader command set AN3154 3.10 Write Protect command The Write Protect command is used to enable the write protection for some or all Flash memory sectors. When the bootloader receives the Write Protect command, it transmits the ACK message to the host if ROP is disabled else it transmits NACK.
  • Page 27: Write Unprotect Command

    AN3154 Bootloader command set Figure 21. Write Protect command: device side 1. WP = Write Protect The STM32 sends messages as follows: ACK message: Std ID = 0x43, DLC = 1, data[0] = ACK if the content of the command is correct and ROP is not active else data[0] = NACK.
  • Page 28: Figure 22. Write Unprotect Command: Host Side

    Bootloader command set AN3154 Figure 22. Write Unprotect command: host side 1. WPUN = Write Unprotect. The host sends messages as follows: Command message: Std ID = 0x73, DLC = 0x01, data = 00. Figure 23. Write Unprotect command: device side 1.
  • Page 29: Readout Protect Command

    AN3154 Bootloader command set The STM32 sends messages as follows: ACK message: Std ID = 0x73, DLC = 1, data[0] = ACK if the content of the command is correct and ROP is not active else data[0] = NACK. 3.12 Readout Protect command The Readout Protect command is used to enable the Flash memory read protection.
  • Page 30: Readout Unprotect Command

    Bootloader command set AN3154 Figure 25. Readout Protect command: device side 1. RDP_PRM = Readout Protect The STM32 sends messages as follows: ACK message: Std ID = 0x82, DLC = 1, data[0] = ACK if the content of the command is correct and ROP is not active else data[0] = NACK.
  • Page 31: Figure 26. Readout Unprotect Command: Host Side

    AN3154 Bootloader command set Figure 26. Readout Unprotect command: host side 1. RDU_PRM = Readout Unprotect. The host sends messages as follows Command message: Std ID = 0x92, DLC = 0x01, data = 00. Figure 27. Readout Unprotect command: device side...
  • Page 32: Bootloader Protocol Version Evolution

    Bootloader protocol version evolution AN3154 Bootloader protocol version evolution Table 2 lists the bootloader versions. Table 2. Bootloader protocol versions Version Description V2.0 Initial bootloader version. 32/34 Doc ID 17063 Rev 1...
  • Page 33: Revision History

    AN3154 Revision history Revision history Table 3. Document revision history Date Revision Changes 09-Mar-2010 Initial release. Doc ID 17063 Rev 1 33/34...
  • Page 34 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.

Table of Contents