I need to use simulated eeprom to save a variable that will be incremented basicaly every second (to explain better my question) and I can't loose this information if a have a power fail, for instance. So, I need to write its value every second on flash.
I'm considering 10000 writes on each address of memory, that is the number of erase guaranteed by datasheet.
So, I would have to change the memory address each 10000 writes, right?
Today I'm using ps_keys to save my variables, but, ps_keys has limitted space (0x4000 to 0x407f). Since I have to change the address each 10000 writes, I thing that I need to use another way to save my variable on simulated eeprom.
Is there another aproach to guarantee that I would be able to write this value every second without having problems with max number of writing process on flash?
Thanks a lot.
would you like to use NVM3, Wear-leveling is applied to reduce erase and write cycles and maximize flash lifetime.
there is a nvm3 baremetal example project, see if this can meet your requirement.
Hi Matt Ji.
I've started using the AN0019 to implement this solution, but I think that nvm3 api is newer and better, right?
I'm gonna implement NVM3 in my code to test.
Where can I found the flash page size of EFR32BG1P332F256GM32?
I've looked on datasheet (flash section), but I was not able to find this information.
Thanks a lot.
Yes, nvm3 api is newer and better, we recommend you use it.
On Series 1 devices the flash page size is typically 2 kB, while on Series 2 devices the flash page size is typically 8 kB.
you can check the reference manual https://www.silabs.com/documents/public/reference-manuals/efr32xg1-rm.pdf
What version of the stack can I use the nvm3 library from?
I only found the files "binapploader_nvm3.o" in v2.13.
Can I use it in v2.8.1?
I'm trying to use it on sdk v2.8.1 and i'm getting this error:
bgapi_ps.c:(.text.sli_bt_cmd_flash_ps_load+0x4e): undefined reference to `nvm3_findObject'
collect2.exe: error: ld returned 1 exit status
make: *** [project.axf] Error 1
When I use on stack v2.13, I don't have any problem.
Is there something that I can do to use nvm3 on v2.8.1 stack?
1. Probably you can not use nvm3 in v2.8.1 if there is no lib.
2. “Today I'm using ps_keys to save my variables, but, ps_keys has limitted space (0x4000 to 0x407f). Since I have to change the address each 10000 writes”, I do not think so, 10000 is without PS store, PS store implements Wear-leveling. The key(0x4000 to 0x407f) is not the real flash address. so please feel safe to use the same key.
I understood what you mean. Thanks.
I think I expressed myself badly.
My question about use PS store is:
Can I write 2.000.000 times at a same PS Store key?
If yes, I would like to use PS Store for this.
But, I'm affraid that is not possible, so I'm looking for another way to save the same variable 2.000.000 times on flash.
Thanks a lot.
Now, I'm using the AN0019 again, since I need to use old BLE Stack version.
I've configured the parameters of eeprom_simulation.h to this parameters
#define PAGE_SIZE FLASH_PAGE_SIZE #define DEFAULT_NUMBER_OF_PAGES 2 #define MAX_NUMBER_OF_PAGES (FLASH_SIZE/PAGE_SIZE) #define SIZE_OF_DATA 2 /* 2 bytes */ #define SIZE_OF_VIRTUAL_ADDRESS 2 /* 2 bytes */ #define SIZE_OF_VARIABLE (SIZE_OF_DATA + SIZE_OF_VIRTUAL_ADDRESS) /* 4 bytes */ #define MAX_ACTIVE_VARIABLES (PAGE_SIZE / SIZE_OF_VARIABLE) #define PAGE_STATUS_ERASED 0xFF #define PAGE_STATUS_RECEIVING 0xAA #define PAGE_STATUS_ACTIVE 0x00
As my flash page size is 2048, my page 0 address is 0x3F800, but this is causing a bug here.
Before init ble stack using command gecko_init(&config), the address 0x3F800 is modified.
Before init stack, the the flash is:
right after init ble stack the flash is:
I would like to know what is being written in this address during stack initialization, because this address can't be modified, since I need this address on eeprom emulation.
Thanks a lot.
I can't see the picture above, can you check it?
I've uploaded the images again.
I can see the pictures now, I will try to reproduce it here,
will update you.
Sorry for the reply late.
I can see the data, minor difference,
I think it is a kind of page status word, I need to check internally.
It is caused by nvm3/ps store, it does not relate to the BLE stack, if you do not use nvm3/ps store, the space is blank.