2025-05-19 10:52 PM
Hi,
I'm working on firmware upgrade functionality for an STM32G491 series MCU. In our system, the MCU communicates with a processor over I2C, where the processor acts as the master and the MCU as the slave. Currently, we're using I2C1 on the MCU for this communication.
However, as per AN2606, I2C1 is not supported in boot mode for firmware flashing, which limits our ability to use standard ISP. Therefore, we're exploring the option of using In-Application Programming (IAP) over I2C1.
Is it possible to perform IAP using I2C1 in this configuration? If so, could you point me to any sample code or reference implementations?
2025-05-20 4:52 AM
How to use the ST Open Bootloader for STM32 Microc... - STMicroelectronics Community
It would be better in the long run to switch to a bootloader supported I2C pins. Less code, more time spent on functionality.
2025-05-20 5:33 AM
You can code your own IAP implementation using whatever interface and protocol you choose.
Review other IAP examples you can find, adapt, or have your coders code.
2025-05-20 6:28 AM
Hi @Tesla DeLorean ,
My doubt is in IAP driver implementation, I need to enable one UART, I2C and a GPIO. After jumping to the User application, whether the initialised I2C, UART and GPIO need to be reinitialised? or I need to de init everything before jumping to user application?
2025-05-20 8:50 AM
You get to decide the contractual details between your loader and your app.
You can initialize the clocks, PLL just once, and not repeat when in the application. This will save time, but just be aware in the application that the entry conditions may be different, and not at reset defaults. The peripherals, clocks, pins, etc will be in whatever state the loader leaves them.
Generally, you want to hand over a relatively quiet and stable system, so not generating interrupt, say for SysTick, TIMx and UARTx, as at the point of handover none of the HAL RAM instances will follow, and the application image will have it's own RAM allocations as doled out by the Linker.
Perhaps look at IAP examples for other STM32 families for simpler implementations, or at
STM32Cube_FW_G4_V1.5.2\Projects\NUCLEO-G491RE\Applications\OpenBootloader