background image

March 2010

Doc ID 17063 Rev 1

1/34

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”

www.st.com

Summary of Contents for AN3154

Page 1: ...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...

Page 2: ...3 Get Version Read Protection Status command 12 3 4 Get ID command 14 3 5 Speed command 16 3 6 Read Memory command 18 3 7 Go command 19 3 8 Write Memory command 21 3 9 Erase Memory command 24 3 10 Wr...

Page 3: ...AN3154 List of tables Doc ID 17063 Rev 1 3 34 List of tables Table 1 CAN bootloader commands 8 Table 2 Bootloader protocol versions 32 Table 3 Document revision history 33...

Page 4: ...12 Read memory command host side 18 Figure 13 Read memory command device side 19 Figure 14 Go command host side 20 Figure 15 Go command device side 21 Figure 16 Write Memory command host side 22 Figu...

Page 5: ...lication note AN2606 STM32 system memory boot mode the bootloader code waits for a frame on the CANx_Rx pin When a detection occurs the CAN bootloader firmware starts to check the external clock frequ...

Page 6: ...X AND WITHOUT FRAME ERROR AI B ONFIGURE BAUDRATE AT KBPS ASSUMING THAT 3 Z NITIALIZE TIMEOUT AT MS ECREMENT TIMEOUT 4IMEOUT X ONFIGURE BAUDRATE AT KBPS ASSUMING THAT 3 Z NITIALIZE TIMEOUT AT MS O 9ES...

Page 7: ...ff Tx identifier 0x00 0x01 0x02 v03 0x11 0x21 0x31 0x43 0x63 0x73 0x82 0x92 The receive settings from the host to the STM32 are Synchronization byte 0x79 is in the RX identifier and not in the data fi...

Page 8: ...of the bootloader Get Version Read Protection Status 1 0x01 Gets the bootloader version and the Read Protection status of the Flash memory Get ID 1 0x02 Gets the chip ID Speed 0x03 The speed command...

Page 9: ...memory option byte areas accepted by the bootloader when the Read Memory Go and Write Memory commands are executed Size of the Flash memory sector used when executing the Write Protect command For mo...

Page 10: ...7AIT FOR OR 2ECEIVE MESSAGE ET COMMAND 2ECEIVE MESSAGE 3PEED COMMAND 2ECEIVE MESSAGE 2EAD COMMAND 2ECEIVE MESSAGE O COMMAND 2ECEIVE MESSAGE 7RITE MEMORY COMMAND 2ECEIVE MESSAGE RASE MEMORY COMMAND 2E...

Page 11: ...x00 Get command Message 5 Std ID 0x00 DLC 1 data 0x01 Get Version Read Protection Status command Message 6 Std ID 0x00 DLC 1 data 0x02 Get ID command Message 7 Std ID 0x00 DLC 1 data 0x03 Speed comman...

Page 12: ...us When the bootloader receives the command it transmits the information described below version read protection number of times it was enabled and disabled to the host Figure 6 Get Version Read Prote...

Page 13: ...as follows Message 1 Std ID 0x01 DLC 1 data ACK Message 2 Std ID 0x01 DLC 1 data 0 bootloader version 0 version 255 example 0x10 Version 1 0 Message 3 Option message 1 Std ID 0x01 DLC 2 data 0x00 byte...

Page 14: ...GID Get ID 2 PID stands for product ID Byte 1 is the MSB and byte 2 the LSB of the address Refer to Section 3 1 Device dependent bootloader parameters for more details about the PID of the device you...

Page 15: ...TM32 sends the bytes as follows Message 1 Std ID 0x02 DLC 1 data ACK with DLC except for current message and ACKs Message 2 Std ID 0x02 DLC N the number of bytes 1 For STM32 N 1 data PID with byte 0 i...

Page 16: ...lization mode Figure 10 Speed command host side 1 After setting the new baud rate the bootloader sends the ACK message Therefore the host sets its baud rate while waiting for the ACK The host sends th...

Page 17: ...age is correct else data 0 NACK 0x1F Message 2 Std ID 0x02 DLC 1 data 0 ACK 0x79 with new baudrate 2ECEIVED A MESSAGE WITH STD X AND WITH VALID DATA 3TART SPEED COMMAND O 9ES ND OF SPEED COMMAND AI HA...

Page 18: ...rect or not ReadOutProtection is disabled or enabled Address to be read is valid or not If the message content is correct it transmits an ACK message otherwise it transmits a NACK message After sendin...

Page 19: ...aded code or any other code by branching to an address specified by the application When the bootloader receives the Go command it starts if the message contains the following valid information ID of...

Page 20: ...on sets the vector table correctly to point to the application address 2 The valid addresses for the Go command are in RAM or Flash memory refer to Section 3 1 Device dependent bootloader parameters f...

Page 21: ...addresses for the device you are using If the received address is valid the bootloader transmits an ACK message otherwise it transmits a NACK message and aborts the command When the address is valid...

Page 22: ...s as follows Command message Std ID 0x31 DLC 0x05 data 0 0xXX MSB address data 3 0xYY LSB address data 4 N number of bytes to be written 0 N 255 then the host send N 8 message Data message Std ID 0x31...

Page 23: ...corrupted Write the received data to RAM from the start address Write the received data to RAM from the start address Write the received data to RAM from the start address ai15719b Address in Flash A...

Page 24: ...or global erase requests For 0 N 254 N 1 pages are erased 2 The bootloader receives N 1 bytes each byte containing a page number Note No error is returned when performing erase operations on write pro...

Page 25: ...0x43 DLC 1 data 0 ACK if content of the command is correct and ROP is not active else data 0 NACK RASE MEMORY PAGE BY PAGE O 3TART RASE EMORY MESSAGES DATA FIELD 2ECEIVED MESSAGE 3END MESSAGE ND OF E...

Page 26: ...ers for more details about the sector size for the device you are using 2 The total number of sectors and the sector number to be protected are not checked this means that no error is returned when a...

Page 27: ...Write Unprotect command it transmits the ACK message to the host if ROP is disabled else it transmits NACK After the transmission of the ACK message the bootloader disables the write protection of al...

Page 28: ...ommand message Std ID 0x73 DLC 0x01 data 00 Figure 23 Write Unprotect command device side 1 WPUN Write Unprotect 7AIT FOR OR 7AIT FOR OR ND OF 705 AI 3END 7RITE UNPROTECT MESSAGE STD X 3TART 705 2EMOV...

Page 29: ...e ACK message to the host if ROP is disabled else it transmits NACK After the transmission of the ACK message the bootloader enables the read protection for the Flash memory At the end of the Readout...

Page 30: ...Readout Unprotect command it transmits the ACK message to the host After the transmission of the ACK message the bootloader erases all the Flash memory sectors and it disables the read protection for...

Page 31: ...e 1 RDU_PRM Readout Unprotect The STM32 sends messages as follows ACK message Std ID 0x92 DLC 1 data 0 ACK if the content of the command is correct and ROP is not active else data 0 NACK 7AIT FOR OR 7...

Page 32: ...l version evolution AN3154 32 34 Doc ID 17063 Rev 1 4 Bootloader protocol version evolution Table 2 lists the bootloader versions Table 2 Bootloader protocol versions Version Description V2 0 Initial...

Page 33: ...AN3154 Revision history Doc ID 17063 Rev 1 33 34 5 Revision history Table 3 Document revision history Date Revision Changes 09 Mar 2010 1 Initial release...

Page 34: ...ARRANTIES 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 UNLE...

Reviews: