Skip to main content
Aimee
Visitor II
November 29, 2022
Solved

X-CUBE-EEPROM calculation of PAGES_NUMBER from NB_OF_VARIABLES is off by one

In X-CUBE-EEPROM, the calculation of PAGES_NUMBER from NB_OF_VARIABLES is defined as:

#define PAGES_NUMBER (((((NB_OF_VARIABLES + NB_MAX_ELEMENTS_BY_PAGE) / NB_MAX_ELEMENTS_BY_PAGE) * 2U) * CYCLES_NUMBER) + GUARD_PAGES_NUMBER)

With a 2K flash page and a 32-byte header, 252 8-byte variables will fit in one page, as stated in AN4894. However, setting NB_OF_VARIABLES to 252 allocates an extra page.

To get the correct number of pages it should be:

#define PAGES_NUMBER (((((NB_OF_VARIABLES + NB_MAX_ELEMENTS_BY_PAGE - 1U) / NB_MAX_ELEMENTS_BY_PAGE) * 2U) * CYCLES_NUMBER) + GUARD_PAGES_NUMBER)

This topic has been closed for replies.
Imen.DBest answer
ST Technical Moderator
November 29, 2022

Hello @Aimee​ ,

Welcome to the STM32 Community and thank you for having reported this issue.

I have submitted an internal ticket (ID 140029) for analysis and work with our development team.

(PS: ID 140029 is an internal tracking number and is not accessible outside of ST).

Thanks

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks

1 reply

Imen.DBest answer
ST Technical Moderator
November 29, 2022

Hello @Aimee​ ,

Welcome to the STM32 Community and thank you for having reported this issue.

I have submitted an internal ticket (ID 140029) for analysis and work with our development team.

(PS: ID 140029 is an internal tracking number and is not accessible outside of ST).

Thanks

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks