Using mcuboot with STM32H7


Per-Erik Klarenfjord
 

In our project we are using the microcontroller STM32H753. We are trying to use mcuboot with the sample smp_svr (overlay-udp.conf) for software updates over Ethernet. This has been working good for the F767 microcontroller, but we are failing when using the H753 microcontroller.

 

From what I’ve read on git-hub I’m not sure if mcuboot right now is compatible with the STM32H7-series due to changes in the flash (dual banks and new byte alignment). Am I right or do you know any walk arounds for using STM32H7-series with mcuboot?

 

I’ve done the following steps when trying to use mcuboot with ”smp_svr”:

 

  1. Build and flash mcuboot. The board boots and everything seems good.

 

  1. Build, sign and flash the sample ”smp_svr” to flash partition slot 0. For the signing procedure to work I hade to add the argument ”align 8” when signing (default was ”align 32”), see below. Mcuboot and smp_svr boots and everything seems good.

> west sign -t imgtool -- --align 8 --key ~/zephyrproject/bootloader/mcuboot/root-rsa-2048.pem

 

  1. Upload a second image to flash partition slot 1, usign mcumgr as the tool for uploading. No errors.

>./mcumgr --conntype udp --connstring=[192.168.2.25]:1337 image upload ~/zephyrproject/zephyr/build/zephyr/zephyr.signed.bin

 

  1. List the images. Both images appear as intended.

>./mcumgr --conntype udp --connstring=[192.168.2.25]:1337 image list

 

Images:

image=0 slot=0

    version: 0.0.0

    bootable: true

    flags: active confirmed

    hash: 5bc6846f35e3f01fcb8351b1e3138ecf9f24039776e3b154095ec695e12d9e79

image=0 slot=1

    version: 0.0.0

    bootable: true

    flags:

    hash: 1b3543e439b29e03ac380f46f87e907fec45cc6aff1cd3b75c75ff570c85f174

Split status: N/A (0)

 

  1. Test the image with the hash code. It fails.

>./mcumgr --conntype udp --connstring=[192.168.2.25]:1337 image test 1b3543e439b29e03ac380f46f87e907fec45cc6aff1cd3b75c75ff570c85f174

 

Error: 1

 

The following is printed on the UART debug port:

[00:01:36.416,000] <err> flash_stm32h7: Write offset not aligned on flashword length. Offset: 0xbfff0, 2

[00:01:36.416,000] <err> flash_stm32h7: Write range invalid. Offset: 786416, len: 16 

 

 

Do you know how to solve this alignment error when using mcuboot with the STM32H7-series of microcontrollers?

 

Regards, Per-Erik


Erwan Gouriou
 

Hi Per-Erik,

There's an on-going change in mcuboot to support extended write sizes:

This should help in the support of H7 and I guess you should start from here.
I don't have specific info on the impact of dual bank, but I'd suggest to ask
directly in mcuboot discussions: https://github.com/mcu-tools/mcuboot/discussions

hih
Erwan 



On Tue, 14 Dec 2021 at 15:02, Per-Erik Klarenfjord <pek@...> wrote:

In our project we are using the microcontroller STM32H753. We are trying to use mcuboot with the sample smp_svr (overlay-udp.conf) for software updates over Ethernet. This has been working good for the F767 microcontroller, but we are failing when using the H753 microcontroller.

 

From what I’ve read on git-hub I’m not sure if mcuboot right now is compatible with the STM32H7-series due to changes in the flash (dual banks and new byte alignment). Am I right or do you know any walk arounds for using STM32H7-series with mcuboot?

 

I’ve done the following steps when trying to use mcuboot with ”smp_svr”:

 

  1. Build and flash mcuboot. The board boots and everything seems good.

 

  1. Build, sign and flash the sample ”smp_svr” to flash partition slot 0. For the signing procedure to work I hade to add the argument ”align 8” when signing (default was ”align 32”), see below. Mcuboot and smp_svr boots and everything seems good.

> west sign -t imgtool -- --align 8 --key ~/zephyrproject/bootloader/mcuboot/root-rsa-2048.pem

 

  1. Upload a second image to flash partition slot 1, usign mcumgr as the tool for uploading. No errors.

>./mcumgr --conntype udp --connstring=[192.168.2.25]:1337 image upload ~/zephyrproject/zephyr/build/zephyr/zephyr.signed.bin

 

  1. List the images. Both images appear as intended.

>./mcumgr --conntype udp --connstring=[192.168.2.25]:1337 image list

 

Images:

image=0 slot=0

    version: 0.0.0

    bootable: true

    flags: active confirmed

    hash: 5bc6846f35e3f01fcb8351b1e3138ecf9f24039776e3b154095ec695e12d9e79

image=0 slot=1

    version: 0.0.0

    bootable: true

    flags:

    hash: 1b3543e439b29e03ac380f46f87e907fec45cc6aff1cd3b75c75ff570c85f174

Split status: N/A (0)

 

  1. Test the image with the hash code. It fails.

>./mcumgr --conntype udp --connstring=[192.168.2.25]:1337 image test 1b3543e439b29e03ac380f46f87e907fec45cc6aff1cd3b75c75ff570c85f174

 

Error: 1

 

The following is printed on the UART debug port:

[00:01:36.416,000] <err> flash_stm32h7: Write offset not aligned on flashword length. Offset: 0xbfff0, 2

[00:01:36.416,000] <err> flash_stm32h7: Write range invalid. Offset: 786416, len: 16 

 

 

Do you know how to solve this alignment error when using mcuboot with the STM32H7-series of microcontrollers?

 

Regards, Per-Erik