Example: stock market

Can protocol used in the STM32 bootloader …

June 2021AN3154 Rev 81/34AN3154 Application noteCAN protocol used in the STM32 bootloader IntroductionThis application note describes the CAN protocol used in the STM32 microcontroller bootloader . It details each supported document applies to the STM32 products embedding bootloader versions , and , as specified in STM32 microcontroller system memory boot mode (AN2606) available on These products are listed in Ta b l e 1, and are referred to as STM32 throughout the more information about the CAN hardware resources and requirements for the bootloader of the used device, refer to the already mentioned AN2606. Table 1. Applicable productsTypePart number or product seriesMicrocontrollersSTM32F1 SeriesSTM32F2 SeriesSTM32F4 SeriesSTM32F7 SeriesSTM32L4 Rev 8 Contents1 bootloader code sequence.

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 allows the baud rate for CAN run-time to be changed. Read Memory (2) 2. Refer to STM32 product datasheet and AN2606 to know the memory spaces valid for these commands. 0x11

Tags:

  Product, Flash, Bootloader

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Transcription of Can protocol used in the STM32 bootloader …

1 June 2021AN3154 Rev 81/34AN3154 Application noteCAN protocol used in the STM32 bootloader IntroductionThis application note describes the CAN protocol used in the STM32 microcontroller bootloader . It details each supported document applies to the STM32 products embedding bootloader versions , and , as specified in STM32 microcontroller system memory boot mode (AN2606) available on These products are listed in Ta b l e 1, and are referred to as STM32 throughout the more information about the CAN hardware resources and requirements for the bootloader of the used device, refer to the already mentioned AN2606. Table 1. Applicable productsTypePart number or product seriesMicrocontrollersSTM32F1 SeriesSTM32F2 SeriesSTM32F4 SeriesSTM32F7 SeriesSTM32L4 Rev 8 Contents1 bootloader code sequence.

2 52 CAN settings .. 73 bootloader command set .. command .. Version & Read Protection Status command .. ID command .. command .. Memory command .. command .. Memory command .. Memory command .. Protect command .. Unprotect command .. Protect command .. Unprotect command .. 304 bootloader protocol version evolution .. 325 Revision history .. 33AN3154 Rev 83/34AN3154 List of tables3 List of tablesTable products .. 1 Table bootloader commands .. 8 Table protocol versions .. 32 Table revision history .. 33 List of figuresAN31544/34AN3154 Rev 8 List of figuresFigure for STM32 with CAN.. 5 Figure HSE frequency .. 6 Figure frame .. 7 Figure command: host side.

3 9 Figure command: device side .. 10 Figure Version & Read Protection Status command: host side .. 11 Figure Version & Read Protection Status command: device side.. 12 Figure ID command: host side .. 13 Figure ID command: device side.. 14 Figure command: host side .. 15 Figure command: device side.. 16 Figure memory command: host side .. 17 Figure memory command: device side .. 18 Figure command: host side .. 19 Figure command: device side .. 20 Figure Memory command: host side .. 21 Figure memory command: device side.. 22 Figure Memory command: host side.. 23 Figure Memory command: device side .. 24 Figure Protect command: host side .. 25 Figure Protect command: device side.

4 26 Figure Unprotect command: host side .. 27 Figure Unprotect command: device side .. 27 Figure Protect command: host side.. 28 Figure Protect command: device side .. 29 Figure Unprotect command: host side .. 30 Figure Unprotect command: device side .. 31AN3154 Rev 85/34AN3154 bootloader code sequence331 bootloader code sequenceFigure 1. bootloader for STM32 with CAN1. It is recommended to send a frame with a Standard ID = the system memory boot mode is entered and the STM32 device (based on Arm (a) cores) has been configured (for more details refer to AN2606), 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 2 shows the flowchart of the frequency Arm is a registered trademark of Arm Limited (or its subsidiaries) in the US and/or detected(1)on CANx_Rx pinWait for acommandGET cmdroutineai17754bCheck HSE frequencyRD cmdroutine(optional)Routines forloading into RAMGO cmdroutineJP to_AddressGO cmdCommandreceivedGET cmdBootloader code sequenceAN31546/34AN3154 Rev 8 Figure 2.

5 Check HSE frequency1. For some devices the HSE frequency is calculated using HSI oscillator connected to a timer. For other devices this measurement is not implemented. For the devices without HSE frequency measurement, only the flow represented on the left is executed, while for the devices with HSE frequency measurement only the flow on the right is executed. To know the flow for the used device refer to check HSE frequencyConfigure external Oscillator mode (System Clock = 60 MHz)Initialize timeout at ~3 msGenerate System ResetEnter an infinite loop, waiting for any CAN bootloader CAN baudrate at 125 KbpsAssuming that HSE = 8 MHzInitialize timeout at ~ msMessage received with stdID=0x79and without frame error?

6 YesNoNoConfigure CAN baudrate at 125 KbpsAssuming that HSE = 25 MHzInitialize timeout at ~ msMessage received with stdID=0x79and without frame error?YesNoNoConfigure CAN baudrate at 125 KbpsAssuming that HSE = timeout at ~ msMessage received with stdID=0x79and without frame error?YesNoHSE measured with HSI and Timer (1)No HSE measurement (1)Message received with stdID=0x79and without frame error?YesYesNoGenerate System Resetai15704cDecrement timeoutTimeout = 0x0 ?Decrement timeoutTimeout = 0x0 ?Decrement timeoutTimeout = 0x0 ?YesYesYesNoDecrement timeoutTimeout=0x0? NoAN3154 Rev 87/34AN3154 CAN settings33 Next, the code initializes the serial interface accordingly. Using this calculated baud rate, an acknowledge byte (0x79) is returned to the host, indicating that the STM32 is ready to receive CAN settingsThe STM32 CAN is compliant with the and B (active) specifications with a bit rate up to 1 Mbit/s.

7 It can receive and transmit standard frames with 11-bit identifiers as well as extended frames with 29-bit 3 shows a CAN frame that uses the standard identifier 3. CAN frameIn this application the CAN settings are: Standard identifier (not extended) Bit rate: at the beginning it is 125 kbps; during runtime it can be changed via the speed command to achieve a maximum bit rate of 1 transmit settings (from the STM32 to the host) are: Tx mailbox0: On Tx mailbox1 and Tx mailbox2: Off 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 field. RX identifier depends on the command (0x00, 0x01, 0x02, 0x03, 0x11, 0x21, 0x31, 0x43, 0x63, 0x73, 0x82, 0x92) Error checking: If the error field (bit [6:4] in the CAN_ESR register) is different from 000b, the message is discarded and a NACK is sent to the host In FIFO overrun condition, the message is discarded and a NACK is sent to the host Incoming messages can contain from 1 to 8 data :The CAN bootloader firmware supports only one node at a time.

8 This means that CAN network management is not supported by the 12 DLC 68 * NCRC 1627 EOF ACK SOF RTRIDEr0 Arbitration fieldControl fieldData fieldCRC fieldACK fieldInter-frame spaceInter-frame spaceor overload frameData frame (standard identifier)44 + 8 * Nai15001 bootloader command setAN31548/34AN3154 Rev 83 bootloader command setThe supported commands are listed in Ta b l e 2, each of them is described in this section. Communication safetyEach packet is either accepted (ACK answer) or discarded (NACK answer): ACK message = 0x79 NACK message = Get commandThe Get command allows the host to get the version of the bootloader and the supported commands.

9 When the bootloader receives this command, it transmits the bootloader version and the supported command codes to the 2. CAN bootloader commands CommandCommand codeCommand descriptionGet(1)1. Read protection When the RDP (read protection) option is active, only this limited subset of commands is available. All other commands are NACK-ed and have no effect on the device. Once the RDP has been removed, the other commands become the version and the allowed commands supported by the current version of the bootloaderGet Version & Read Protection Status(1)0x01 Gets the bootloader version and the Read Protection status of the flash memoryGet ID(1)0x02 Gets the chip IDSpeed0x03 The speed command allows the baud rate for CAN run-time to be changed.

10 Read Memory(2)2. Refer to STM32 product datasheet and AN2606 to know the memory spaces valid for these up to 256 bytes of memory starting from an address specified by the applicationGo(2)0x21 Jumps to user application code located in the internal flash memory or in SRAMW rite Memory(2)0x31 Writes up to 256 bytes to the RAM or flash memory starting from an address specified by the applicationErase(2)0x43 Erases from one to all the flash memory sectorsWrite Protect0x63 Enables the write protection for some sectorsWrite Unprotect0x73 Disables the write protection for all flash memory sectorsReadout Protect(1)0x82 Enables the read protectionReadout Unprotect(1)0x92 Disables the read protectionAN3154 Rev 89/34AN3154 bootloader command set33 Figure 4.


Related search queries