cancel
Showing results for 
Search instead for 
Did you mean: 

stm32 MCU flashing via i2c

abhijith_raj
Associate III

Hi,

I'm working on flashing an STM32 MCU via I2C. The current setup involves a processor (host) and an STM32 MCU (G491RET6), where the processor needs to upload firmware to the MCU and perform flashing over I2C with the STM32 acting as the slave.

I have a question regarding the I2C interface used during bootloader mode. The MCU has I2C1, I2C2, and I2C3 available — can any of these be used for flashing in boot mode, or is only a specific I2C peripheral supported by the STM32 bootloader?

Also, for I2C1, there are multiple pin options available in the pinmux configuration. Which specific pins should be used for flashing via I2C in this case?

1 ACCEPTED SOLUTION

Accepted Solutions

Hello @abhijith_raj 


@abhijith_raj wrote:

abhijith_raj_0-1745564339628.jpeg

Hi @TDK 
Our basic schematic is as follows: we’ve connected I2C1 for communication between the processor and the MCU, as well as for firmware flashing. I2C3 is used for external sensors.

Will this setup cause any issues during boot mode for firmware flashing? The documentation mentions that only I2C2 and I2C3 are supported in boot mode.


No, this will no gonna working. 

You cannot use I2C1 for the bootloader (Processor Host/MCU G4), Only I2C2 and I2C3 are available as indicated by the AN2606 / page 263. Moreover only PC4/PA8 are available for I2C2 and PC8/PC9 are available for I2C3.

mALLEm_0-1745577789009.png

So what we suggest is to swap the I2C instances: I2C1 for the sensor communication and I2C3 for the bootloader with PC8/PC9 as you've already indicated in your sketch. 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

View solution in original post

7 REPLIES 7
Ozone
Principal

This is usually documented in the reference manual for your MCU variant.

Here an example for some F3 variants I have at hand :

Ozone_0-1745471900562.png

 

abhijith_raj_0-1745500285061.png

Hi @Ozone ,
I’m currently using the Nucleo-G491RE evaluation board.
In the current firmware, I2C2 and I2C3 are configured as masters.
During boot mode, do these pins get reconfigured? If so, can I still use either of the I2C interfaces?

 

TDK
Guru

The AN2606 document will specify which pins and peripherals are available to the bootloader. Only those pins are supported. Here are the supported I2C interfaces for the STM32G491xx chips:

TDK_0-1745500929603.png

https://www.st.com/resource/en/application_note/cd00167594-stm32-microcontroller-system-memory-boot-mode-stmicroelectronics.pdf

 

If you feel a post has answered your question, please click "Accept as Solution".

abhijith_raj_0-1745564339628.jpeg

Hi @TDK 
Our basic schematic is as follows: we’ve connected I2C1 for communication between the processor and the MCU, as well as for firmware flashing. I2C3 is used for external sensors.

Will this setup cause any issues during boot mode for firmware flashing? The documentation mentions that only I2C2 and I2C3 are supported in boot mode.

Firmware upate via I2C means you need to attach an external device to one of the supported I2C peripherals, either 2 or 3. This might be I2C3, because the pins the BL would allocate for I2C2 might be used for other purposes, and thus interfere.

As you see in the AN screenshot, there are no pin options in the BL.
The BL is ROM-based code, and it will use PC4/PA8 or PC8/PC9, respectively.

You need to design your firmware update capability around this constraints.

Hello @abhijith_raj 


@abhijith_raj wrote:

abhijith_raj_0-1745564339628.jpeg

Hi @TDK 
Our basic schematic is as follows: we’ve connected I2C1 for communication between the processor and the MCU, as well as for firmware flashing. I2C3 is used for external sensors.

Will this setup cause any issues during boot mode for firmware flashing? The documentation mentions that only I2C2 and I2C3 are supported in boot mode.


No, this will no gonna working. 

You cannot use I2C1 for the bootloader (Processor Host/MCU G4), Only I2C2 and I2C3 are available as indicated by the AN2606 / page 263. Moreover only PC4/PA8 are available for I2C2 and PC8/PC9 are available for I2C3.

mALLEm_0-1745577789009.png

So what we suggest is to swap the I2C instances: I2C1 for the sensor communication and I2C3 for the bootloader with PC8/PC9 as you've already indicated in your sketch. 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

It states what pins are supported, as I also said in my response. Read it.

If you feel a post has answered your question, please click "Accept as Solution".