Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] Fix STM32 storage partition for compatibility with NVS #80150

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

erwango
Copy link
Member

@erwango erwango commented Oct 21, 2024

STM32 used to rely overlays in samples/subsys/nvs to pass test.
Now that nvs is used in a variety of tests (tests/subsys/secure_storage for instance) a more global approach is required.

Draft for now while I'm passing the tests.

STM32F2 series flash layout is as follows:
	{.pages_count = 4, .pages_size = KB(16)},
	{.pages_count = 1, .pages_size = KB(64)},
	{.pages_count = 7, .pages_size = KB(128)}

Since NVS subsys requires 2 sectors of max 32K in total, provide a
flash partition which respects this constraint using 2 of the 16K sectors
in the beginning of the layout.

Provide a compatible flash partition usable with mcuboot, but keep the
storage partition commented as its usage is not compatible with use w/o
mcuboot enabled (in this case main image starts as offset 0 which conflicts
with storage partition).

Note that it isn't possible either to get main image starting directly
in the 128K sectors w/o bootloader as boot flash address can't be
configured.


Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
Rework flash partition to make use of the whole 2M of flash.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
Rework flash partition to provide a storage partition and 2 image slots.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
NVS susbsystem requires a slot covering 2 sectors of flash, which
should be at minimum 4K on G0 series which provised 2K sectors.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
NVS susbsystem requires a slot covering 2 sectors of flash, which
should be at minimum 8K on L1 series which provides 4K sectors.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
These tests could be long on slow targets


Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
    STM32F4 series flash layout is as follows:
    	{.pages_count = 4, .pages_size = KB(16)},
    	{.pages_count = 1, .pages_size = KB(64)},
    	{.pages_count = 7, .pages_size = KB(128)}

Since NVS subsys requires 2 sectors of max 32K in total, provide a
flash partition which respects this constraint using 2 of the 16K sectors
in the beginning of the layout.

Provide a compatible flash partition usable with mcuboot, but keep the
storage partition commented as its usage is not compatible with use w/o
mcuboot enabled (in this case main image starts as offset 0 which conflicts
with storage partition).

Note that it isn't possible either to get main image starting directly
in the 128K sectors w/o bootloader as boot flash address can't be
configured.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
flash_copy() is performed on a page.size span but following flash_read()
verification step is performed on EXPECTED_SIZE length (512).

This doesn't work on devices where page.size is lower than EXPECTED_SIZE,
such as STM32L1 where page size is 256.

To fix this, perform verification on the smalest value between page.size
and EXPECTED_SIZE.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
It's same test as "default", but more restrictive target wise.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
erwango and others added 3 commits November 15, 2024 11:31
Fix a copy paste issue in storage_partition reg property.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
Don't try to delete partitions that doesn't exist anymore

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
Set the CONFIG_MAIN_STACK_SIZE to 2048 when running
the samples/subsys/nvs/sample.nvs.basic
on stm32 target boards

Signed-off-by: Francois Ramu <francois.ramu@st.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants