cancel
Showing results for 
Search instead for 
Did you mean: 

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

Aimee
Associate

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)

1 ACCEPTED SOLUTION

Accepted Solutions
Imen.D
ST Employee

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

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

View solution in original post

1 REPLY 1
Imen.D
ST Employee

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

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen