Skip to content

Conversation

djiatsaf-st
Copy link
Contributor

@djiatsaf-st djiatsaf-st commented Jul 30, 2025

This PR adds support for testing MCUboot tests and samples. However, not all series are supported yet due to some limitations and hardware incapacity.

Related tests and samples :

  • zephyr/samples/sysbuild/with_mcuboot
  • zephyr/tests/boot/test_mcuboot
  • zephyr/tests/boot/with_mcumgr

add boot and slots  partitions for flash memory
in dedicated mcu boards

Signed-off-by: Fabrice DJIATSA <[email protected]>
Add STM32 supported boards for the test.

Signed-off-by: Fabrice DJIATSA <[email protected]>
Add STM32 supported boards for the test.

Signed-off-by: Fabrice DJIATSA <[email protected]>
Add STM32 supported boards for the test.

Signed-off-by: Fabrice DJIATSA <[email protected]>
Since the addition of a new storage partition definition in
the nucleo_f746zg dts, this node must be deleted before performing
this test.

Signed-off-by: Fabrice DJIATSA <[email protected]>
@djiatsaf-st djiatsaf-st force-pushed the support_mcuboot_tests branch from 9b3a129 to 920d124 Compare August 11, 2025 08:24
Copy link

@djiatsaf-st djiatsaf-st marked this pull request as ready for review August 14, 2025 15:45
boot_partition: partition@0 {
label = "mcuboot";
reg = <0x00000000 DT_SIZE_K(34)>;
reg = <0x00000000 DT_SIZE_K(64)>;
Copy link
Contributor

@JarmouniA JarmouniA Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

48KB is the minimum MCUboot partition size, Flash sectors are atmost 4KB on this SoC, so why give more to MCUboot?
Same for other Flash-constrainted SoCs with sub-32KB sector size.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just based it on how the nucleo_wba55cg was added, and also compared the sizes of the flash sectors/pages in the refman and adapted with the rest so that it worked on the tests.
If you have some references on the rules to follow, that would be welcome.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@nordicjm nordicjm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comments, there is a bunch of different things in this PR so not sure what the idea is...

Comment on lines +204 to +208
/* Set 4KB of storage at the end of 128KB flash */
storage_partition: partition@1f000 {
label = "storage";
reg = <0x0001f000 DT_SIZE_K(4)>;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't know what the sector size is but for nvs this would need to be at least 3 sectors to be usable

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed sectors (named "pages" in th SoC refman) are 2kB large.

Comment on lines +176 to +184
slot0_partition: partition@10000 {
label = "image-0";
reg = <0x00010000 DT_SIZE_K(32)>;
};

slot1_partition: partition@18000 {
label = "image-1";
reg = <0x00018000 DT_SIZE_K(30)>;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sizes are different?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't the sizes required to be different? There is no scratch partition, so this is using one of the move algorithms.

Comment on lines +256 to +264
slot0_partition: partition@40000 {
label = "image-0";
reg = <0x00040000 DT_SIZE_K(448)>;
};

slot1_partition: partition@b0000 {
label = "image-1";
reg = <0x000b0000 DT_SIZE_K(320)>;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sizes are very different? If using different sizes then the extra sector should be in slot 1 and swap using offset should be used rather than swap using move

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your feedback.
Before addressing the comments, if you could please provide some references on algorithm-based partition distribution or other useful resources, they would be very helpful.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seen F746xx SoCs flash sectors distribution (rm0385 rev9/table 3/page 79), I think the sole supported layout requires: slot0 is 2x256kB, slot1 is 1x256kB, storage is 3x32kB (placed at flash start) and boot occupies a signle 128kB sector.

*/

/delete-node/ &storage_partition;
&flash0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newline line 8

Copy link
Contributor

@str4t0m str4t0m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good to get better test coverage, but I don't think it is reasonable to increase the bootloader partition so much. You may want add additional configuration overlays to trim it down and look at smaller nordic nrf51/nrf52 socs to see what is possible.

Copy link
Contributor

@d3zd3z d3zd3z left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the dts files in the zephyr tree are where most people will start when trying to support something new, I think it is important that we get this right. For the stm32 this means:

  • scratch should only be used on the devices that need it. These generally have very large sectors, and there ends up being three partitions for code, slot0, slot1, and scratch all being 128k.
  • For other devices, we should always be configured for swap-offset, and the partition tables should have a slot1 image that is 1 sector larger than slot0.

slot1_partition: partition@27800 {
label = "image-1";
reg = <0x00027800 DT_SIZE_K(94)>;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this actually work? At least as I remember it, without a scratch partition, there are specific requirements for the sizes, and specifically one slot must be exactly one sector larger than the other (we'd have to look up which is which.)

Comment on lines +176 to +184
slot0_partition: partition@10000 {
label = "image-0";
reg = <0x00010000 DT_SIZE_K(32)>;
};

slot1_partition: partition@18000 {
label = "image-1";
reg = <0x00018000 DT_SIZE_K(30)>;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't the sizes required to be different? There is no scratch partition, so this is using one of the move algorithms.

* SPDX-License-Identifier: Apache-2.0
*/

/delete-node/ &storage_partition;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the board already provides a storage area, it's seems not needed to override it.

Comment on lines +256 to +264
slot0_partition: partition@40000 {
label = "image-0";
reg = <0x00040000 DT_SIZE_K(448)>;
};

slot1_partition: partition@b0000 {
label = "image-1";
reg = <0x000b0000 DT_SIZE_K(320)>;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seen F746xx SoCs flash sectors distribution (rm0385 rev9/table 3/page 79), I think the sole supported layout requires: slot0 is 2x256kB, slot1 is 1x256kB, storage is 3x32kB (placed at flash start) and boot occupies a signle 128kB sector.


slot1_partition: partition@17800 {
label = "image-1";
reg = <0x00017800 DT_SIZE_K(30)>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you update the flash: tag in board specific YAML files to reflect the Zephyr application max flash size for each of these modified layouts?

Copy link
Contributor

@JarmouniA JarmouniA Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you update the flash: tag in board specific YAML files to reflect the Zephyr application max flash size for each of these modified layouts?

No, it's not a good idea, unless the target is meant to be used exclusively with MCUboot.

Instead, there should be a board mcuboot variant, with - sysbuild=true in its YAML file and MIN(slot0,slot1) as flash size.

Comment on lines +204 to +208
/* Set 4KB of storage at the end of 128KB flash */
storage_partition: partition@1f000 {
label = "storage";
reg = <0x0001f000 DT_SIZE_K(4)>;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed sectors (named "pages" in th SoC refman) are 2kB large.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants