Skip to main content
Associate
July 6, 2026
Question

STM32L071KZ MCU Flash Issue over ST bootloader

  • July 6, 2026
  • 18 replies
  • 268 views

We are currently working on flashing an STM32L071KZ MCU using the STM32 bootloader.

The flashing process completes successfully when using a 64-byte payload. However, when we reduce the payload size to 8, 16, or 32 bytes, we observe unexpected behavior. In each case, only the first 8, 16, or 32 bytes of every 64-byte flash block are programmed successfully, while the remaining writes within the same 64-byte block do not take effect. This pattern repeats consistently for every subsequent 64-byte-aligned address.

We have verified that:

  1. The correct data is being transmitted to the MCU.
  2. The target flash address is incremented correctly for each write operation.
  3. The bootloader acknowledges the write commands.

Despite this, the flash programming behaves correctly only when using a 64-byte payload.

Is there any known limitation or programming requirement for the STM32L071KZ bootloader or flash controller regarding payload sizes? Are there any additional steps or constraints that must be followed when programming the flash using payloads smaller than 64 bytes?

Do we need to set any configuration in the keil software to support other size payload while flashing?

Any guidance or insights would be greatly appreciated.

 

Thank you.

18 replies

Pavel A.
July 6, 2026

Do you use the ST HAL library to program the flash? If yes: the HAL_FLASH_Program function accepts only 4-byte payload, so it’s not clear how you program other sizes.

https://github.com/STMicroelectronics/stm32l0xx-hal-driver/blob/9f614d91f5a4aa094a86c7ee3ca9292e8492f2c0/Src/stm32l0xx_hal_flash.c#L228

However, STM32L0 has a “multiple” programming mode that programs by chunks of exactly 64 bytes - but this mode is off after reset, and the current STM32L0 HAL library doesn't seem to implement it.

Looks like you’ve activated it somehow.

( see RM0377, 3.3.4)

UPDATE:

Sorry so you’re using the built-in ST bootloader. Then again, it looks like the “multiple” mode activates somehow. If this behavior is stable (always reproduces) - just keep programming by 64 bytes?

 

Associate
July 7, 2026

Hi ​@Pavel A. 

Thanks for your response. Is there any way to configure mode in bootloader?
We didn’t activate any specific mode during our flashing. Is this factory made setting in the MCU series?

 

Looking forward for your response.

 

Thank you.

Pavel A.
July 7, 2026

@Koil Arul Raj.S 

I don’t have a L0 board to test; hopefully ​@mƎALLEm can resolve the riddle.🙏

TDK
July 6, 2026

It should work. Which bootloader are you using (UART, SPI, I2C, USB DFU, etc)? Which program is being used to communicate with it?

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

Hi ​@TDK,

Thanks for your response. We are using bootloader commands via I2C to program the flash. Is there any additional configuration needed to flash different payloads.

 

Thank you.

 

mƎALLEm
ST Technical Moderator
July 7, 2026

Hello ​@Koil Arul Raj.S and welcome to the ST community,

Could you please provide the command sequence you are performing during this process?

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
LCE
Principal II
July 7, 2026

I have decided against the internal STM32 bootloader, it’s too much of a black box.

For flash update i only use “half pages”, which has a size of 64 bytes = 16 words, not the seemingly possible word size.

Edit: I’m using the L073