Skip to main content
Visitor II
August 6, 2025
Solved

Flash write fails when using mcumgr from zephyr to upload an image

  • August 6, 2025
  • 3 replies
  • 873 views

I'm using the nucleo-H753ZI board to test mcuboot.

The setup works and I can successfully run the bootloader and the application in slot0_partition using zephyr sysbuild.
However when trying to upload an image I get the following flash write error:

[00:00:29.758,000] <inf> mcuboot_util: Image index: 0, Swap type: none
[00:00:29.758,000] <inf> mcuboot_util: Image index: 0, Swap type: none
[00:00:29.922,000] <err> flash_stm32h7: Status Bank2: 0x00040000
[00:00:29.922,000] <err> STREAM_FLASH: flash_write error -5 offset=0x00100000
[00:00:29.922,000] <err> mcumgr_img_grp: Irrecoverable error: flash write failed: 12

Here is my flash0 dts:

&flash0 {
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;

boot_partition: partition@0 {
label = "mcuboot";
reg = <0x00000000 DT_SIZE_K(128)>;
};
slot0_partition: partition@20000 {
label = "image-0";
reg = <0x00020000 DT_SIZE_K(896)>;
};
slot1_partition: partition@100000 {
label = "image-1";
reg = <0x00100000 DT_SIZE_K(896)>;
};
storage_partition: partition@1e0000 {
label = "storage";
reg = <0x001e0000 DT_SIZE_K(128)>;
};
};
};

I have also attached the .config file from the build output as reference.

Appreciate any help to get this resolved. I assume it is some KCONFIG settings which is causing this.
    This topic has been closed for replies.
    Best answer by raphaZahnd

    Turns out it was a stm32_flash driver bug in the zephyr repo recently fixed: https://github.com/zephyrproject-rtos/zephyr/commit/ea1245eb92000d3fe24d2b974754714973ce5ab1 Works with this fix also when slot2 is in bank2!

    3 replies

    Visitor II
    August 15, 2025

    Unfortunately I'm still stuck with the flash write error during a application image upload with mcumgr. Any help would be appreciated. Thanks!

    Visitor II
    September 12, 2025

    Having both slots in bank1 fixes the issue and I can successfully upgrade the firmware with the mcumgr and there is NO flash write error: [00:00:29.922,000] <err> flash_stm32h7: Status Bank2: 0x00040000 (PGSERR).

    However that let's me waste the other 1MB of flash in bank2. So still unclear why writing into bank2 doesn't work while writing into bank1 works.

    raphaZahndAuthorAnswer
    Visitor II
    September 12, 2025

    Turns out it was a stm32_flash driver bug in the zephyr repo recently fixed: https://github.com/zephyrproject-rtos/zephyr/commit/ea1245eb92000d3fe24d2b974754714973ce5ab1 Works with this fix also when slot2 is in bank2!